decompiled_code:
__int64 __fastcall server_window_check_content(__int64 a1, __int64 a2, __int64 a3)
{
__int64 v3; // r12
_BYTE *v6; // rax
__int64 v8; // rdi
unsigned int v9; // ebx
__int64 v10; // rbp
unsigned int *v11; // rax

v3 = *(_QWORD *)(a2 + 8);
if ( (*(_BYTE *)(v3 + 208) & 2) == 0 )
return 0LL;
if ( (*(_BYTE *)(a2 + 40) & 4) != 0 )
return 0LL;
if ( *(_QWORD *)(a1 + 64) == a2 )
return 0LL;
v6 = (_BYTE *)options_get_string(v3 + 216, "monitor-content");
if ( !v6 )
return 0LL;
if ( !*v6 )
return 0LL;
v8 = window_pane_search(a3, v6, 0LL);
if ( !v8 )
return 0LL;
xfree(v8);
*(_DWORD *)(a2 + 40) |= 4u;
if ( options_get_number(a1 + 96, "visual-content") && *((_DWORD *)&clients + 2) )
{
v9 = 0;
do
{
v10 = *(_QWORD *)(clients + 8LL * v9);
if ( v10 )
{
if ( *(_QWORD *)(v10 + 66760) == a1 )
{
v11 = (unsigned int *)winlink_find_by_window(a1 + 88, v3);
status_message_set(v10, "Content in window %u", *v11);
}
}
++v9;
}
while ( *((_DWORD *)&clients + 2) > v9 );
}
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, __int64 a2, __int64 a3)
{
__int64 v3; // r12
_BYTE *v6; // rax
__int64 v8; // rdi
unsigned int v9; // ebx
__int64 v10; // rbp
unsigned int *v11; // rax

v3 = *(_QWORD *)(a2 + 8);
if ( (*(_BYTE *)(v3 + 208) & 2) == 0 )
return 0LL;
if ( (*(_BYTE *)(a2 + 40) & 4) != 0 )
return 0LL;
if ( *(_QWORD *)(a1 + 64) == a2 )
return 0LL;
v6 = (_BYTE *)options_get_string(v3 + 216, "monitor-content");
if ( !v6 )
return 0LL;
if ( !*v6 )
return 0LL;
v8 = window_pane_search(a3, v6, 0LL);
if ( !v8 )
return 0LL;
xfree(v8);
*(_DWORD *)(a2 + 40) |= 4u;
if ( options_get_number(a1 + 96, "visual-content") && *((_DWORD *)&clients + 2) )
{
v9 = 0;
do
{
v10 = *(_QWORD *)(clients + 8LL * v9);
if ( v10 )
{
if ( *(_QWORD *)(v10 + 66760) == a1 )
{
v11 = (unsigned int *)winlink_find_by_window(a1 + 88, v3);
status_message_set(v10, "Content in window %u", *v11);
}
}
++v9;
}
while ( *((_DWORD *)&clients + 2) > v9 );
}
return 1LL;
}

original_code:
int
server_window_check_content(
    struct session *s, struct window *w, struct window_pane *wp)
{
 struct client *c;
 u_int i;
 char *found, *ptr;
 if (!(w->flags & 0x4))
  return (0);
 if (s->curw->window == w)
  return (0);
 ptr = options_get_string(&w->options, "monitor-content");
 if (ptr == ((void *)0) || *ptr == '\0')
  return (0);
 if (session_alert_has_window(s, w, 0x8))
  return (0);
 if ((found = window_pane_search(wp, ptr, ((void *)0))) == ((void *)0))
  return (0);
     xfree(found);
 session_alert_add(s, w, 0x8);
 if (s->flags & 0x1)
  return (0);
  if (options_get_number(&s->options, "visual-content")) {
  for (i = 0; i < ((&clients)->num); i++) {
   c = ((&clients)->list[i]);
   if (c == ((void *)0) || c->session != s)
    continue;
   status_message_set(c, "Content in window %u",
       winlink_find_by_window(&s->windows, w)->idx);
  }
 }
 return (1);
}

canonical_original_code:
int server_window_check_content(struct session *s, struct window *w, struct window_pane *wp)
{
 struct client *c;
 unsigned int i;
 char *found; char *ptr;
 if (!(w->flags & 0x4))
  return (0);
 if (s->curw->window == w)
  return (0);
 ptr = options_get_string(&w->options, "monitor-content");
 if (ptr == ((void *)0) || *ptr == '\0')
  return (0);
 if (session_alert_has_window(s, w, 0x8))
  return (0);
 if ((found = window_pane_search(wp, ptr, ((void *)0))) == ((void *)0))
  return (0);
     xfree(found);
 session_alert_add(s, w, 0x8);
 if (s->flags & 0x1)
  return (0);
  if (options_get_number(&s->options, "visual-content")) {
  for (i = 0; i < ((&clients)->num); i++) {
   c = ((&clients)->list[i]);
   if (c == ((void *)0) || c->session != s)
    continue;
   status_message_set(c, "Content in window %u",
       winlink_find_by_window(&s->windows, w)->idx);
  }
 }
 return (1);
}

variable_types:
wp
struct window_pane *

variable_types:
found
char *

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

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

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

user_defined_types: struct environ { struct environ_entry *rbh_root; }

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

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

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

user_defined_types: struct 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_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 mode_key_tree { struct mode_key_binding *sph_root; }

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

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

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

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

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

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

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


repo: ThomasAdam/tmux-ARCHIVED

decompiled_code:
__int64 server_window_loop()
{
__int64 result; // rax
unsigned int v1; // er13
__int64 v2; // r12
__int64 i; // rbp
__int64 v4; // rax
__int64 v5; // r14
__int64 v6; // rbx

result = *((unsigned int *)&windows + 2);
if ( (_DWORD)result )
{
v1 = 0;
do
{
while ( 1 )
{
result = v1;
v2 = *(_QWORD *)(windows + 8LL * v1);
if ( v2 )
break;
if ( *((_DWORD *)&windows + 2) <= ++v1 )
return result;
}
result = sessions_RB_MINMAX(&sessions, 0xFFFFFFFFLL);
for ( i = result; result; i = result )
{
while ( 1 )
{
v4 = session_has(i, v2);
v5 = v4;
if ( v4 )
{
if ( (unsigned int)server_window_check_bell(i, v4)
|| (unsigned int)server_window_check_activity(i, v5)
|| (unsigned int)server_window_check_silence(i, v5) )
{
server_status_session(i);
}
v6 = *(_QWORD *)(v2 + 168);
if ( v6 )
break;
}
result = sessions_RB_NEXT(i);
i = result;
if ( !result )
goto LABEL_15;
}
do
{
server_window_check_content(i, v5, v6);
v6 = *(_QWORD *)(v6 + 816);
}
while ( v6 );
result = sessions_RB_NEXT(i);
}
LABEL_15:
*(_DWORD *)(v2 + 208) &= 0xFFFFFFFC;
++v1;
}
while ( *((_DWORD *)&windows + 2) > v1 );
}
return result;
}

