decompiled_code:
__int64 __fastcall window_choose_scroll_up(_QWORD *a1)
{
__int64 v1; // rbx
__int64 result; // rax
_BYTE v3[40]; // [rsp+0h] [rbp-28h] BYREF

v1 = a1[101];
result = *(unsigned int *)(v1 + 120);
if ( (_DWORD)result )
{
*(_DWORD *)(v1 + 120) = result - 1;
screen_write_start(v3, a1, 0LL);
screen_write_cursormove(v3, 0LL, 0LL);
screen_write_insertline(v3, 1LL);
window_choose_write_line(a1, (__int64)v3, 0);
if ( *(_DWORD *)(*(_QWORD *)(v1 + 8) + 8LL) > 1u )
window_choose_write_line(a1, (__int64)v3, 1u);
result = screen_write_stop(v3);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func11(_QWORD *a1)
{
__int64 v1; // rbx
__int64 result; // rax
_BYTE v3[40]; // [rsp+0h] [rbp-28h] BYREF

v1 = a1[101];
result = *(unsigned int *)(v1 + 120);
if ( (_DWORD)result )
{
*(_DWORD *)(v1 + 120) = result - 1;
screen_write_start(v3, a1, 0LL);
screen_write_cursormove(v3, 0LL, 0LL);
screen_write_insertline(v3, 1LL);
func6(a1, (__int64)v3, 0);
if ( *(_DWORD *)(*(_QWORD *)(v1 + 8) + 8LL) > 1u )
func6(a1, (__int64)v3, 1u);
result = screen_write_stop(v3);
}
return result;
}

original_code:
void
window_choose_scroll_up(struct window_pane *wp)
{
 struct window_choose_mode_data *data = wp->modedata;
 struct screen_write_ctx ctx;
 if (data->top == 0)
  return;
 data->top--;
 screen_write_start(&ctx, wp, ((void *)0));
 screen_write_cursormove(&ctx, 0, 0);
 screen_write_insertline(&ctx, 1);
 window_choose_write_line(wp, &ctx, 0);
 if (((&data->screen)->grid->sy) > 1)
  window_choose_write_line(wp, &ctx, 1);
 screen_write_stop(&ctx);
}

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 window_choose_mode_data { struct screen screen; struct mode_key_data mdata; struct { struct window_choose_mode_item *list; unsigned int num; unsigned long space; } list; unsigned int top; unsigned int selected; void (*callback)(void *, int); void *data; }

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; }

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; struct screen_sel sel; }

user_defined_types: struct mode_key_data { int type; int flags; }

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 buffer { unsigned char *base; unsigned long space; unsigned long size; unsigned long off; }

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 *, unsigned char, unsigned char, unsigned char); void (*timer)(struct window_pane *); }

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 options { struct options_tree tree; struct options *parent; }

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 options_tree { struct options_entry *sph_root; }

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_hidden; 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 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 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 paste_stack { struct paste_buffer **list; unsigned int num; unsigned long space; }

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


repo: ThomasAdam/tmux-ARCHIVED

