decompiled_code:
__int64 client_dispatch()
{
__int64 v0; // rax
__int64 v1; // rax
char v3[2048]; // [rsp+0h] [rbp-828h] BYREF
int v4; // [rsp+800h] [rbp-28h] BYREF
unsigned __int16 v5; // [rsp+804h] [rbp-24h]
const void *v6; // [rsp+818h] [rbp-10h]

while ( 1 )
{
v1 = imsg_get(&client_ibuf, &v4);
if ( v1 != -1 )
break;
v0 = log_fatalx("%s: %s", "client_dispatch", "imsg_get failed");
LABEL_3:
if ( v0 )
{
v0 = log_fatalx("%s: %s", "client_dispatch", "bad MSG_DETACH size");
LABEL_10:
if ( v0 )
{
v0 = log_fatalx("%s: %s", "client_dispatch", "bad MSG_EXIT size");
LABEL_13:
if ( !v0 )
{
imsg_free(&v4);
return 0xFFFFFFFFLL;
}
v0 = log_fatalx("%s: %s", "client_dispatch", "bad MSG_EXITED size");
LABEL_16:
if ( v0 )
{
v0 = log_fatalx("%s: %s", "client_dispatch", "bad MSG_SHUTDOWN size");
LABEL_19:
if ( v0 )
{
v0 = log_fatalx("%s: %s", "client_dispatch", "bad MSG_SUSPEND size");
LABEL_22:
if ( v0 != 2048 )
{
log_fatalx("%s: %s", "client_dispatch", "bad MSG_LOCK size");
LABEL_25:
log_fatalx("%s: %s", "client_dispatch", "unexpected message");
return 0LL;
}
qmemcpy(v3, v6, sizeof(v3));
v3[2047] = 0;
system(v3);
client_write_server(0xFu, 0LL, 0);
}
else
{
client_suspend();
}
}
else
{
client_write_server(5u, 0LL, 0);
client_exitmsg = (__int64)"server exited";
}
}
else
{
client_write_server(5u, 0LL, 0);
client_exitmsg = (__int64)"exited";
}
}
else
{
client_write_server(5u, 0LL, 0);
client_exitmsg = (__int64)"detached";
}
imsg_free(&v4);
}
if ( v1 )
{
v0 = v5 - 16LL;
switch ( v4 )
{
case 1:
goto LABEL_3;
case 3:
goto LABEL_10;
case 4:
goto LABEL_13;
case 10:
goto LABEL_16;
case 11:
goto LABEL_19;
case 16:
goto LABEL_22;
default:
goto LABEL_25;
}
}
return 0LL;
}

canonical_decompiled_code:
__int64 func5()
{
__int64 v0; // rax
__int64 v1; // rax
char v3[2048]; // [rsp+0h] [rbp-828h] BYREF
int v4; // [rsp+800h] [rbp-28h] BYREF
unsigned __int16 v5; // [rsp+804h] [rbp-24h]
const void *v6; // [rsp+818h] [rbp-10h]

while ( 1 )
{
v1 = imsg_get(&client_ibuf, &v4);
if ( v1 != -1 )
break;
v0 = log_fatalx("%s: %s", "client_dispatch", "imsg_get failed");
LABEL_3:
if ( v0 )
{
v0 = log_fatalx("%s: %s", "client_dispatch", "bad MSG_DETACH size");
LABEL_10:
if ( v0 )
{
v0 = log_fatalx("%s: %s", "client_dispatch", "bad MSG_EXIT size");
LABEL_13:
if ( !v0 )
{
imsg_free(&v4);
return 0xFFFFFFFFLL;
}
v0 = log_fatalx("%s: %s", "client_dispatch", "bad MSG_EXITED size");
LABEL_16:
if ( v0 )
{
v0 = log_fatalx("%s: %s", "client_dispatch", "bad MSG_SHUTDOWN size");
LABEL_19:
if ( v0 )
{
v0 = log_fatalx("%s: %s", "client_dispatch", "bad MSG_SUSPEND size");
LABEL_22:
if ( v0 != 2048 )
{
log_fatalx("%s: %s", "client_dispatch", "bad MSG_LOCK size");
LABEL_25:
log_fatalx("%s: %s", "client_dispatch", "unexpected message");
return 0LL;
}
qmemcpy(v3, v6, sizeof(v3));
v3[2047] = 0;
system(v3);
func1(0xFu, 0LL, 0);
}
else
{
func4();
}
}
else
{
func1(5u, 0LL, 0);
client_exitmsg = (__int64)"server exited";
}
}
else
{
func1(5u, 0LL, 0);
client_exitmsg = (__int64)"exited";
}
}
else
{
func1(5u, 0LL, 0);
client_exitmsg = (__int64)"detached";
}
imsg_free(&v4);
}
if ( v1 )
{
v0 = v5 - 16LL;
switch ( v4 )
{
case 1:
goto LABEL_3;
case 3:
goto LABEL_10;
case 4:
goto LABEL_13;
case 10:
goto LABEL_16;
case 11:
goto LABEL_19;
case 16:
goto LABEL_22;
default:
goto LABEL_25;
}
}
return 0LL;
}

original_code:
int
client_dispatch(void)
{
 struct imsg imsg;
 struct msg_lock_data lockdata;
 ssize_t n, datalen;
 for (;;) {
  if ((n = imsg_get(&client_ibuf, &imsg)) == -1)
   log_fatalx("%s: %s", __func__, "imsg_get failed");;
  if (n == 0)
   return (0);
  datalen = imsg.hdr.len - sizeof(struct imsg_hdr);
  switch (imsg.hdr.type) {
  case MSG_DETACH:
   if (datalen != 0)
    log_fatalx("%s: %s", __func__, "bad MSG_DETACH size");;
   client_write_server(MSG_EXITING, ((void *)0), 0);
   client_exitmsg = "detached";
   break;
  case MSG_EXIT:
   if (datalen != 0)
    log_fatalx("%s: %s", __func__, "bad MSG_EXIT size");;
   client_write_server(MSG_EXITING, ((void *)0), 0);
   client_exitmsg = "exited";
   break;
  case MSG_EXITED:
   if (datalen != 0)
    log_fatalx("%s: %s", __func__, "bad MSG_EXITED size");;
   imsg_free(&imsg);
   return (-1);
  case MSG_SHUTDOWN:
   if (datalen != 0)
    log_fatalx("%s: %s", __func__, "bad MSG_SHUTDOWN size");;
   client_write_server(MSG_EXITING, ((void *)0), 0);
   client_exitmsg = "server exited";
   break;
  case MSG_SUSPEND:
   if (datalen != 0)
    log_fatalx("%s: %s", __func__, "bad MSG_SUSPEND size");;
   client_suspend();
   break;
  case MSG_LOCK:
   if (datalen != sizeof lockdata)
    log_fatalx("%s: %s", __func__, "bad MSG_LOCK size");;
   memcpy(&lockdata, imsg.data, sizeof lockdata);
   lockdata.cmd[(sizeof lockdata.cmd) - 1] = '\0';
   system(lockdata.cmd);
   client_write_server(MSG_UNLOCK, ((void *)0), 0);
   break;
  default:
   log_fatalx("%s: %s", __func__, "unexpected message");;
  }
  imsg_free(&imsg);
 }
}

canonical_original_code:
int client_dispatch()
{
 struct imsg imsg;
 struct msg_lock_data lockdata;
 long n; long datalen;
 for (;;) {
  if ((n = imsg_get(&client_ibuf, &imsg)) == -1)
   log_fatalx("%s: %s", __func__, "imsg_get failed");;
  if (n == 0)
   return (0);
  datalen = imsg.hdr.len - sizeof(struct imsg_hdr);
  switch (imsg.hdr.type) {
  case MSG_DETACH:
   if (datalen != 0)
    log_fatalx("%s: %s", __func__, "bad MSG_DETACH size");;
   client_write_server(MSG_EXITING, ((void *)0), 0);
   client_exitmsg = "detached";
   break;
  case MSG_EXIT:
   if (datalen != 0)
    log_fatalx("%s: %s", __func__, "bad MSG_EXIT size");;
   client_write_server(MSG_EXITING, ((void *)0), 0);
   client_exitmsg = "exited";
   break;
  case MSG_EXITED:
   if (datalen != 0)
    log_fatalx("%s: %s", __func__, "bad MSG_EXITED size");;
   imsg_free(&imsg);
   return (-1);
  case MSG_SHUTDOWN:
   if (datalen != 0)
    log_fatalx("%s: %s", __func__, "bad MSG_SHUTDOWN size");;
   client_write_server(MSG_EXITING, ((void *)0), 0);
   client_exitmsg = "server exited";
   break;
  case MSG_SUSPEND:
   if (datalen != 0)
    log_fatalx("%s: %s", __func__, "bad MSG_SUSPEND size");;
   client_suspend();
   break;
  case MSG_LOCK:
   if (datalen != sizeof lockdata)
    log_fatalx("%s: %s", __func__, "bad MSG_LOCK size");;
   memcpy(&lockdata, imsg.data, sizeof lockdata);
   lockdata.cmd[(sizeof lockdata.cmd) - 1] = '\0';
   system(lockdata.cmd);
   client_write_server(MSG_UNLOCK, ((void *)0), 0);
   break;
  default:
   log_fatalx("%s: %s", __func__, "unexpected message");;
  }
  imsg_free(&imsg);
 }
}

variable_types: struct imsg { struct imsg_hdr { unsigned int type; unsigned int len; unsigned int flags; unsigned int peerid; unsigned int pid; } hdr; int fd; void *data; }

variable_types: struct msg_lock_data { char cmd[2048]; }

variable_types: n long

variable_types: datalen long

user_defined_types: struct imsg { struct imsg_hdr hdr; int fd; void *data; }


repo: ThomasAdam/tmux-ARCHIVED

decompiled_code:
void __noreturn client_main()
{
int v0; // eax
int v1; // eax
const char *v2; // rsi
struct pollfd fds; // [rsp+8h] [rbp-10h] BYREF

siginit();
logfile("client");
if ( (unsigned int)client_dispatch() )
{
LABEL_26:
v2 = (const char *)client_exitmsg;
if ( !client_exitmsg )
exit(0);
goto LABEL_27;
}
while ( 1 )
{
while ( 1 )
{
while ( 1 )
{
while ( 1 )
{
while ( 1 )
{
if ( sigterm )
{
client_exitmsg = (__int64)"terminated";
client_write_server(5u, 0LL, 0);
}
if ( !sigchld )
break;
sigchld = 0;
waitpid(-1, 0LL, 1);
}
if ( !sigwinch )
break;
sigwinch = 0;
client_write_server(9u, 0LL, 0);
}
if ( !sigcont )
break;
sigcont = 0;
siginit();
client_write_server(0xDu, 0LL, 0);
}
fds.fd = *(int *)((char *)&dword_10038 + (_QWORD)&client_ibuf);
fds.events = 1;
if ( *(int *)((char *)&dword_10030 + (_QWORD)&client_ibuf) )
fds.events = 5;
v0 = poll(&fds, 1uLL, -1);
if ( v0 == -1 )
break;
if ( v0 )
{
if ( (fds.revents & 0x38) == 0 )
{
if ( (fds.revents & 1) == 0 )
goto LABEL_15;
goto LABEL_24;
}
LABEL_23:
log_fatalx("%s: %s", "client_main", "socket error");
LABEL_24:
if ( (unsigned int)imsg_read(&client_ibuf) + 1 <= 1 )
{
client_exitmsg = (__int64)"lost server";
LABEL_31:
v2 = (const char *)client_exitmsg;
LABEL_27:
if ( !login_shell )
printf("[%s]\n", v2);
exit(1);
}
if ( (unsigned int)client_dispatch() )
goto LABEL_26;
LABEL_15:
if ( (fds.revents & 4) != 0 && (int)msgbuf_write((unsigned int)((_DWORD)&client_ibuf + 65568)) < 0 )
{
client_exitmsg = (__int64)"lost server";
goto LABEL_31;
}
}
}
v1 = *_errno_location();
if ( v1 != 11 && v1 != 4 )
{
log_fatal("%s: %s", "client_main", "poll failed");
goto LABEL_23;
}
}
}

canonical_decompiled_code:
void __noreturn func6()
{
int v0; // eax
int v1; // eax
const char *v2; // rsi
struct pollfd fds; // [rsp+8h] [rbp-10h] BYREF

siginit();
logfile("client");
if ( (unsigned int)func5() )
{
LABEL_26:
v2 = (const char *)client_exitmsg;
if ( !client_exitmsg )
exit(0);
goto LABEL_27;
}
while ( 1 )
{
while ( 1 )
{
while ( 1 )
{
while ( 1 )
{
while ( 1 )
{
if ( sigterm )
{
client_exitmsg = (__int64)"terminated";
func1(5u, 0LL, 0);
}
if ( !sigchld )
break;
sigchld = 0;
waitpid(-1, 0LL, 1);
}
if ( !sigwinch )
break;
sigwinch = 0;
func1(9u, 0LL, 0);
}
if ( !sigcont )
break;
sigcont = 0;
siginit();
func1(0xDu, 0LL, 0);
}
fds.fd = *(int *)((char *)&dword_10038 + (_QWORD)&client_ibuf);
fds.events = 1;
if ( *(int *)((char *)&dword_10030 + (_QWORD)&client_ibuf) )
fds.events = 5;
v0 = poll(&fds, 1uLL, -1);
if ( v0 == -1 )
break;
if ( v0 )
{
if ( (fds.revents & 0x38) == 0 )
{
if ( (fds.revents & 1) == 0 )
goto LABEL_15;
goto LABEL_24;
}
LABEL_23:
log_fatalx("%s: %s", "client_main", "socket error");
LABEL_24:
if ( (unsigned int)imsg_read(&client_ibuf) + 1 <= 1 )
{
client_exitmsg = (__int64)"lost server";
LABEL_31:
v2 = (const char *)client_exitmsg;
LABEL_27:
if ( !login_shell )
printf("[%s]\n", v2);
exit(1);
}
if ( (unsigned int)func5() )
goto LABEL_26;
LABEL_15:
if ( (fds.revents & 4) != 0 && (int)msgbuf_write((unsigned int)((_DWORD)&client_ibuf + 65568)) < 0 )
{
client_exitmsg = (__int64)"lost server";
goto LABEL_31;
}
}
}
v1 = *_errno_location();
if ( v1 != 11 && v1 != 4 )
{
log_fatal("%s: %s", "client_main", "poll failed");
goto LABEL_23;
}
}
}

original_code:
__attribute__ ((__noreturn__)) void
client_main(void)
{
 struct pollfd pfd;
 int n, nfds;
 siginit();
 logfile("client");
 if (client_dispatch() != 0)
  goto out;
 for (;;) {
  if (sigterm) {
   client_exitmsg = "terminated";
   client_write_server(MSG_EXITING, ((void *)0), 0);
  }
  if (sigchld) {
   sigchld = 0;
   waitpid((-1), ((void *)0), 1);
   continue;
  }
  if (sigwinch) {
   sigwinch = 0;
   client_write_server(MSG_RESIZE, ((void *)0), 0);
   continue;
  }
  if (sigcont) {
   sigcont = 0;
   siginit();
   client_write_server(MSG_WAKEUP, ((void *)0), 0);
   continue;
  }
  pfd.fd = client_ibuf.fd;
  pfd.events = 0x001;
  if (client_ibuf.w.queued > 0)
   pfd.events |= 0x004;
  if ((nfds = poll(&pfd, 1, -1)) == -1) {
   if ((*__errno_location ()) == 11 || (*__errno_location ()) == 4)
    continue;
   log_fatal("%s: %s", __func__, "poll failed");;
  }
  if (nfds == 0)
   continue;
  if (pfd.revents & (0x008|0x010|0x020))
   log_fatalx("%s: %s", __func__, "socket error");;
  if (pfd.revents & 0x001) {
   if ((n = imsg_read(&client_ibuf)) == -1 || n == 0) {
    client_exitmsg = "lost server";
    break;
   }
   if (client_dispatch() != 0)
    break;
  }
  if (pfd.revents & 0x004) {
   if (msgbuf_write(&client_ibuf.w) < 0) {
    client_exitmsg = "lost server";
    break;
   }
  }
 }
out:
 if (client_exitmsg != ((void *)0)) {
  if (!login_shell)
   printf("[%s]\n", client_exitmsg);
  exit(1);
 }
 exit(0);
}