canonical_decompiled_code:
__int64 func4()
{
__int64 result; // rax
unsigned int v1; // er13
__int64 v2; // r12
__int64 i; // rbp
__int64 v4; // rax
__int64 v5; // r14
__int64 v6; // rbx

result = *((unsigned int *)&windows + 2);
if ( (_DWORD)result )
{
v1 = 0;
do
{
while ( 1 )
{
result = v1;
v2 = *(_QWORD *)(windows + 8LL * v1);
if ( v2 )
break;
if ( *((_DWORD *)&windows + 2) <= ++v1 )
return result;
}
result = sessions_RB_MINMAX(&sessions, 0xFFFFFFFFLL);
for ( i = result; result; i = result )
{
while ( 1 )
{
v4 = session_has(i, v2);
v5 = v4;
if ( v4 )
{
if ( (unsigned int)func0(i, v4)
|| (unsigned int)func1(i, v5)
|| (unsigned int)func2(i, v5) )
{
server_status_session(i);
}
v6 = *(_QWORD *)(v2 + 168);
if ( v6 )
break;
}
result = sessions_RB_NEXT(i);
i = result;
if ( !result )
goto LABEL_15;
}
do
{
func3(i, v5, v6);
v6 = *(_QWORD *)(v6 + 816);
}
while ( v6 );
result = sessions_RB_NEXT(i);
}
LABEL_15:
*(_DWORD *)(v2 + 208) &= 0xFFFFFFFC;
++v1;
}
while ( *((_DWORD *)&windows + 2) > v1 );
}
return result;
}

original_code:
void
server_window_loop(void)
{
 struct window *w;
 struct window_pane *wp;
 struct session *s;
 u_int i, j;
 for (i = 0; i < ((&windows)->num); i++) {
  w = ((&windows)->list[i]);
  if (w == ((void *)0))
   continue;
  for (j = 0; j < ((&sessions)->num); j++) {
   s = ((&sessions)->list[j]);
   if (s == ((void *)0) || !session_has(s, w))
    continue;
   if (server_window_check_bell(s, w) ||
       server_window_check_activity(s, w))
    server_status_session(s);
   for((wp) = ((&w->panes)->tqh_first); (wp) != ((void *)0); (wp) = ((wp)->entry.tqe_next))
    server_window_check_content(s, w, wp);
  }
  w->flags &= ~(0x1|0x4|0x8);
  server_window_check_alive(w);
 }
 set_window_names();
}

canonical_original_code:
void server_window_loop()
{
 struct window *w;
 struct window_pane *wp;
 struct session *s;
 unsigned int i; unsigned int j;
 for (i = 0; i < ((&windows)->num); i++) {
  w = ((&windows)->list[i]);
  if (w == ((void *)0))
   continue;
  for (j = 0; j < ((&sessions)->num); j++) {
   s = ((&sessions)->list[j]);
   if (s == ((void *)0) || !session_has(s, w))
    continue;
   if (server_window_check_bell(s, w) ||
       server_window_check_activity(s, w))
    server_status_session(s);
   for((wp) = ((&w->panes)->tqh_first); (wp) != ((void *)0); (wp) = ((wp)->entry.tqe_next))
    server_window_check_content(s, w, wp);
  }
  w->flags &= ~(0x1|0x4|0x8);
  server_window_check_alive(w);
 }
 set_window_names();
}