decompiled_code:
__int64 __fastcall window_choose_scroll_down(_QWORD *a1)
{
__int64 v1; // rbx
__int64 result; // rax
unsigned int v3; // edx
_BYTE v4[40]; // [rsp+0h] [rbp-28h] BYREF

v1 = a1[101];
result = *(unsigned int *)(v1 + 120);
if ( (unsigned int)result < *(_DWORD *)(v1 + 104) )
{
*(_DWORD *)(v1 + 120) = result + 1;
screen_write_start(v4, a1, 0LL);
screen_write_cursormove(v4, 0LL, 0LL);
screen_write_deleteline(v4, 1LL);
window_choose_write_line(a1, (__int64)v4, *(_DWORD *)(*(_QWORD *)(v1 + 8) + 8LL) - 1);
v3 = *(_DWORD *)(*(_QWORD *)(v1 + 8) + 8LL);
if ( v3 > 1 )
window_choose_write_line(a1, (__int64)v4, v3 - 2);
result = screen_write_stop(v4);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func12(_QWORD *a1)
{
__int64 v1; // rbx
__int64 result; // rax
unsigned int v3; // edx
_BYTE v4[40]; // [rsp+0h] [rbp-28h] BYREF

v1 = a1[101];
result = *(unsigned int *)(v1 + 120);
if ( (unsigned int)result < *(_DWORD *)(v1 + 104) )
{
*(_DWORD *)(v1 + 120) = result + 1;
screen_write_start(v4, a1, 0LL);
screen_write_cursormove(v4, 0LL, 0LL);
screen_write_deleteline(v4, 1LL);
func6(a1, (__int64)v4, *(_DWORD *)(*(_QWORD *)(v1 + 8) + 8LL) - 1);
v3 = *(_DWORD *)(*(_QWORD *)(v1 + 8) + 8LL);
if ( v3 > 1 )
func6(a1, (__int64)v4, v3 - 2);
result = screen_write_stop(v4);
}
return result;
}

original_code:
void
window_choose_scroll_down(struct window_pane *wp)
{
 struct window_choose_mode_data *data = wp->modedata;
 struct screen *s = &data->screen;
 struct screen_write_ctx ctx;
 if (data->top >= ((&data->list)->num))
  return;
 data->top++;
 screen_write_start(&ctx, wp, ((void *)0));
 screen_write_cursormove(&ctx, 0, 0);
 screen_write_deleteline(&ctx, 1);
 window_choose_write_line(wp, &ctx, ((s)->grid->sy) - 1);
 if (((&data->screen)->grid->sy) > 1)
  window_choose_write_line(wp, &ctx, ((s)->grid->sy) - 2);
 screen_write_stop(&ctx);
}

variable_types: struct window_pane { struct window { char *name; struct timeval { long tv_sec; long tv_usec; } name_timer; struct window_pane *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; 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 { unsigned char *base; unsigned long space; unsigned long size; unsigned long off; } *in; struct buffer *out; struct input_ctx { struct window_pane *wp; struct screen_write_ctx { struct window_pane *wp; struct screen { char *title; struct grid { unsigned int sx; unsigned int sy; unsigned int hsize; unsigned int hlimit; unsigned int *size; struct grid_cell { unsigned char attr; unsigned char flags; unsigned char fg; unsigned char bg; unsigned char data; } **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; struct screen_sel { int flag; unsigned int sx; unsigned int sy; unsigned int ex; unsigned int ey; struct grid_cell cell; } sel; } *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 fd; struct buffer *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 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 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_hidden; 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 *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; } *, 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; } *

variable_types: struct window_choose_mode_data { struct screen { char *title; struct grid { unsigned int sx; unsigned int sy; unsigned int hsize; unsigned int hlimit; unsigned int *size; struct grid_cell { unsigned char attr; unsigned char flags; unsigned char fg; unsigned char bg; unsigned char data; } **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; struct screen_sel { int flag; unsigned int sx; unsigned int sy; unsigned int ex; unsigned int ey; struct grid_cell cell; } sel; } screen; struct mode_key_data { int type; int flags; } mdata; struct { struct window_choose_mode_item { char *name; int idx; } *list; unsigned int num; unsigned long space; } list; unsigned int top; unsigned int selected; void (*callback)(void *, int); void *data; } *

variable_types: struct screen_write_ctx { struct window_pane { struct window { char *name; struct timeval { long tv_sec; long tv_usec; } name_timer; struct window_pane *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; 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 { unsigned char *base; unsigned long space; unsigned long size; unsigned long off; } *in; struct buffer *out; struct input_ctx { struct window_pane *wp; struct screen_write_ctx ctx; unsigned char *buf; unsigned long len; unsigned long off; struct grid_cell { unsigned char attr; unsigned char flags; unsigned char fg; unsigned char bg; unsigned char data; } 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 { 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; struct screen_sel { int flag; unsigned int sx; unsigned int sy; unsigned int ex; unsigned int ey; struct grid_cell cell; } sel; } *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 fd; struct buffer *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 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 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_hidden; 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 *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; } *, 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; } *wp; struct screen *s; }

return_type: void

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

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 window_choose_mode_data { struct screen screen; struct mode_key_data mdata; struct { struct window_choose_mode_item *list; unsigned int num; unsigned long space; } list; unsigned int top; unsigned int selected; void (*callback)(void *, int); void *data; }

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; }


decompiled_code:
__int64 __fastcall cmd_recv(__int64 a1)
{
__int64 v1; // rbx
void **v2; // rax
_QWORD *v3; // r12
__int64 v4; // rax
void (__fastcall *v5)(_QWORD *, __int64); // rax
__int64 result; // rax
unsigned int v7[7]; // [rsp+Ch] [rbp-1Ch] BYREF

buffer_read(a1, v7, 4LL);
if ( cmd_table )
{
v1 = v7[0];
v2 = &cmd_table;
while ( &cmd_table + v7[0] != v2 )
{
if ( !*++v2 )
goto LABEL_8;
}
v3 = (_QWORD *)xmalloc(32LL);
v4 = (__int64)*(&cmd_table + v1);
*v3 = v4;
v5 = *(void (__fastcall **)(_QWORD *, __int64))(v4 + 64);
if ( v5 )
v5(v3, a1);
result = (__int64)v3;
}
else
{
LABEL_8:
log_fatalx("%s: %s", "cmd_recv", "command not found");
result = cmd_free();
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
__int64 v1; // rbx
void **v2; // rax
_QWORD *v3; // r12
__int64 v4; // rax
void (__fastcall *v5)(_QWORD *, __int64); // rax
__int64 result; // rax
unsigned int v7[7]; // [rsp+Ch] [rbp-1Ch] BYREF

buffer_read(a1, v7, 4LL);
if ( cmd_table )
{
v1 = v7[0];
v2 = &cmd_table;
while ( &cmd_table + v7[0] != v2 )
{
if ( !*++v2 )
goto LABEL_8;
}
v3 = (_QWORD *)xmalloc(32LL);
v4 = (__int64)*(&cmd_table + v1);
*v3 = v4;
v5 = *(void (__fastcall **)(_QWORD *, __int64))(v4 + 64);
if ( v5 )
v5(v3, a1);
result = (__int64)v3;
}
else
{
LABEL_8:
log_fatalx("%s: %s", "cmd_recv", "command not found");
result = func3();
}
return result;
}

original_code:
struct cmd *
cmd_recv(struct buffer *b)
{
 const struct cmd_entry **entryp;
 struct cmd *cmd;
 u_int m, n;
 buffer_read(b, &m, sizeof m);
 n = 0;
 for (entryp = cmd_table; *entryp != ((void *)0); entryp++) {
  if (n == m)
   break;
  n++;
 }
 if (*entryp == ((void *)0))
  log_fatalx("%s: %s", __func__, "command not found");;
 cmd = xmalloc(sizeof *cmd);
 cmd->entry = *entryp;
 if (cmd->entry->recv != ((void *)0))
  cmd->entry->recv(cmd, b);
 return (cmd);
}

canonical_original_code:
struct cmd *cmd_recv(struct buffer *b)
{
 struct cmd_entry **entryp;
 struct cmd *cmd;
 unsigned int m; unsigned int n;
 buffer_read(b, &m, sizeof m);
 n = 0;
 for (entryp = cmd_table; *entryp != ((void *)0); entryp++) {
  if (n == m)
   break;
  n++;
 }
 if (*entryp == ((void *)0))
  log_fatalx("%s: %s", __func__, "command not found");;
 cmd = xmalloc(sizeof *cmd);
 cmd->entry = *entryp;
 if (cmd->entry->recv != ((void *)0))
  cmd->entry->recv(cmd, b);
 return (cmd);
}

variable_types:
b
struct buffer *

variable_types: struct cmd_entry { char *name; char *alias; char *usage; int flags; void (*init)(struct cmd { struct cmd_entry *entry; void *data; struct { struct cmd *tqe_next; struct cmd **tqe_prev; } qentry; } *, 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; 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_hidden; 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); } **

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; 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_hidden; 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:
m
unsigned int

variable_types:
n
unsigned int

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 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 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; struct screen_sel sel; }

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 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; }


decompiled_code:
__int64 __fastcall cmd_free(_QWORD *a1)
{
void (*v1)(void); // rax

if ( a1[1] )
{
v1 = *(void (**)(void))(*a1 + 72LL);
if ( v1 )
v1();
}
return xfree(a1);
}

canonical_decompiled_code:
__int64 __fastcall func3(_QWORD *a1)
{
void (*v1)(void); // rax

if ( a1[1] )
{
v1 = *(void (**)(void))(*a1 + 72LL);
if ( v1 )
v1();
}
return xfree(a1);
}

original_code:
void
cmd_free(struct cmd *cmd)
{
 if (cmd->data != ((void *)0) && cmd->entry->free != ((void *)0))
  cmd->entry->free(cmd);
 xfree(cmd);
}

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 msg_command_data { int pid; unsigned int idx; unsigned long namelen; }

user_defined_types: struct mode_key_data { int type; int flags; }

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

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 timeval { long tv_sec; long tv_usec; }

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 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 winlink_stack { struct winlink *slh_first; }

user_defined_types: struct winlinks { struct winlink *rbh_root; }

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 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: struct grid_utf8 { unsigned char width; unsigned char data[8]; }

user_defined_types: struct paste_buffer { char *data; struct timeval tv; }

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

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

user_defined_types: struct options_tree { struct options_entry *sph_root; }

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 *, unsigned char, unsigned char, unsigned char); void (*timer)(struct window_pane *); }

user_defined_types: 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; }

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


decompiled_code:
__int64 __fastcall cmd_print(const char ***a1, __int64 a2, __int64 a3, __int64 a4)
{
const char *v4; // rax
__int64 result; // rax

v4 = (*a1)[10];
if ( v4 )
result = ((__int64 (__fastcall *)(const char ***, __int64, __int64, __int64, __int64))v4)(a1, a2, a3, a4, a2);
else
result = (int)xsnprintf(a2, a3, "%s", **a1);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(const char ***a1, __int64 a2, __int64 a3, __int64 a4)
{
const char *v4; // rax
__int64 result; // rax

v4 = (*a1)[10];
if ( v4 )
result = ((__int64 (__fastcall *)(const char ***, __int64, __int64, __int64, __int64))v4)(a1, a2, a3, a4, a2);
else
result = (int)xsnprintf(a2, a3, "%s", **a1);
return result;
}

original_code:
size_t
cmd_print(struct cmd *cmd, char *buf, size_t len)
{
 if (cmd->entry->print == ((void *)0)) {
  return (xsnprintf(buf, len, "%s", cmd->entry->name));
 }
 return (cmd->entry->print(cmd, buf, len));
}

canonical_original_code:
unsigned long cmd_print(struct cmd *cmd, char *buf, unsigned long len)
{
 if (cmd->entry->print == ((void *)0)) {
  return (xsnprintf(buf, len, "%s", cmd->entry->name));
 }
 return (cmd->entry->print(cmd, buf, len));
}

variable_types:
buf
char *

variable_types:
len
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_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 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 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_hidden; 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 msg_command_data { int pid; unsigned int idx; unsigned long namelen; }

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; struct screen_sel sel; }

user_defined_types: struct mode_key_data { int type; int flags; }

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

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 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 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 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 tty_code { enum tty_code_type type; union { char *string; int number; int flag; } value; }

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 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 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; }

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


decompiled_code:
__int64 __fastcall cmd_send_string(__int64 a1, const char *a2)
{
__int64 result; // rax
__int64 v3[4]; // [rsp+8h] [rbp-20h] BYREF

if ( a2 )
{
v3[0] = strlen(a2) + 1;
buffer_write(a1, v3, 8LL);
result = buffer_write(a1, a2, v3[0]);
}
else
{
v3[0] = 0LL;
result = buffer_write(a1, v3, 8LL);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, const char *a2)
{
__int64 result; // rax
__int64 v3[4]; // [rsp+8h] [rbp-20h] BYREF

if ( a2 )
{
v3[0] = strlen(a2) + 1;
buffer_write(a1, v3, 8LL);
result = buffer_write(a1, a2, v3[0]);
}
else
{
v3[0] = 0LL;
result = buffer_write(a1, v3, 8LL);
}
return result;
}

original_code:
void
cmd_send_string(struct buffer *b, const char *s)
{
 size_t n;
 if (s == ((void *)0)) {
  n = 0;
  buffer_write(b, &n, sizeof n);
  return;
 }
 n = strlen(s) + 1;
 buffer_write(b, &n, sizeof n);
 buffer_write(b, s, n);
}

canonical_original_code:
void cmd_send_string(struct buffer *b, char *s)
{
 unsigned long n;
 if (s == ((void *)0)) {
  n = 0;
  buffer_write(b, &n, sizeof n);
  return;
 }
 n = strlen(s) + 1;
 buffer_write(b, &n, sizeof n);
 buffer_write(b, s, n);
}

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

variable_types:
s
char *

variable_types:
n
unsigned long


original_code:
char *
cmd_recv_string(struct buffer *b)
{
 char *s;
 size_t n;
 buffer_read(b, &n, sizeof n);
 if (n == 0)
  return (((void *)0));
 s = xmalloc(n);
 buffer_read(b, s, n);
 s[n - 1] = '\0';
 return (s);
}

canonical_original_code:
char *cmd_recv_string(struct buffer *b)
{
 char *s;
 unsigned long n;
 buffer_read(b, &n, sizeof n);
 if (n == 0)
  return (((void *)0));
 s = xmalloc(n);
 buffer_read(b, s, n);
 s[n - 1] = '\0';
 return (s);
}

return_type: char *


decompiled_code:
__int64 __fastcall tty_keys_add1(__int64 *a1, unsigned __int8 *a2, int a3)
{
__int64 result; // rax
bool v7; // cc
unsigned __int8 v8; // dl

LABEL_1:
while ( 2 )
{
result = *a1;
if ( *a1 )
{
LABEL_2:
v7 = (char)*a2 < *(_BYTE *)result;
if ( *a2 == *(_BYTE *)result )
goto LABEL_6;
goto LABEL_3;
}
while ( 1 )
{
result = xcalloc(1LL, 32LL);
*a1 = result;
v8 = *a2;
*(_DWORD *)(result + 4) = 4095;
*(_BYTE *)result = v8;
v7 = (char)*a2 < (char)v8;
if ( *a2 == v8 )
break;
LABEL_3:
if ( !v7 )
{
if ( !v7 )
a1 = (__int64 *)(result + 16);
goto LABEL_1;
}
a1 = (__int64 *)(result + 8);
result = *(_QWORD *)(result + 8);
if ( result )
goto LABEL_2;
}
LABEL_6:
if ( a2[1] )
{
++a2;
a1 = (__int64 *)(result + 24);
continue;
}
break;
}
*(_DWORD *)(result + 4) = a3;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 *a1, unsigned __int8 *a2, int a3)
{
__int64 result; // rax
bool v7; // cc
unsigned __int8 v8; // dl

LABEL_1:
while ( 2 )
{
result = *a1;
if ( *a1 )
{
LABEL_2:
v7 = (char)*a2 < *(_BYTE *)result;
if ( *a2 == *(_BYTE *)result )
goto LABEL_6;
goto LABEL_3;
}
while ( 1 )
{
result = xcalloc(1LL, 32LL);
*a1 = result;
v8 = *a2;
*(_DWORD *)(result + 4) = 4095;
*(_BYTE *)result = v8;
v7 = (char)*a2 < (char)v8;
if ( *a2 == v8 )
break;
LABEL_3:
if ( !v7 )
{
if ( !v7 )
a1 = (__int64 *)(result + 16);
goto LABEL_1;
}
a1 = (__int64 *)(result + 8);
result = *(_QWORD *)(result + 8);
if ( result )
goto LABEL_2;
}
LABEL_6:
if ( a2[1] )
{
++a2;
a1 = (__int64 *)(result + 24);
continue;
}
break;
}
*(_DWORD *)(result + 4) = a3;
return result;
}

original_code:
void
tty_keys_add1(struct tty_key **tkp, const char *s, int key)
{
 struct tty_key *tk;
 tk = *tkp;
 if (tk == ((void *)0)) {
  tk = *tkp = xcalloc(1, sizeof *tk);
  tk->ch = *s;
  tk->key = 0xfff;
 }
 if (*s == tk->ch) {
  s++;
  if (*s == '\0') {
   tk->key = key;
   return;
  }
  tkp = &tk->next;
 } else {
  if (*s < tk->ch)
   tkp = &tk->left;
  else if (*s > tk->ch)
   tkp = &tk->right;
 }
 tty_keys_add1(tkp, s, key);
}

canonical_original_code:
void tty_keys_add1(struct tty_key **tkp, char *s, int key)
{
 struct tty_key *tk;
 tk = *tkp;
 if (tk == ((void *)0)) {
  tk = *tkp = xcalloc(1, sizeof *tk);
  tk->ch = *s;
  tk->key = 0xfff;
 }
 if (*s == tk->ch) {
  s++;
  if (*s == '\0') {
   tk->key = key;
   return;
  }
  tkp = &tk->next;
 } else {
  if (*s < tk->ch)
   tkp = &tk->left;
  else if (*s > tk->ch)
   tkp = &tk->right;
 }
 tty_keys_add1(tkp, s, key);
}

variable_types: struct tty_key { char ch; int key; struct tty_key *left; struct tty_key *right; struct tty_key *next; } **

variable_types: key int


decompiled_code:
__int64 __fastcall tty_keys_free1(_QWORD *a1)
{
if ( a1[3] )
tty_keys_free1();
if ( a1[1] )
tty_keys_free1();
if ( a1[2] )
tty_keys_free1();
return xfree(a1);
}

canonical_decompiled_code:
__int64 __fastcall func1(_QWORD *a1)
{
if ( a1[3] )
func1();
if ( a1[1] )
func1();
if ( a1[2] )
func1();
return xfree(a1);
}

original_code:
void
tty_keys_free1(struct tty_key *tk)
{
 if (tk->next != ((void *)0))
  tty_keys_free1(tk->next);
 if (tk->left != ((void *)0))
  tty_keys_free1(tk->left);
 if (tk->right != ((void *)0))
  tty_keys_free1(tk->right);
 xfree(tk);
}

variable_types: struct tty_key { char ch; int key; struct tty_key *left; struct tty_key *right; struct tty_key *next; } *


decompiled_code:
__int64 __fastcall tty_keys_free(__int64 a1)
{
return tty_keys_free1(*(_QWORD **)(a1 + 552));
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
return func1(*(_QWORD **)(a1 + 552));
}

original_code:
void
tty_keys_free(struct tty *tty)
{
 struct tty_key *tk;
 while (!((&tty->ktree)->rbh_root == ((void *)0))) {
  tk = (&tty->ktree)->rbh_root;
  tty_keys_RB_REMOVE(&tty->ktree, tk);
  xfree(tk->string);
  xfree(tk);
 }
}

variable_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 { 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 { 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; } *


decompiled_code:
char *__fastcall tty_keys_find(__int64 a1, char *a2, __int64 a3, _QWORD *a4)
{
*a4 = 0LL;
return tty_keys_find1(*(char **)(a1 + 552), a2, a3, a4);
}

canonical_decompiled_code:
char *__fastcall func4(__int64 a1, char *a2, __int64 a3, _QWORD *a4)
{
*a4 = 0LL;
return func3(*(char **)(a1 + 552), a2, a3, a4);
}

original_code:
struct tty_key *
tty_keys_find(struct tty *tty, char *buf, size_t len, size_t *size)
{
 struct tty_key *tk, tl;
 char *s;
 if (len == 0)
  return (((void *)0));
 s = xmalloc(tty->ksize + 1);
 for (*size = tty->ksize; (*size) > 0; (*size)--) {
  if ((*size) > len)
   continue;
  memcpy(s, buf, *size);
  s[*size] = '\0';
  log_debug2("looking for key: %s", s);
  tl.string = s;
  tk = tty_keys_RB_FIND(&tty->ktree, &tl);
  if (tk != ((void *)0)) {
   log_debug2("got key: 0x%x", tk->key);
   xfree(s);
   return (tk);
  }
 }
 xfree(s);
 return (((void *)0));
}

canonical_original_code:
struct tty_key *tty_keys_find(struct tty *tty, char *buf, unsigned long len, unsigned long *size)
{
 struct tty_key *tk; struct tty_key tl;
 char *s;
 if (len == 0)
  return (((void *)0));
 s = xmalloc(tty->ksize + 1);
 for (*size = tty->ksize; (*size) > 0; (*size)--) {
  if ((*size) > len)
   continue;
  memcpy(s, buf, *size);
  s[*size] = '\0';
  log_debug2("looking for key: %s", s);
  tl.string = s;
  tk = tty_keys_RB_FIND(&tty->ktree, &tl);
  if (tk != ((void *)0)) {
   log_debug2("got key: 0x%x", tk->key);
   xfree(s);
   return (tk);
  }
 }
 xfree(s);
 return (((void *)0));
}

variable_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 { 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 { long tv_sec; long tv_usec; } key_timer; unsigned long ksize; struct tty_keys { struct tty_key *rbh_root; } ktree; } *

variable_types:
size
unsigned long *

variable_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; } *


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

result = cmd_pane_init();
if ( a2 == 196688 )
{
v3 = *(_QWORD *)(a1 + 8);
result = xstrdup(&unk_1DA);
*(_QWORD *)(v3 + 16) = result;
}
return result;
}

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

result = cmd_pane_init();
if ( a2 == 196688 )
{
v3 = *(_QWORD *)(a1 + 8);
result = xstrdup(&unk_1DA);
*(_QWORD *)(v3 + 16) = result;
}
return result;
}

