decompiled_code:
__int64 __fastcall cmd_source_file_free(__int64 a1)
{
_QWORD *v1; // rbx

v1 = *(_QWORD **)(a1 + 8);
if ( *v1 )
xfree(*v1);
return xfree(v1);
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
_QWORD *v1; // rbx

v1 = *(_QWORD **)(a1 + 8);
if ( *v1 )
xfree(*v1);
return xfree(v1);
}

original_code:
void
cmd_source_file_free(struct cmd *self)
{
 struct cmd_source_file_data *data = self->data;
 if (data->path != ((void *)0))
  xfree(data->path);
 xfree(data);
}

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

variable_types: struct cmd_source_file_data { char *path; } *

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

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

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

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

user_defined_types: struct tty_keys { struct tty_key *rbh_root; }

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

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

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

user_defined_types: struct 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 *tqe_next; struct winlink **tqe_prev; } sentry; }

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

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

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

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

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

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


repo: ThomasAdam/tmux-ARCHIVED

decompiled_code:
__int64 __fastcall cmd_source_file_send(__int64 a1, __int64 a2)
{
_QWORD *v2; // rbp

v2 = *(_QWORD **)(a1 + 8);
buffer_write(a2, v2, 8LL);
return cmd_send_string(a2, *v2);
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, __int64 a2)
{
_QWORD *v2; // rbp

v2 = *(_QWORD **)(a1 + 8);
buffer_write(a2, v2, 8LL);
return cmd_send_string(a2, *v2);
}

original_code:
void
cmd_source_file_send(struct cmd *self, struct buffer *b)
{
 struct cmd_source_file_data *data = self->data;
 buffer_write(b, data, sizeof *data);
 cmd_send_string(b, data->path);
}

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:
b
struct buffer *

return_type: void

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_source_file_data { char *path; }

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_flags; unsigned int prompt_hindex; struct { char **list; unsigned int num; unsigned long space; } prompt_hdata; struct mode_key_data prompt_mdata; struct session *session; }

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

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

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

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

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

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

user_defined_types: struct options_tree { struct options_entry *sph_root; }

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


decompiled_code:
__int64 __fastcall cmd_source_file_recv(__int64 a1, __int64 a2)
{
__int64 *v2; // rbx
__int64 result; // rax

v2 = (__int64 *)xmalloc(8LL);
*(_QWORD *)(a1 + 8) = v2;
buffer_read(a2, v2, 8LL);
result = cmd_recv_string(a2);
*v2 = result;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, __int64 a2)
{
__int64 *v2; // rbx
__int64 result; // rax

v2 = (__int64 *)xmalloc(8LL);
*(_QWORD *)(a1 + 8) = v2;
buffer_read(a2, v2, 8LL);
result = cmd_recv_string(a2);
*v2 = result;
return result;
}

original_code:
void
cmd_source_file_recv(struct cmd *self, struct buffer *b)
{
 struct cmd_source_file_data *data;
 self->data = data = xmalloc(sizeof *data);
 buffer_read(b, data, sizeof *data);
 data->path = cmd_recv_string(b);
}

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 tty_keys { struct tty_key *rbh_root; }

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

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

user_defined_types: struct winlinks { struct winlink *rbh_root; }

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

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

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

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_source_file_print(__int64 a1, __int64 a2, unsigned __int64 a3)
{
_QWORD *v4; // r13
int v5; // eax
__int64 v6; // rbx

v4 = *(_QWORD **)(a1 + 8);
v5 = xsnprintf(a2, a3, "%s", **(const char ***)a1);
v6 = v5;
if ( v5 < a3 && v4 && *v4 )
v6 = cmd_prarg(a2 + v5, a3 - v5, " ") + v5;
return v6;
}

original_code:
size_t
cmd_source_file_print(struct cmd *self, char *buf, size_t len)
{
 struct cmd_source_file_data *data = self->data;
 size_t off = 0;
 off += xsnprintf(buf, len, "%s", self->entry->name);
 if (data == ((void *)0))
  return (off);
 if (off < len && data->path != ((void *)0))
  off += cmd_prarg(buf + off, len - off, " ", data->path);
 return (off);
}

canonical_original_code:
unsigned long cmd_source_file_print(struct cmd *self, char *buf, unsigned long len)
{
 struct cmd_source_file_data *data = self->data;
 unsigned long off = 0;
 off += xsnprintf(buf, len, "%s", self->entry->name);
 if (data == ((void *)0))
  return (off);
 if (off < len && data->path != ((void *)0))
  off += cmd_prarg(buf + off, len - off, " ", data->path);
 return (off);
}

variable_types:
buf
char *

variable_types:
len
unsigned long

variable_types:
off
unsigned long

return_type: unsigned long

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

user_defined_types: struct cmd_source_file_data { char *path; }

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

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

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

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

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

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

user_defined_types: struct environ { struct environ_entry *rbh_root; }

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

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

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

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

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

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

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

user_defined_types: struct tty_keys { struct tty_key *rbh_root; }

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

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

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

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

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

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

user_defined_types: struct mode_key_tree { struct mode_key_binding *sph_root; }

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

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

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

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

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

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

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

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

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

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

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

user_defined_types: struct options_tree { struct options_entry *sph_root; }

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

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

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

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

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

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

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

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