variable_types: struct window { char *name; struct timeval { long tv_sec; long tv_usec; } 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 { 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 { 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; 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; } *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 options; unsigned int references; } *

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 session { char *name; struct timeval { long tv_sec; long tv_usec; } 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 { 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 *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; } *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; } *

variable_types:
i
unsigned int

variable_types:
j
unsigned int

return_type: void

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

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

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 grid { int flags; unsigned int sx; unsigned int sy; unsigned int hsize; unsigned int hlimit; struct grid_line *linedata; }

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 grid_line { unsigned int cellsize; struct grid_cell *celldata; unsigned int utf8size; struct grid_utf8 *utf8data; int flags; }

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 tty_term { char *name; unsigned int references; struct tty_code codes[-1]; int flags; struct { struct tty_term *sle_next; } entry; }

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

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 __fastcall cmd_switch_client_exec(__int64 a1, __int64 a2)
{
__int64 result; // rax
__int64 v3; // rbx
__int64 v4; // rax
__int64 v5; // rbp
__int64 v6; // rax
__int64 v7; // rdx

result = 0LL;
v3 = *(_QWORD *)(a1 + 8);
if ( !v3 )
return result;
v4 = cmd_find_client(a2, *(_QWORD *)v3);
v5 = v4;
if ( !v4 )
return 0xFFFFFFFFLL;
if ( *(_DWORD *)(v3 + 20) )
{
v6 = session_next_session(*(_QWORD *)(v4 + 66760));
if ( !v6 )
{
(*(void (__fastcall **)(__int64, const char *))(a2 + 40))(a2, "can't find next session");
return 0xFFFFFFFFLL;
}
}
else if ( *(_DWORD *)(v3 + 24) )
{
v6 = session_previous_session(*(_QWORD *)(v4 + 66760));
if ( !v6 )
{
(*(void (__fastcall **)(__int64, const char *))(a2 + 40))(a2, "can't find previous session");
return 0xFFFFFFFFLL;
}
}
else
{
if ( *(_DWORD *)(v3 + 16) )
{
if ( !*(_QWORD *)(v4 + 66768) || !(unsigned int)session_alive() || (v6 = *(_QWORD *)(v5 + 66768)) == 0 )
{
(*(void (__fastcall **)(__int64, const char *))(a2 + 40))(a2, "can't find last session");
return 0xFFFFFFFFLL;
}
goto LABEL_9;
}
v6 = cmd_find_session(a2, *(_QWORD *)(v3 + 8));
if ( !v6 )
return 0xFFFFFFFFLL;
}
LABEL_9:
v7 = *(_QWORD *)(v5 + 66760);
if ( v7 )
*(_QWORD *)(v5 + 66768) = v7;
*(_QWORD *)(v5 + 66760) = v6;
recalculate_sizes();
server_check_unattached();
server_redraw_client(v5);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 a2)
{
__int64 result; // rax
__int64 v3; // rbx
__int64 v4; // rax
__int64 v5; // rbp
__int64 v6; // rax
__int64 v7; // rdx

result = 0LL;
v3 = *(_QWORD *)(a1 + 8);
if ( !v3 )
return result;
v4 = cmd_find_client(a2, *(_QWORD *)v3);
v5 = v4;
if ( !v4 )
return 0xFFFFFFFFLL;
if ( *(_DWORD *)(v3 + 20) )
{
v6 = session_next_session(*(_QWORD *)(v4 + 66760));
if ( !v6 )
{
(*(void (__fastcall **)(__int64, const char *))(a2 + 40))(a2, "can't find next session");
return 0xFFFFFFFFLL;
}
}
else if ( *(_DWORD *)(v3 + 24) )
{
v6 = session_previous_session(*(_QWORD *)(v4 + 66760));
if ( !v6 )
{
(*(void (__fastcall **)(__int64, const char *))(a2 + 40))(a2, "can't find previous session");
return 0xFFFFFFFFLL;
}
}
else
{
if ( *(_DWORD *)(v3 + 16) )
{
if ( !*(_QWORD *)(v4 + 66768) || !(unsigned int)session_alive() || (v6 = *(_QWORD *)(v5 + 66768)) == 0 )
{
(*(void (__fastcall **)(__int64, const char *))(a2 + 40))(a2, "can't find last session");
return 0xFFFFFFFFLL;
}
goto LABEL_9;
}
v6 = cmd_find_session(a2, *(_QWORD *)(v3 + 8));
if ( !v6 )
return 0xFFFFFFFFLL;
}
LABEL_9:
v7 = *(_QWORD *)(v5 + 66760);
if ( v7 )
*(_QWORD *)(v5 + 66768) = v7;
*(_QWORD *)(v5 + 66760) = v6;
recalculate_sizes();
server_check_unattached();
server_redraw_client(v5);
return 0LL;
}

original_code:
int
cmd_switch_client_exec(struct cmd *self, struct cmd_ctx *ctx)
{
 struct cmd_switch_client_data *data = self->data;
 struct client *c;
 struct session *s;
 if (data == ((void *)0))
  return (0);
 if ((c = cmd_find_client(ctx, data->name)) == ((void *)0))
  return (-1);
 if ((s = cmd_find_session(ctx, data->target)) == ((void *)0))
  return (-1);
 c->session = s;
 recalculate_sizes();
 server_redraw_client(c);
 return (0);
}

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

variable_types:
ctx
struct cmd_ctx *

variable_types: struct cmd_switch_client_data { char *name; char *target; } *

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

return_type: int

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

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

user_defined_types: struct 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 screen { char *title; struct grid *grid; unsigned int cx; unsigned int cy; unsigned int old_cx; unsigned int old_cy; unsigned int rupper; unsigned int rlower; unsigned int old_rupper; unsigned int old_rlower; int mode; struct screen_sel sel; }

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

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 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 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 window { char *name; struct timeval name_timer; struct window_pane *active; struct window_panes panes; unsigned int layout; unsigned int sx; unsigned int sy; int flags; struct options options; unsigned int references; }

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

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

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

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


decompiled_code:
__int64 __fastcall cmd_switch_client_free(__int64 a1)
{
_QWORD *v1; // rbp

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

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

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

original_code:
void
cmd_switch_client_free(struct cmd *self)
{
 struct cmd_switch_client_data *data = self->data;
 if (data->name != ((void *)0))
  xfree(data->name);
 if (data->target != ((void *)0))
  xfree(data->target);
 xfree(data);
}

user_defined_types: struct cmd_switch_client_data { char *name; char *target; }

user_defined_types: struct msg_command_data { int pid; unsigned int idx; unsigned long namelen; }

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

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

user_defined_types: struct winlinks { struct winlink *rbh_root; }

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

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

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

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

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

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

user_defined_types: struct options_tree { struct options_entry *sph_root; }

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:
unsigned __int64 __fastcall cmd_switch_client_print(__int64 a1, __int64 a2, unsigned __int64 a3)
{
__int64 v4; // rbp
int v5; // eax
unsigned __int64 v6; // r12

v4 = *(_QWORD *)(a1 + 8);
v5 = xsnprintf(a2, a3, "%s", **(const char ***)a1);
v6 = v5;
if ( !v4 || v5 >= a3 )
return v6;
if ( !*(_DWORD *)(v4 + 16) )
{
if ( !*(_DWORD *)(v4 + 20) )
goto LABEL_5;
LABEL_13:
v6 += (int)xsnprintf(a2 + v6, a3 - v6, "%s", " -n");
if ( a3 <= v6 )
return v6;
if ( !*(_DWORD *)(v4 + 24) )
goto LABEL_6;
goto LABEL_15;
}
v6 = (int)xsnprintf(a2 + v5, a3 - v5, "%s", " -l") + (__int64)v5;
if ( a3 <= v6 )
return v6;
if ( *(_DWORD *)(v4 + 20) )
goto LABEL_13;
LABEL_5:
if ( *(_DWORD *)(v4 + 24) )
{
LABEL_15:
v6 += (int)xsnprintf(a2 + v6, a3 - v6, "%s", " -p");
if ( a3 <= v6 )
return v6;
}
LABEL_6:
if ( !*(_QWORD *)v4 || (v6 += cmd_prarg(a2 + v6, a3 - v6, " -c "), a3 > v6) )
{
if ( *(_QWORD *)(v4 + 8) )
v6 += cmd_prarg(a2 + v6, a3 - v6, " -t ");
}
return v6;
}

original_code:
size_t
cmd_switch_client_print(struct cmd *self, char *buf, size_t len)
{
 struct cmd_switch_client_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->name != ((void *)0))
  off += cmd_prarg(buf + off, len - off, " -c ", data->name);
 if (off < len && data->target != ((void *)0))
  off += cmd_prarg(buf + off, len - off, " -t ", data->target);
 return (off);
}

canonical_original_code:
unsigned long cmd_switch_client_print(struct cmd *self, char *buf, unsigned long len)
{
 struct cmd_switch_client_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->name != ((void *)0))
  off += cmd_prarg(buf + off, len - off, " -c ", data->name);
 if (off < len && data->target != ((void *)0))
  off += cmd_prarg(buf + off, len - off, " -t ", data->target);
 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_switch_client_data { char *name; char *target; }

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

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

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

user_defined_types: struct msg_command_data { int pid; unsigned int idx; unsigned long namelen; }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

user_defined_types: struct 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:
char *__fastcall client_fill_session(_DWORD *a1)
{
char *result; // rax
char *v2; // rbx
char *v3; // rsi
unsigned __int64 v4; // rsi
char *v5; // r12
char *v6; // rbx
__int64 v7; // [rsp+8h] [rbp-120h] BYREF
char dest[280]; // [rsp+10h] [rbp-118h] BYREF

*a1 = -1;
result = getenv("TMUX");
if ( !result )
return result;
v2 = result;
result = strrchr(result, 44);
if ( v2 == result || !result )
return result;
v3 = result - 1;
if ( v2 < result - 1 )
{
while ( *v3 != 44 )
{
if ( v2 == --v3 )
goto LABEL_10;
}
goto LABEL_8;
}
v2 = result - 1;
LABEL_10:
if ( *v2 == 44 )
{
v3 = v2;
LABEL_8:
v4 = (unsigned __int64)(v3 + 1);
v5 = result + 1;
result -= v4;
v6 = result;
if ( (unsigned __int64)result <= 0xFF )
{
memcpy(dest, (const void *)v4, (size_t)result);
dest[(_QWORD)v6] = 0;
result = (char *)strtonum(dest, 0LL, 0x7FFFFFFFFFFFFFFFLL, &v7);
if ( !v7 )
{
*a1 = (_DWORD)result;
result = (char *)strtonum(v5, 0LL, 0xFFFFFFFFLL, &v7);
if ( !v7 )
a1[1] = (_DWORD)result;
}
}
}
return result;
}

canonical_decompiled_code:
char *__fastcall func0(_DWORD *a1)
{
char *result; // rax
char *v2; // rbx
char *v3; // rsi
unsigned __int64 v4; // rsi
char *v5; // r12
char *v6; // rbx
__int64 v7; // [rsp+8h] [rbp-120h] BYREF
char dest[280]; // [rsp+10h] [rbp-118h] BYREF

*a1 = -1;
result = getenv("TMUX");
if ( !result )
return result;
v2 = result;
result = strrchr(result, 44);
if ( v2 == result || !result )
return result;
v3 = result - 1;
if ( v2 < result - 1 )
{
while ( *v3 != 44 )
{
if ( v2 == --v3 )
goto LABEL_10;
}
goto LABEL_8;
}
v2 = result - 1;
LABEL_10:
if ( *v2 == 44 )
{
v3 = v2;
LABEL_8:
v4 = (unsigned __int64)(v3 + 1);
v5 = result + 1;
result -= v4;
v6 = result;
if ( (unsigned __int64)result <= 0xFF )
{
memcpy(dest, (const void *)v4, (size_t)result);
dest[(_QWORD)v6] = 0;
result = (char *)strtonum(dest, 0LL, 0x7FFFFFFFFFFFFFFFLL, &v7);
if ( !v7 )
{
*a1 = (_DWORD)result;
result = (char *)strtonum(v5, 0LL, 0xFFFFFFFFLL, &v7);
if ( !v7 )
a1[1] = (_DWORD)result;
}
}
}
return result;
}

original_code:
void
client_fill_session(struct msg_command_data *data)
{
 char *env, *ptr1, *ptr2, buf[256];
 size_t len;
 const char *errstr;
 long long ll;
 data->pid = -1;
 if ((env = getenv("TMUX")) == ((void *)0))
  return;
 if ((ptr2 = strrchr(env, ',')) == ((void *)0) || ptr2 == env)
  return;
 for (ptr1 = ptr2 - 1; ptr1 > env && *ptr1 != ','; ptr1--)
  ;
 if (*ptr1 != ',')
  return;
 ptr1++;
 ptr2++;
 len = ptr2 - ptr1 - 1;
 if (len > (sizeof buf) - 1)
  return;
 memcpy(buf, ptr1, len);
 buf[len] = '\0';
 ll = strtonum(buf, 0, 0x7fffffffffffffffL, &errstr);
 if (errstr != ((void *)0))
  return;
 data->pid = ll;
 ll = strtonum(ptr2, 0, (0x7fffffff * 2U + 1U), &errstr);
 if (errstr != ((void *)0))
  return;
 data->idx = ll;
}

canonical_original_code:
void client_fill_session(struct msg_command_data *data)
{
 char *env; char *ptr1; char *ptr2; char buf[256];
 unsigned long len;
 char *errstr;
 long long ll;
 data->pid = -1;
 if ((env = getenv("TMUX")) == ((void *)0))
  return;
 if ((ptr2 = strrchr(env, ',')) == ((void *)0) || ptr2 == env)
  return;
 for (ptr1 = ptr2 - 1; ptr1 > env && *ptr1 != ','; ptr1--)
  ;
 if (*ptr1 != ',')
  return;
 ptr1++;
 ptr2++;
 len = ptr2 - ptr1 - 1;
 if (len > (sizeof buf) - 1)
  return;
 memcpy(buf, ptr1, len);
 buf[len] = '\0';
 ll = strtonum(buf, 0, 0x7fffffffffffffffL, &errstr);
 if (errstr != ((void *)0))
  return;
 data->pid = ll;
 ll = strtonum(ptr2, 0, (0x7fffffff * 2U + 1U), &errstr);
 if (errstr != ((void *)0))
  return;
 data->idx = ll;
}

variable_types: struct msg_command_data { int pid; unsigned int idx; unsigned long namelen; } *

variable_types:
env
char *

variable_types:
buf
char [256]

variable_types:
errstr
char *

variable_types:
ll
long long


decompiled_code:
int client_suspend()
{
__pid_t v0; // eax
struct sigaction vars0; // [rsp+0h] [rbp+0h] BYREF

memset(&vars0, 0, sizeof(vars0));
sigemptyset(&vars0.sa_mask);
vars0.sa_flags = 0x10000000;
vars0.sa_handler = 0LL;
if ( sigaction(20, &vars0, 0LL) || (vars0.sa_handler = (__sighandler_t)&sighandler, sigaction(18, &vars0, 0LL)) )
{
log_fatal("%s: %s", "client_suspend", "sigaction failed");
JUMPOUT(0x1C3LL);
}
v0 = getpid();
return kill(v0, 20);
}

canonical_decompiled_code:
int func2()
{
__pid_t v0; // eax
struct sigaction vars0; // [rsp+0h] [rbp+0h] BYREF

memset(&vars0, 0, sizeof(vars0));
sigemptyset(&vars0.sa_mask);
vars0.sa_flags = 0x10000000;
vars0.sa_handler = 0LL;
if ( sigaction(20, &vars0, 0LL) || (vars0.sa_handler = (__sighandler_t)&sighandler, sigaction(18, &vars0, 0LL)) )
{
log_fatal("%s: %s", "client_suspend", "sigaction failed");
JUMPOUT(0x1C3LL);
}
v0 = getpid();
return kill(v0, 20);
}

original_code:
void
client_suspend(void)
{
 struct sigaction act;
 memset(&act, 0, sizeof act);
 sigemptyset(&act.sa_mask);
 act.sa_flags = 0x10000000;
 act.__sigaction_handler.sa_handler = ((__sighandler_t) 0);
 if (sigaction(20, &act, ((void *)0)) != 0)
  log_fatal("%s: %s", __func__, "sigaction failed");;
 act.__sigaction_handler.sa_handler = sighandler;
 if (sigaction(18, &act, ((void *)0)) != 0)
  log_fatal("%s: %s", __func__, "sigaction failed");;
 kill(getpid(), 20);
}

canonical_original_code:
void client_suspend()
{
 struct sigaction act;
 memset(&act, 0, sizeof act);
 sigemptyset(&act.sa_mask);
 act.sa_flags = 0x10000000;
 act.__sigaction_handler.sa_handler = ((void (*)(int)) 0);
 if (sigaction(20, &act, ((void *)0)) != 0)
  log_fatal("%s: %s", __func__, "sigaction failed");;
 act.__sigaction_handler.sa_handler = sighandler;
 if (sigaction(18, &act, ((void *)0)) != 0)
  log_fatal("%s: %s", __func__, "sigaction failed");;
 kill(getpid(), 20);
}

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


calculaValor

repo: TiagoTT/academic

original_code:
void calculaValor(Circuito* circuito, int node_index)
{
  int i;
  Node* node;
  node = circuito->vectorNodes + node_index ;
  node->valor = tabela1[ ( node->tipo / 2 ) * 2 ]
    [ circuito->vectorNodes[ node->inputs[ 0 ] ].valor ];
  for( i = 1 ; i < node->fanin ; i++ )
    {
      node->valor = tabela2[ ( node->tipo / 2 ) * 2 ]
 [ node->valor ][ circuito->vectorNodes[ node->inputs[ i ] ].valor ];
    }
  if( node->tipo % 2 )
    {
      node->valor = tabela1[ 3 ]
 [ node->valor ];
    }
  return;
}

canonical_original_code:
void calculaValor(struct CircuitoStr *circuito, int node_index)
{
  int i;
  struct NodeStr *node;
  node = circuito->vectorNodes + node_index ;
  node->valor = tabela1[ ( node->tipo / 2 ) * 2 ]
    [ circuito->vectorNodes[ node->inputs[ 0 ] ].valor ];
  for( i = 1 ; i < node->fanin ; i++ )
    {
      node->valor = tabela2[ ( node->tipo / 2 ) * 2 ]
 [ node->valor ][ circuito->vectorNodes[ node->inputs[ i ] ].valor ];
    }
  if( node->tipo % 2 )
    {
      node->valor = tabela1[ 3 ]
 [ node->valor ];
    }
  return;
}

variable_types: struct CircuitoStr { int nNodes; struct NodeStr { char nome[16]; int tipo; int fanin; int *inputs; int valor; char flag; int fanout; char *sa0; char *sa1; int leituras; } *vectorNodes; int nMax; int nInputs; int realNodes; } *

variable_types: i int

user_defined_types: struct CircuitoStr { int nNodes; struct NodeStr *vectorNodes; int nMax; int nInputs; int realNodes; }


valorControlo

decompiled_code:
__int64 __fastcall valorControlo(__int64 a1, int a2)
{
int v2; // eax
__int64 result; // rax

v2 = *(_DWORD *)(*(_QWORD *)(a1 + 8) + 72LL * a2 + 16);
if ( v2 <= 1 )
result = 2 * ((unsigned int)v2 >> 31);
else
result = (unsigned int)((unsigned int)(v2 - 2) > 1) + 1;
return result;
}

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

v2 = *(_DWORD *)(*(_QWORD *)(a1 + 8) + 72LL * a2 + 16);
if ( v2 <= 1 )
result = 2 * ((unsigned int)v2 >> 31);
else
result = (unsigned int)((unsigned int)(v2 - 2) > 1) + 1;
return result;
}