original_code:
void
cmd_resize_pane_up_init(struct cmd *self, int key)
{
 struct cmd_pane_data *data;
 cmd_pane_init(self, key);
 data = self->data;
 if (key == (((0x010000 + 0x50)) | 0x020000))
  data->arg = xstrdup("5");
}

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

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; 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 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 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_hidden; 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 msg_command_data { int pid; unsigned int idx; unsigned long namelen; }

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

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 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 winlink_stack { struct winlink *slh_first; }

user_defined_types: struct winlinks { struct winlink *rbh_root; }

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 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: struct grid_utf8 { unsigned char width; unsigned char data[8]; }

user_defined_types: struct paste_buffer { char *data; struct timeval tv; }

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

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

user_defined_types: struct options_tree { struct options_entry *sph_root; }

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 *, unsigned char, unsigned char, unsigned char); void (*timer)(struct window_pane *); }

user_defined_types: 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; }

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


decompiled_code:
__int64 __fastcall cmd_resize_pane_up_exec(__int64 a1, __int64 a2)
{
__int64 v2; // r14
__int64 v3; // rax
__int64 v4; // rdi
__int64 v5; // r13
int v6; // er12
__int64 v7; // rbx
__int64 v8; // rdi
int v9; // eax
__int64 v10; // rbp
__int64 result; // rax
const char *v12; // [rsp+8h] [rbp-30h] BYREF

v2 = *(_QWORD *)(a1 + 8);
v3 = cmd_find_window(a2, *(_QWORD *)(v2 + 8), 0LL);
if ( !v3 )
return 0xFFFFFFFFLL;
v4 = *(_QWORD *)(v3 + 8);
v5 = v3;
v6 = *(_DWORD *)(v4 + 48);
if ( v6 )
{
(*(void (__fastcall **)(__int64, const char *))(a2 + 48))(a2, "window not in manual layout");
result = 0xFFFFFFFFLL;
}
else
{
if ( *(_DWORD *)(v2 + 24) == -1 )
{
v7 = *(_QWORD *)(v4 + 24);
}
else
{
v7 = window_pane_at_index();
if ( !v7 )
{
(*(void (**)(__int64, const char *, ...))(a2 + 48))(a2, "no pane: %d", *(unsigned int *)(v2 + 24));
return 0xFFFFFFFFLL;
}
}
v8 = *(_QWORD *)(v2 + 16);
if ( v8 )
{
v9 = strtonum(v8, 1LL, 0x7FFFFFFFLL, &v12);
if ( v12 )
{
(*(void (**)(__int64, const char *, ...))(a2 + 48))(a2, "adjustment %s: %s", v12, *(const char **)(v2 + 16));
return 0xFFFFFFFFLL;
}
v10 = *(_QWORD *)(v7 + 360);
if ( v10 )
goto LABEL_8;
}
else
{
v10 = *(_QWORD *)(v7 + 360);
if ( v10 )
goto LABEL_12;
v9 = 1;
}
if ( *(_QWORD *)(*(_QWORD *)(v5 + 8) + 32LL) != v7 )
{
v10 = v7;
v7 = **(_QWORD **)(*(_QWORD *)(v7 + 368) + 8LL);
LABEL_8:
v6 = v9 - 1;
if ( !v9 )
{
LABEL_13:
window_update_panes(*(_QWORD *)(v5 + 8));
server_redraw_window(*(_QWORD *)(v5 + 8));
return 0LL;
}
LABEL_12:
while ( *(_DWORD *)(v7 + 12) > 4u )
{
window_pane_resize(v10, *(unsigned int *)(v10 + 8), (unsigned int)(*(_DWORD *)(v10 + 12) + 1));
window_pane_resize(v7, *(unsigned int *)(v7 + 8), (unsigned int)(*(_DWORD *)(v7 + 12) - 1));
if ( !v6 )
break;
--v6;
}
goto LABEL_13;
}
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2)
{
__int64 v2; // r14
__int64 v3; // rax
__int64 v4; // rdi
__int64 v5; // r13
int v6; // er12
__int64 v7; // rbx
__int64 v8; // rdi
int v9; // eax
__int64 v10; // rbp
__int64 result; // rax
const char *v12; // [rsp+8h] [rbp-30h] BYREF

v2 = *(_QWORD *)(a1 + 8);
v3 = cmd_find_window(a2, *(_QWORD *)(v2 + 8), 0LL);
if ( !v3 )
return 0xFFFFFFFFLL;
v4 = *(_QWORD *)(v3 + 8);
v5 = v3;
v6 = *(_DWORD *)(v4 + 48);
if ( v6 )
{
(*(void (__fastcall **)(__int64, const char *))(a2 + 48))(a2, "window not in manual layout");
result = 0xFFFFFFFFLL;
}
else
{
if ( *(_DWORD *)(v2 + 24) == -1 )
{
v7 = *(_QWORD *)(v4 + 24);
}
else
{
v7 = window_pane_at_index();
if ( !v7 )
{
(*(void (**)(__int64, const char *, ...))(a2 + 48))(a2, "no pane: %d", *(unsigned int *)(v2 + 24));
return 0xFFFFFFFFLL;
}
}
v8 = *(_QWORD *)(v2 + 16);
if ( v8 )
{
v9 = strtonum(v8, 1LL, 0x7FFFFFFFLL, &v12);
if ( v12 )
{
(*(void (**)(__int64, const char *, ...))(a2 + 48))(a2, "adjustment %s: %s", v12, *(const char **)(v2 + 16));
return 0xFFFFFFFFLL;
}
v10 = *(_QWORD *)(v7 + 360);
if ( v10 )
goto LABEL_8;
}
else
{
v10 = *(_QWORD *)(v7 + 360);
if ( v10 )
goto LABEL_12;
v9 = 1;
}
if ( *(_QWORD *)(*(_QWORD *)(v5 + 8) + 32LL) != v7 )
{
v10 = v7;
v7 = **(_QWORD **)(*(_QWORD *)(v7 + 368) + 8LL);
LABEL_8:
v6 = v9 - 1;
if ( !v9 )
{
LABEL_13:
window_update_panes(*(_QWORD *)(v5 + 8));
server_redraw_window(*(_QWORD *)(v5 + 8));
return 0LL;
}
LABEL_12:
while ( *(_DWORD *)(v7 + 12) > 4u )
{
window_pane_resize(v10, *(unsigned int *)(v10 + 8), (unsigned int)(*(_DWORD *)(v10 + 12) + 1));
window_pane_resize(v7, *(unsigned int *)(v7 + 8), (unsigned int)(*(_DWORD *)(v7 + 12) - 1));
if ( !v6 )
break;
--v6;
}
goto LABEL_13;
}
result = 0LL;
}
return result;
}

original_code:
int
cmd_resize_pane_up_exec(struct cmd *self, struct cmd_ctx *ctx)
{
 struct cmd_pane_data *data = self->data;
 struct winlink *wl;
 const char *errstr;
 struct window_pane *wp, *wq;
 u_int adjust;
 if ((wl = cmd_find_window(ctx, data->target, ((void *)0))) == ((void *)0))
  return (-1);
 if (wl->window->layout != 0) {
  ctx->error(ctx, "window not in manual layout");
  return (-1);
 }
 if (data->pane == -1)
  wp = wl->window->active;
 else {
  wp = window_pane_at_index(wl->window, data->pane);
  if (wp == ((void *)0)) {
   ctx->error(ctx, "no pane: %d", data->pane);
   return (-1);
  }
 }
 if (data->arg == ((void *)0))
  adjust = 1;
 else {
  adjust = strtonum(data->arg, 1, 0x7fffffff, &errstr);
  if (errstr != ((void *)0)) {
   ctx->error(ctx, "adjustment %s: %s", errstr, data->arg);
   return (-1);
  }
 }
 wq = ((wp)->entry.tqe_next);
 if (wq == ((void *)0)) {
  if (wp == ((&wl->window->panes)->tqh_first)) {
   return (0);
  }
  wq = wp;
  wp = (*(((struct window_panes *)((wq)->entry.tqe_prev))->tqh_last));
 }
 while (adjust-- > 0) {
  if (wp->sy <= 4)
   break;
  window_pane_resize(wq, wq->sx, wq->sy + 1);
  window_pane_resize(wp, wp->sx, wp->sy - 1);
 }
 window_update_panes(wl->window);
 server_redraw_window(wl->window);
 return (0);
}

canonical_original_code:
int cmd_resize_pane_up_exec(struct cmd *self, struct cmd_ctx *ctx)
{
 struct cmd_pane_data *data = self->data;
 struct winlink *wl;
 char *errstr;
 struct window_pane *wp; struct window_pane *wq;
 unsigned int adjust;
 if ((wl = cmd_find_window(ctx, data->target, ((void *)0))) == ((void *)0))
  return (-1);
 if (wl->window->layout != 0) {
  ctx->error(ctx, "window not in manual layout");
  return (-1);
 }
 if (data->pane == -1)
  wp = wl->window->active;
 else {
  wp = window_pane_at_index(wl->window, data->pane);
  if (wp == ((void *)0)) {
   ctx->error(ctx, "no pane: %d", data->pane);
   return (-1);
  }
 }
 if (data->arg == ((void *)0))
  adjust = 1;
 else {
  adjust = strtonum(data->arg, 1, 0x7fffffff, &errstr);
  if (errstr != ((void *)0)) {
   ctx->error(ctx, "adjustment %s: %s", errstr, data->arg);
   return (-1);
  }
 }
 wq = ((wp)->entry.tqe_next);
 if (wq == ((void *)0)) {
  if (wp == ((&wl->window->panes)->tqh_first)) {
   return (0);
  }
  wq = wp;
  wp = (*(((struct window_panes *)((wq)->entry.tqe_prev))->tqh_last));
 }
 while (adjust-- > 0) {
  if (wp->sy <= 4)
   break;
  window_pane_resize(wq, wq->sx, wq->sy + 1);
  window_pane_resize(wp, wp->sx, wp->sy - 1);
 }
 window_update_panes(wl->window);
 server_redraw_window(wl->window);
 return (0);
}

variable_types:
ctx
struct cmd_ctx *

variable_types: struct winlink { int idx; struct window { char *name; struct timeval { long tv_sec; long tv_usec; } 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 { unsigned char *base; unsigned long space; unsigned long size; unsigned long off; } *in; struct buffer *out; struct input_ctx { struct window_pane *wp; struct screen_write_ctx { struct window_pane *wp; struct screen { char *title; struct grid { unsigned int sx; unsigned int sy; unsigned int hsize; unsigned int hlimit; unsigned int *size; struct grid_cell { unsigned char attr; unsigned char flags; unsigned char fg; unsigned char bg; unsigned char data; } **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; struct screen_sel { int flag; unsigned int sx; unsigned int sy; unsigned int ex; unsigned int ey; struct grid_cell cell; } sel; } *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 fd; struct buffer *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 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 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_hidden; 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 *curw; struct winlink_stack { struct winlink *slh_first; } lastw; struct winlinks { struct winlink *rbh_root; } windows; 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; 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; } *, 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 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; } *

variable_types:
errstr
char *

variable_types: struct window_pane { struct window { char *name; struct timeval { long tv_sec; long tv_usec; } name_timer; struct window_pane *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; 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 { unsigned char *base; unsigned long space; unsigned long size; unsigned long off; } *in; struct buffer *out; struct input_ctx { struct window_pane *wp; struct screen_write_ctx { struct window_pane *wp; struct screen { char *title; struct grid { unsigned int sx; unsigned int sy; unsigned int hsize; unsigned int hlimit; unsigned int *size; struct grid_cell { unsigned char attr; unsigned char flags; unsigned char fg; unsigned char bg; unsigned char data; } **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; struct screen_sel { int flag; unsigned int sx; unsigned int sy; unsigned int ex; unsigned int ey; struct grid_cell cell; } sel; } *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 fd; struct buffer *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 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 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_hidden; 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 *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; } *, 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; } *

variable_types:
adjust
unsigned int

return_type: int

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_pane_data { int flags; char *target; char *arg; int pane; }

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 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; }

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 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 screen_write_ctx { struct window_pane *wp; struct screen *s; }

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; struct screen_sel sel; }

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 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_hidden; 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 msg_command_data { int pid; unsigned int idx; unsigned long namelen; }

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 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 paste_stack { struct paste_buffer **list; unsigned int num; unsigned long space; }

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


decompiled_code:
__int64 __fastcall cmd_delete_buffer_exec(__int64 a1, __int64 a2)
{
__int64 v2; // rbp
__int64 v3; // rax
__int64 v4; // rdi
__int64 result; // rax

v2 = *(_QWORD *)(a1 + 8);
v3 = cmd_find_session(a2, *(_QWORD *)(v2 + 8));
if ( !v3 )
return 0xFFFFFFFFLL;
v4 = v3 + 72;
if ( *(_DWORD *)(v2 + 16) == -1 )
{
paste_free_top(v4);
result = 0LL;
}
else
{
result = paste_free_index(v4);
if ( (_DWORD)result )
{
(*(void (**)(__int64, const char *, ...))(a2 + 48))(a2, "no buffer %d", *(unsigned int *)(v2 + 16));
result = 0xFFFFFFFFLL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2)
{
__int64 v2; // rbp
__int64 v3; // rax
__int64 v4; // rdi
__int64 result; // rax

v2 = *(_QWORD *)(a1 + 8);
v3 = cmd_find_session(a2, *(_QWORD *)(v2 + 8));
if ( !v3 )
return 0xFFFFFFFFLL;
v4 = v3 + 72;
if ( *(_DWORD *)(v2 + 16) == -1 )
{
paste_free_top(v4);
result = 0LL;
}
else
{
result = paste_free_index(v4);
if ( (_DWORD)result )
{
(*(void (**)(__int64, const char *, ...))(a2 + 48))(a2, "no buffer %d", *(unsigned int *)(v2 + 16));
result = 0xFFFFFFFFLL;
}
}
return result;
}

original_code:
int
cmd_delete_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
{
 struct cmd_buffer_data *data = self->data;
 struct session *s;
 if ((s = cmd_find_session(ctx, data->target)) == ((void *)0))
  return (-1);
 if (data->buffer == -1)
  paste_free_top(&s->buffers);
 else if (paste_free_index(&s->buffers, data->buffer) != 0) {
  ctx->error(ctx, "no buffer %d", data->buffer);
  return (-1);
 }
 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: struct cmd_buffer_data { int flags; char *target; int buffer; char *arg; } *

variable_types: struct session { char *name; struct timeval { long tv_sec; long tv_usec; } 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 { unsigned char *base; unsigned long space; unsigned long size; unsigned long off; } *in; struct buffer *out; struct input_ctx { struct window_pane *wp; struct screen_write_ctx { struct window_pane *wp; struct screen { char *title; struct grid { unsigned int sx; unsigned int sy; unsigned int hsize; unsigned int hlimit; unsigned int *size; struct grid_cell { unsigned char attr; unsigned char flags; unsigned char fg; unsigned char bg; unsigned char data; } **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; } *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 fd; struct buffer *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 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 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 { int type; int flags; } prompt_mdata; struct session *session; } *, 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; } *

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 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 options { struct options_tree tree; struct options *parent; }

user_defined_types: struct options_tree { struct options_entry *sph_root; }

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 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 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; }