canonical_original_code:
void client_main()
{
 struct pollfd pfd;
 int n; int nfds;
 siginit();
 logfile("client");
 if (client_dispatch() != 0)
  goto out;
 for (;;) {
  if (sigterm) {
   client_exitmsg = "terminated";
   client_write_server(MSG_EXITING, ((void *)0), 0);
  }
  if (sigchld) {
   sigchld = 0;
   waitpid((-1), ((void *)0), 1);
   continue;
  }
  if (sigwinch) {
   sigwinch = 0;
   client_write_server(MSG_RESIZE, ((void *)0), 0);
   continue;
  }
  if (sigcont) {
   sigcont = 0;
   siginit();
   client_write_server(MSG_WAKEUP, ((void *)0), 0);
   continue;
  }
  pfd.fd = client_ibuf.fd;
  pfd.events = 0x001;
  if (client_ibuf.w.queued > 0)
   pfd.events |= 0x004;
  if ((nfds = poll(&pfd, 1, -1)) == -1) {
   if ((*__errno_location ()) == 11 || (*__errno_location ()) == 4)
    continue;
   log_fatal("%s: %s", __func__, "poll failed");;
  }
  if (nfds == 0)
   continue;
  if (pfd.revents & (0x008|0x010|0x020))
   log_fatalx("%s: %s", __func__, "socket error");;
  if (pfd.revents & 0x001) {
   if ((n = imsg_read(&client_ibuf)) == -1 || n == 0) {
    client_exitmsg = "lost server";
    break;
   }
   if (client_dispatch() != 0)
    break;
  }
  if (pfd.revents & 0x004) {
   if (msgbuf_write(&client_ibuf.w) < 0) {
    client_exitmsg = "lost server";
    break;
   }
  }
 }
out:
 if (client_exitmsg != ((void *)0)) {
  if (!login_shell)
   printf("[%s]\n", client_exitmsg);
  exit(1);
 }
 exit(0);
}

variable_types: struct pollfd { int fd; short events; short revents; }

variable_types: n int

variable_types: nfds int

return_type: void


decompiled_code:
__int64 __fastcall tty_term_strip(const char *a1)
{
char *v1; // rbx
char v2; // dl
__int64 v3; // rax
char i; // dl

v1 = (char *)a1;
if ( !strchr(a1, 36) )
return xstrdup(a1);
v2 = *a1;
v3 = 0LL;
if ( *a1 )
{
while ( 1 )
{
if ( v2 == 36 && v1[1] == 60 )
{
for ( i = *v1; *v1 && i != 62; i = *v1 )
++v1;
v1 += i == 62;
}
byte_C7F[++v3] = *v1;
if ( v3 == 0x1FFF )
break;
v2 = v1[1];
if ( !v2 )
break;
++v1;
}
}
buf_0[v3] = 0;
return xstrdup(buf_0);
}

original_code:
char *
tty_term_strip(const char *s)
{
 const char *ptr;
 static char buf[8192];
 size_t len;
 if (strchr(s, '$') == ((void *)0))
  return (xstrdup(s));
 len = 0;
 for (ptr = s; *ptr != '\0'; ptr++) {
  if (*ptr == '$' && *(ptr + 1) == '<') {
   while (*ptr != '\0' && *ptr != '>')
    ptr++;
   if (*ptr == '>')
    ptr++;
  }
  buf[len++] = *ptr;
  if (len == (sizeof buf) - 1)
   break;
 }
 buf[len] = '\0';
 return (xstrdup(buf));
}

canonical_original_code:
char *tty_term_strip(char *s)
{
 char *ptr;
 static char buf[8192];
 unsigned long len;
 if (strchr(s, '$') == ((void *)0))
  return (xstrdup(s));
 len = 0;
 for (ptr = s; *ptr != '\0'; ptr++) {
  if (*ptr == '$' && *(ptr + 1) == '<') {
   while (*ptr != '\0' && *ptr != '>')
    ptr++;
   if (*ptr == '>')
    ptr++;
  }
  buf[len++] = *ptr;
  if (len == (sizeof buf) - 1)
   break;
 }
 buf[len] = '\0';
 return (xstrdup(buf));
}

variable_types:
s
char *

variable_types:
ptr
char *

variable_types:
buf
char [8192]

variable_types:
len
unsigned long

return_type: char *