original_code:
int valorControlo(Circuito* circuito, int node_index)
{
  Node* node;
  node = circuito->vectorNodes + node_index ;
  switch( node->tipo )
    {
    case 0:
    case 1:
      return 0;
    case 2:
    case 3:
      return 1;
    }
  return 2;
}

canonical_original_code:
int valorControlo(struct CircuitoStr *circuito, int node_index)
{
  struct NodeStr *node;
  node = circuito->vectorNodes + node_index ;
  switch( node->tipo )
    {
    case 0:
    case 1:
      return 0;
    case 2:
    case 3:
      return 1;
    }
  return 2;
}

variable_types: struct NodeStr { char nome[16]; int tipo; int fanin; int *inputs; int valor; char flag; int fanout; char *sa0; char *sa1; int leituras; } *


haEntradasControlo

original_code:
int haEntradasControlo(Circuito* circuito, int node_index)
{
  int i;
  int controlo;
  Node* node;
  controlo = valorControlo( circuito, node_index );
  node = circuito->vectorNodes + node_index ;
  for( i = 0 ; i < node->fanin ; i++ )
    {
      if( controlo == circuito->vectorNodes[ node->inputs[ i ] ].valor )
 {
   return 1;
 }
    }
  return 0;
}

canonical_original_code:
int haEntradasControlo(struct CircuitoStr *circuito, int node_index)
{
  int i;
  int controlo;
  struct NodeStr *node;
  controlo = valorControlo( circuito, node_index );
  node = circuito->vectorNodes + node_index ;
  for( i = 0 ; i < node->fanin ; i++ )
    {
      if( controlo == circuito->vectorNodes[ node->inputs[ i ] ].valor )
 {
   return 1;
 }
    }
  return 0;
}