decompiled_code:
__int64 __fastcall client_connect(char *name, int a2)
{
int v2; // er12
unsigned int v3; // ebx
int v4; // eax
int v5; // eax
unsigned int v6; // eax
_BYTE v8[104]; // [rsp+0h] [rbp-98h] BYREF
int v9; // [rsp+68h] [rbp-30h]
__int16 v10; // [rsp+6Ch] [rbp-2Ch]

memset(v8, 0, sizeof(v8));
v9 = 0;
v10 = 0;
*(_WORD *)v8 = 1;
if ( (unsigned __int64)strlcpy(&v8[2], name, 108LL) > 0x6B )
{
*_errno_location() = 36;
return (unsigned int)-1;
}
v3 = socket(1, 1, 0);
if ( v3 == -1 )
{
log_fatal("%s: %s", "client_connect", "socket failed");
LABEL_14:
log_fatal("%s: %s", "client_connect", "fcntl failed");
goto LABEL_15;
}
v4 = strlen(&v8[2]);
v2 = connect(v3, (const struct sockaddr *)v8, v4 + 2);
if ( v2 == -1 )
{
if ( !a2 )
goto LABEL_16;
v5 = *_errno_location();
if ( v5 != 2 && (v5 != 111 || unlink(name)) )
goto LABEL_16;
v3 = server_start();
if ( v3 == -1 )
goto LABEL_16;
}
v6 = fcntl(v3, 3);
if ( v6 == -1 )
goto LABEL_14;
BYTE1(v6) |= 8u;
if ( fcntl(v3, 4, v6) == -1 )
{
LABEL_15:
log_fatal("%s: %s", "client_connect", "fcntl failed");
LABEL_16:
close(v3);
v3 = v2;
}
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func0(char *name, int a2)
{
int v2; // er12
unsigned int v3; // ebx
int v4; // eax
int v5; // eax
unsigned int v6; // eax
_BYTE v8[104]; // [rsp+0h] [rbp-98h] BYREF
int v9; // [rsp+68h] [rbp-30h]
__int16 v10; // [rsp+6Ch] [rbp-2Ch]

memset(v8, 0, sizeof(v8));
v9 = 0;
v10 = 0;
*(_WORD *)v8 = 1;
if ( (unsigned __int64)strlcpy(&v8[2], name, 108LL) > 0x6B )
{
*_errno_location() = 36;
return (unsigned int)-1;
}
v3 = socket(1, 1, 0);
if ( v3 == -1 )
{
log_fatal("%s: %s", "client_connect", "socket failed");
LABEL_14:
log_fatal("%s: %s", "client_connect", "fcntl failed");
goto LABEL_15;
}
v4 = strlen(&v8[2]);
v2 = connect(v3, (const struct sockaddr *)v8, v4 + 2);
if ( v2 == -1 )
{
if ( !a2 )
goto LABEL_16;
v5 = *_errno_location();
if ( v5 != 2 && (v5 != 111 || unlink(name)) )
goto LABEL_16;
v3 = server_start();
if ( v3 == -1 )
goto LABEL_16;
}
v6 = fcntl(v3, 3);
if ( v6 == -1 )
goto LABEL_14;
BYTE1(v6) |= 8u;
if ( fcntl(v3, 4, v6) == -1 )
{
LABEL_15:
log_fatal("%s: %s", "client_connect", "fcntl failed");
LABEL_16:
close(v3);
v3 = v2;
}
return v3;
}

original_code:
int
client_connect(char *path, int start_server)
{
 struct sockaddr_un sa;
 size_t size;
 int fd, mode;
 memset(&sa, 0, sizeof sa);
 sa.sun_family = 1;
 size = strlcpy(sa.sun_path, path, sizeof sa.sun_path);
 if (size >= sizeof sa.sun_path) {
  (*__errno_location ()) = 36;
  return (-1);
 }
 if ((fd = socket(1, SOCK_STREAM, 0)) == -1)
  log_fatal("%s: %s", __func__, "socket failed");;
 if (connect(fd, (struct sockaddr *) &sa, ((size_t) (((struct sockaddr_un *) 0)->sun_path) + strlen ((&sa)->sun_path))) == -1) {
  if (!start_server)
   goto failed;
  switch ((*__errno_location ())) {
  case 111:
   if (unlink(path) != 0)
    goto failed;
  case 2:
   if ((fd = server_start()) == -1)
    goto failed;
   break;
  default:
   goto failed;
  }
 }
 if ((mode = fcntl(fd, 3)) == -1)
  log_fatal("%s: %s", __func__, "fcntl failed");;
 if (fcntl(fd, 4, mode|04000) == -1)
  log_fatal("%s: %s", __func__, "fcntl failed");;
 return (fd);
failed:
 close(fd);
 return (-1);
}

canonical_original_code:
int client_connect(char *path, int start_server)
{
 struct sockaddr_un sa;
 unsigned long size;
 int fd; int mode;
 memset(&sa, 0, sizeof sa);
 sa.sun_family = 1;
 size = strlcpy(sa.sun_path, path, sizeof sa.sun_path);
 if (size >= sizeof sa.sun_path) {
  (*__errno_location ()) = 36;
  return (-1);
 }
 if ((fd = socket(1, SOCK_STREAM, 0)) == -1)
  log_fatal("%s: %s", __func__, "socket failed");;
 if (connect(fd, (struct sockaddr *) &sa, ((unsigned long) (((struct sockaddr_un *) 0)->sun_path) + strlen ((&sa)->sun_path))) == -1) {
  if (!start_server)
   goto failed;
  switch ((*__errno_location ())) {
  case 111:
   if (unlink(path) != 0)
    goto failed;
  case 2:
   if ((fd = server_start()) == -1)
    goto failed;
   break;
  default:
   goto failed;
  }
 }
 if ((mode = fcntl(fd, 3)) == -1)
  log_fatal("%s: %s", __func__, "fcntl failed");;
 if (fcntl(fd, 4, mode|04000) == -1)
  log_fatal("%s: %s", __func__, "fcntl failed");;
 return (fd);
failed:
 close(fd);
 return (-1);
}

variable_types:
path
char *

variable_types: struct sockaddr_un { unsigned short sun_family; char sun_path[108]; }

variable_types:
size
unsigned long

variable_types: fd int

variable_types: mode int

return_type: int

user_defined_types: struct sockaddr { unsigned short sa_family; char sa_data[14]; }


decompiled_code:
__int64 __fastcall client_dispatch_wait(__int64 a1)
{
__int64 v1; // rax
__int64 v2; // rax
__int64 v3; // rdx
__int64 result; // rax
char v5[4096]; // [rsp+0h] [rbp-1028h] BYREF
int v6; // [rsp+1000h] [rbp-28h] BYREF
unsigned __int16 v7; // [rsp+1004h] [rbp-24h]
unsigned int v8; // [rsp+1008h] [rbp-20h]
int *v9; // [rsp+1018h] [rbp-10h]

v1 = imsg_read(client_ibuf);
if ( v1 == -1 || v1 == 0 )
{
log_fatalx("%s: %s", "client_dispatch_wait", "imsg_read failed");
LABEL_6:
log_fatalx("%s: %s", "client_dispatch_wait", "imsg_get failed");
LABEL_7:
if ( v3 != 4 )
{
if ( !v3 )
{
LABEL_9:
imsg_free(&v6);
return 0xFFFFFFFFLL;
}
log_fatalx("%s: %s", "client_dispatch_wait", "bad MSG_EXIT size");
}
client_exitval = *v9;
goto LABEL_9;
}
while ( 2 )
{
v2 = imsg_get(client_ibuf, &v6);
if ( v2 == -1 )
goto LABEL_6;
if ( !v2 )
goto LABEL_22;
v3 = v7 - 16LL;
switch ( v6 )
{
case 3:
case 10:
goto LABEL_7;
case 8:
if ( v7 == 16LL )
{
client_attached = 1;
imsg_free(&v6);
continue;
}
log_fatalx("%s: %s", "client_dispatch_wait", "bad MSG_READY size");
LABEL_15:
if ( v3 )
{
log_fatalx("%s: %s", "client_dispatch_wait", "bad MSG_VERSION size");
LABEL_18:
if ( v3 != 4096 )
log_fatalx("%s: %s", "client_dispatch_wait", "bad MSG_SHELL size");
qmemcpy(v5, v9, sizeof(v5));
v5[4095] = 0;
clear_signals(0LL);
shell_exec(v5, a1);
LABEL_21:
log_fatalx("%s: %s", "client_dispatch_wait", "unexpected message");
LABEL_22:
result = 0LL;
}
else
{
log_warnx("protocol version mismatch (client %u, server %u)", 6LL, v8);
client_exitval = 1;
imsg_free(&v6);
result = 0xFFFFFFFFLL;
}
return result;
case 12:
goto LABEL_15;
case 17:
goto LABEL_18;
default:
goto LABEL_21;
}
}
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1)
{
__int64 v1; // rax
__int64 v2; // rax
__int64 v3; // rdx
__int64 result; // rax
char v5[4096]; // [rsp+0h] [rbp-1028h] BYREF
int v6; // [rsp+1000h] [rbp-28h] BYREF
unsigned __int16 v7; // [rsp+1004h] [rbp-24h]
unsigned int v8; // [rsp+1008h] [rbp-20h]
int *v9; // [rsp+1018h] [rbp-10h]

v1 = imsg_read(client_ibuf);
if ( v1 == -1 || v1 == 0 )
{
log_fatalx("%s: %s", "client_dispatch_wait", "imsg_read failed");
LABEL_6:
log_fatalx("%s: %s", "client_dispatch_wait", "imsg_get failed");
LABEL_7:
if ( v3 != 4 )
{
if ( !v3 )
{
LABEL_9:
imsg_free(&v6);
return 0xFFFFFFFFLL;
}
log_fatalx("%s: %s", "client_dispatch_wait", "bad MSG_EXIT size");
}
client_exitval = *v9;
goto LABEL_9;
}
while ( 2 )
{
v2 = imsg_get(client_ibuf, &v6);
if ( v2 == -1 )
goto LABEL_6;
if ( !v2 )
goto LABEL_22;
v3 = v7 - 16LL;
switch ( v6 )
{
case 3:
case 10:
goto LABEL_7;
case 8:
if ( v7 == 16LL )
{
client_attached = 1;
imsg_free(&v6);
continue;
}
log_fatalx("%s: %s", "client_dispatch_wait", "bad MSG_READY size");
LABEL_15:
if ( v3 )
{
log_fatalx("%s: %s", "client_dispatch_wait", "bad MSG_VERSION size");
LABEL_18:
if ( v3 != 4096 )
log_fatalx("%s: %s", "client_dispatch_wait", "bad MSG_SHELL size");
qmemcpy(v5, v9, sizeof(v5));
v5[4095] = 0;
clear_signals(0LL);
shell_exec(v5, a1);
LABEL_21:
log_fatalx("%s: %s", "client_dispatch_wait", "unexpected message");
LABEL_22:
result = 0LL;
}
else
{
log_warnx("protocol version mismatch (client %u, server %u)", 6LL, v8);
client_exitval = 1;
imsg_free(&v6);
result = 0xFFFFFFFFLL;
}
return result;
case 12:
goto LABEL_15;
case 17:
goto LABEL_18;
default:
goto LABEL_21;
}
}
}

original_code:
int
client_dispatch_wait(void *data)
{
 struct imsg imsg;
 ssize_t n, datalen;
 struct msg_shell_data shelldata;
 struct msg_exit_data exitdata;
 const char *shellcmd = data;
 if ((n = imsg_read(&client_ibuf)) == -1 || n == 0)
  log_fatalx("%s: %s", __func__, "imsg_read failed");;
 for (;;) {
  if ((n = imsg_get(&client_ibuf, &imsg)) == -1)
   log_fatalx("%s: %s", __func__, "imsg_get failed");;
  if (n == 0)
   return (0);
  datalen = imsg.hdr.len - sizeof(struct imsg_hdr);
  switch (imsg.hdr.type) {
  case MSG_EXIT:
  case MSG_SHUTDOWN:
   if (datalen != sizeof exitdata) {
    if (datalen != 0)
     log_fatalx("%s: %s", __func__, "bad MSG_EXIT size");;
   } else {
    memcpy(&exitdata, imsg.data, sizeof exitdata);
    client_exitval = exitdata.retcode;
   }
   imsg_free(&imsg);
   return (-1);
  case MSG_READY:
   if (datalen != 0)
    log_fatalx("%s: %s", __func__, "bad MSG_READY size");;
   client_attached = 1;
   break;
  case MSG_VERSION:
   if (datalen != 0)
    log_fatalx("%s: %s", __func__, "bad MSG_VERSION size");;
   log_warnx("protocol version mismatch (client %u, "
       "server %u)", 6, imsg.hdr.peerid);
   client_exitval = 1;
   imsg_free(&imsg);
   return (-1);
  case MSG_SHELL:
   if (datalen != sizeof shelldata)
    log_fatalx("%s: %s", __func__, "bad MSG_SHELL size");;
   memcpy(&shelldata, imsg.data, sizeof shelldata);
   shelldata.shell[(sizeof shelldata.shell) - 1] = '\0';
   clear_signals(0);
   shell_exec(shelldata.shell, shellcmd);
  default:
   log_fatalx("%s: %s", __func__, "unexpected message");;
  }
  imsg_free(&imsg);
 }
}

canonical_original_code:
int client_dispatch_wait(void *data)
{
 struct imsg imsg;
 long n; long datalen;
 struct msg_shell_data shelldata;
 struct msg_exit_data exitdata;
 char *shellcmd = data;
 if ((n = imsg_read(&client_ibuf)) == -1 || n == 0)
  log_fatalx("%s: %s", __func__, "imsg_read failed");;
 for (;;) {
  if ((n = imsg_get(&client_ibuf, &imsg)) == -1)
   log_fatalx("%s: %s", __func__, "imsg_get failed");;
  if (n == 0)
   return (0);
  datalen = imsg.hdr.len - sizeof(struct imsg_hdr);
  switch (imsg.hdr.type) {
  case MSG_EXIT:
  case MSG_SHUTDOWN:
   if (datalen != sizeof exitdata) {
    if (datalen != 0)
     log_fatalx("%s: %s", __func__, "bad MSG_EXIT size");;
   } else {
    memcpy(&exitdata, imsg.data, sizeof exitdata);
    client_exitval = exitdata.retcode;
   }
   imsg_free(&imsg);
   return (-1);
  case MSG_READY:
   if (datalen != 0)
    log_fatalx("%s: %s", __func__, "bad MSG_READY size");;
   client_attached = 1;
   break;
  case MSG_VERSION:
   if (datalen != 0)
    log_fatalx("%s: %s", __func__, "bad MSG_VERSION size");;
   log_warnx("protocol version mismatch (client %u, "
       "server %u)", 6, imsg.hdr.peerid);
   client_exitval = 1;
   imsg_free(&imsg);
   return (-1);
  case MSG_SHELL:
   if (datalen != sizeof shelldata)
    log_fatalx("%s: %s", __func__, "bad MSG_SHELL size");;
   memcpy(&shelldata, imsg.data, sizeof shelldata);
   shelldata.shell[(sizeof shelldata.shell) - 1] = '\0';
   clear_signals(0);
   shell_exec(shelldata.shell, shellcmd);
  default:
   log_fatalx("%s: %s", __func__, "unexpected message");;
  }
  imsg_free(&imsg);
 }
}

variable_types:
data
void *

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

variable_types: n long

variable_types: datalen long

variable_types: struct msg_shell_data { char shell[4096]; }

variable_types:
exitdata
struct msg_exit_data { int retcode; }

variable_types:
shellcmd
char *

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


decompiled_code:
__int64 __fastcall client_dispatch_attached()
{
struct sigaction *v0; // rbx
int v1; // ebp
__int64 v2; // rax
__pid_t v4; // eax
struct sigaction v5; // [rsp+0h] [rbp-8D8h] BYREF
char command[2048]; // [rsp+A0h] [rbp-838h] BYREF
unsigned int v7; // [rsp+8A0h] [rbp-38h] BYREF
unsigned __int16 v8; // [rsp+8A4h] [rbp-34h]
const void *v9; // [rsp+8B8h] [rbp-20h]

while ( 1 )
{
v2 = imsg_get(client_ibuf, &v7);
if ( v2 != -1 )
break;
log_fatalx("%s: %s", "client_dispatch_attached", "imsg_get failed");
LABEL_3:
if ( !v0 )
{
client_write_server(5u, 0LL, 0);
client_exitmsg = (__int64)"detached";
goto LABEL_5;
}
log_fatalx("%s: %s", "client_dispatch_attached", "bad MSG_DETACH size");
LABEL_10:
v1 &= 0xFFFFFFFB;
if ( (_WORD)v1 == 16 )
{
client_write_server(5u, 0LL, 0);
client_exitmsg = (__int64)"exited";
goto LABEL_5;
}
log_fatalx("%s: %s", "client_dispatch_attached", "bad MSG_EXIT size");
LABEL_13:
if ( !v0 )
{
imsg_free(&v7);
return 0xFFFFFFFFLL;
}
log_fatalx("%s: %s", "client_dispatch_attached", "bad MSG_EXITED size");
LABEL_16:
if ( !v0 )
{
client_write_server(5u, 0LL, 0);
client_exitmsg = (__int64)"server exited";
client_exitval = 1;
goto LABEL_5;
}
log_fatalx("%s: %s", "client_dispatch_attached", "bad MSG_SHUTDOWN size");
LABEL_19:
if ( v0 )
{
log_fatalx("%s: %s", "client_dispatch_attached", "bad MSG_SUSPEND size");
}
else
{
v0 = &v5;
memset(&v5, 0, sizeof(v5));
sigemptyset(&v5.sa_mask);
v5.sa_flags = 0x10000000;
v5.sa_handler = 0LL;
if ( !sigaction(20, &v5, 0LL) )
{
v4 = getpid();
kill(v4, 20);
goto LABEL_5;
}
}
log_fatal("%s: %s", "client_dispatch_attached", "sigaction failed");
LABEL_24:
if ( v0 != (struct sigaction *)((char *)&loc_7FF + 1) )
{
log_fatalx("%s: %s", "client_dispatch_attached", "bad MSG_LOCK size");
LABEL_27:
log_fatalx("%s: %s", "client_dispatch_attached", "unexpected message");
return 0LL;
}
qmemcpy(command, v9, sizeof(command));
command[2047] = 0;
system(command);
client_write_server(0xFu, 0LL, 0);
LABEL_5:
imsg_free(&v7);
}
if ( v2 )
{
v1 = v8;
v0 = (struct sigaction *)(v8 - 16LL);
log_debug("client got %d", v7);
switch ( v7 )
{
case 1u:
goto LABEL_3;
case 3u:
goto LABEL_10;
case 4u:
goto LABEL_13;
case 0xAu:
goto LABEL_16;
case 0xBu:
goto LABEL_19;
case 0x10u:
goto LABEL_24;
default:
goto LABEL_27;
}
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func8()
{
struct sigaction *v0; // rbx
int v1; // ebp
__int64 v2; // rax
__pid_t v4; // eax
struct sigaction v5; // [rsp+0h] [rbp-8D8h] BYREF
char command[2048]; // [rsp+A0h] [rbp-838h] BYREF
unsigned int v7; // [rsp+8A0h] [rbp-38h] BYREF
unsigned __int16 v8; // [rsp+8A4h] [rbp-34h]
const void *v9; // [rsp+8B8h] [rbp-20h]

while ( 1 )
{
v2 = imsg_get(client_ibuf, &v7);
if ( v2 != -1 )
break;
log_fatalx("%s: %s", "client_dispatch_attached", "imsg_get failed");
LABEL_3:
if ( !v0 )
{
func2(5u, 0LL, 0);
client_exitmsg = (__int64)"detached";
goto LABEL_5;
}
log_fatalx("%s: %s", "client_dispatch_attached", "bad MSG_DETACH size");
LABEL_10:
v1 &= 0xFFFFFFFB;
if ( (_WORD)v1 == 16 )
{
func2(5u, 0LL, 0);
client_exitmsg = (__int64)"exited";
goto LABEL_5;
}
log_fatalx("%s: %s", "client_dispatch_attached", "bad MSG_EXIT size");
LABEL_13:
if ( !v0 )
{
imsg_free(&v7);
return 0xFFFFFFFFLL;
}
log_fatalx("%s: %s", "client_dispatch_attached", "bad MSG_EXITED size");
LABEL_16:
if ( !v0 )
{
func2(5u, 0LL, 0);
client_exitmsg = (__int64)"server exited";
client_exitval = 1;
goto LABEL_5;
}
log_fatalx("%s: %s", "client_dispatch_attached", "bad MSG_SHUTDOWN size");
LABEL_19:
if ( v0 )
{
log_fatalx("%s: %s", "client_dispatch_attached", "bad MSG_SUSPEND size");
}
else
{
v0 = &v5;
memset(&v5, 0, sizeof(v5));
sigemptyset(&v5.sa_mask);
v5.sa_flags = 0x10000000;
v5.sa_handler = 0LL;
if ( !sigaction(20, &v5, 0LL) )
{
v4 = getpid();
kill(v4, 20);
goto LABEL_5;
}
}
log_fatal("%s: %s", "client_dispatch_attached", "sigaction failed");
LABEL_24:
if ( v0 != (struct sigaction *)((char *)&loc_7FF + 1) )
{
log_fatalx("%s: %s", "client_dispatch_attached", "bad MSG_LOCK size");
LABEL_27:
log_fatalx("%s: %s", "client_dispatch_attached", "unexpected message");
return 0LL;
}
qmemcpy(command, v9, sizeof(command));
command[2047] = 0;
system(command);
func2(0xFu, 0LL, 0);
LABEL_5:
imsg_free(&v7);
}
if ( v2 )
{
v1 = v8;
v0 = (struct sigaction *)(v8 - 16LL);
log_debug("client got %d", v7);
switch ( v7 )
{
case 1u:
goto LABEL_3;
case 3u:
goto LABEL_10;
case 4u:
goto LABEL_13;
case 0xAu:
goto LABEL_16;
case 0xBu:
goto LABEL_19;
case 0x10u:
goto LABEL_24;
default:
goto LABEL_27;
}
}
return 0LL;
}

original_code:
int
client_dispatch_attached(void)
{
 struct imsg imsg;
 struct msg_lock_data lockdata;
 struct sigaction sigact;
 ssize_t n, datalen;
 for (;;) {
  if ((n = imsg_get(&client_ibuf, &imsg)) == -1)
   log_fatalx("%s: %s", __func__, "imsg_get failed");;
  if (n == 0)
   return (0);
  datalen = imsg.hdr.len - sizeof(struct imsg_hdr);
  log_debug("client got %d", imsg.hdr.type);
  switch (imsg.hdr.type) {
  case MSG_DETACH:
   if (datalen != 0)
    log_fatalx("%s: %s", __func__, "bad MSG_DETACH size");;
   client_write_server(MSG_EXITING, ((void *)0), 0);
   client_exitmsg = "detached";
   break;
  case MSG_EXIT:
   if (datalen != 0 &&
       datalen != sizeof (struct msg_exit_data))
    log_fatalx("%s: %s", __func__, "bad MSG_EXIT size");;
   client_write_server(MSG_EXITING, ((void *)0), 0);
   client_exitmsg = "exited";
   break;
  case MSG_EXITED:
   if (datalen != 0)
    log_fatalx("%s: %s", __func__, "bad MSG_EXITED size");;
   imsg_free(&imsg);
   return (-1);
  case MSG_SHUTDOWN:
   if (datalen != 0)
    log_fatalx("%s: %s", __func__, "bad MSG_SHUTDOWN size");;
   client_write_server(MSG_EXITING, ((void *)0), 0);
   client_exitmsg = "server exited";
   client_exitval = 1;
   break;
  case MSG_SUSPEND:
   if (datalen != 0)
    log_fatalx("%s: %s", __func__, "bad MSG_SUSPEND size");;
   memset(&sigact, 0, sizeof sigact);
   sigemptyset(&sigact.sa_mask);
   sigact.sa_flags = 0x10000000;
   sigact.__sigaction_handler.sa_handler = ((__sighandler_t) 0);
   if (sigaction(20, &sigact, ((void *)0)) != 0)
    log_fatal("%s: %s", __func__, "sigaction failed");;
   kill(getpid(), 20);
   break;
  case MSG_LOCK:
   if (datalen != sizeof lockdata)
    log_fatalx("%s: %s", __func__, "bad MSG_LOCK size");;
   memcpy(&lockdata, imsg.data, sizeof lockdata);
   lockdata.cmd[(sizeof lockdata.cmd) - 1] = '\0';
   system(lockdata.cmd);
   client_write_server(MSG_UNLOCK, ((void *)0), 0);
   break;
  default:
   log_fatalx("%s: %s", __func__, "unexpected message");;
  }
  imsg_free(&imsg);
 }
}

canonical_original_code:
int client_dispatch_attached()
{
 struct imsg imsg;
 struct msg_lock_data lockdata;
 struct sigaction sigact;
 long n; long datalen;
 for (;;) {
  if ((n = imsg_get(&client_ibuf, &imsg)) == -1)
   log_fatalx("%s: %s", __func__, "imsg_get failed");;
  if (n == 0)
   return (0);
  datalen = imsg.hdr.len - sizeof(struct imsg_hdr);
  log_debug("client got %d", imsg.hdr.type);
  switch (imsg.hdr.type) {
  case MSG_DETACH:
   if (datalen != 0)
    log_fatalx("%s: %s", __func__, "bad MSG_DETACH size");;
   client_write_server(MSG_EXITING, ((void *)0), 0);
   client_exitmsg = "detached";
   break;
  case MSG_EXIT:
   if (datalen != 0 &&
       datalen != sizeof (struct msg_exit_data))
    log_fatalx("%s: %s", __func__, "bad MSG_EXIT size");;
   client_write_server(MSG_EXITING, ((void *)0), 0);
   client_exitmsg = "exited";
   break;
  case MSG_EXITED:
   if (datalen != 0)
    log_fatalx("%s: %s", __func__, "bad MSG_EXITED size");;
   imsg_free(&imsg);
   return (-1);
  case MSG_SHUTDOWN:
   if (datalen != 0)
    log_fatalx("%s: %s", __func__, "bad MSG_SHUTDOWN size");;
   client_write_server(MSG_EXITING, ((void *)0), 0);
   client_exitmsg = "server exited";
   client_exitval = 1;
   break;
  case MSG_SUSPEND:
   if (datalen != 0)
    log_fatalx("%s: %s", __func__, "bad MSG_SUSPEND size");;
   memset(&sigact, 0, sizeof sigact);
   sigemptyset(&sigact.sa_mask);
   sigact.sa_flags = 0x10000000;
   sigact.__sigaction_handler.sa_handler = ((void (*)(int)) 0);
   if (sigaction(20, &sigact, ((void *)0)) != 0)
    log_fatal("%s: %s", __func__, "sigaction failed");;
   kill(getpid(), 20);
   break;
  case MSG_LOCK:
   if (datalen != sizeof lockdata)
    log_fatalx("%s: %s", __func__, "bad MSG_LOCK size");;
   memcpy(&lockdata, imsg.data, sizeof lockdata);
   lockdata.cmd[(sizeof lockdata.cmd) - 1] = '\0';
   system(lockdata.cmd);
   client_write_server(MSG_UNLOCK, ((void *)0), 0);
   break;
  default:
   log_fatalx("%s: %s", __func__, "unexpected message");;
  }
  imsg_free(&imsg);
 }
}

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

variable_types: struct sigaction { union { void (*sa_handler)(int); void (*sa_sigaction)(int, struct siginfo_t { int si_signo; int si_errno; int si_code; int __pad0; union { int _pad[-1]; struct { int si_pid; unsigned int si_uid; } _kill; struct { int si_tid; int si_overrun; union sigval { int sival_int; void *sival_ptr; } si_sigval; } _timer; struct { int si_pid; unsigned int si_uid; union sigval si_sigval; } _rt; struct { int si_pid; unsigned int si_uid; int si_status; long si_utime; long si_stime; } _sigchld; struct { void *si_addr; short si_addr_lsb; union { struct { void *_lower; void *_upper; } _addr_bnd; unsigned int _pkey; } _bounds; } _sigfault; struct { long si_band; int si_fd; } _sigpoll; struct { void *_call_addr; int _syscall; unsigned int _arch; } _sigsys; } _sifields; } *, void *); } __sigaction_handler; struct __sigset_t { unsigned long __val[-1]; } sa_mask; int sa_flags; void (*sa_restorer)(); }

user_defined_types: struct sigaction { union { void (*sa_handler)(int); void (*sa_sigaction)(int, struct siginfo_t *, void *); } __sigaction_handler; struct __sigset_t sa_mask; int sa_flags; void (*sa_restorer)(); }

user_defined_types: struct imsg_hdr { unsigned int type; unsigned int len; unsigned int flags; unsigned int peerid; unsigned int pid; }

user_defined_types: struct siginfo_t { int si_signo; int si_errno; int si_code; int __pad0; union { int _pad[-1]; struct { int si_pid; unsigned int si_uid; } _kill; struct { int si_tid; int si_overrun; union sigval si_sigval; } _timer; struct { int si_pid; unsigned int si_uid; union sigval si_sigval; } _rt; struct { int si_pid; unsigned int si_uid; int si_status; long si_utime; long si_stime; } _sigchld; struct { void *si_addr; short si_addr_lsb; union { struct { void *_lower; void *_upper; } _addr_bnd; unsigned int _pkey; } _bounds; } _sigfault; struct { long si_band; int si_fd; } _sigpoll; struct { void *_call_addr; int _syscall; unsigned int _arch; } _sigsys; } _sifields; }


decompiled_code:
__int64 __fastcall client_send_identify(int a1)
{
char *v1; // rax
unsigned int v2; // eax
unsigned int v3; // eax
unsigned int v4; // eax
char v6[4096]; // [rsp+0h] [rbp-1098h] BYREF
char v7[128]; // [rsp+1000h] [rbp-98h] BYREF
int v8; // [rsp+1080h] [rbp-18h]

v8 = a1;
if ( !getcwd(v6, 0x1000uLL) )
v6[0] = 0;
v1 = getenv("TERM");
if ( !v1 || (unsigned __int64)strlcpy(v7, v1, 128LL) > 0x7F )
v7[0] = 0;
v2 = dup(0);
if ( v2 == -1 )
{
log_fatal("%s: %s", "client_send_identify", "dup failed");
goto LABEL_11;
}
imsg_compose(&client_ibuf, 6LL, 6LL, 0xFFFFFFFFLL, v2, v6, 4228LL);
v3 = dup(1);
if ( v3 == -1 )
{
LABEL_11:
log_fatal("%s: %s", "client_send_identify", "dup failed");
goto LABEL_12;
}
imsg_compose(&client_ibuf, 19LL, 6LL, 0xFFFFFFFFLL, v3, 0LL, 0LL);
v4 = dup(2);
if ( v4 != -1 )
return imsg_compose(&client_ibuf, 18LL, 6LL, 0xFFFFFFFFLL, v4, 0LL, 0LL);
LABEL_12:
log_fatal("%s: %s", "client_send_identify", "dup failed");
return client_write_server();
}

canonical_decompiled_code:
__int64 __fastcall func1(int a1)
{
char *v1; // rax
unsigned int v2; // eax
unsigned int v3; // eax
unsigned int v4; // eax
char v6[4096]; // [rsp+0h] [rbp-1098h] BYREF
char v7[128]; // [rsp+1000h] [rbp-98h] BYREF
int v8; // [rsp+1080h] [rbp-18h]

v8 = a1;
if ( !getcwd(v6, 0x1000uLL) )
v6[0] = 0;
v1 = getenv("TERM");
if ( !v1 || (unsigned __int64)strlcpy(v7, v1, 128LL) > 0x7F )
v7[0] = 0;
v2 = dup(0);
if ( v2 == -1 )
{
log_fatal("%s: %s", "client_send_identify", "dup failed");
goto LABEL_11;
}
imsg_compose(&client_ibuf, 6LL, 6LL, 0xFFFFFFFFLL, v2, v6, 4228LL);
v3 = dup(1);
if ( v3 == -1 )
{
LABEL_11:
log_fatal("%s: %s", "client_send_identify", "dup failed");
goto LABEL_12;
}
imsg_compose(&client_ibuf, 19LL, 6LL, 0xFFFFFFFFLL, v3, 0LL, 0LL);
v4 = dup(2);
if ( v4 != -1 )
return imsg_compose(&client_ibuf, 18LL, 6LL, 0xFFFFFFFFLL, v4, 0LL, 0LL);
LABEL_12:
log_fatal("%s: %s", "client_send_identify", "dup failed");
return func2();
}

original_code:
void
client_send_identify(int flags)
{
 struct msg_identify_data data;
 char *term;
 int fd;
 data.flags = flags;
 if (getcwd(data.cwd, sizeof data.cwd) == ((void *)0))
  *data.cwd = '\0';
 term = getenv("TERM");
 if (term == ((void *)0) ||
     strlcpy(data.term, term, sizeof data.term) >= sizeof data.term)
  *data.term = '\0';
 if ((fd = dup(0)) == -1)
  log_fatal("%s: %s", __func__, "dup failed");;
 imsg_compose(&client_ibuf,
     MSG_IDENTIFY, 6, -1, fd, &data, sizeof data);
 if ((fd = dup(1)) == -1)
  log_fatal("%s: %s", __func__, "dup failed");;
 imsg_compose(&client_ibuf,
     MSG_STDOUT, 6, -1, fd, ((void *)0), 0);
 if ((fd = dup(2)) == -1)
  log_fatal("%s: %s", __func__, "dup failed");;
 imsg_compose(&client_ibuf,
     MSG_STDERR, 6, -1, fd, ((void *)0), 0);
}

variable_types: flags int

variable_types: struct msg_identify_data { char cwd[4096]; char term[128]; int flags; }

variable_types:
term
char *


decompiled_code:
__int64 __fastcall client_write_server(unsigned int a1, __int64 a2, unsigned __int16 a3)
{
return imsg_compose(&client_ibuf, a1, 6LL, 0xFFFFFFFFLL, 0xFFFFFFFFLL, a2, a3);
}

canonical_decompiled_code:
__int64 __fastcall func2(unsigned int a1, __int64 a2, unsigned __int16 a3)
{
return imsg_compose(&client_ibuf, a1, 6LL, 0xFFFFFFFFLL, 0xFFFFFFFFLL, a2, a3);
}

original_code:
void
client_write_server(enum msgtype type, void *buf, size_t len)
{
 imsg_compose(&client_ibuf, type, 6, -1, -1, buf, len);
}

canonical_original_code:
void client_write_server(enum msgtype type, void *buf, unsigned long len)
{
 imsg_compose(&client_ibuf, type, 6, -1, -1, buf, len);
}

variable_types: enum msgtype { MSG_COMMAND=0, MSG_DETACH=1, MSG_ERROR=2, MSG_EXIT=3, MSG_EXITED=4, MSG_EXITING=5, MSG_IDENTIFY=6, MSG_PRINT=7, MSG_READY=8, MSG_RESIZE=9, MSG_SHUTDOWN=10, MSG_SUSPEND=11, MSG_VERSION=12, MSG_WAKEUP=13, MSG_ENVIRON=14, MSG_UNLOCK=15, MSG_LOCK=16, MSG_SHELL=17, MSG_STDERR=18, MSG_STDOUT=19 }

variable_types:
buf
void *

variable_types:
len
unsigned long


decompiled_code:
void client_send_environ()
{
char **v0; // rbx
char *i; // rsi
_BYTE v2[1032]; // [rsp+0h] [rbp-408h] BYREF

v0 = environ;
for ( i = *environ; *v0; i = *v0 )
{
if ( (unsigned __int64)strlcpy(v2, i, 1024LL) <= 0x3FF )
client_write_server(0xEu, (__int64)v2, 0x400u);
++v0;
}
}

canonical_decompiled_code:
void func3()
{
char **v0; // rbx
char *i; // rsi
_BYTE v2[1032]; // [rsp+0h] [rbp-408h] BYREF

v0 = environ;
for ( i = *environ; *v0; i = *v0 )
{
if ( (unsigned __int64)strlcpy(v2, i, 1024LL) <= 0x3FF )
func2(0xEu, (__int64)v2, 0x400u);
++v0;
}
}

original_code:
void
client_send_environ(void)
{
 struct msg_environ_data data;
 char **var;
 for (var = environ; *var != ((void *)0); var++) {
  if (strlcpy(data.var, *var, sizeof data.var) >= sizeof data.var)
   continue;
  client_write_server(MSG_ENVIRON, &data, sizeof data);
 }
}

canonical_original_code:
void client_send_environ()
{
 struct msg_environ_data data;
 char **var;
 for (var = environ; *var != ((void *)0); var++) {
  if (strlcpy(data.var, *var, sizeof data.var) >= sizeof data.var)
   continue;
  client_write_server(MSG_ENVIRON, &data, sizeof data);
 }
}

variable_types: struct msg_environ_data { char var[1024]; }

variable_types:
var
char **


decompiled_code:
__int64 client_update_event()
{
event_del(&client_event);
event_set(
&client_event,
client_ibuf[16398],
(unsigned int)(__int16)(client_ibuf[16396] == 0 ? 2 : 6),
client_callback,
shell_cmd);
return event_add(&client_event, 0LL);
}

canonical_decompiled_code:
__int64 func4()
{
event_del(&client_event);
event_set(
&client_event,
client_ibuf[16398],
(unsigned int)(__int16)(client_ibuf[16396] == 0 ? 2 : 6),
client_callback,
shell_cmd);
return event_add(&client_event, 0LL);
}

original_code:
void
client_update_event(void)
{
 short events;
 event_del(&client_event);
 events = 0x02;
 if (client_ibuf.w.queued > 0)
  events |= 0x04;
 event_set(
     &client_event, client_ibuf.fd, events, client_callback, shell_cmd);
 event_add(&client_event, ((void *)0));
}

canonical_original_code:
void client_update_event()
{
 short events;
 event_del(&client_event);
 events = 0x02;
 if (client_ibuf.w.queued > 0)
  events |= 0x04;
 event_set(
     &client_event, client_ibuf.fd, events, client_callback, shell_cmd);
 event_add(&client_event, ((void *)0));
}

variable_types: events short


decompiled_code:
__int64 __fastcall client_signal(int a1)
{
int stat_loc; // [rsp+Ch] [rbp-ACh] BYREF
struct sigaction v3; // [rsp+10h] [rbp-A8h] BYREF

if ( !client_attached )
{
if ( a1 == 15 )
{
event_loopexit(0LL);
}
else if ( a1 == 17 )
{
waitpid(-1, &stat_loc, 1);
}
return client_update_event();
}
if ( a1 != 18 )
{
if ( a1 > 18 )
{
if ( a1 == 28 )
client_write_server(9u, 0LL, 0);
}
else if ( a1 == 1 )
{
client_exitmsg = (__int64)"lost tty";
client_exitval = 1;
client_write_server(5u, 0LL, 0);
}
else if ( a1 == 15 )
{
client_exitmsg = (__int64)"terminated";
client_exitval = 1;
client_write_server(5u, 0LL, 0);
}
return client_update_event();
}
memset(&v3, 0, sizeof(v3));
sigemptyset(&v3.sa_mask);
v3.sa_flags = 0x10000000;
v3.sa_handler = (__sighandler_t)(client_connect + 1);
if ( !sigaction(20, &v3, 0LL) )
{
client_write_server(0xDu, 0LL, 0);
return client_update_event();
}
log_fatal("%s: %s", "client_signal", "sigaction failed");
return client_dispatch_wait();
}

canonical_decompiled_code:
__int64 __fastcall func6(int a1)
{
int stat_loc; // [rsp+Ch] [rbp-ACh] BYREF
struct sigaction v3; // [rsp+10h] [rbp-A8h] BYREF

if ( !client_attached )
{
if ( a1 == 15 )
{
event_loopexit(0LL);
}
else if ( a1 == 17 )
{
waitpid(-1, &stat_loc, 1);
}
return func4();
}
if ( a1 != 18 )
{
if ( a1 > 18 )
{
if ( a1 == 28 )
func2(9u, 0LL, 0);
}
else if ( a1 == 1 )
{
client_exitmsg = (__int64)"lost tty";
client_exitval = 1;
func2(5u, 0LL, 0);
}
else if ( a1 == 15 )
{
client_exitmsg = (__int64)"terminated";
client_exitval = 1;
func2(5u, 0LL, 0);
}
return func4();
}
memset(&v3, 0, sizeof(v3));
sigemptyset(&v3.sa_mask);
v3.sa_flags = 0x10000000;
v3.sa_handler = (__sighandler_t)(client_connect + 1);
if ( !sigaction(20, &v3, 0LL) )
{
func2(0xDu, 0LL, 0);
return func4();
}
log_fatal("%s: %s", "client_signal", "sigaction failed");
return func7();
}

original_code:
void
client_signal(int sig, __attribute__ ((unused)) short events, __attribute__ ((unused)) void *data)
{
 struct sigaction sigact;
 int status;
 if (!client_attached) {
  switch (sig) {
  case 17:
   waitpid((-1), &status, 1);
   break;
  case 15:
   event_loopexit(((void *)0));
   break;
  }
 } else {
  switch (sig) {
  case 1:
   client_exitmsg = "lost tty";
   client_exitval = 1;
   client_write_server(MSG_EXITING, ((void *)0), 0);
   break;
  case 15:
   client_exitmsg = "terminated";
   client_exitval = 1;
   client_write_server(MSG_EXITING, ((void *)0), 0);
   break;
  case 28:
   client_write_server(MSG_RESIZE, ((void *)0), 0);
   break;
  case 18:
   memset(&sigact, 0, sizeof sigact);
   sigemptyset(&sigact.sa_mask);
   sigact.sa_flags = 0x10000000;
   sigact.__sigaction_handler.sa_handler = ((__sighandler_t) 1);
   if (sigaction(20, &sigact, ((void *)0)) != 0)
    log_fatal("%s: %s", __func__, "sigaction failed");;
   client_write_server(MSG_WAKEUP, ((void *)0), 0);
   break;
  }
 }
 client_update_event();
}

canonical_original_code:
void client_signal(int sig, short events, void *data)
{
 struct sigaction sigact;
 int status;
 if (!client_attached) {
  switch (sig) {
  case 17:
   waitpid((-1), &status, 1);
   break;
  case 15:
   event_loopexit(((void *)0));
   break;
  }
 } else {
  switch (sig) {
  case 1:
   client_exitmsg = "lost tty";
   client_exitval = 1;
   client_write_server(MSG_EXITING, ((void *)0), 0);
   break;
  case 15:
   client_exitmsg = "terminated";
   client_exitval = 1;
   client_write_server(MSG_EXITING, ((void *)0), 0);
   break;
  case 28:
   client_write_server(MSG_RESIZE, ((void *)0), 0);
   break;
  case 18:
   memset(&sigact, 0, sizeof sigact);
   sigemptyset(&sigact.sa_mask);
   sigact.sa_flags = 0x10000000;
   sigact.__sigaction_handler.sa_handler = ((void (*)(int)) 1);
   if (sigaction(20, &sigact, ((void *)0)) != 0)
    log_fatal("%s: %s", __func__, "sigaction failed");;
   client_write_server(MSG_WAKEUP, ((void *)0), 0);
   break;
  }
 }
 client_update_event();
}

variable_types: sig int

variable_types:
data
void *

variable_types: status int

user_defined_types: struct __sigset_t { unsigned long __val[-1]; }

user_defined_types: union sigval { int sival_int; void *sival_ptr; }


decompiled_code:
__int64 __fastcall client_callback(__int64 a1, char a2, __int64 a3)
{
__int64 v5; // rax
int v6; // eax

if ( (a2 & 2) == 0 )
{
LABEL_2:
if ( (a2 & 4) == 0 || (int)msgbuf_write((unsigned int)((_DWORD)client_ibuf + 65568)) >= 0 )
return client_update_event();
goto LABEL_11;
}
v5 = imsg_read(client_ibuf);
if ( v5 != -1 && v5 != 0 )
{
if ( client_attached )
v6 = client_dispatch_attached();
else
v6 = client_dispatch_wait(a3);
if ( v6 )
return event_loopexit(0LL);
goto LABEL_2;
}
LABEL_11:
client_exitmsg = (__int64)"lost server";
client_exitval = 1;
return event_loopexit(0LL);
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1, char a2, __int64 a3)
{
__int64 v5; // rax
int v6; // eax

if ( (a2 & 2) == 0 )
{
LABEL_2:
if ( (a2 & 4) == 0 || (int)msgbuf_write((unsigned int)((_DWORD)client_ibuf + 65568)) >= 0 )
return func4();
goto LABEL_11;
}
v5 = imsg_read(client_ibuf);
if ( v5 != -1 && v5 != 0 )
{
if ( client_attached )
v6 = func8();
else
v6 = func7(a3);
if ( v6 )
return event_loopexit(0LL);
goto LABEL_2;
}
LABEL_11:
client_exitmsg = (__int64)"lost server";
client_exitval = 1;
return event_loopexit(0LL);
}

original_code:
void
client_callback(__attribute__ ((unused)) int fd, short events, void *data)
{
 ssize_t n;
 int retval;
 if (events & 0x02) {
  if ((n = imsg_read(&client_ibuf)) == -1 || n == 0)
   goto lost_server;
  if (client_attached)
   retval = client_dispatch_attached();
  else
   retval = client_dispatch_wait(data);
  if (retval != 0) {
   event_loopexit(((void *)0));
   return;
  }
 }
 if (events & 0x04) {
  if (msgbuf_write(&client_ibuf.w) < 0)
   goto lost_server;
 }
 client_update_event();
 return;
lost_server:
 client_exitmsg = "lost server";
 client_exitval = 1;
 event_loopexit(((void *)0));
}

canonical_original_code:
void client_callback(int fd, short events, void *data)
{
 long n;
 int retval;
 if (events & 0x02) {
  if ((n = imsg_read(&client_ibuf)) == -1 || n == 0)
   goto lost_server;
  if (client_attached)
   retval = client_dispatch_attached();
  else
   retval = client_dispatch_wait(data);
  if (retval != 0) {
   event_loopexit(((void *)0));
   return;
  }
 }
 if (events & 0x04) {
  if (msgbuf_write(&client_ibuf.w) < 0)
   goto lost_server;
 }
 client_update_event();
 return;
lost_server:
 client_exitmsg = "lost server";
 client_exitval = 1;
 event_loopexit(((void *)0));
}

variable_types: fd int

variable_types: n long

variable_types: retval int


decompiled_code:
__int64 __fastcall window_clock_free(__int64 a1)
{
__int64 v1; // rbx

v1 = *(_QWORD *)(a1 + 352);
screen_free(v1);
return xfree(v1);
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
__int64 v1; // rbx

v1 = *(_QWORD *)(a1 + 352);
screen_free(v1);
return xfree(v1);
}

original_code:
void
window_clock_free(struct window_pane *wp)
{
 struct window_clock_mode_data *data = wp->modedata;
 screen_free(&data->screen);
 xfree(data);
}

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

variable_types: struct window_clock_mode_data { struct screen { char *title; struct grid { int flags; unsigned int sx; unsigned int sy; unsigned int hsize; unsigned int hlimit; struct grid_line { unsigned int cellsize; struct grid_cell { unsigned char attr; unsigned char flags; unsigned char fg; unsigned char bg; unsigned char data; } *celldata; unsigned int utf8size; struct grid_utf8 { unsigned char width; unsigned char data[9]; } *utf8data; int flags; } *linedata; } *grid; unsigned int cx; unsigned int cy; unsigned int rupper; unsigned int rlower; int mode; unsigned char *tabs; struct screen_sel { int flag; unsigned int sx; unsigned int sy; unsigned int ex; unsigned int ey; struct grid_cell cell; } sel; } screen; long tim; } *

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

user_defined_types: struct window_clock_mode_data { struct screen screen; long tim; }

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

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

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

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

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

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

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

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

user_defined_types: struct environ { struct environ_entry *rbh_root; }

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

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

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

user_defined_types: struct tty_keys { struct tty_key *rbh_root; }

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

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

user_defined_types: struct mode_key_tree { struct mode_key_binding *sph_root; }

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

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

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


decompiled_code:
__int64 window_clock_key()
{
return window_pane_reset_mode();
}

canonical_decompiled_code:
__int64 func1()
{
return window_pane_reset_mode();
}

original_code:
void
window_clock_key(
    struct window_pane *wp, __attribute__ ((unused)) struct client *c, __attribute__ ((unused)) int key)
{
 window_pane_reset_mode(wp);
}

canonical_original_code:
void window_clock_key(struct window_pane *wp, struct client *c, int key)
{
 window_pane_reset_mode(wp);
}

variable_types:
c
struct client *

variable_types: key int

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

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

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

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

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

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

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

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

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

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

user_defined_types: struct options_tree { struct options_entry *sph_root; }

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

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

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

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

user_defined_types: struct 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_entry { char *name; enum { OPTIONS_STRING=0, OPTIONS_NUMBER=1, OPTIONS_DATA=2 } type; char *str; long long num; void *data; void (*freefn)(void *); struct { struct options_entry *spe_left; struct options_entry *spe_right; } entry; }

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

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

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 environ_entry { char *name; char *value; struct { struct environ_entry *rbe_left; struct environ_entry *rbe_right; struct environ_entry *rbe_parent; int rbe_color; } entry; }

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

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

user_defined_types: struct winlinks { struct winlink *rbh_root; }

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

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

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

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

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

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

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

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

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