decompiled_code:
_BOOL8 __fastcall tty_term_has(__int64 a1, unsigned int a2)
{
return *(_DWORD *)(16LL * a2 + a1 + 16) != 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func2(__int64 a1, unsigned int a2)
{
return *(_DWORD *)(16LL * a2 + a1 + 16) != 0;
}

original_code:
int
tty_term_has(struct tty_term *term, enum tty_code_code code)
{
 return (term->codes[code].type != TTYCODE_NONE);
}

variable_types: struct tty_term { char *name; unsigned int references; struct tty_code { enum tty_code_type { TTYCODE_NONE=0, TTYCODE_STRING=1, TTYCODE_NUMBER=2, TTYCODE_FLAG=3 } type; union { char *string; int number; int flag; } value; } codes[-1]; int flags; struct { struct tty_term *sle_next; } entry; } *

variable_types: enum tty_code_code { TTYC_AX=0, TTYC_ACSC=1, TTYC_BEL=2, TTYC_BLINK=3, TTYC_BOLD=4, TTYC_CIVIS=5, TTYC_CLEAR=6, TTYC_CNORM=7, TTYC_COLORS=8, TTYC_CSR=9, TTYC_CUD=10, TTYC_CUD1=11, TTYC_CUP=12, TTYC_DCH=13, TTYC_DCH1=14, TTYC_DIM=15, TTYC_DL=16, TTYC_DL1=17, TTYC_EL=18, TTYC_EL1=19, TTYC_ENACS=20, TTYC_ICH=21, TTYC_ICH1=22, TTYC_IL=23, TTYC_IL1=24, TTYC_INVIS=25, TTYC_IS1=26, TTYC_IS2=27, TTYC_IS3=28, TTYC_KCBT=29, TTYC_KCUB1=30, TTYC_KCUD1=31, TTYC_KCUF1=32, TTYC_KCUU1=33, TTYC_KDCH1=34, TTYC_KEND=35, TTYC_KF1=36, TTYC_KF10=37, TTYC_KF11=38, TTYC_KF12=39, TTYC_KF13=40, TTYC_KF14=41, TTYC_KF15=42, TTYC_KF16=43, TTYC_KF17=44, TTYC_KF18=45, TTYC_KF19=46, TTYC_KF20=47, TTYC_KF2=48, TTYC_KF3=49, TTYC_KF4=50, TTYC_KF5=51, TTYC_KF6=52, TTYC_KF7=53, TTYC_KF8=54, TTYC_KF9=55, TTYC_KHOME=56, TTYC_KICH1=57, TTYC_KMOUS=58, TTYC_KNP=59, TTYC_KPP=60, TTYC_OP=61, TTYC_REV=62, TTYC_RI=63, TTYC_RMACS=64, TTYC_RMCUP=65, TTYC_RMIR=66, TTYC_RMKX=67, TTYC_SETAB=68, TTYC_SETAF=69, TTYC_SGR0=70, TTYC_SMACS=71, TTYC_SMCUP=72, TTYC_SMIR=73, TTYC_SMKX=74, TTYC_SMSO=75, TTYC_SMUL=76, TTYC_XENL=77 }

return_type: int

user_defined_types: struct tty_term { char *name; unsigned int references; struct tty_code codes[-1]; int flags; struct { struct tty_term *sle_next; } entry; }

user_defined_types: struct tty_code { enum tty_code_type type; union { char *string; int number; int flag; } value; }


decompiled_code:
char __fastcall tty_term_quirks(__int64 a1)
{
bool v2; // zf
__int64 v3; // rax

if ( !memcmp(*(const void **)a1, "rxvt", 4uLL) && !tty_term_has(a1, 0xEu) )
{
*(_DWORD *)(a1 + 240) = 1;
*(_QWORD *)(a1 + 248) = xstrdup("\x1B[P");
}
v2 = memcmp(*(const void **)a1, "xterm", 5uLL) == 0;
LOBYTE(v3) = !v2;
if ( v2 )
{
LODWORD(v3) = tty_term_has(a1, 0x16u);
if ( !(_DWORD)v3 )
{
*(_DWORD *)(a1 + 368) = 1;
v3 = xstrdup("\x1B[@");
*(_QWORD *)(a1 + 376) = v3;
}
}
return v3;
}

original_code:
void
tty_term_quirks(struct tty_term *term)
{
 if (strncmp(term->name, "rxvt", 4) == 0) {
  if (!tty_term_has(term, TTYC_DCH1)) {
   term->codes[TTYC_DCH1].type = TTYCODE_STRING;
   term->codes[TTYC_DCH1].value.string = xstrdup("\033[P");
  }
 }
 if (strncmp(term->name, "xterm", 5) == 0) {
  if (!tty_term_has(term, TTYC_ICH1)) {
   term->codes[TTYC_ICH1].type = TTYCODE_STRING;
   term->codes[TTYC_ICH1].value.string = xstrdup("\033[@");
  }
 }
}

user_defined_types: enum tty_code_type { TTYCODE_NONE=0, TTYCODE_STRING=1, TTYCODE_NUMBER=2, TTYCODE_FLAG=3 }


decompiled_code:
void *__fastcall tty_term_string(__int64 a1, unsigned int a2)
{
__int64 v2; // rbx

if ( tty_term_has(a1, a2) )
{
v2 = 16LL * a2 + a1;
if ( *(_DWORD *)(v2 + 16) == 1 )
return *(void **)(v2 + 24);
log_fatalx("not a string: %d", a2);
}
return &unk_2C93;
}

canonical_decompiled_code:
void *__fastcall func4(__int64 a1, unsigned int a2)
{
__int64 v2; // rbx

if ( func2(a1, a2) )
{
v2 = 16LL * a2 + a1;
if ( *(_DWORD *)(v2 + 16) == 1 )
return *(void **)(v2 + 24);
log_fatalx("not a string: %d", a2);
}
return &unk_2C93;
}

original_code:
const char *
tty_term_string(struct tty_term *term, enum tty_code_code code)
{
 if (!tty_term_has(term, code))
  return ("");
 if (term->codes[code].type != TTYCODE_STRING)
  log_fatalx("not a string: %d", code);
 return (term->codes[code].value.string);
}

canonical_original_code:
char *tty_term_string(struct tty_term *term, enum tty_code_code code)
{
 if (!tty_term_has(term, code))
  return ("");
 if (term->codes[code].type != TTYCODE_STRING)
  log_fatalx("not a string: %d", code);
 return (term->codes[code].value.string);
}

user_defined_types: enum tty_code_code { TTYC_AX=0, TTYC_ACSC=1, TTYC_BEL=2, TTYC_BLINK=3, TTYC_BOLD=4, TTYC_CIVIS=5, TTYC_CLEAR=6, TTYC_CNORM=7, TTYC_COLORS=8, TTYC_CSR=9, TTYC_CUD=10, TTYC_CUD1=11, TTYC_CUP=12, TTYC_DCH=13, TTYC_DCH1=14, TTYC_DIM=15, TTYC_DL=16, TTYC_DL1=17, TTYC_EL=18, TTYC_EL1=19, TTYC_ENACS=20, TTYC_ICH=21, TTYC_ICH1=22, TTYC_IL=23, TTYC_IL1=24, TTYC_INVIS=25, TTYC_IS1=26, TTYC_IS2=27, TTYC_IS3=28, TTYC_KCBT=29, TTYC_KCUB1=30, TTYC_KCUD1=31, TTYC_KCUF1=32, TTYC_KCUU1=33, TTYC_KDCH1=34, TTYC_KEND=35, TTYC_KF1=36, TTYC_KF10=37, TTYC_KF11=38, TTYC_KF12=39, TTYC_KF13=40, TTYC_KF14=41, TTYC_KF15=42, TTYC_KF16=43, TTYC_KF17=44, TTYC_KF18=45, TTYC_KF19=46, TTYC_KF20=47, TTYC_KF2=48, TTYC_KF3=49, TTYC_KF4=50, TTYC_KF5=51, TTYC_KF6=52, TTYC_KF7=53, TTYC_KF8=54, TTYC_KF9=55, TTYC_KHOME=56, TTYC_KICH1=57, TTYC_KMOUS=58, TTYC_KNP=59, TTYC_KPP=60, TTYC_OP=61, TTYC_REV=62, TTYC_RI=63, TTYC_RMACS=64, TTYC_RMCUP=65, TTYC_RMIR=66, TTYC_RMKX=67, TTYC_SETAB=68, TTYC_SETAF=69, TTYC_SGR0=70, TTYC_SMACS=71, TTYC_SMCUP=72, TTYC_SMIR=73, TTYC_SMKX=74, TTYC_SMSO=75, TTYC_SMUL=76, TTYC_XENL=77 }


decompiled_code:
__int64 __fastcall tty_term_number(__int64 a1, unsigned int a2)
{
__int64 result; // rax
__int64 v3; // rbx

result = tty_term_has(a1, a2);
if ( (_DWORD)result )
{
v3 = 16LL * a2 + a1;
if ( *(_DWORD *)(v3 + 16) == 2 )
{
result = *(unsigned int *)(v3 + 24);
}
else
{
log_fatalx("not a number: %d", a2);
result = tty_term_flag();
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, unsigned int a2)
{
__int64 result; // rax
__int64 v3; // rbx

result = func2(a1, a2);
if ( (_DWORD)result )
{
v3 = 16LL * a2 + a1;
if ( *(_DWORD *)(v3 + 16) == 2 )
{
result = *(unsigned int *)(v3 + 24);
}
else
{
log_fatalx("not a number: %d", a2);
result = func8();
}
}
return result;
}

original_code:
int
tty_term_number(struct tty_term *term, enum tty_code_code code)
{
 if (!tty_term_has(term, code))
  return (0);
 if (term->codes[code].type != TTYCODE_NUMBER)
  log_fatalx("not a number: %d", code);
 return (term->codes[code].value.number);
}


decompiled_code:
__int64 __fastcall tty_term_flag(__int64 a1, unsigned int a2)
{
__int64 result; // rax
__int64 v3; // rbx

result = tty_term_has(a1, a2);
if ( (_DWORD)result )
{
v3 = 16LL * a2 + a1;
if ( *(_DWORD *)(v3 + 16) == 3 )
{
result = *(unsigned int *)(v3 + 24);
}
else
{
log_fatalx("not a flag: %d", a2);
result = tty_term_find("not a flag: %d", a2);
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1, unsigned int a2)
{
__int64 result; // rax
__int64 v3; // rbx

result = func2(a1, a2);
if ( (_DWORD)result )
{
v3 = 16LL * a2 + a1;
if ( *(_DWORD *)(v3 + 16) == 3 )
{
result = *(unsigned int *)(v3 + 24);
}
else
{
log_fatalx("not a flag: %d", a2);
result = func9("not a flag: %d", a2);
}
}
return result;
}

original_code:
int
tty_term_flag(struct tty_term *term, enum tty_code_code code)
{
 if (!tty_term_has(term, code))
  return (0);
 if (term->codes[code].type != TTYCODE_FLAG)
  log_fatalx("not a flag: %d", code);
 return (term->codes[code].value.flag);
}


decompiled_code:
__int64 __fastcall cmd_suspend_client_exec(__int64 a1, __int64 a2)
{
__int64 v2; // rax
__int64 v3; // rbx

v2 = cmd_find_client(a2, *(_QWORD *)(*(_QWORD *)(a1 + 8) + 8LL));
if ( !v2 )
return 0xFFFFFFFFLL;
v3 = v2;
tty_stop_tty(v2 + 65656);
*(_DWORD *)(v3 + 66224) |= 0x40u;
server_write_client(v3, 11LL, 0LL, 0LL);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2)
{
__int64 v2; // rax
__int64 v3; // rbx

v2 = cmd_find_client(a2, *(_QWORD *)(*(_QWORD *)(a1 + 8) + 8LL));
if ( !v2 )
return 0xFFFFFFFFLL;
v3 = v2;
tty_stop_tty(v2 + 65656);
*(_DWORD *)(v3 + 66224) |= 0x40u;
server_write_client(v3, 11LL, 0LL, 0LL);
return 0LL;
}

original_code:
int
cmd_suspend_client_exec(struct cmd *self, struct cmd_ctx *ctx)
{
 struct cmd_target_data *data = self->data;
 struct client *c;
 if ((c = cmd_find_client(ctx, data->target)) == ((void *)0))
  return (-1);
 tty_stop_tty(&c->tty);
 c->flags |= 0x40;
 server_write_client(c, MSG_SUSPEND, ((void *)0), 0);
 return (0);
}

variable_types: struct cmd { struct cmd_entry { char *name; char *alias; char *usage; int flags; void (*init)(struct cmd *, int); int (*parse)(struct cmd *, int, char **, char **); int (*exec)(struct cmd *, struct cmd_ctx { struct client { int fd; struct buffer { unsigned char *base; unsigned long space; unsigned long size; unsigned long off; } *in; struct buffer *out; char *title; char *cwd; struct tty { char *path; unsigned int sx; unsigned int sy; unsigned int cx; unsigned int cy; int mode; unsigned int rlower; unsigned int rupper; char *termname; struct tty_term { char *name; unsigned int references; struct tty_code { enum tty_code_type { TTYCODE_NONE=0, TTYCODE_STRING=1, TTYCODE_NUMBER=2, TTYCODE_FLAG=3 } type; union { char *string; int number; int flag; } value; } codes[-1]; int flags; struct { struct tty_term *sle_next; } entry; } *term; int fd; struct buffer *in; struct buffer *out; int log_fd; struct termios { unsigned int c_iflag; unsigned int c_oflag; unsigned int c_cflag; unsigned int c_lflag; unsigned char c_line; unsigned char c_cc[32]; unsigned int c_ispeed; unsigned int c_ospeed; } tio; struct grid_cell { unsigned char attr; unsigned char flags; unsigned char fg; unsigned char bg; unsigned char data; } cell; unsigned char acs[-1]; int flags; int term_flags; struct timeval { long tv_sec; long tv_usec; } key_timer; unsigned long ksize; struct tty_keys { struct tty_key { int key; char *string; int flags; struct { struct tty_key *rbe_left; struct tty_key *rbe_right; struct tty_key *rbe_parent; int rbe_color; } entry; } *rbh_root; } ktree; } tty; struct timeval status_timer; struct timeval repeat_timer; struct screen { char *title; struct grid { unsigned int sx; unsigned int sy; unsigned int hsize; unsigned int hlimit; unsigned int *size; struct grid_cell **data; unsigned int *usize; struct grid_utf8 { unsigned char width; unsigned char data[8]; } **udata; } *grid; unsigned int cx; unsigned int cy; unsigned int old_cx; unsigned int old_cy; unsigned int rupper; unsigned int rlower; unsigned int old_rupper; unsigned int old_rlower; int mode; unsigned char *tabs; struct screen_sel { int flag; unsigned int sx; unsigned int sy; unsigned int ex; unsigned int ey; struct grid_cell cell; } sel; } status; int flags; char *message_string; struct timeval message_timer; char *prompt_string; char *prompt_buffer; unsigned long prompt_index; int (*prompt_callback)(void *, char *); void *prompt_data; int prompt_flags; unsigned int prompt_hindex; struct { char **list; unsigned int num; unsigned long space; } prompt_hdata; struct mode_key_data { int type; int flags; } prompt_mdata; struct session { char *name; struct timeval tv; unsigned int sx; unsigned int sy; struct winlink { int idx; struct window { char *name; struct timeval name_timer; struct window_pane { struct window *window; unsigned int sx; unsigned int sy; unsigned int xoff; unsigned int yoff; int flags; char *cmd; char *cwd; int pid; int fd; char tty[32]; struct buffer *in; struct buffer *out; struct input_ctx { struct window_pane *wp; struct screen_write_ctx { struct window_pane *wp; struct screen *s; } ctx; unsigned char *buf; unsigned long len; unsigned long off; struct grid_cell cell; struct grid_cell saved_cell; unsigned int saved_cx; unsigned int saved_cy; unsigned char *string_buf; unsigned long string_len; int string_type; unsigned char utf8_buf[4]; unsigned int utf8_len; unsigned int utf8_off; unsigned char intermediate; void *(*state)(unsigned char, struct input_ctx *); unsigned char private; struct { struct input_arg { unsigned char data[64]; unsigned long used; } *list; unsigned int num; unsigned long space; } args; } ictx; struct screen *screen; struct screen base; struct window_mode { struct screen *(*init)(struct window_pane *); void (*free)(struct window_pane *); void (*resize)(struct window_pane *, unsigned int, unsigned int); void (*key)(struct window_pane *, struct client *, int); void (*mouse)(struct window_pane *, struct client *, unsigned char, unsigned char, unsigned char); void (*timer)(struct window_pane *); } *mode; void *modedata; struct { struct window_pane *tqe_next; struct window_pane **tqe_prev; } entry; } *active; struct window_panes { struct window_pane *tqh_first; struct window_pane **tqh_last; } panes; unsigned int layout; unsigned int sx; unsigned int sy; int flags; struct options { struct options_tree { struct options_entry { char *name; enum { OPTIONS_STRING=0, OPTIONS_NUMBER=1, OPTIONS_KEY=2 } type; union { char *string; long long number; int key; } value; struct { struct options_entry *spe_left; struct options_entry *spe_right; } entry; } *sph_root; } tree; struct options *parent; } options; unsigned int references; } *window; struct { struct winlink *rbe_left; struct winlink *rbe_right; struct winlink *rbe_parent; int rbe_color; } entry; struct { struct winlink *sle_next; } sentry; } *curw; struct winlink_stack { struct winlink *slh_first; } lastw; struct winlinks { struct winlink *rbh_root; } windows; struct options options; struct paste_stack { struct paste_buffer { char *data; struct timeval tv; } **list; unsigned int num; unsigned long space; } buffers; struct { struct session_alert { struct winlink *wl; int type; struct { struct session_alert *sle_next; } entry; } *slh_first; } alerts; int flags; } *session; } *cmdclient; struct client *curclient; struct session *cursession; struct msg_command_data { int pid; unsigned int idx; unsigned long namelen; } *msgdata; void (*print)(struct cmd_ctx *, char *, ...); void (*info)(struct cmd_ctx *, char *, ...); void (*error)(struct cmd_ctx *, char *, ...); } *); void (*send)(struct cmd *, struct buffer *); void (*recv)(struct cmd *, struct buffer *); void (*free)(struct cmd *); unsigned long (*print)(struct cmd *, char *, unsigned long); } *entry; void *data; struct { struct cmd *tqe_next; struct cmd **tqe_prev; } qentry; } *

variable_types:
ctx
struct cmd_ctx *

variable_types: struct cmd_target_data { int flags; char *target; char *arg; } *

user_defined_types: struct cmd { struct cmd_entry *entry; void *data; struct { struct cmd *tqe_next; struct cmd **tqe_prev; } qentry; }

user_defined_types: struct client { int fd; struct buffer *in; struct buffer *out; char *title; char *cwd; struct tty tty; struct timeval status_timer; struct timeval repeat_timer; struct screen status; int flags; char *message_string; struct timeval message_timer; char *prompt_string; char *prompt_buffer; unsigned long prompt_index; int (*prompt_callback)(void *, char *); void *prompt_data; int prompt_flags; unsigned int prompt_hindex; struct { char **list; unsigned int num; unsigned long space; } prompt_hdata; struct mode_key_data prompt_mdata; struct session *session; }

user_defined_types: struct tty { char *path; unsigned int sx; unsigned int sy; unsigned int cx; unsigned int cy; int mode; unsigned int rlower; unsigned int rupper; char *termname; struct tty_term *term; int fd; struct buffer *in; struct buffer *out; int log_fd; struct termios tio; struct grid_cell cell; unsigned char acs[-1]; int flags; int term_flags; struct timeval key_timer; unsigned long ksize; struct tty_keys ktree; }

user_defined_types: struct screen { char *title; struct grid *grid; unsigned int cx; unsigned int cy; unsigned int old_cx; unsigned int old_cy; unsigned int rupper; unsigned int rlower; unsigned int old_rupper; unsigned int old_rlower; int mode; unsigned char *tabs; struct screen_sel sel; }

user_defined_types: struct cmd_entry { char *name; char *alias; char *usage; int flags; void (*init)(struct cmd *, int); int (*parse)(struct cmd *, int, char **, char **); int (*exec)(struct cmd *, struct cmd_ctx *); void (*send)(struct cmd *, struct buffer *); void (*recv)(struct cmd *, struct buffer *); void (*free)(struct cmd *); unsigned long (*print)(struct cmd *, char *, unsigned long); }

user_defined_types: struct tty_keys { struct tty_key *rbh_root; }

user_defined_types: struct session { char *name; struct timeval tv; unsigned int sx; unsigned int sy; struct winlink *curw; struct winlink_stack lastw; struct winlinks windows; struct options options; struct paste_stack buffers; struct { struct session_alert *slh_first; } alerts; int flags; }

user_defined_types: struct grid { unsigned int sx; unsigned int sy; unsigned int hsize; unsigned int hlimit; unsigned int *size; struct grid_cell **data; unsigned int *usize; struct grid_utf8 **udata; }

user_defined_types: struct paste_stack { struct paste_buffer **list; unsigned int num; unsigned long space; }

user_defined_types: struct winlink { int idx; struct window *window; struct { struct winlink *rbe_left; struct winlink *rbe_right; struct winlink *rbe_parent; int rbe_color; } entry; struct { struct winlink *sle_next; } sentry; }

user_defined_types: struct cmd_ctx { struct client *cmdclient; struct client *curclient; struct session *cursession; struct msg_command_data *msgdata; void (*print)(struct cmd_ctx *, char *, ...); void (*info)(struct cmd_ctx *, char *, ...); void (*error)(struct cmd_ctx *, char *, ...); }

user_defined_types: struct window { char *name; struct timeval name_timer; struct window_pane *active; struct window_panes panes; unsigned int layout; unsigned int sx; unsigned int sy; int flags; struct options options; unsigned int references; }

user_defined_types: struct options { struct options_tree tree; struct options *parent; }

user_defined_types: struct window_pane { struct window *window; unsigned int sx; unsigned int sy; unsigned int xoff; unsigned int yoff; int flags; char *cmd; char *cwd; int pid; int fd; char tty[32]; struct buffer *in; struct buffer *out; struct input_ctx ictx; struct screen *screen; struct screen base; struct window_mode *mode; void *modedata; struct { struct window_pane *tqe_next; struct window_pane **tqe_prev; } entry; }

user_defined_types: struct options_tree { struct options_entry *sph_root; }

user_defined_types: struct input_ctx { struct window_pane *wp; struct screen_write_ctx ctx; unsigned char *buf; unsigned long len; unsigned long off; struct grid_cell cell; struct grid_cell saved_cell; unsigned int saved_cx; unsigned int saved_cy; unsigned char *string_buf; unsigned long string_len; int string_type; unsigned char utf8_buf[4]; unsigned int utf8_len; unsigned int utf8_off; unsigned char intermediate; void *(*state)(unsigned char, struct input_ctx *); unsigned char private; struct { struct input_arg *list; unsigned int num; unsigned long space; } args; }


original_code: void mode_key_tree_SPLAY_MINMAX(struct mode_key_tree *head, int __comp) { struct mode_key_binding __node, *__left, *__right, *__tmp; (&__node)->entry.spe_left = (&__node)->entry.spe_right = ((void *)0); __left = __right = &__node; while (1) { if (__comp < 0) { __tmp = ((head)->sph_root)->entry.spe_left; if (__tmp == ((void *)0)) break; if (__comp < 0){ do { ((head)->sph_root)->entry.spe_left = (__tmp)->entry.spe_right; (__tmp)->entry.spe_right = (head)->sph_root; (head)->sph_root = __tmp; } while (0); if (((head)->sph_root)->entry.spe_left == ((void *)0)) break; } do { (__right)->entry.spe_left = (head)->sph_root; __right = (head)->sph_root; (head)->sph_root = ((head)->sph_root)->entry.spe_left; } while (0); } else if (__comp > 0) { __tmp = ((head)->sph_root)->entry.spe_right; if (__tmp == ((void *)0)) break; if (__comp > 0) { do { ((head)->sph_root)->entry.spe_right = (__tmp)->entry.spe_left; (__tmp)->entry.spe_left = (head)->sph_root; (head)->sph_root = __tmp; } while (0); if (((head)->sph_root)->entry.spe_right == ((void *)0)) break; } do { (__left)->entry.spe_right = (head)->sph_root; __left = (head)->sph_root; (head)->sph_root = ((head)->sph_root)->entry.spe_right; } while (0); } } do { (__left)->entry.spe_right = ((head)->sph_root)->entry.spe_left; (__right)->entry.spe_left = ((head)->sph_root)->entry.spe_right; ((head)->sph_root)->entry.spe_left = (&__node)->entry.spe_right; ((head)->sph_root)->entry.spe_right = (&__node)->entry.spe_left; } while (0); }

canonical_original_code: void mode_key_tree_SPLAY_MINMAX(struct mode_key_tree *head, int __comp) { struct mode_key_binding __node; struct mode_key_binding *__left; struct mode_key_binding *__right; struct mode_key_binding *__tmp; (&__node)->entry.spe_left = (&__node)->entry.spe_right = ((void *)0); __left = __right = &__node; while (1) { if (__comp < 0) { __tmp = ((head)->sph_root)->entry.spe_left; if (__tmp == ((void *)0)) break; if (__comp < 0){ do { ((head)->sph_root)->entry.spe_left = (__tmp)->entry.spe_right; (__tmp)->entry.spe_right = (head)->sph_root; (head)->sph_root = __tmp; } while (0); if (((head)->sph_root)->entry.spe_left == ((void *)0)) break; } do { (__right)->entry.spe_left = (head)->sph_root; __right = (head)->sph_root; (head)->sph_root = ((head)->sph_root)->entry.spe_left; } while (0); } else if (__comp > 0) { __tmp = ((head)->sph_root)->entry.spe_right; if (__tmp == ((void *)0)) break; if (__comp > 0) { do { ((head)->sph_root)->entry.spe_right = (__tmp)->entry.spe_left; (__tmp)->entry.spe_left = (head)->sph_root; (head)->sph_root = __tmp; } while (0); if (((head)->sph_root)->entry.spe_right == ((void *)0)) break; } do { (__left)->entry.spe_right = (head)->sph_root; __left = (head)->sph_root; (head)->sph_root = ((head)->sph_root)->entry.spe_right; } while (0); } } do { (__left)->entry.spe_right = ((head)->sph_root)->entry.spe_left; (__right)->entry.spe_left = ((head)->sph_root)->entry.spe_right; ((head)->sph_root)->entry.spe_left = (&__node)->entry.spe_right; ((head)->sph_root)->entry.spe_right = (&__node)->entry.spe_left; } while (0); }

variable_types: struct mode_key_tree { struct mode_key_binding { int key; int mode; enum mode_key_cmd { MODEKEY_NONE=0, MODEKEY_OTHER=1, MODEKEYEDIT_BACKSPACE=2, MODEKEYEDIT_CANCEL=3, MODEKEYEDIT_COMPLETE=4, MODEKEYEDIT_CURSORLEFT=5, MODEKEYEDIT_CURSORRIGHT=6, MODEKEYEDIT_DELETE=7, MODEKEYEDIT_DELETELINE=8, MODEKEYEDIT_DELETETOENDOFLINE=9, MODEKEYEDIT_ENDOFLINE=10, MODEKEYEDIT_ENTER=11, MODEKEYEDIT_HISTORYDOWN=12, MODEKEYEDIT_HISTORYUP=13, MODEKEYEDIT_PASTE=14, MODEKEYEDIT_STARTOFLINE=15, MODEKEYEDIT_SWITCHMODE=16, MODEKEYEDIT_SWITCHMODEAPPEND=17, MODEKEYEDIT_TRANSPOSECHARS=18, MODEKEYCHOICE_CANCEL=19, MODEKEYCHOICE_CHOOSE=20, MODEKEYCHOICE_DOWN=21, MODEKEYCHOICE_PAGEDOWN=22, MODEKEYCHOICE_PAGEUP=23, MODEKEYCHOICE_UP=24, MODEKEYCOPY_BACKTOINDENTATION=25, MODEKEYCOPY_BOTTOMLINE=26, MODEKEYCOPY_CANCEL=27, MODEKEYCOPY_CLEARSELECTION=28, MODEKEYCOPY_COPYSELECTION=29, MODEKEYCOPY_DOWN=30, MODEKEYCOPY_ENDOFLINE=31, MODEKEYCOPY_GOTOLINE=32, MODEKEYCOPY_HALFPAGEDOWN=33, MODEKEYCOPY_HALFPAGEUP=34, MODEKEYCOPY_LEFT=35, MODEKEYCOPY_MIDDLELINE=36, MODEKEYCOPY_NEXTPAGE=37, MODEKEYCOPY_NEXTWORD=38, MODEKEYCOPY_PREVIOUSPAGE=39, MODEKEYCOPY_PREVIOUSWORD=40, MODEKEYCOPY_RIGHT=41, MODEKEYCOPY_SCROLLDOWN=42, MODEKEYCOPY_SCROLLUP=43, MODEKEYCOPY_SEARCHAGAIN=44, MODEKEYCOPY_SEARCHDOWN=45, MODEKEYCOPY_SEARCHUP=46, MODEKEYCOPY_STARTOFLINE=47, MODEKEYCOPY_STARTSELECTION=48, MODEKEYCOPY_TOPLINE=49, MODEKEYCOPY_UP=50 } cmd; struct { struct mode_key_binding *spe_left; struct mode_key_binding *spe_right; } entry; } *sph_root; } *

user_defined_types: struct mode_key_binding { int key; int mode; enum mode_key_cmd cmd; struct { struct mode_key_binding *spe_left; struct mode_key_binding *spe_right; } entry; }

user_defined_types: struct mode_key_tree { struct mode_key_binding *sph_root; }


decompiled_code:
__int64 __fastcall mode_key_cmp(_DWORD *a1, _DWORD *a2)
{
int v2; // eax
int v3; // edx
__int64 result; // rax

v2 = a1[1];
v3 = a2[1];
if ( v2 == v3 )
result = (unsigned int)(*a1 - *a2);
else
result = (unsigned int)(v2 - v3);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(_DWORD *a1, _DWORD *a2)
{
int v2; // eax
int v3; // edx
__int64 result; // rax

v2 = a1[1];
v3 = a2[1];
if ( v2 == v3 )
result = (unsigned int)(*a1 - *a2);
else
result = (unsigned int)(v2 - v3);
return result;
}

original_code:
int
mode_key_cmp(struct mode_key_binding *mbind1, struct mode_key_binding *mbind2)
{
 if (mbind1->mode != mbind2->mode)
  return (mbind1->mode - mbind2->mode);
 return (mbind1->key - mbind2->key);
}

variable_types: struct mode_key_binding { int key; int mode; enum mode_key_cmd { MODEKEY_NONE=0, MODEKEY_OTHER=1, MODEKEYEDIT_BACKSPACE=2, MODEKEYEDIT_CANCEL=3, MODEKEYEDIT_COMPLETE=4, MODEKEYEDIT_CURSORLEFT=5, MODEKEYEDIT_CURSORRIGHT=6, MODEKEYEDIT_DELETE=7, MODEKEYEDIT_DELETELINE=8, MODEKEYEDIT_DELETETOENDOFLINE=9, MODEKEYEDIT_ENDOFLINE=10, MODEKEYEDIT_ENTER=11, MODEKEYEDIT_HISTORYDOWN=12, MODEKEYEDIT_HISTORYUP=13, MODEKEYEDIT_PASTE=14, MODEKEYEDIT_STARTOFLINE=15, MODEKEYEDIT_SWITCHMODE=16, MODEKEYEDIT_SWITCHMODEAPPEND=17, MODEKEYEDIT_TRANSPOSECHARS=18, MODEKEYCHOICE_CANCEL=19, MODEKEYCHOICE_CHOOSE=20, MODEKEYCHOICE_DOWN=21, MODEKEYCHOICE_PAGEDOWN=22, MODEKEYCHOICE_PAGEUP=23, MODEKEYCHOICE_UP=24, MODEKEYCOPY_BACKTOINDENTATION=25, MODEKEYCOPY_BOTTOMLINE=26, MODEKEYCOPY_CANCEL=27, MODEKEYCOPY_CLEARSELECTION=28, MODEKEYCOPY_COPYSELECTION=29, MODEKEYCOPY_DOWN=30, MODEKEYCOPY_ENDOFLINE=31, MODEKEYCOPY_GOTOLINE=32, MODEKEYCOPY_HALFPAGEDOWN=33, MODEKEYCOPY_HALFPAGEUP=34, MODEKEYCOPY_LEFT=35, MODEKEYCOPY_MIDDLELINE=36, MODEKEYCOPY_NEXTPAGE=37, MODEKEYCOPY_NEXTWORD=38, MODEKEYCOPY_PREVIOUSPAGE=39, MODEKEYCOPY_PREVIOUSWORD=40, MODEKEYCOPY_RIGHT=41, MODEKEYCOPY_SCROLLDOWN=42, MODEKEYCOPY_SCROLLUP=43, MODEKEYCOPY_SEARCHAGAIN=44, MODEKEYCOPY_SEARCHDOWN=45, MODEKEYCOPY_SEARCHUP=46, MODEKEYCOPY_STARTOFLINE=47, MODEKEYCOPY_STARTSELECTION=48, MODEKEYCOPY_TOPLINE=49, MODEKEYCOPY_UP=50 } cmd; struct { struct mode_key_binding *spe_left; struct mode_key_binding *spe_right; } entry; } *


original_code: void mode_key_tree_SPLAY(struct mode_key_tree *head, struct mode_key_binding *elm) { struct mode_key_binding __node, *__left, *__right, *__tmp; int __comp; (&__node)->entry.spe_left = (&__node)->entry.spe_right = ((void *)0); __left = __right = &__node; while ((__comp = (mode_key_cmp)(elm, (head)->sph_root))) { if (__comp < 0) { __tmp = ((head)->sph_root)->entry.spe_left; if (__tmp == ((void *)0)) break; if ((mode_key_cmp)(elm, __tmp) < 0){ do { ((head)->sph_root)->entry.spe_left = (__tmp)->entry.spe_right; (__tmp)->entry.spe_right = (head)->sph_root; (head)->sph_root = __tmp; } while (0); if (((head)->sph_root)->entry.spe_left == ((void *)0)) break; } do { (__right)->entry.spe_left = (head)->sph_root; __right = (head)->sph_root; (head)->sph_root = ((head)->sph_root)->entry.spe_left; } while (0); } else if (__comp > 0) { __tmp = ((head)->sph_root)->entry.spe_right; if (__tmp == ((void *)0)) break; if ((mode_key_cmp)(elm, __tmp) > 0){ do { ((head)->sph_root)->entry.spe_right = (__tmp)->entry.spe_left; (__tmp)->entry.spe_left = (head)->sph_root; (head)->sph_root = __tmp; } while (0); if (((head)->sph_root)->entry.spe_right == ((void *)0)) break; } do { (__left)->entry.spe_right = (head)->sph_root; __left = (head)->sph_root; (head)->sph_root = ((head)->sph_root)->entry.spe_right; } while (0); } } do { (__left)->entry.spe_right = ((head)->sph_root)->entry.spe_left; (__right)->entry.spe_left = ((head)->sph_root)->entry.spe_right; ((head)->sph_root)->entry.spe_left = (&__node)->entry.spe_right; ((head)->sph_root)->entry.spe_right = (&__node)->entry.spe_left; } while (0); }

canonical_original_code: void mode_key_tree_SPLAY(struct mode_key_tree *head, struct mode_key_binding *elm) { struct mode_key_binding __node; struct mode_key_binding *__left; struct mode_key_binding *__right; struct mode_key_binding *__tmp; int __comp; (&__node)->entry.spe_left = (&__node)->entry.spe_right = ((void *)0); __left = __right = &__node; while ((__comp = (mode_key_cmp)(elm, (head)->sph_root))) { if (__comp < 0) { __tmp = ((head)->sph_root)->entry.spe_left; if (__tmp == ((void *)0)) break; if ((mode_key_cmp)(elm, __tmp) < 0){ do { ((head)->sph_root)->entry.spe_left = (__tmp)->entry.spe_right; (__tmp)->entry.spe_right = (head)->sph_root; (head)->sph_root = __tmp; } while (0); if (((head)->sph_root)->entry.spe_left == ((void *)0)) break; } do { (__right)->entry.spe_left = (head)->sph_root; __right = (head)->sph_root; (head)->sph_root = ((head)->sph_root)->entry.spe_left; } while (0); } else if (__comp > 0) { __tmp = ((head)->sph_root)->entry.spe_right; if (__tmp == ((void *)0)) break; if ((mode_key_cmp)(elm, __tmp) > 0){ do { ((head)->sph_root)->entry.spe_right = (__tmp)->entry.spe_left; (__tmp)->entry.spe_left = (head)->sph_root; (head)->sph_root = __tmp; } while (0); if (((head)->sph_root)->entry.spe_right == ((void *)0)) break; } do { (__left)->entry.spe_right = (head)->sph_root; __left = (head)->sph_root; (head)->sph_root = ((head)->sph_root)->entry.spe_right; } while (0); } } do { (__left)->entry.spe_right = ((head)->sph_root)->entry.spe_left; (__right)->entry.spe_left = ((head)->sph_root)->entry.spe_right; ((head)->sph_root)->entry.spe_left = (&__node)->entry.spe_right; ((head)->sph_root)->entry.spe_right = (&__node)->entry.spe_left; } while (0); }

variable_types:
elm
struct mode_key_binding *

variable_types: struct mode_key_binding { int key; int mode; enum mode_key_cmd { MODEKEY_NONE=0, MODEKEY_OTHER=1, MODEKEYEDIT_BACKSPACE=2, MODEKEYEDIT_CANCEL=3, MODEKEYEDIT_COMPLETE=4, MODEKEYEDIT_CURSORLEFT=5, MODEKEYEDIT_CURSORRIGHT=6, MODEKEYEDIT_DELETE=7, MODEKEYEDIT_DELETELINE=8, MODEKEYEDIT_DELETETOENDOFLINE=9, MODEKEYEDIT_ENDOFLINE=10, MODEKEYEDIT_ENTER=11, MODEKEYEDIT_HISTORYDOWN=12, MODEKEYEDIT_HISTORYUP=13, MODEKEYEDIT_PASTE=14, MODEKEYEDIT_STARTOFLINE=15, MODEKEYEDIT_SWITCHMODE=16, MODEKEYEDIT_SWITCHMODEAPPEND=17, MODEKEYEDIT_TRANSPOSECHARS=18, MODEKEYCHOICE_CANCEL=19, MODEKEYCHOICE_CHOOSE=20, MODEKEYCHOICE_DOWN=21, MODEKEYCHOICE_PAGEDOWN=22, MODEKEYCHOICE_PAGEUP=23, MODEKEYCHOICE_UP=24, MODEKEYCOPY_BACKTOINDENTATION=25, MODEKEYCOPY_BOTTOMLINE=26, MODEKEYCOPY_CANCEL=27, MODEKEYCOPY_CLEARSELECTION=28, MODEKEYCOPY_COPYSELECTION=29, MODEKEYCOPY_DOWN=30, MODEKEYCOPY_ENDOFLINE=31, MODEKEYCOPY_GOTOLINE=32, MODEKEYCOPY_HALFPAGEDOWN=33, MODEKEYCOPY_HALFPAGEUP=34, MODEKEYCOPY_LEFT=35, MODEKEYCOPY_MIDDLELINE=36, MODEKEYCOPY_NEXTPAGE=37, MODEKEYCOPY_NEXTWORD=38, MODEKEYCOPY_PREVIOUSPAGE=39, MODEKEYCOPY_PREVIOUSWORD=40, MODEKEYCOPY_RIGHT=41, MODEKEYCOPY_SCROLLDOWN=42, MODEKEYCOPY_SCROLLUP=43, MODEKEYCOPY_SEARCHAGAIN=44, MODEKEYCOPY_SEARCHDOWN=45, MODEKEYCOPY_SEARCHUP=46, MODEKEYCOPY_STARTOFLINE=47, MODEKEYCOPY_STARTSELECTION=48, MODEKEYCOPY_TOPLINE=49, MODEKEYCOPY_UP=50 } cmd; struct { struct mode_key_binding *spe_left; struct mode_key_binding *spe_right; } entry; }


decompiled_code:
__int64 __fastcall mode_key_tostring(__int64 a1, int a2)
{
__int64 result; // rax

for ( result = *(_QWORD *)(a1 + 8); result; result = *(_QWORD *)(a1 + 8) )
{
if ( *(_DWORD *)a1 == a2 )
break;
a1 += 16LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, int a2)
{
__int64 result; // rax

for ( result = *(_QWORD *)(a1 + 8); result; result = *(_QWORD *)(a1 + 8) )
{
if ( *(_DWORD *)a1 == a2 )
break;
a1 += 16LL;
}
return result;
}

original_code:
const char *
mode_key_tostring(struct mode_key_cmdstr *cmdstr, enum mode_key_cmd cmd)
{
 for (; cmdstr->name != ((void *)0); cmdstr++) {
  if (cmdstr->cmd == cmd)
   return (cmdstr->name);
 }
 return (((void *)0));
}

canonical_original_code:
char *mode_key_tostring(struct mode_key_cmdstr *cmdstr, enum mode_key_cmd cmd)
{
 for (; cmdstr->name != ((void *)0); cmdstr++) {
  if (cmdstr->cmd == cmd)
   return (cmdstr->name);
 }
 return (((void *)0));
}

variable_types: struct mode_key_cmdstr { enum mode_key_cmd { MODEKEY_NONE=0, MODEKEY_OTHER=1, MODEKEYEDIT_BACKSPACE=2, MODEKEYEDIT_CANCEL=3, MODEKEYEDIT_COMPLETE=4, MODEKEYEDIT_CURSORLEFT=5, MODEKEYEDIT_CURSORRIGHT=6, MODEKEYEDIT_DELETE=7, MODEKEYEDIT_DELETELINE=8, MODEKEYEDIT_DELETETOENDOFLINE=9, MODEKEYEDIT_ENDOFLINE=10, MODEKEYEDIT_ENTER=11, MODEKEYEDIT_HISTORYDOWN=12, MODEKEYEDIT_HISTORYUP=13, MODEKEYEDIT_PASTE=14, MODEKEYEDIT_STARTOFLINE=15, MODEKEYEDIT_SWITCHMODE=16, MODEKEYEDIT_SWITCHMODEAPPEND=17, MODEKEYEDIT_TRANSPOSECHARS=18, MODEKEYCHOICE_CANCEL=19, MODEKEYCHOICE_CHOOSE=20, MODEKEYCHOICE_DOWN=21, MODEKEYCHOICE_PAGEDOWN=22, MODEKEYCHOICE_PAGEUP=23, MODEKEYCHOICE_UP=24, MODEKEYCOPY_BACKTOINDENTATION=25, MODEKEYCOPY_BOTTOMLINE=26, MODEKEYCOPY_CANCEL=27, MODEKEYCOPY_CLEARSELECTION=28, MODEKEYCOPY_COPYSELECTION=29, MODEKEYCOPY_DOWN=30, MODEKEYCOPY_ENDOFLINE=31, MODEKEYCOPY_GOTOLINE=32, MODEKEYCOPY_HALFPAGEDOWN=33, MODEKEYCOPY_HALFPAGEUP=34, MODEKEYCOPY_LEFT=35, MODEKEYCOPY_MIDDLELINE=36, MODEKEYCOPY_NEXTPAGE=37, MODEKEYCOPY_NEXTWORD=38, MODEKEYCOPY_PREVIOUSPAGE=39, MODEKEYCOPY_PREVIOUSWORD=40, MODEKEYCOPY_RIGHT=41, MODEKEYCOPY_SCROLLDOWN=42, MODEKEYCOPY_SCROLLUP=43, MODEKEYCOPY_SEARCHAGAIN=44, MODEKEYCOPY_SEARCHDOWN=45, MODEKEYCOPY_SEARCHUP=46, MODEKEYCOPY_STARTOFLINE=47, MODEKEYCOPY_STARTSELECTION=48, MODEKEYCOPY_TOPLINE=49, MODEKEYCOPY_UP=50 } cmd; char *name; } *

user_defined_types: struct mode_key_cmdstr { enum mode_key_cmd cmd; char *name; }


decompiled_code:
__int64 __fastcall mode_key_fromstring(__int64 a1, const char *a2)
{
_QWORD *v2; // rbx
const char *v3; // rdi

v2 = (_QWORD *)a1;
v3 = *(const char **)(a1 + 8);
if ( !v3 )
return 0LL;
while ( strcasecmp(v3, a2) )
{
v2 += 2;
v3 = (const char *)v2[1];
if ( !v3 )
return 0LL;
}
return *(unsigned int *)v2;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, const char *a2)
{
_QWORD *v2; // rbx
const char *v3; // rdi

v2 = (_QWORD *)a1;
v3 = *(const char **)(a1 + 8);
if ( !v3 )
return 0LL;
while ( strcasecmp(v3, a2) )
{
v2 += 2;
v3 = (const char *)v2[1];
if ( !v3 )
return 0LL;
}
return *(unsigned int *)v2;
}

original_code:
enum mode_key_cmd
mode_key_fromstring(struct mode_key_cmdstr *cmdstr, const char *name)
{
 for (; cmdstr->name != ((void *)0); cmdstr++) {
  if (strcasecmp(cmdstr->name, name) == 0)
   return (cmdstr->cmd);
 }
 return (MODEKEY_NONE);
}

canonical_original_code:
enum mode_key_cmd mode_key_fromstring(struct mode_key_cmdstr *cmdstr, char *name)
{
 for (; cmdstr->name != ((void *)0); cmdstr++) {
  if (strcasecmp(cmdstr->name, name) == 0)
   return (cmdstr->cmd);
 }
 return (MODEKEY_NONE);
}

variable_types:
name
char *

return_type: enum mode_key_cmd { MODEKEY_NONE=0, MODEKEY_OTHER=1, MODEKEYEDIT_BACKSPACE=2, MODEKEYEDIT_CANCEL=3, MODEKEYEDIT_COMPLETE=4, MODEKEYEDIT_CURSORLEFT=5, MODEKEYEDIT_CURSORRIGHT=6, MODEKEYEDIT_DELETE=7, MODEKEYEDIT_DELETELINE=8, MODEKEYEDIT_DELETETOENDOFLINE=9, MODEKEYEDIT_ENDOFLINE=10, MODEKEYEDIT_ENTER=11, MODEKEYEDIT_HISTORYDOWN=12, MODEKEYEDIT_HISTORYUP=13, MODEKEYEDIT_PASTE=14, MODEKEYEDIT_STARTOFLINE=15, MODEKEYEDIT_SWITCHMODE=16, MODEKEYEDIT_SWITCHMODEAPPEND=17, MODEKEYEDIT_TRANSPOSECHARS=18, MODEKEYCHOICE_CANCEL=19, MODEKEYCHOICE_CHOOSE=20, MODEKEYCHOICE_DOWN=21, MODEKEYCHOICE_PAGEDOWN=22, MODEKEYCHOICE_PAGEUP=23, MODEKEYCHOICE_UP=24, MODEKEYCOPY_BACKTOINDENTATION=25, MODEKEYCOPY_BOTTOMLINE=26, MODEKEYCOPY_CANCEL=27, MODEKEYCOPY_CLEARSELECTION=28, MODEKEYCOPY_COPYSELECTION=29, MODEKEYCOPY_DOWN=30, MODEKEYCOPY_ENDOFLINE=31, MODEKEYCOPY_GOTOLINE=32, MODEKEYCOPY_HALFPAGEDOWN=33, MODEKEYCOPY_HALFPAGEUP=34, MODEKEYCOPY_LEFT=35, MODEKEYCOPY_MIDDLELINE=36, MODEKEYCOPY_NEXTPAGE=37, MODEKEYCOPY_NEXTWORD=38, MODEKEYCOPY_PREVIOUSPAGE=39, MODEKEYCOPY_PREVIOUSWORD=40, MODEKEYCOPY_RIGHT=41, MODEKEYCOPY_SCROLLDOWN=42, MODEKEYCOPY_SCROLLUP=43, MODEKEYCOPY_SEARCHAGAIN=44, MODEKEYCOPY_SEARCHDOWN=45, MODEKEYCOPY_SEARCHUP=46, MODEKEYCOPY_STARTOFLINE=47, MODEKEYCOPY_STARTSELECTION=48, MODEKEYCOPY_TOPLINE=49, MODEKEYCOPY_UP=50 }


decompiled_code:
const char **__fastcall mode_key_findtable(char *s1)
{
const char **v1; // rbx
const char *v2; // rsi

v1 = (const char **)&mode_key_tables;
v2 = "vi-edit";
while ( strcasecmp(s1, v2) )
{
v1 += 4;
v2 = *v1;
if ( !*v1 )
return 0LL;
}
return v1;
}

canonical_decompiled_code:
const char **__fastcall func5(char *s1)
{
const char **v1; // rbx
const char *v2; // rsi

v1 = (const char **)&mode_key_tables;
v2 = "vi-edit";
while ( strcasecmp(s1, v2) )
{
v1 += 4;
v2 = *v1;
if ( !*v1 )
return 0LL;
}
return v1;
}

original_code:
const struct mode_key_table *
mode_key_findtable(const char *name)
{
 const struct mode_key_table *mtab;
 for (mtab = mode_key_tables; mtab->name != ((void *)0); mtab++) {
  if (strcasecmp(name, mtab->name) == 0)
   return (mtab);
 }
 return (((void *)0));
}

canonical_original_code:
struct mode_key_table *mode_key_findtable(char *name)
{
 struct mode_key_table *mtab;
 for (mtab = mode_key_tables; mtab->name != ((void *)0); mtab++) {
  if (strcasecmp(name, mtab->name) == 0)
   return (mtab);
 }
 return (((void *)0));
}

variable_types: struct mode_key_table { char *name; struct mode_key_cmdstr { enum mode_key_cmd { MODEKEY_NONE=0, MODEKEY_OTHER=1, MODEKEYEDIT_BACKSPACE=2, MODEKEYEDIT_CANCEL=3, MODEKEYEDIT_COMPLETE=4, MODEKEYEDIT_CURSORLEFT=5, MODEKEYEDIT_CURSORRIGHT=6, MODEKEYEDIT_DELETE=7, MODEKEYEDIT_DELETELINE=8, MODEKEYEDIT_DELETETOENDOFLINE=9, MODEKEYEDIT_ENDOFLINE=10, MODEKEYEDIT_ENTER=11, MODEKEYEDIT_HISTORYDOWN=12, MODEKEYEDIT_HISTORYUP=13, MODEKEYEDIT_PASTE=14, MODEKEYEDIT_STARTOFLINE=15, MODEKEYEDIT_SWITCHMODE=16, MODEKEYEDIT_SWITCHMODEAPPEND=17, MODEKEYEDIT_TRANSPOSECHARS=18, MODEKEYCHOICE_CANCEL=19, MODEKEYCHOICE_CHOOSE=20, MODEKEYCHOICE_DOWN=21, MODEKEYCHOICE_PAGEDOWN=22, MODEKEYCHOICE_PAGEUP=23, MODEKEYCHOICE_UP=24, MODEKEYCOPY_BACKTOINDENTATION=25, MODEKEYCOPY_BOTTOMLINE=26, MODEKEYCOPY_CANCEL=27, MODEKEYCOPY_CLEARSELECTION=28, MODEKEYCOPY_COPYSELECTION=29, MODEKEYCOPY_DOWN=30, MODEKEYCOPY_ENDOFLINE=31, MODEKEYCOPY_GOTOLINE=32, MODEKEYCOPY_HALFPAGEDOWN=33, MODEKEYCOPY_HALFPAGEUP=34, MODEKEYCOPY_LEFT=35, MODEKEYCOPY_MIDDLELINE=36, MODEKEYCOPY_NEXTPAGE=37, MODEKEYCOPY_NEXTWORD=38, MODEKEYCOPY_PREVIOUSPAGE=39, MODEKEYCOPY_PREVIOUSWORD=40, MODEKEYCOPY_RIGHT=41, MODEKEYCOPY_SCROLLDOWN=42, MODEKEYCOPY_SCROLLUP=43, MODEKEYCOPY_SEARCHAGAIN=44, MODEKEYCOPY_SEARCHDOWN=45, MODEKEYCOPY_SEARCHUP=46, MODEKEYCOPY_STARTOFLINE=47, MODEKEYCOPY_STARTSELECTION=48, MODEKEYCOPY_TOPLINE=49, MODEKEYCOPY_UP=50 } cmd; char *name; } *cmdstr; struct mode_key_tree { struct mode_key_binding { int key; int mode; enum mode_key_cmd { MODEKEY_NONE=0, MODEKEY_OTHER=1, MODEKEYEDIT_BACKSPACE=2, MODEKEYEDIT_CANCEL=3, MODEKEYEDIT_COMPLETE=4, MODEKEYEDIT_CURSORLEFT=5, MODEKEYEDIT_CURSORRIGHT=6, MODEKEYEDIT_DELETE=7, MODEKEYEDIT_DELETELINE=8, MODEKEYEDIT_DELETETOENDOFLINE=9, MODEKEYEDIT_ENDOFLINE=10, MODEKEYEDIT_ENTER=11, MODEKEYEDIT_HISTORYDOWN=12, MODEKEYEDIT_HISTORYUP=13, MODEKEYEDIT_PASTE=14, MODEKEYEDIT_STARTOFLINE=15, MODEKEYEDIT_SWITCHMODE=16, MODEKEYEDIT_SWITCHMODEAPPEND=17, MODEKEYEDIT_TRANSPOSECHARS=18, MODEKEYCHOICE_CANCEL=19, MODEKEYCHOICE_CHOOSE=20, MODEKEYCHOICE_DOWN=21, MODEKEYCHOICE_PAGEDOWN=22, MODEKEYCHOICE_PAGEUP=23, MODEKEYCHOICE_UP=24, MODEKEYCOPY_BACKTOINDENTATION=25, MODEKEYCOPY_BOTTOMLINE=26, MODEKEYCOPY_CANCEL=27, MODEKEYCOPY_CLEARSELECTION=28, MODEKEYCOPY_COPYSELECTION=29, MODEKEYCOPY_DOWN=30, MODEKEYCOPY_ENDOFLINE=31, MODEKEYCOPY_GOTOLINE=32, MODEKEYCOPY_HALFPAGEDOWN=33, MODEKEYCOPY_HALFPAGEUP=34, MODEKEYCOPY_LEFT=35, MODEKEYCOPY_MIDDLELINE=36, MODEKEYCOPY_NEXTPAGE=37, MODEKEYCOPY_NEXTWORD=38, MODEKEYCOPY_PREVIOUSPAGE=39, MODEKEYCOPY_PREVIOUSWORD=40, MODEKEYCOPY_RIGHT=41, MODEKEYCOPY_SCROLLDOWN=42, MODEKEYCOPY_SCROLLUP=43, MODEKEYCOPY_SEARCHAGAIN=44, MODEKEYCOPY_SEARCHDOWN=45, MODEKEYCOPY_SEARCHUP=46, MODEKEYCOPY_STARTOFLINE=47, MODEKEYCOPY_STARTSELECTION=48, MODEKEYCOPY_TOPLINE=49, MODEKEYCOPY_UP=50 } cmd; struct { struct mode_key_binding *spe_left; struct mode_key_binding *spe_right; } entry; } *sph_root; } *tree; struct mode_key_entry { int key; int mode; enum mode_key_cmd { MODEKEY_NONE=0, MODEKEY_OTHER=1, MODEKEYEDIT_BACKSPACE=2, MODEKEYEDIT_CANCEL=3, MODEKEYEDIT_COMPLETE=4, MODEKEYEDIT_CURSORLEFT=5, MODEKEYEDIT_CURSORRIGHT=6, MODEKEYEDIT_DELETE=7, MODEKEYEDIT_DELETELINE=8, MODEKEYEDIT_DELETETOENDOFLINE=9, MODEKEYEDIT_ENDOFLINE=10, MODEKEYEDIT_ENTER=11, MODEKEYEDIT_HISTORYDOWN=12, MODEKEYEDIT_HISTORYUP=13, MODEKEYEDIT_PASTE=14, MODEKEYEDIT_STARTOFLINE=15, MODEKEYEDIT_SWITCHMODE=16, MODEKEYEDIT_SWITCHMODEAPPEND=17, MODEKEYEDIT_TRANSPOSECHARS=18, MODEKEYCHOICE_CANCEL=19, MODEKEYCHOICE_CHOOSE=20, MODEKEYCHOICE_DOWN=21, MODEKEYCHOICE_PAGEDOWN=22, MODEKEYCHOICE_PAGEUP=23, MODEKEYCHOICE_UP=24, MODEKEYCOPY_BACKTOINDENTATION=25, MODEKEYCOPY_BOTTOMLINE=26, MODEKEYCOPY_CANCEL=27, MODEKEYCOPY_CLEARSELECTION=28, MODEKEYCOPY_COPYSELECTION=29, MODEKEYCOPY_DOWN=30, MODEKEYCOPY_ENDOFLINE=31, MODEKEYCOPY_GOTOLINE=32, MODEKEYCOPY_HALFPAGEDOWN=33, MODEKEYCOPY_HALFPAGEUP=34, MODEKEYCOPY_LEFT=35, MODEKEYCOPY_MIDDLELINE=36, MODEKEYCOPY_NEXTPAGE=37, MODEKEYCOPY_NEXTWORD=38, MODEKEYCOPY_PREVIOUSPAGE=39, MODEKEYCOPY_PREVIOUSWORD=40, MODEKEYCOPY_RIGHT=41, MODEKEYCOPY_SCROLLDOWN=42, MODEKEYCOPY_SCROLLUP=43, MODEKEYCOPY_SEARCHAGAIN=44, MODEKEYCOPY_SEARCHDOWN=45, MODEKEYCOPY_SEARCHUP=46, MODEKEYCOPY_STARTOFLINE=47, MODEKEYCOPY_STARTSELECTION=48, MODEKEYCOPY_TOPLINE=49, MODEKEYCOPY_UP=50 } cmd; } *table; } *

user_defined_types: struct mode_key_table { char *name; struct mode_key_cmdstr *cmdstr; struct mode_key_tree *tree; struct mode_key_entry *table; }

user_defined_types: struct mode_key_entry { int key; int mode; enum mode_key_cmd cmd; }


decompiled_code:
char *mode_key_init_trees()
{
char **v0; // rbp
char *result; // rax
char *i; // rbx
_DWORD *v3; // rsi

v0 = &mode_key_tables;
do
{
result = v0[2];
*(_QWORD *)result = 0LL;
for ( i = v0[3]; *((_DWORD *)i + 1) != -1; i += 12 )
{
v3 = (_DWORD *)xmalloc(32LL);
*v3 = *(_DWORD *)i;
v3[1] = *((_DWORD *)i + 1);
v3[2] = *((_DWORD *)i + 2);
result = (char *)mode_key_tree_SPLAY_INSERT((_DWORD **)v0[2], (__int64)v3);
}
v0 += 4;
}
while ( *v0 );
return result;
}

canonical_decompiled_code:
char *func6()
{
char **v0; // rbp
char *result; // rax
char *i; // rbx
_DWORD *v3; // rsi

v0 = &mode_key_tables;
do
{
result = v0[2];
*(_QWORD *)result = 0LL;
for ( i = v0[3]; *((_DWORD *)i + 1) != -1; i += 12 )
{
v3 = (_DWORD *)xmalloc(32LL);
*v3 = *(_DWORD *)i;
v3[1] = *((_DWORD *)i + 1);
v3[2] = *((_DWORD *)i + 2);
result = (char *)mode_key_tree_SPLAY_INSERT((_DWORD **)v0[2], (__int64)v3);
}
v0 += 4;
}
while ( *v0 );
return result;
}

original_code:
void
mode_key_init_trees(void)
{
 const struct mode_key_table *mtab;
 const struct mode_key_entry *ment;
 struct mode_key_binding *mbind;
 for (mtab = mode_key_tables; mtab->name != ((void *)0); mtab++) {
  do { (mtab->tree)->sph_root = ((void *)0); } while (0);
  for (ment = mtab->table; ment->mode != -1; ment++) {
   mbind = xmalloc(sizeof *mbind);
   mbind->key = ment->key;
   mbind->mode = ment->mode;
   mbind->cmd = ment->cmd;
   mode_key_tree_SPLAY_INSERT(mtab->tree, mbind);
  }
 }
}

canonical_original_code:
void mode_key_init_trees()
{
 struct mode_key_table *mtab;
 struct mode_key_entry *ment;
 struct mode_key_binding *mbind;
 for (mtab = mode_key_tables; mtab->name != ((void *)0); mtab++) {
  do { (mtab->tree)->sph_root = ((void *)0); } while (0);
  for (ment = mtab->table; ment->mode != -1; ment++) {
   mbind = xmalloc(sizeof *mbind);
   mbind->key = ment->key;
   mbind->mode = ment->mode;
   mbind->cmd = ment->cmd;
   mode_key_tree_SPLAY_INSERT(mtab->tree, mbind);
  }
 }
}

variable_types: struct mode_key_entry { int key; int mode; enum mode_key_cmd { MODEKEY_NONE=0, MODEKEY_OTHER=1, MODEKEYEDIT_BACKSPACE=2, MODEKEYEDIT_CANCEL=3, MODEKEYEDIT_COMPLETE=4, MODEKEYEDIT_CURSORLEFT=5, MODEKEYEDIT_CURSORRIGHT=6, MODEKEYEDIT_DELETE=7, MODEKEYEDIT_DELETELINE=8, MODEKEYEDIT_DELETETOENDOFLINE=9, MODEKEYEDIT_ENDOFLINE=10, MODEKEYEDIT_ENTER=11, MODEKEYEDIT_HISTORYDOWN=12, MODEKEYEDIT_HISTORYUP=13, MODEKEYEDIT_PASTE=14, MODEKEYEDIT_STARTOFLINE=15, MODEKEYEDIT_SWITCHMODE=16, MODEKEYEDIT_SWITCHMODEAPPEND=17, MODEKEYEDIT_TRANSPOSECHARS=18, MODEKEYCHOICE_CANCEL=19, MODEKEYCHOICE_CHOOSE=20, MODEKEYCHOICE_DOWN=21, MODEKEYCHOICE_PAGEDOWN=22, MODEKEYCHOICE_PAGEUP=23, MODEKEYCHOICE_UP=24, MODEKEYCOPY_BACKTOINDENTATION=25, MODEKEYCOPY_BOTTOMLINE=26, MODEKEYCOPY_CANCEL=27, MODEKEYCOPY_CLEARSELECTION=28, MODEKEYCOPY_COPYSELECTION=29, MODEKEYCOPY_DOWN=30, MODEKEYCOPY_ENDOFLINE=31, MODEKEYCOPY_GOTOLINE=32, MODEKEYCOPY_HALFPAGEDOWN=33, MODEKEYCOPY_HALFPAGEUP=34, MODEKEYCOPY_LEFT=35, MODEKEYCOPY_MIDDLELINE=36, MODEKEYCOPY_NEXTPAGE=37, MODEKEYCOPY_NEXTWORD=38, MODEKEYCOPY_PREVIOUSPAGE=39, MODEKEYCOPY_PREVIOUSWORD=40, MODEKEYCOPY_RIGHT=41, MODEKEYCOPY_SCROLLDOWN=42, MODEKEYCOPY_SCROLLUP=43, MODEKEYCOPY_SEARCHAGAIN=44, MODEKEYCOPY_SEARCHDOWN=45, MODEKEYCOPY_SEARCHUP=46, MODEKEYCOPY_STARTOFLINE=47, MODEKEYCOPY_STARTSELECTION=48, MODEKEYCOPY_TOPLINE=49, MODEKEYCOPY_UP=50 } cmd; } *


decompiled_code:
__int64 mode_key_free_trees()
{
char **v0; // rbp
__int64 result; // rax
char *v2; // rdi
_DWORD *i; // rbx

v0 = &mode_key_tables;
do
{
v2 = v0[2];
for ( i = *(_DWORD **)v2; *(_QWORD *)v2; i = *(_DWORD **)v2 )
{
mode_key_tree_SPLAY_REMOVE((_DWORD **)v2, i);
result = xfree(i);
v2 = v0[2];
}
v0 += 4;
}
while ( *v0 );
return result;
}

canonical_decompiled_code:
__int64 func7()
{
char **v0; // rbp
__int64 result; // rax
char *v2; // rdi
_DWORD *i; // rbx

v0 = &mode_key_tables;
do
{
v2 = v0[2];
for ( i = *(_DWORD **)v2; *(_QWORD *)v2; i = *(_DWORD **)v2 )
{
mode_key_tree_SPLAY_REMOVE((_DWORD **)v2, i);
result = xfree(i);
v2 = v0[2];
}
v0 += 4;
}
while ( *v0 );
return result;
}

original_code:
void
mode_key_free_trees(void)
{
 const struct mode_key_table *mtab;
 struct mode_key_binding *mbind;
 for (mtab = mode_key_tables; mtab->name != ((void *)0); mtab++) {
  while (!((mtab->tree)->sph_root == ((void *)0))) {
   mbind = (mtab->tree)->sph_root;
   mode_key_tree_SPLAY_REMOVE(mtab->tree, mbind);
   xfree(mbind);
  }
 }
}

canonical_original_code:
void mode_key_free_trees()
{
 struct mode_key_table *mtab;
 struct mode_key_binding *mbind;
 for (mtab = mode_key_tables; mtab->name != ((void *)0); mtab++) {
  while (!((mtab->tree)->sph_root == ((void *)0))) {
   mbind = (mtab->tree)->sph_root;
   mode_key_tree_SPLAY_REMOVE(mtab->tree, mbind);
   xfree(mbind);
  }
 }
}

user_defined_types: enum mode_key_cmd { MODEKEY_NONE=0, MODEKEY_OTHER=1, MODEKEYEDIT_BACKSPACE=2, MODEKEYEDIT_CANCEL=3, MODEKEYEDIT_COMPLETE=4, MODEKEYEDIT_CURSORLEFT=5, MODEKEYEDIT_CURSORRIGHT=6, MODEKEYEDIT_DELETE=7, MODEKEYEDIT_DELETELINE=8, MODEKEYEDIT_DELETETOENDOFLINE=9, MODEKEYEDIT_ENDOFLINE=10, MODEKEYEDIT_ENTER=11, MODEKEYEDIT_HISTORYDOWN=12, MODEKEYEDIT_HISTORYUP=13, MODEKEYEDIT_PASTE=14, MODEKEYEDIT_STARTOFLINE=15, MODEKEYEDIT_SWITCHMODE=16, MODEKEYEDIT_SWITCHMODEAPPEND=17, MODEKEYEDIT_TRANSPOSECHARS=18, MODEKEYCHOICE_CANCEL=19, MODEKEYCHOICE_CHOOSE=20, MODEKEYCHOICE_DOWN=21, MODEKEYCHOICE_PAGEDOWN=22, MODEKEYCHOICE_PAGEUP=23, MODEKEYCHOICE_UP=24, MODEKEYCOPY_BACKTOINDENTATION=25, MODEKEYCOPY_BOTTOMLINE=26, MODEKEYCOPY_CANCEL=27, MODEKEYCOPY_CLEARSELECTION=28, MODEKEYCOPY_COPYSELECTION=29, MODEKEYCOPY_DOWN=30, MODEKEYCOPY_ENDOFLINE=31, MODEKEYCOPY_GOTOLINE=32, MODEKEYCOPY_HALFPAGEDOWN=33, MODEKEYCOPY_HALFPAGEUP=34, MODEKEYCOPY_LEFT=35, MODEKEYCOPY_MIDDLELINE=36, MODEKEYCOPY_NEXTPAGE=37, MODEKEYCOPY_NEXTWORD=38, MODEKEYCOPY_PREVIOUSPAGE=39, MODEKEYCOPY_PREVIOUSWORD=40, MODEKEYCOPY_RIGHT=41, MODEKEYCOPY_SCROLLDOWN=42, MODEKEYCOPY_SCROLLUP=43, MODEKEYCOPY_SEARCHAGAIN=44, MODEKEYCOPY_SEARCHDOWN=45, MODEKEYCOPY_SEARCHUP=46, MODEKEYCOPY_STARTOFLINE=47, MODEKEYCOPY_STARTSELECTION=48, MODEKEYCOPY_TOPLINE=49, MODEKEYCOPY_UP=50 }


decompiled_code:
__int64 __fastcall cmd_command_prompt_free(__int64 a1)
{
_QWORD *v1; // rbx
__int64 v2; // rdi
__int64 v3; // rdi

v1 = *(_QWORD **)(a1 + 8);
if ( *v1 )
xfree(*v1);
v2 = v1[1];
if ( v2 )
xfree(v2);
v3 = v1[2];
if ( v3 )
xfree(v3);
return xfree(v1);
}

original_code:
void
cmd_command_prompt_free(struct cmd *self)
{
 struct cmd_command_prompt_data *data = self->data;
 if (data->prompts != ((void *)0))
  xfree(data->prompts);
 if (data->target != ((void *)0))
  xfree(data->target);
 if (data->template != ((void *)0))
  xfree(data->template);
 xfree(data);
}

variable_types: struct cmd { struct cmd_entry { char *name; char *alias; char *usage; int flags; unsigned long chflags; void (*init)(struct cmd *, int); int (*parse)(struct cmd *, int, char **, char **); int (*exec)(struct cmd *, struct cmd_ctx { struct client { struct imsgbuf { struct { struct imsg_fd { struct { struct imsg_fd *tqe_next; struct imsg_fd **tqe_prev; } entry; int fd; } *tqh_first; struct imsg_fd **tqh_last; } fds; struct buf_read { unsigned char buf[65535]; unsigned char *rptr; unsigned long wpos; } r; struct msgbuf { struct { struct buf { struct { struct buf *tqe_next; struct buf **tqe_prev; } entry; unsigned char *buf; unsigned long size; unsigned long max; unsigned long wpos; unsigned long rpos; int fd; } *tqh_first; struct buf **tqh_last; } bufs; unsigned int queued; int fd; } w; int fd; int pid; } ibuf; struct timeval { long tv_sec; long tv_usec; } creation_time; struct timeval activity_time; struct environ { struct environ_entry { char *name; char *value; struct { struct environ_entry *rbe_left; struct environ_entry *rbe_right; struct environ_entry *rbe_parent; int rbe_color; } entry; } *rbh_root; } environ; char *title; char *cwd; struct tty { char *path; unsigned int sx; unsigned int sy; unsigned int cx; unsigned int cy; int mode; unsigned int rlower; unsigned int rupper; char *termname; struct tty_term { char *name; unsigned int references; struct tty_code { enum tty_code_type { TTYCODE_NONE=0, TTYCODE_STRING=1, TTYCODE_NUMBER=2, TTYCODE_FLAG=3 } type; union { char *string; int number; int flag; } value; } codes[-1]; int flags; struct { struct tty_term *sle_next; } entry; } *term; int fd; struct buffer { unsigned char *base; unsigned long space; unsigned long size; unsigned long off; } *in; struct buffer *out; int log_fd; struct termios { unsigned int c_iflag; unsigned int c_oflag; unsigned int c_cflag; unsigned int c_lflag; unsigned char c_line; unsigned char c_cc[32]; unsigned int c_ispeed; unsigned int c_ospeed; } tio; struct grid_cell { unsigned char attr; unsigned char flags; unsigned char fg; unsigned char bg; unsigned char data; } cell; unsigned char acs[-1]; int flags; int term_flags; struct timeval key_timer; unsigned long ksize; struct tty_keys { struct tty_key { int key; char *string; int flags; struct { struct tty_key *rbe_left; struct tty_key *rbe_right; struct tty_key *rbe_parent; int rbe_color; } entry; } *rbh_root; } ktree; } tty; struct timeval repeat_timer; struct timeval status_timer; struct jobs { struct job { char *cmd; int pid; int status; struct client *client; int fd; struct buffer *out; void (*callbackfn)(struct job *); void (*freefn)(void *); void *data; int flags; struct { struct job *rbe_left; struct job *rbe_right; struct job *rbe_parent; int rbe_color; } entry; struct { struct job *sle_next; } lentry; } *rbh_root; } status_jobs; struct screen { char *title; struct grid { int flags; unsigned int sx; unsigned int sy; unsigned int hsize; unsigned int hlimit; struct grid_line { unsigned int cellsize; struct grid_cell *celldata; unsigned int utf8size; struct grid_utf8 { unsigned char width; unsigned char data[9]; } *utf8data; int flags; } *linedata; } *grid; unsigned int cx; unsigned int cy; unsigned int rupper; unsigned int rlower; int mode; unsigned char *tabs; struct screen_sel { int flag; unsigned int sx; unsigned int sy; unsigned int ex; unsigned int ey; struct grid_cell cell; } sel; } status; int flags; struct timeval identify_timer; char *message_string; struct timeval message_timer; char *prompt_string; char *prompt_buffer; unsigned long prompt_index; int (*prompt_callbackfn)(void *, char *); void (*prompt_freefn)(void *); void *prompt_data; int prompt_flags; unsigned int prompt_hindex; struct { char **list; unsigned int num; unsigned long space; } prompt_hdata; struct mode_key_data { struct mode_key_tree { struct mode_key_binding { int key; int mode; enum mode_key_cmd { MODEKEY_NONE=0, MODEKEY_OTHER=1, MODEKEYEDIT_BACKSPACE=2, MODEKEYEDIT_CANCEL=3, MODEKEYEDIT_COMPLETE=4, MODEKEYEDIT_CURSORLEFT=5, MODEKEYEDIT_CURSORRIGHT=6, MODEKEYEDIT_DELETE=7, MODEKEYEDIT_DELETELINE=8, MODEKEYEDIT_DELETETOENDOFLINE=9, MODEKEYEDIT_ENDOFLINE=10, MODEKEYEDIT_ENTER=11, MODEKEYEDIT_HISTORYDOWN=12, MODEKEYEDIT_HISTORYUP=13, MODEKEYEDIT_PASTE=14, MODEKEYEDIT_STARTOFLINE=15, MODEKEYEDIT_SWITCHMODE=16, MODEKEYEDIT_SWITCHMODEAPPEND=17, MODEKEYEDIT_TRANSPOSECHARS=18, MODEKEYCHOICE_CANCEL=19, MODEKEYCHOICE_CHOOSE=20, MODEKEYCHOICE_DOWN=21, MODEKEYCHOICE_PAGEDOWN=22, MODEKEYCHOICE_PAGEUP=23, MODEKEYCHOICE_UP=24, MODEKEYCOPY_BACKTOINDENTATION=25, MODEKEYCOPY_BOTTOMLINE=26, MODEKEYCOPY_CANCEL=27, MODEKEYCOPY_CLEARSELECTION=28, MODEKEYCOPY_COPYSELECTION=29, MODEKEYCOPY_DOWN=30, MODEKEYCOPY_ENDOFLINE=31, MODEKEYCOPY_GOTOLINE=32, MODEKEYCOPY_HALFPAGEDOWN=33, MODEKEYCOPY_HALFPAGEUP=34, MODEKEYCOPY_LEFT=35, MODEKEYCOPY_MIDDLELINE=36, MODEKEYCOPY_NEXTPAGE=37, MODEKEYCOPY_NEXTWORD=38, MODEKEYCOPY_PREVIOUSPAGE=39, MODEKEYCOPY_PREVIOUSWORD=40, MODEKEYCOPY_RIGHT=41, MODEKEYCOPY_SCROLLDOWN=42, MODEKEYCOPY_SCROLLUP=43, MODEKEYCOPY_SEARCHAGAIN=44, MODEKEYCOPY_SEARCHDOWN=45, MODEKEYCOPY_SEARCHUP=46, MODEKEYCOPY_STARTOFLINE=47, MODEKEYCOPY_STARTSELECTION=48, MODEKEYCOPY_TOPLINE=49, MODEKEYCOPY_UP=50 } cmd; struct { struct mode_key_binding *spe_left; struct mode_key_binding *spe_right; } entry; } *sph_root; } *tree; int mode; } prompt_mdata; struct session { char *name; struct timeval creation_time; struct timeval activity_time; unsigned int sx; unsigned int sy; struct winlink { int idx; struct window { char *name; struct timeval name_timer; struct window_pane { struct window *window; struct layout_cell { enum layout_type { LAYOUT_LEFTRIGHT=0, LAYOUT_TOPBOTTOM=1, LAYOUT_WINDOWPANE=2 } type; struct layout_cell *parent; unsigned int sx; unsigned int sy; unsigned int xoff; unsigned int yoff; struct window_pane *wp; struct layout_cells { struct layout_cell *tqh_first; struct layout_cell **tqh_last; } cells; struct { struct layout_cell *tqe_next; struct layout_cell **tqe_prev; } entry; } *layout_cell; unsigned int sx; unsigned int sy; unsigned int xoff; unsigned int yoff; int flags; char *cmd; char *shell; char *cwd; int pid; int fd; char tty[32]; struct buffer *in; struct buffer *out; struct input_ctx { struct window_pane *wp; struct screen_write_ctx { struct window_pane *wp; struct screen *s; } ctx; unsigned char *buf; unsigned long len; unsigned long off; unsigned long was; struct grid_cell cell; struct grid_cell saved_cell; unsigned int saved_cx; unsigned int saved_cy; unsigned char *string_buf; unsigned long string_len; int string_type; struct utf8_data { unsigned char data[9]; unsigned long have; unsigned long size; unsigned int width; } utf8data; unsigned char intermediate; void *(*state)(unsigned char, struct input_ctx *); unsigned char private; struct { struct input_arg { unsigned char data[64]; unsigned long used; } *list; unsigned int num; unsigned long space; } args; } ictx; int pipe_fd; struct buffer *pipe_buf; unsigned long pipe_off; struct screen *screen; struct screen base; unsigned int saved_cx; unsigned int saved_cy; struct grid *saved_grid; struct grid_cell saved_cell; struct window_mode { struct screen *(*init)(struct window_pane *); void (*free)(struct window_pane *); void (*resize)(struct window_pane *, unsigned int, unsigned int); void (*key)(struct window_pane *, struct client *, int); void (*mouse)(struct window_pane *, struct client *, struct mouse_event { unsigned char b; unsigned char x; unsigned char y; } *); void (*timer)(struct window_pane *); } *mode; void *modedata; struct { struct window_pane *tqe_next; struct window_pane **tqe_prev; } entry; } *active; struct window_panes { struct window_pane *tqh_first; struct window_pane **tqh_last; } panes; int lastlayout; struct layout_cell *layout_root; unsigned int sx; unsigned int sy; int flags; struct options { struct options_tree { struct options_entry { char *name; enum { OPTIONS_STRING=0, OPTIONS_NUMBER=1, OPTIONS_DATA=2 } type; char *str; long long num; void *data; void (*freefn)(void *); struct { struct options_entry *spe_left; struct options_entry *spe_right; } entry; } *sph_root; } tree; struct options *parent; } options; unsigned int references; } *window; struct { struct winlink *rbe_left; struct winlink *rbe_right; struct winlink *rbe_parent; int rbe_color; } entry; struct { struct winlink *tqe_next; struct winlink **tqe_prev; } sentry; } *curw; struct winlink_stack { struct winlink *tqh_first; struct winlink **tqh_last; } lastw; struct winlinks { struct winlink *rbh_root; } windows; struct options options; struct paste_stack { struct paste_buffer { char *data; unsigned long size; } **list; unsigned int num; unsigned long space; } buffers; struct { struct session_alert { struct winlink *wl; int type; struct { struct session_alert *sle_next; } entry; } *slh_first; } alerts; int flags; struct termios *tio; struct environ environ; int references; struct { struct session *tqe_next; struct session **tqe_prev; } gentry; } *session; int references; } *curclient; struct client *cmdclient; struct msg_command_data { int pid; unsigned int idx; int argc; char argv[2048]; } *msgdata; void (*print)(struct cmd_ctx *, char *, ...); void (*info)(struct cmd_ctx *, char *, ...); void (*error)(struct cmd_ctx *, char *, ...); } *); void (*free)(struct cmd *); unsigned long (*print)(struct cmd *, char *, unsigned long); } *entry; void *data; struct { struct cmd *tqe_next; struct cmd **tqe_prev; } qentry; } *

variable_types: struct cmd_command_prompt_data { char *prompts; char *target; char *template; } *

user_defined_types: struct cmd { struct cmd_entry *entry; void *data; struct { struct cmd *tqe_next; struct cmd **tqe_prev; } qentry; }

user_defined_types: struct cmd_entry { char *name; char *alias; char *usage; int flags; unsigned long chflags; void (*init)(struct cmd *, int); int (*parse)(struct cmd *, int, char **, char **); int (*exec)(struct cmd *, struct cmd_ctx *); void (*free)(struct cmd *); unsigned long (*print)(struct cmd *, char *, unsigned long); }

user_defined_types: struct cmd_ctx { struct client *curclient; struct client *cmdclient; struct msg_command_data *msgdata; void (*print)(struct cmd_ctx *, char *, ...); void (*info)(struct cmd_ctx *, char *, ...); void (*error)(struct cmd_ctx *, char *, ...); }

user_defined_types: struct client { struct imsgbuf ibuf; struct timeval creation_time; struct timeval activity_time; struct environ environ; char *title; char *cwd; struct tty tty; struct timeval repeat_timer; struct timeval status_timer; struct jobs status_jobs; struct screen status; int flags; struct timeval identify_timer; char *message_string; struct timeval message_timer; char *prompt_string; char *prompt_buffer; unsigned long prompt_index; int (*prompt_callbackfn)(void *, char *); void (*prompt_freefn)(void *); void *prompt_data; int prompt_flags; unsigned int prompt_hindex; struct { char **list; unsigned int num; unsigned long space; } prompt_hdata; struct mode_key_data prompt_mdata; struct session *session; int references; }

user_defined_types: struct imsgbuf { struct { struct imsg_fd *tqh_first; struct imsg_fd **tqh_last; } fds; struct buf_read r; struct msgbuf w; int fd; int pid; }

user_defined_types: struct environ { struct environ_entry *rbh_root; }

user_defined_types: struct tty { char *path; unsigned int sx; unsigned int sy; unsigned int cx; unsigned int cy; int mode; unsigned int rlower; unsigned int rupper; char *termname; struct tty_term *term; int fd; struct buffer *in; struct buffer *out; int log_fd; struct termios tio; struct grid_cell cell; unsigned char acs[-1]; int flags; int term_flags; struct timeval key_timer; unsigned long ksize; struct tty_keys ktree; }

user_defined_types: struct screen { char *title; struct grid *grid; unsigned int cx; unsigned int cy; unsigned int rupper; unsigned int rlower; int mode; unsigned char *tabs; struct screen_sel sel; }

user_defined_types: struct mode_key_data { struct mode_key_tree *tree; int mode; }

user_defined_types: struct msgbuf { struct { struct buf *tqh_first; struct buf **tqh_last; } bufs; unsigned int queued; int fd; }

user_defined_types: struct tty_keys { struct tty_key *rbh_root; }

user_defined_types: struct session { char *name; struct timeval creation_time; struct timeval activity_time; unsigned int sx; unsigned int sy; struct winlink *curw; struct winlink_stack lastw; struct winlinks windows; struct options options; struct paste_stack buffers; struct { struct session_alert *slh_first; } alerts; int flags; struct termios *tio; struct environ environ; int references; struct { struct session *tqe_next; struct session **tqe_prev; } gentry; }

user_defined_types: struct tty_term { char *name; unsigned int references; struct tty_code codes[-1]; int flags; struct { struct tty_term *sle_next; } entry; }

user_defined_types: struct grid { int flags; unsigned int sx; unsigned int sy; unsigned int hsize; unsigned int hlimit; struct grid_line *linedata; }

user_defined_types: struct winlink { int idx; struct window *window; struct { struct winlink *rbe_left; struct winlink *rbe_right; struct winlink *rbe_parent; int rbe_color; } entry; struct { struct winlink *tqe_next; struct winlink **tqe_prev; } sentry; }

user_defined_types: struct tty_code { enum tty_code_type type; union { char *string; int number; int flag; } value; }

user_defined_types: struct grid_line { unsigned int cellsize; struct grid_cell *celldata; unsigned int utf8size; struct grid_utf8 *utf8data; int flags; }

user_defined_types: struct window { char *name; struct timeval name_timer; struct window_pane *active; struct window_panes panes; int lastlayout; struct layout_cell *layout_root; unsigned int sx; unsigned int sy; int flags; struct options options; unsigned int references; }

user_defined_types: struct window_pane { struct window *window; struct layout_cell *layout_cell; unsigned int sx; unsigned int sy; unsigned int xoff; unsigned int yoff; int flags; char *cmd; char *shell; char *cwd; int pid; int fd; char tty[32]; struct buffer *in; struct buffer *out; struct input_ctx ictx; int pipe_fd; struct buffer *pipe_buf; unsigned long pipe_off; struct screen *screen; struct screen base; unsigned int saved_cx; unsigned int saved_cy; struct grid *saved_grid; struct grid_cell saved_cell; struct window_mode *mode; void *modedata; struct { struct window_pane *tqe_next; struct window_pane **tqe_prev; } entry; }

user_defined_types: struct input_ctx { struct window_pane *wp; struct screen_write_ctx ctx; unsigned char *buf; unsigned long len; unsigned long off; unsigned long was; struct grid_cell cell; struct grid_cell saved_cell; unsigned int saved_cx; unsigned int saved_cy; unsigned char *string_buf; unsigned long string_len; int string_type; struct utf8_data utf8data; unsigned char intermediate; void *(*state)(unsigned char, struct input_ctx *); unsigned char private; struct { struct input_arg *list; unsigned int num; unsigned long space; } args; }

user_defined_types: struct layout_cell { enum layout_type type; struct layout_cell *parent; unsigned int sx; unsigned int sy; unsigned int xoff; unsigned int yoff; struct window_pane *wp; struct layout_cells cells; struct { struct layout_cell *tqe_next; struct layout_cell **tqe_prev; } entry; }

user_defined_types: struct window_mode { struct screen *(*init)(struct window_pane *); void (*free)(struct window_pane *); void (*resize)(struct window_pane *, unsigned int, unsigned int); void (*key)(struct window_pane *, struct client *, int); void (*mouse)(struct window_pane *, struct client *, struct mouse_event *); void (*timer)(struct window_pane *); }


decompiled_code:
__int64 __fastcall cmd_command_prompt_cfree(__int64 a1)
{
__int64 v2; // rdi
__int64 v3; // rdi

v2 = *(_QWORD *)(a1 + 16);
if ( v2 )
xfree(v2);
v3 = *(_QWORD *)(a1 + 24);
if ( v3 )
xfree(v3);
return xfree(a1);
}

original_code:
void
cmd_command_prompt_cfree(void *data)
{
 struct cmd_command_prompt_cdata *cdata = data;
 if (cdata->prompts != ((void *)0))
  xfree(cdata->prompts);
 if (cdata->template != ((void *)0))
  xfree(cdata->template);
 xfree(cdata);
}

variable_types:
data
void *

variable_types: struct cmd_command_prompt_cdata { struct client { struct imsgbuf { struct { struct imsg_fd { struct { struct imsg_fd *tqe_next; struct imsg_fd **tqe_prev; } entry; int fd; } *tqh_first; struct imsg_fd **tqh_last; } fds; struct buf_read { unsigned char buf[65535]; unsigned char *rptr; unsigned long wpos; } r; struct msgbuf { struct { struct buf { struct { struct buf *tqe_next; struct buf **tqe_prev; } entry; unsigned char *buf; unsigned long size; unsigned long max; unsigned long wpos; unsigned long rpos; int fd; } *tqh_first; struct buf **tqh_last; } bufs; unsigned int queued; int fd; } w; int fd; int pid; } ibuf; struct timeval { long tv_sec; long tv_usec; } creation_time; struct timeval activity_time; struct environ { struct environ_entry { char *name; char *value; struct { struct environ_entry *rbe_left; struct environ_entry *rbe_right; struct environ_entry *rbe_parent; int rbe_color; } entry; } *rbh_root; } environ; char *title; char *cwd; struct tty { char *path; unsigned int sx; unsigned int sy; unsigned int cx; unsigned int cy; int mode; unsigned int rlower; unsigned int rupper; char *termname; struct tty_term { char *name; unsigned int references; struct tty_code { enum tty_code_type { TTYCODE_NONE=0, TTYCODE_STRING=1, TTYCODE_NUMBER=2, TTYCODE_FLAG=3 } type; union { char *string; int number; int flag; } value; } codes[-1]; int flags; struct { struct tty_term *sle_next; } entry; } *term; int fd; struct buffer { unsigned char *base; unsigned long space; unsigned long size; unsigned long off; } *in; struct buffer *out; int log_fd; struct termios { unsigned int c_iflag; unsigned int c_oflag; unsigned int c_cflag; unsigned int c_lflag; unsigned char c_line; unsigned char c_cc[32]; unsigned int c_ispeed; unsigned int c_ospeed; } tio; struct grid_cell { unsigned char attr; unsigned char flags; unsigned char fg; unsigned char bg; unsigned char data; } cell; unsigned char acs[-1]; int flags; int term_flags; struct timeval key_timer; unsigned long ksize; struct tty_keys { struct tty_key { int key; char *string; int flags; struct { struct tty_key *rbe_left; struct tty_key *rbe_right; struct tty_key *rbe_parent; int rbe_color; } entry; } *rbh_root; } ktree; } tty; struct timeval repeat_timer; struct timeval status_timer; struct jobs { struct job { char *cmd; int pid; int status; struct client *client; int fd; struct buffer *out; void (*callbackfn)(struct job *); void (*freefn)(void *); void *data; int flags; struct { struct job *rbe_left; struct job *rbe_right; struct job *rbe_parent; int rbe_color; } entry; struct { struct job *sle_next; } lentry; } *rbh_root; } status_jobs; struct screen { char *title; struct grid { int flags; unsigned int sx; unsigned int sy; unsigned int hsize; unsigned int hlimit; struct grid_line { unsigned int cellsize; struct grid_cell *celldata; unsigned int utf8size; struct grid_utf8 { unsigned char width; unsigned char data[9]; } *utf8data; int flags; } *linedata; } *grid; unsigned int cx; unsigned int cy; unsigned int rupper; unsigned int rlower; int mode; unsigned char *tabs; struct screen_sel { int flag; unsigned int sx; unsigned int sy; unsigned int ex; unsigned int ey; struct grid_cell cell; } sel; } status; int flags; struct timeval identify_timer; char *message_string; struct timeval message_timer; char *prompt_string; char *prompt_buffer; unsigned long prompt_index; int (*prompt_callbackfn)(void *, char *); void (*prompt_freefn)(void *); void *prompt_data; int prompt_flags; unsigned int prompt_hindex; struct { char **list; unsigned int num; unsigned long space; } prompt_hdata; struct mode_key_data { struct mode_key_tree { struct mode_key_binding { int key; int mode; enum mode_key_cmd { MODEKEY_NONE=0, MODEKEY_OTHER=1, MODEKEYEDIT_BACKSPACE=2, MODEKEYEDIT_CANCEL=3, MODEKEYEDIT_COMPLETE=4, MODEKEYEDIT_CURSORLEFT=5, MODEKEYEDIT_CURSORRIGHT=6, MODEKEYEDIT_DELETE=7, MODEKEYEDIT_DELETELINE=8, MODEKEYEDIT_DELETETOENDOFLINE=9, MODEKEYEDIT_ENDOFLINE=10, MODEKEYEDIT_ENTER=11, MODEKEYEDIT_HISTORYDOWN=12, MODEKEYEDIT_HISTORYUP=13, MODEKEYEDIT_PASTE=14, MODEKEYEDIT_STARTOFLINE=15, MODEKEYEDIT_SWITCHMODE=16, MODEKEYEDIT_SWITCHMODEAPPEND=17, MODEKEYEDIT_TRANSPOSECHARS=18, MODEKEYCHOICE_CANCEL=19, MODEKEYCHOICE_CHOOSE=20, MODEKEYCHOICE_DOWN=21, MODEKEYCHOICE_PAGEDOWN=22, MODEKEYCHOICE_PAGEUP=23, MODEKEYCHOICE_UP=24, MODEKEYCOPY_BACKTOINDENTATION=25, MODEKEYCOPY_BOTTOMLINE=26, MODEKEYCOPY_CANCEL=27, MODEKEYCOPY_CLEARSELECTION=28, MODEKEYCOPY_COPYSELECTION=29, MODEKEYCOPY_DOWN=30, MODEKEYCOPY_ENDOFLINE=31, MODEKEYCOPY_GOTOLINE=32, MODEKEYCOPY_HALFPAGEDOWN=33, MODEKEYCOPY_HALFPAGEUP=34, MODEKEYCOPY_LEFT=35, MODEKEYCOPY_MIDDLELINE=36, MODEKEYCOPY_NEXTPAGE=37, MODEKEYCOPY_NEXTWORD=38, MODEKEYCOPY_PREVIOUSPAGE=39, MODEKEYCOPY_PREVIOUSWORD=40, MODEKEYCOPY_RIGHT=41, MODEKEYCOPY_SCROLLDOWN=42, MODEKEYCOPY_SCROLLUP=43, MODEKEYCOPY_SEARCHAGAIN=44, MODEKEYCOPY_SEARCHDOWN=45, MODEKEYCOPY_SEARCHUP=46, MODEKEYCOPY_STARTOFLINE=47, MODEKEYCOPY_STARTSELECTION=48, MODEKEYCOPY_TOPLINE=49, MODEKEYCOPY_UP=50 } cmd; struct { struct mode_key_binding *spe_left; struct mode_key_binding *spe_right; } entry; } *sph_root; } *tree; int mode; } prompt_mdata; struct session { char *name; struct timeval creation_time; struct timeval activity_time; unsigned int sx; unsigned int sy; struct winlink { int idx; struct window { char *name; struct timeval name_timer; struct window_pane { struct window *window; struct layout_cell { enum layout_type { LAYOUT_LEFTRIGHT=0, LAYOUT_TOPBOTTOM=1, LAYOUT_WINDOWPANE=2 } type; struct layout_cell *parent; unsigned int sx; unsigned int sy; unsigned int xoff; unsigned int yoff; struct window_pane *wp; struct layout_cells { struct layout_cell *tqh_first; struct layout_cell **tqh_last; } cells; struct { struct layout_cell *tqe_next; struct layout_cell **tqe_prev; } entry; } *layout_cell; unsigned int sx; unsigned int sy; unsigned int xoff; unsigned int yoff; int flags; char *cmd; char *shell; char *cwd; int pid; int fd; char tty[32]; struct buffer *in; struct buffer *out; struct input_ctx { struct window_pane *wp; struct screen_write_ctx { struct window_pane *wp; struct screen *s; } ctx; unsigned char *buf; unsigned long len; unsigned long off; unsigned long was; struct grid_cell cell; struct grid_cell saved_cell; unsigned int saved_cx; unsigned int saved_cy; unsigned char *string_buf; unsigned long string_len; int string_type; struct utf8_data { unsigned char data[9]; unsigned long have; unsigned long size; unsigned int width; } utf8data; unsigned char intermediate; void *(*state)(unsigned char, struct input_ctx *); unsigned char private; struct { struct input_arg { unsigned char data[64]; unsigned long used; } *list; unsigned int num; unsigned long space; } args; } ictx; int pipe_fd; struct buffer *pipe_buf; unsigned long pipe_off; struct screen *screen; struct screen base; unsigned int saved_cx; unsigned int saved_cy; struct grid *saved_grid; struct grid_cell saved_cell; struct window_mode { struct screen *(*init)(struct window_pane *); void (*free)(struct window_pane *); void (*resize)(struct window_pane *, unsigned int, unsigned int); void (*key)(struct window_pane *, struct client *, int); void (*mouse)(struct window_pane *, struct client *, struct mouse_event { unsigned char b; unsigned char x; unsigned char y; } *); void (*timer)(struct window_pane *); } *mode; void *modedata; struct { struct window_pane *tqe_next; struct window_pane **tqe_prev; } entry; } *active; struct window_panes { struct window_pane *tqh_first; struct window_pane **tqh_last; } panes; int lastlayout; struct layout_cell *layout_root; unsigned int sx; unsigned int sy; int flags; struct options { struct options_tree { struct options_entry { char *name; enum { OPTIONS_STRING=0, OPTIONS_NUMBER=1, OPTIONS_DATA=2 } type; char *str; long long num; void *data; void (*freefn)(void *); struct { struct options_entry *spe_left; struct options_entry *spe_right; } entry; } *sph_root; } tree; struct options *parent; } options; unsigned int references; } *window; struct { struct winlink *rbe_left; struct winlink *rbe_right; struct winlink *rbe_parent; int rbe_color; } entry; struct { struct winlink *tqe_next; struct winlink **tqe_prev; } sentry; } *curw; struct winlink_stack { struct winlink *tqh_first; struct winlink **tqh_last; } lastw; struct winlinks { struct winlink *rbh_root; } windows; struct options options; struct paste_stack { struct paste_buffer { char *data; unsigned long size; } **list; unsigned int num; unsigned long space; } buffers; struct { struct session_alert { struct winlink *wl; int type; struct { struct session_alert *sle_next; } entry; } *slh_first; } alerts; int flags; struct termios *tio; struct environ environ; int references; struct { struct session *tqe_next; struct session **tqe_prev; } gentry; } *session; int references; } *c; char *next_prompt; char *prompts; char *template; int idx; } *

user_defined_types: struct cmd_command_prompt_cdata { struct client *c; char *next_prompt; char *prompts; char *template; int idx; }

user_defined_types: struct client { struct imsgbuf ibuf; struct timeval creation_time; struct timeval activity_time; struct environ environ; char *title; char *cwd; struct tty tty; struct timeval repeat_timer; struct timeval status_timer; struct jobs status_jobs; struct screen status; int flags; struct timeval identify_timer; char *message_string; struct timeval message_timer; char *prompt_string; char *prompt_buffer; unsigned long prompt_index; int (*prompt_callbackfn)(void *, char *); void (*prompt_freefn)(void *); void *prompt_data; int prompt_flags; unsigned int prompt_hindex; struct { char **list; unsigned int num; unsigned long space; } prompt_hdata; struct mode_key_data prompt_mdata; struct session *session; int references; }

user_defined_types: struct imsgbuf { struct { struct imsg_fd *tqh_first; struct imsg_fd **tqh_last; } fds; struct buf_read r; struct msgbuf w; int fd; int pid; }

user_defined_types: struct environ { struct environ_entry *rbh_root; }

user_defined_types: struct mode_key_tree { struct mode_key_binding *sph_root; }

user_defined_types: struct paste_stack { struct paste_buffer **list; unsigned int num; unsigned long space; }

user_defined_types: struct mode_key_binding { int key; int mode; enum mode_key_cmd cmd; struct { struct mode_key_binding *spe_left; struct mode_key_binding *spe_right; } entry; }

user_defined_types: struct options { struct options_tree tree; struct options *parent; }

user_defined_types: struct options_tree { struct options_entry *sph_root; }


original_code:
size_t
cmd_command_prompt_print(struct cmd *self, char *buf, size_t len)
{
 struct cmd_command_prompt_data *data = self->data;
 size_t off = 0;
 off += xsnprintf(buf, len, "%s", self->entry->name);
 if (data == ((void *)0))
  return (off);
 if (off < len && data->prompts != ((void *)0))
  off += cmd_prarg(buf + off, len - off, " -p ", data->prompts);
 if (off < len && data->target != ((void *)0))
  off += cmd_prarg(buf + off, len - off, " -t ", data->target);
 if (off < len && data->template != ((void *)0))
  off += cmd_prarg(buf + off, len - off, " ", data->template);
 return (off);
}

canonical_original_code:
unsigned long cmd_command_prompt_print(struct cmd *self, char *buf, unsigned long len)
{
 struct cmd_command_prompt_data *data = self->data;
 unsigned long off = 0;
 off += xsnprintf(buf, len, "%s", self->entry->name);
 if (data == ((void *)0))
  return (off);
 if (off < len && data->prompts != ((void *)0))
  off += cmd_prarg(buf + off, len - off, " -p ", data->prompts);
 if (off < len && data->target != ((void *)0))
  off += cmd_prarg(buf + off, len - off, " -t ", data->target);
 if (off < len && data->template != ((void *)0))
  off += cmd_prarg(buf + off, len - off, " ", data->template);
 return (off);
}

variable_types:
buf
char *

variable_types:
len
unsigned long

variable_types:
off
unsigned long

return_type: unsigned long

user_defined_types: struct cmd { struct cmd_entry *entry; void *data; struct { struct cmd *tqe_next; struct cmd **tqe_prev; } qentry; }

user_defined_types: struct cmd_command_prompt_data { char *prompts; char *target; char *template; }

user_defined_types: struct cmd_entry { char *name; char *alias; char *usage; int flags; unsigned long chflags; void (*init)(struct cmd *, int); int (*parse)(struct cmd *, int, char **, char **); int (*exec)(struct cmd *, struct cmd_ctx *); void (*free)(struct cmd *); unsigned long (*print)(struct cmd *, char *, unsigned long); }

user_defined_types: struct cmd_ctx { struct client *curclient; struct client *cmdclient; struct msg_command_data *msgdata; void (*print)(struct cmd_ctx *, char *, ...); void (*info)(struct cmd_ctx *, char *, ...); void (*error)(struct cmd_ctx *, char *, ...); }

user_defined_types: struct msg_command_data { int pid; unsigned int idx; int argc; char argv[2048]; }

user_defined_types: struct timeval { long tv_sec; long tv_usec; }

user_defined_types: struct tty { char *path; unsigned int sx; unsigned int sy; unsigned int cx; unsigned int cy; int mode; unsigned int rlower; unsigned int rupper; char *termname; struct tty_term *term; int fd; struct buffer *in; struct buffer *out; int log_fd; struct termios tio; struct grid_cell cell; unsigned char acs[-1]; int flags; int term_flags; struct timeval key_timer; unsigned long ksize; struct tty_keys ktree; }

user_defined_types: struct screen { char *title; struct grid *grid; unsigned int cx; unsigned int cy; unsigned int rupper; unsigned int rlower; int mode; unsigned char *tabs; struct screen_sel sel; }

user_defined_types: struct mode_key_data { struct mode_key_tree *tree; int mode; }

user_defined_types: struct buf_read { unsigned char buf[65535]; unsigned char *rptr; unsigned long wpos; }

user_defined_types: struct msgbuf { struct { struct buf *tqh_first; struct buf **tqh_last; } bufs; unsigned int queued; int fd; }

user_defined_types: struct termios { unsigned int c_iflag; unsigned int c_oflag; unsigned int c_cflag; unsigned int c_lflag; unsigned char c_line; unsigned char c_cc[32]; unsigned int c_ispeed; unsigned int c_ospeed; }

user_defined_types: struct grid_cell { unsigned char attr; unsigned char flags; unsigned char fg; unsigned char bg; unsigned char data; }

user_defined_types: struct tty_keys { struct tty_key *rbh_root; }

user_defined_types: struct screen_sel { int flag; unsigned int sx; unsigned int sy; unsigned int ex; unsigned int ey; struct grid_cell cell; }

user_defined_types: struct session { char *name; struct timeval creation_time; struct timeval activity_time; unsigned int sx; unsigned int sy; struct winlink *curw; struct winlink_stack lastw; struct winlinks windows; struct options options; struct paste_stack buffers; struct { struct session_alert *slh_first; } alerts; int flags; struct termios *tio; struct environ environ; int references; struct { struct session *tqe_next; struct session **tqe_prev; } gentry; }

user_defined_types: struct environ_entry { char *name; char *value; struct { struct environ_entry *rbe_left; struct environ_entry *rbe_right; struct environ_entry *rbe_parent; int rbe_color; } entry; }

user_defined_types: struct tty_term { char *name; unsigned int references; struct tty_code codes[-1]; int flags; struct { struct tty_term *sle_next; } entry; }

user_defined_types: struct buffer { unsigned char *base; unsigned long space; unsigned long size; unsigned long off; }

user_defined_types: struct job { char *cmd; int pid; int status; struct client *client; int fd; struct buffer *out; void (*callbackfn)(struct job *); void (*freefn)(void *); void *data; int flags; struct { struct job *rbe_left; struct job *rbe_right; struct job *rbe_parent; int rbe_color; } entry; struct { struct job *sle_next; } lentry; }

user_defined_types: struct grid { int flags; unsigned int sx; unsigned int sy; unsigned int hsize; unsigned int hlimit; struct grid_line *linedata; }

user_defined_types: struct winlink_stack { struct winlink *tqh_first; struct winlink **tqh_last; }

user_defined_types: struct winlinks { struct winlink *rbh_root; }

user_defined_types: struct imsg_fd { struct { struct imsg_fd *tqe_next; struct imsg_fd **tqe_prev; } entry; int fd; }

user_defined_types: struct tty_key { int key; char *string; int flags; struct { struct tty_key *rbe_left; struct tty_key *rbe_right; struct tty_key *rbe_parent; int rbe_color; } entry; }

user_defined_types: struct winlink { int idx; struct window *window; struct { struct winlink *rbe_left; struct winlink *rbe_right; struct winlink *rbe_parent; int rbe_color; } entry; struct { struct winlink *tqe_next; struct winlink **tqe_prev; } sentry; }

user_defined_types: struct buf { struct { struct buf *tqe_next; struct buf **tqe_prev; } entry; unsigned char *buf; unsigned long size; unsigned long max; unsigned long wpos; unsigned long rpos; int fd; }

user_defined_types: struct session_alert { struct winlink *wl; int type; struct { struct session_alert *sle_next; } entry; }

user_defined_types: enum tty_code_type { TTYCODE_NONE=0, TTYCODE_STRING=1, TTYCODE_NUMBER=2, TTYCODE_FLAG=3 }

user_defined_types: enum mode_key_cmd { MODEKEY_NONE=0, MODEKEY_OTHER=1, MODEKEYEDIT_BACKSPACE=2, MODEKEYEDIT_CANCEL=3, MODEKEYEDIT_COMPLETE=4, MODEKEYEDIT_CURSORLEFT=5, MODEKEYEDIT_CURSORRIGHT=6, MODEKEYEDIT_DELETE=7, MODEKEYEDIT_DELETELINE=8, MODEKEYEDIT_DELETETOENDOFLINE=9, MODEKEYEDIT_ENDOFLINE=10, MODEKEYEDIT_ENTER=11, MODEKEYEDIT_HISTORYDOWN=12, MODEKEYEDIT_HISTORYUP=13, MODEKEYEDIT_PASTE=14, MODEKEYEDIT_STARTOFLINE=15, MODEKEYEDIT_SWITCHMODE=16, MODEKEYEDIT_SWITCHMODEAPPEND=17, MODEKEYEDIT_TRANSPOSECHARS=18, MODEKEYCHOICE_CANCEL=19, MODEKEYCHOICE_CHOOSE=20, MODEKEYCHOICE_DOWN=21, MODEKEYCHOICE_PAGEDOWN=22, MODEKEYCHOICE_PAGEUP=23, MODEKEYCHOICE_UP=24, MODEKEYCOPY_BACKTOINDENTATION=25, MODEKEYCOPY_BOTTOMLINE=26, MODEKEYCOPY_CANCEL=27, MODEKEYCOPY_CLEARSELECTION=28, MODEKEYCOPY_COPYSELECTION=29, MODEKEYCOPY_DOWN=30, MODEKEYCOPY_ENDOFLINE=31, MODEKEYCOPY_GOTOLINE=32, MODEKEYCOPY_HALFPAGEDOWN=33, MODEKEYCOPY_HALFPAGEUP=34, MODEKEYCOPY_LEFT=35, MODEKEYCOPY_MIDDLELINE=36, MODEKEYCOPY_NEXTPAGE=37, MODEKEYCOPY_NEXTWORD=38, MODEKEYCOPY_PREVIOUSPAGE=39, MODEKEYCOPY_PREVIOUSWORD=40, MODEKEYCOPY_RIGHT=41, MODEKEYCOPY_SCROLLDOWN=42, MODEKEYCOPY_SCROLLUP=43, MODEKEYCOPY_SEARCHAGAIN=44, MODEKEYCOPY_SEARCHDOWN=45, MODEKEYCOPY_SEARCHUP=46, MODEKEYCOPY_STARTOFLINE=47, MODEKEYCOPY_STARTSELECTION=48, MODEKEYCOPY_TOPLINE=49, MODEKEYCOPY_UP=50 }

user_defined_types: struct paste_buffer { char *data; unsigned long size; }

user_defined_types: struct grid_utf8 { unsigned char width; unsigned char data[9]; }

user_defined_types: struct window_panes { struct window_pane *tqh_first; struct window_pane **tqh_last; }

user_defined_types: struct screen_write_ctx { struct window_pane *wp; struct screen *s; }

user_defined_types: struct utf8_data { unsigned char data[9]; unsigned long have; unsigned long size; unsigned int width; }

user_defined_types: struct options_entry { char *name; enum { OPTIONS_STRING=0, OPTIONS_NUMBER=1, OPTIONS_DATA=2 } type; char *str; long long num; void *data; void (*freefn)(void *); struct { struct options_entry *spe_left; struct options_entry *spe_right; } entry; }

user_defined_types: enum layout_type { LAYOUT_LEFTRIGHT=0, LAYOUT_TOPBOTTOM=1, LAYOUT_WINDOWPANE=2 }

user_defined_types: struct layout_cells { struct layout_cell *tqh_first; struct layout_cell **tqh_last; }

user_defined_types: struct input_arg { unsigned char data[64]; unsigned long used; }

user_defined_types: struct mouse_event { unsigned char b; unsigned char x; unsigned char y; }