variable_types: controlo int

user_defined_types: struct NodeStr { char nome[16]; int tipo; int fanin; int *inputs; int valor; char flag; int fanout; char *sa0; char *sa1; int leituras; }


IdentificaSoldado

decompiled_code:
__int64 __fastcall IdentificaSoldado(__int64 a1)
{
unsigned int v2; // [rsp+Ch] [rbp-Ch] BYREF

_isoc99_sscanf(a1, "Apresenta-se o Soldado %d", &v2);
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
unsigned int v2; // [rsp+Ch] [rbp-Ch] BYREF

_isoc99_sscanf(a1, "Apresenta-se o Soldado %d", &v2);
return v2;
}

original_code:
int IdentificaSoldado(char* msg)
{
 int pid;
 sscanf( msg, "Apresenta-se o Soldado %d", &pid);
 return pid;
}

canonical_original_code:
int IdentificaSoldado(char *msg)
{
 int pid;
 sscanf( msg, "Apresenta-se o Soldado %d", &pid);
 return pid;
}

variable_types:
msg
char *

variable_types: pid int


IdentificaOficial

decompiled_code:
__int64 __fastcall IdentificaOficial(__int64 a1)
{
unsigned int v2; // [rsp+Ch] [rbp-Ch] BYREF

_isoc99_sscanf(a1, "Apresenta-se o Oficial %d", &v2);
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
unsigned int v2; // [rsp+Ch] [rbp-Ch] BYREF

_isoc99_sscanf(a1, "Apresenta-se o Oficial %d", &v2);
return v2;
}

original_code:
int IdentificaOficial(char* msg)
{
 int pid;
 sscanf( msg, "Apresenta-se o Oficial %d", &pid);
 return pid;
}

canonical_original_code:
int IdentificaOficial(char *msg)
{
 int pid;
 sscanf( msg, "Apresenta-se o Oficial %d", &pid);
 return pid;
}


GetIndiceMilitar

decompiled_code:
__int64 __fastcall GetIndiceMilitar(int a1)
{
int v1; // ecx
_DWORD *v2; // rdx
__int64 result; // rax

v1 = *((_DWORD *)&clientes + 2);
if ( v1 <= 0 )
return 0xFFFFFFFFLL;
v2 = clientes;
result = 0LL;
while ( *v2 != a1 )
{
result = (unsigned int)(result + 1);
v2 += 6;
if ( (_DWORD)result == v1 )
return 0xFFFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(int a1)
{
int v1; // ecx
_DWORD *v2; // rdx
__int64 result; // rax

v1 = *((_DWORD *)&clientes + 2);
if ( v1 <= 0 )
return 0xFFFFFFFFLL;
v2 = clientes;
result = 0LL;
while ( *v2 != a1 )
{
result = (unsigned int)(result + 1);
v2 += 6;
if ( (_DWORD)result == v1 )
return 0xFFFFFFFFLL;
}
return result;
}

original_code:
int GetIndiceMilitar(int pid)
{
 int i;
 for( i = 0 ; i < clientes.n_cli ; i++ )
 {
  if( clientes.vector[i].id == pid )
  {
   return i;
  }
 }
 return -1;
}


RegistaEntrada

decompiled_code:
__int64 __fastcall RegistaEntrada(int a1, int a2)
{
int v3; // eax
int v4; // edx
char *v5; // rdi
__int64 v6; // rdx
__int64 result; // rax
char *v8; // rdx
int v9; // edx

v3 = *((_DWORD *)&clientes + 2);
v4 = *((_DWORD *)&clientes + 3);
v5 = (char *)clientes;
if ( v3 >= v4 )
{
v9 = v4 + 10;
*((_DWORD *)&clientes + 3) = v9;
clientes = realloc(v5, 24LL * v9);
v5 = (char *)clientes;
v3 = *((_DWORD *)&clientes + 2);
}
v6 = v3;
result = (unsigned int)(v3 + 1);
v8 = &v5[24 * v6];
*(_DWORD *)v8 = a1;
*((_DWORD *)v8 + 1) = a2;
*((_QWORD *)v8 + 1) = 0LL;
*((_QWORD *)v8 + 2) = 0LL;
*((_DWORD *)&clientes + 2) = result;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(int a1, int a2)
{
int v3; // eax
int v4; // edx
char *v5; // rdi
__int64 v6; // rdx
__int64 result; // rax
char *v8; // rdx
int v9; // edx

v3 = *((_DWORD *)&clientes + 2);
v4 = *((_DWORD *)&clientes + 3);
v5 = (char *)clientes;
if ( v3 >= v4 )
{
v9 = v4 + 10;
*((_DWORD *)&clientes + 3) = v9;
clientes = realloc(v5, 24LL * v9);
v5 = (char *)clientes;
v3 = *((_DWORD *)&clientes + 2);
}
v6 = v3;
result = (unsigned int)(v3 + 1);
v8 = &v5[24 * v6];
*(_DWORD *)v8 = a1;
*((_DWORD *)v8 + 1) = a2;
*((_QWORD *)v8 + 1) = 0LL;
*((_QWORD *)v8 + 2) = 0LL;
*((_DWORD *)&clientes + 2) = result;
return result;
}

original_code:
void RegistaEntrada(int pid, int tipo)
{
 Militar novo;
 novo.id = pid;
 novo.tipo = tipo;
 novo.pedido = ((void *)0);
 if( clientes.n_cli >= clientes.n_max )
 {
  clientes.n_max += 10;
  clientes.vector = (Militar*)realloc( clientes.vector, sizeof(Militar)*(clientes.n_max) );
 }
 clientes.vector[ clientes.n_cli ] = novo;
 clientes.n_cli ++;
 return;
}

canonical_original_code:
void RegistaEntrada(int pid, int tipo)
{
 struct MilitarStr novo;
 novo.id = pid;
 novo.tipo = tipo;
 novo.pedido = ((void *)0);
 if( clientes.n_cli >= clientes.n_max )
 {
  clientes.n_max += 10;
  clientes.vector = (struct MilitarStr *)realloc( clientes.vector, sizeof(Militar)*(clientes.n_max) );
 }
 clientes.vector[ clientes.n_cli ] = novo;
 clientes.n_cli ++;
 return;
}

variable_types: tipo int

variable_types: struct MilitarStr { unsigned int id; unsigned int tipo; struct PedidoStr { struct ProdutoStr { char nome[20]; char quantidade[5]; } *prod; int n_prod; } *pedido; unsigned long tid; }

user_defined_types: struct MilitarStr { unsigned int id; unsigned int tipo; struct PedidoStr *pedido; unsigned long tid; }

user_defined_types: struct PedidoStr { struct ProdutoStr *prod; int n_prod; }


RegistaSaida

decompiled_code:
int __fastcall RegistaSaida(unsigned int a1)
{
int v1; // ecx
char *v2; // rax
char *v3; // rcx

v1 = *((_DWORD *)&clientes + 2);
if ( v1 <= 0 )
{
LABEL_6:
LODWORD(v2) = fprintf(stderr, "O militar %d nao esta no Refeitorio.\n", a1);
}
else
{
v2 = (char *)clientes;
v3 = (char *)clientes + 24 * (unsigned int)(v1 - 1) + 24;
while ( *(_DWORD *)v2 != a1 )
{
v2 += 24;
if ( v2 == v3 )
goto LABEL_6;
}
*(_DWORD *)v2 = 0;
}
return (int)v2;
}

canonical_decompiled_code:
int __fastcall func4(unsigned int a1)
{
int v1; // ecx
char *v2; // rax
char *v3; // rcx

v1 = *((_DWORD *)&clientes + 2);
if ( v1 <= 0 )
{
LABEL_6:
LODWORD(v2) = fprintf(stderr, "O militar %d nao esta no Refeitorio.\n", a1);
}
else
{
v2 = (char *)clientes;
v3 = (char *)clientes + 24 * (unsigned int)(v1 - 1) + 24;
while ( *(_DWORD *)v2 != a1 )
{
v2 += 24;
if ( v2 == v3 )
goto LABEL_6;
}
*(_DWORD *)v2 = 0;
}
return (int)v2;
}

original_code:
void RegistaSaida(int pid)
{
 int i;
 for( i = 0 ; i < clientes.n_cli ; i++ )
 {
  if( clientes.vector[i].id == pid )
  {
   clientes.vector[i].id = 0;
   return;
  }
 }
 fprintf(stderr, "O militar %d nao esta no Refeitorio.\n", pid);
 return;
}


MandaTodosSair

decompiled_code:
char *MandaTodosSair()
{
char *result; // rax
int v1; // ebp
__int64 v2; // rbx
__pid_t v3; // edi

result = (char *)*((unsigned int *)&clientes + 2);
if ( (int)result > 0 )
{
v1 = 0;
v2 = 0LL;
result = (char *)clientes;
do
{
while ( 1 )
{
v3 = *(_DWORD *)&result[v2];
if ( v3 )
break;
++v1;
v2 += 24LL;
if ( *((_DWORD *)&clientes + 2) <= v1 )
return result;
}
++v1;
kill(v3, 2);
result = (char *)clientes;
*(_DWORD *)((char *)clientes + v2) = 0;
v2 += 24LL;
}
while ( *((_DWORD *)&clientes + 2) > v1 );
}
return result;
}

canonical_decompiled_code:
char *func5()
{
char *result; // rax
int v1; // ebp
__int64 v2; // rbx
__pid_t v3; // edi

result = (char *)*((unsigned int *)&clientes + 2);
if ( (int)result > 0 )
{
v1 = 0;
v2 = 0LL;
result = (char *)clientes;
do
{
while ( 1 )
{
v3 = *(_DWORD *)&result[v2];
if ( v3 )
break;
++v1;
v2 += 24LL;
if ( *((_DWORD *)&clientes + 2) <= v1 )
return result;
}
++v1;
kill(v3, 2);
result = (char *)clientes;
*(_DWORD *)((char *)clientes + v2) = 0;
v2 += 24LL;
}
while ( *((_DWORD *)&clientes + 2) > v1 );
}
return result;
}

original_code:
void MandaTodosSair()
{
 int i;
 for( i = 0 ; i < clientes.n_cli ; i++ )
 {
  if( clientes.vector[i].id )
  {
   kill( clientes.vector[i].id, 2 );
   clientes.vector[i].id = 0;
  }
 }
 return;
}


IniciaClientes

decompiled_code:
__int64 IniciaClientes()
{
__int64 result; // rax

clientes = malloc(0x1E0uLL);
result = 0x1400000000LL;
*(&clientes + 1) = (void *)0x1400000000LL;
return result;
}

canonical_decompiled_code:
__int64 func6()
{
__int64 result; // rax

clientes = malloc(0x1E0uLL);
result = 0x1400000000LL;
*(&clientes + 1) = (void *)0x1400000000LL;
return result;
}

original_code:
void IniciaClientes()
{
 clientes.vector = ( Militar* )malloc( sizeof( Militar )*20 );
 clientes.n_cli = 0;
 clientes.n_max = 20;
 return;
}

canonical_original_code:
void IniciaClientes()
{
 clientes.vector = ( struct MilitarStr * )malloc( sizeof( Militar )*20 );
 clientes.n_cli = 0;
 clientes.n_max = 20;
 return;
}

user_defined_types: struct ProdutoStr { char nome[20]; char quantidade[5]; }


ReiniciaClientes

decompiled_code:
void *ReiniciaClientes()
{
int v0; // ebx
char *v1; // rax
void *v2; // rdi
__int64 v3; // rdx
char *v4; // rbp
int v5; // ebx
const __m128i *v6; // rax
const __m128i *v7; // rcx
__int64 v8; // rdx
__m128i v9; // xmm0
__m128i *v10; // rdx
signed int v11; // eax
void *v12; // rax
void *v13; // rdi
size_t v14; // rdx
void *result; // rax

v0 = *((_DWORD *)&clientes + 2);
v1 = (char *)malloc(24LL * v0);
v2 = clientes;
if ( v0 <= 0 )
{
*((_DWORD *)&clientes + 3) = 20;
result = realloc(v2, 0x1E0uLL);
*((_DWORD *)&clientes + 2) = 0;
clientes = result;
return result;
}
v3 = (unsigned int)(v0 - 1);
v4 = v1;
v5 = 0;
v6 = (const __m128i *)clientes;
v7 = (const __m128i *)((char *)clientes + 24 * v3 + 24);
do
{
if ( v6->m128i_i32[0] )
{
v8 = v5;
v9 = _mm_loadu_si128(v6);
++v5;
v10 = (__m128i *)&v4[24 * v8];
v10[1].m128i_i64[0] = v6[1].m128i_i64[0];
*v10 = v9;
}
v6 = (const __m128i *)((char *)v6 + 24);
}
while ( v7 != v6 );
if ( v5 <= 20 )
{
*((_DWORD *)&clientes + 3) = 20;
result = realloc(v2, 0x1E0uLL);
*((_DWORD *)&clientes + 2) = v5;
clientes = result;
v13 = result;
if ( !v5 )
return result;
}
else
{
v11 = 2 * (5 * (v5 / 0xAu) + 5);
*((_DWORD *)&clientes + 3) = v11;
v12 = realloc(v2, 24LL * v11);
*((_DWORD *)&clientes + 2) = v5;
clientes = v12;
v13 = v12;
}
v14 = 8 * (3LL * (unsigned int)(v5 - 1) + 3);
if ( v5 <= 0 )
v14 = 24LL;
return memcpy(v13, v4, v14);
}

canonical_decompiled_code:
void *func7()
{
int v0; // ebx
char *v1; // rax
void *v2; // rdi
__int64 v3; // rdx
char *v4; // rbp
int v5; // ebx
const __m128i *v6; // rax
const __m128i *v7; // rcx
__int64 v8; // rdx
__m128i v9; // xmm0
__m128i *v10; // rdx
signed int v11; // eax
void *v12; // rax
void *v13; // rdi
size_t v14; // rdx
void *result; // rax

v0 = *((_DWORD *)&clientes + 2);
v1 = (char *)malloc(24LL * v0);
v2 = clientes;
if ( v0 <= 0 )
{
*((_DWORD *)&clientes + 3) = 20;
result = realloc(v2, 0x1E0uLL);
*((_DWORD *)&clientes + 2) = 0;
clientes = result;
return result;
}
v3 = (unsigned int)(v0 - 1);
v4 = v1;
v5 = 0;
v6 = (const __m128i *)clientes;
v7 = (const __m128i *)((char *)clientes + 24 * v3 + 24);
do
{
if ( v6->m128i_i32[0] )
{
v8 = v5;
v9 = _mm_loadu_si128(v6);
++v5;
v10 = (__m128i *)&v4[24 * v8];
v10[1].m128i_i64[0] = v6[1].m128i_i64[0];
*v10 = v9;
}
v6 = (const __m128i *)((char *)v6 + 24);
}
while ( v7 != v6 );
if ( v5 <= 20 )
{
*((_DWORD *)&clientes + 3) = 20;
result = realloc(v2, 0x1E0uLL);
*((_DWORD *)&clientes + 2) = v5;
clientes = result;
v13 = result;
if ( !v5 )
return result;
}
else
{
v11 = 2 * (5 * (v5 / 0xAu) + 5);
*((_DWORD *)&clientes + 3) = v11;
v12 = realloc(v2, 24LL * v11);
*((_DWORD *)&clientes + 2) = v5;
clientes = v12;
v13 = v12;
}
v14 = 8 * (3LL * (unsigned int)(v5 - 1) + 3);
if ( v5 <= 0 )
v14 = 24LL;
return memcpy(v13, v4, v14);
}

original_code:
void ReiniciaClientes()
{
 int i, n_ofi;
 Militar* tmp;
 tmp = ( Militar* )malloc( sizeof( Militar )*clientes.n_cli );
 for( i = 0, n_ofi = 0 ; i < clientes.n_cli ; i++ )
 {
  if( clientes.vector[i].id )
  {
   tmp[ n_ofi ] = clientes.vector[i];
   n_ofi++;
  }
 }
 clientes.n_max = (n_ofi > 20) ?
  (1+n_ofi/10)*10:
  20;
 clientes.vector = (Militar*)realloc( clientes.vector, sizeof(Militar)*(clientes.n_max) );
 clientes.n_cli = n_ofi;
 for( i = 0 ; i < clientes.n_cli ; i++ )
 {
  clientes.vector[i] = tmp[i];
 }
 return;
}

canonical_original_code:
void ReiniciaClientes()
{
 int i; int n_ofi;
 struct MilitarStr *tmp;
 tmp = ( struct MilitarStr * )malloc( sizeof( Militar )*clientes.n_cli );
 for( i = 0, n_ofi = 0 ; i < clientes.n_cli ; i++ )
 {
  if( clientes.vector[i].id )
  {
   tmp[ n_ofi ] = clientes.vector[i];
   n_ofi++;
  }
 }
 clientes.n_max = (n_ofi > 20) ?
  (1+n_ofi/10)*10:
  20;
 clientes.vector = (struct MilitarStr *)realloc( clientes.vector, sizeof(Militar)*(clientes.n_max) );
 clientes.n_cli = n_ofi;
 for( i = 0 ; i < clientes.n_cli ; i++ )
 {
  clientes.vector[i] = tmp[i];
 }
 return;
}

variable_types: struct MilitarStr { unsigned int id; unsigned int tipo; struct PedidoStr { struct ProdutoStr { char nome[20]; char quantidade[5]; } *prod; int n_prod; } *pedido; unsigned long tid; } *


ThreadOficiais

decompiled_code:
void *__fastcall ThreadOficiais(void *a1)
{
return 0LL;
}

canonical_decompiled_code:
void *__fastcall func0(void *a1)
{
return 0LL;
}

original_code:
void* ThreadOficiais(void* argumento)
{
  return 0;
}

canonical_original_code:
void *ThreadOficiais(void *argumento)
{
  return 0;
}

variable_types:
argumento
void *

return_type: void *


CancelaThreadOfic

decompiled_code:
void CancelaThreadOfic()
{
;
}

canonical_decompiled_code:
void func1()
{
;
}

original_code:
void CancelaThreadOfic(void)
{
  return;
}

canonical_original_code:
void CancelaThreadOfic()
{
  return;
}