decompiled_code:
__int64 __fastcall client_msg_dispatch(__int64 a1)
{
__int64 v1; // rax
int v3; // [rsp+0h] [rbp-228h] BYREF
__int16 v4; // [rsp+4h] [rbp-224h]
const void *v5; // [rsp+18h] [rbp-210h]
char v6[520]; // [rsp+20h] [rbp-208h] BYREF

while ( 1 )
{
v1 = imsg_get(a1, &v3);
if ( v1 == -1 )
break;
if ( !v1 )
return 0LL;
switch ( v3 )
{
case 1:
if ( v4 != 16LL )
goto LABEL_23;
client_write_server(a1, 5LL, 0LL, 0LL);
*(_DWORD *)(a1 + 65600) = 0;
goto LABEL_6;
case 2:
if ( v4 != 528LL )
goto LABEL_25;
qmemcpy(v6, v5, 0x200uLL);
v6[511] = 0;
*(_QWORD *)(a1 + 65608) = xstrdup(v6);
imsg_free(&v3);
return 0xFFFFFFFFLL;
case 3:
if ( v4 != 16LL )
goto LABEL_24;
client_write_server(a1, 5LL, 0LL, 0LL);
*(_DWORD *)(a1 + 65600) = 1;
goto LABEL_6;
case 4:
if ( v4 != 16LL )
goto LABEL_21;
imsg_free(&v3);
return 0xFFFFFFFFLL;
case 10:
if ( v4 != 16LL )
goto LABEL_20;
client_write_server(a1, 5LL, 0LL, 0LL);
*(_DWORD *)(a1 + 65600) = 3;
goto LABEL_6;
case 11:
if ( v4 != 16LL )
goto LABEL_22;
client_suspend();
LABEL_6:
imsg_free(&v3);
break;
default:
log_fatalx("%s: %s", "client_msg_dispatch", "unexpected message");
goto LABEL_19;
}
}
LABEL_19:
log_fatalx("%s: %s", "client_msg_dispatch", "imsg_get failed");
LABEL_20:
log_fatalx("%s: %s", "client_msg_dispatch", "bad MSG_SHUTDOWN size");
LABEL_21:
log_fatalx("%s: %s", "client_msg_dispatch", "bad MSG_EXITED size");
LABEL_22:
log_fatalx("%s: %s", "client_msg_dispatch", "bad MSG_SUSPEND size");
LABEL_23:
log_fatalx("%s: %s", "client_msg_dispatch", "bad MSG_DETACH size");
LABEL_24:
log_fatalx("%s: %s", "client_msg_dispatch", "bad MSG_EXIT size");
LABEL_25:
log_fatalx("%s: %s", "client_msg_dispatch", "bad MSG_ERROR size");
return client_main();
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
__int64 v1; // rax
int v3; // [rsp+0h] [rbp-228h] BYREF
__int16 v4; // [rsp+4h] [rbp-224h]
const void *v5; // [rsp+18h] [rbp-210h]
char v6[520]; // [rsp+20h] [rbp-208h] BYREF

while ( 1 )
{
v1 = imsg_get(a1, &v3);
if ( v1 == -1 )
break;
if ( !v1 )
return 0LL;
switch ( v3 )
{
case 1:
if ( v4 != 16LL )
goto LABEL_23;
client_write_server(a1, 5LL, 0LL, 0LL);
*(_DWORD *)(a1 + 65600) = 0;
goto LABEL_6;
case 2:
if ( v4 != 528LL )
goto LABEL_25;
qmemcpy(v6, v5, 0x200uLL);
v6[511] = 0;
*(_QWORD *)(a1 + 65608) = xstrdup(v6);
imsg_free(&v3);
return 0xFFFFFFFFLL;
case 3:
if ( v4 != 16LL )
goto LABEL_24;
client_write_server(a1, 5LL, 0LL, 0LL);
*(_DWORD *)(a1 + 65600) = 1;
goto LABEL_6;
case 4:
if ( v4 != 16LL )
goto LABEL_21;
imsg_free(&v3);
return 0xFFFFFFFFLL;
case 10:
if ( v4 != 16LL )
goto LABEL_20;
client_write_server(a1, 5LL, 0LL, 0LL);
*(_DWORD *)(a1 + 65600) = 3;
goto LABEL_6;
case 11:
if ( v4 != 16LL )
goto LABEL_22;
client_suspend();
LABEL_6:
imsg_free(&v3);
break;
default:
log_fatalx("%s: %s", "client_msg_dispatch", "unexpected message");
goto LABEL_19;
}
}
LABEL_19:
log_fatalx("%s: %s", "client_msg_dispatch", "imsg_get failed");
LABEL_20:
log_fatalx("%s: %s", "client_msg_dispatch", "bad MSG_SHUTDOWN size");
LABEL_21:
log_fatalx("%s: %s", "client_msg_dispatch", "bad MSG_EXITED size");
LABEL_22:
log_fatalx("%s: %s", "client_msg_dispatch", "bad MSG_SUSPEND size");
LABEL_23:
log_fatalx("%s: %s", "client_msg_dispatch", "bad MSG_DETACH size");
LABEL_24:
log_fatalx("%s: %s", "client_msg_dispatch", "bad MSG_EXIT size");
LABEL_25:
log_fatalx("%s: %s", "client_msg_dispatch", "bad MSG_ERROR size");
return func4();
}

original_code:
int
client_msg_dispatch(struct client_ctx *cctx)
{
 struct imsg imsg;
 struct msg_print_data printdata;
 ssize_t n, datalen;
 for (;;) {
  if ((n = imsg_get(&cctx->ibuf, &imsg)) == -1)
   log_fatalx("%s: %s", __func__, "imsg_get failed");;
  if (n == 0)
   return (0);
  datalen = imsg.hdr.len - sizeof(struct imsg_hdr);
  switch (imsg.hdr.type) {
  case MSG_DETACH:
   if (datalen != 0)
    log_fatalx("%s: %s", __func__, "bad MSG_DETACH size");;
   client_write_server(cctx, MSG_EXITING, ((void *)0), 0);
   cctx->exittype = CCTX_DETACH;
   break;
  case MSG_ERROR:
   if (datalen != sizeof printdata)
    log_fatalx("%s: %s", __func__, "bad MSG_ERROR size");;
   memcpy(&printdata, imsg.data, sizeof printdata);
   printdata.msg[(sizeof printdata.msg) - 1] = '\0';
   cctx->errstr = xstrdup(printdata.msg);
   imsg_free(&imsg);
   return (-1);
  case MSG_EXIT:
   if (datalen != 0)
    log_fatalx("%s: %s", __func__, "bad MSG_EXIT size");;
   client_write_server(cctx, MSG_EXITING, ((void *)0), 0);
   cctx->exittype = CCTX_EXIT;
   break;
  case MSG_EXITED:
   if (datalen != 0)
    log_fatalx("%s: %s", __func__, "bad MSG_EXITED size");;
   imsg_free(&imsg);
   return (-1);
  case MSG_SHUTDOWN:
   if (datalen != 0)
    log_fatalx("%s: %s", __func__, "bad MSG_SHUTDOWN size");;
   client_write_server(cctx, MSG_EXITING, ((void *)0), 0);
   cctx->exittype = CCTX_SHUTDOWN;
   break;
  case MSG_SUSPEND:
   if (datalen != 0)
    log_fatalx("%s: %s", __func__, "bad MSG_SUSPEND size");;
   client_suspend();
   break;
  default:
   log_fatalx("%s: %s", __func__, "unexpected message");;
  }
  imsg_free(&imsg);
 }
}

canonical_original_code:
int client_msg_dispatch(struct client_ctx *cctx)
{
 struct imsg imsg;
 struct msg_print_data printdata;
 long n; long datalen;
 for (;;) {
  if ((n = imsg_get(&cctx->ibuf, &imsg)) == -1)
   log_fatalx("%s: %s", __func__, "imsg_get failed");;
  if (n == 0)
   return (0);
  datalen = imsg.hdr.len - sizeof(struct imsg_hdr);
  switch (imsg.hdr.type) {
  case MSG_DETACH:
   if (datalen != 0)
    log_fatalx("%s: %s", __func__, "bad MSG_DETACH size");;
   client_write_server(cctx, MSG_EXITING, ((void *)0), 0);
   cctx->exittype = CCTX_DETACH;
   break;
  case MSG_ERROR:
   if (datalen != sizeof printdata)
    log_fatalx("%s: %s", __func__, "bad MSG_ERROR size");;
   memcpy(&printdata, imsg.data, sizeof printdata);
   printdata.msg[(sizeof printdata.msg) - 1] = '\0';
   cctx->errstr = xstrdup(printdata.msg);
   imsg_free(&imsg);
   return (-1);
  case MSG_EXIT:
   if (datalen != 0)
    log_fatalx("%s: %s", __func__, "bad MSG_EXIT size");;
   client_write_server(cctx, MSG_EXITING, ((void *)0), 0);
   cctx->exittype = CCTX_EXIT;
   break;
  case MSG_EXITED:
   if (datalen != 0)
    log_fatalx("%s: %s", __func__, "bad MSG_EXITED size");;
   imsg_free(&imsg);
   return (-1);
  case MSG_SHUTDOWN:
   if (datalen != 0)
    log_fatalx("%s: %s", __func__, "bad MSG_SHUTDOWN size");;
   client_write_server(cctx, MSG_EXITING, ((void *)0), 0);
   cctx->exittype = CCTX_SHUTDOWN;
   break;
  case MSG_SUSPEND:
   if (datalen != 0)
    log_fatalx("%s: %s", __func__, "bad MSG_SUSPEND size");;
   client_suspend();
   break;
  default:
   log_fatalx("%s: %s", __func__, "unexpected message");;
  }
  imsg_free(&imsg);
 }
}

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

variable_types: struct msg_print_data { char msg[512]; }

variable_types: n long

variable_types: datalen long

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

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

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

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


repo: ThomasAdam/tmux-ARCHIVED

decompiled_code:
__int64 __fastcall buffer_destroy(_QWORD *a1)
{
xfree(*a1);
return xfree(a1);
}

canonical_decompiled_code:
__int64 __fastcall func1(_QWORD *a1)
{
xfree(*a1);
return xfree(a1);
}

original_code:
void
buffer_destroy(struct buffer *b)
{
 xfree(b->base);
 xfree(b);
}

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

return_type: void


decompiled_code:
void __fastcall buffer_clear(__int64 a1)
{
*(_QWORD *)(a1 + 16) = 0LL;
*(_QWORD *)(a1 + 24) = 0LL;
}

original_code:
void
buffer_clear(struct buffer *b)
{
 b->size = 0;
 b->off = 0;
}

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


decompiled_code:
unsigned __int64 __fastcall buffer_ensure(__int64 a1, unsigned __int64 a2)
{
size_t v2; // r8
__int64 v4; // rsi
unsigned __int64 result; // rax
__int64 v7; // rdi
__int64 v8; // rax
unsigned __int64 v9; // rdx
__int64 v10; // rax

if ( !a2 )
{
log_fatalx("%s: %s", "buffer_ensure", "zero size");
goto LABEL_13;
}
v2 = *(_QWORD *)(a1 + 16);
v4 = *(_QWORD *)(a1 + 24);
result = *(_QWORD *)(a1 + 8) - (v4 + v2);
if ( result >= a2 )
return result;
if ( v4 )
{
if ( v2 )
{
memmove(*(void **)a1, (const void *)(*(_QWORD *)a1 + v4), v2);
v2 = *(_QWORD *)(a1 + 16);
}
*(_QWORD *)(a1 + 24) = 0LL;
}
result = ~v2;
if ( ~v2 < a2 )
{
LABEL_13:
log_fatalx("%s: %s", "buffer_ensure", "size too big");
return buffer_add();
}
if ( *(_QWORD *)(a1 + 8) < a2 + v2 )
{
v7 = *(_QWORD *)a1;
do
{
v8 = xrealloc(v7, 2LL);
*(_QWORD *)a1 = v8;
v7 = v8;
v9 = 2LL * *(_QWORD *)(a1 + 8);
v10 = *(_QWORD *)(a1 + 16);
*(_QWORD *)(a1 + 8) = v9;
result = a2 + v10;
}
while ( v9 < result );
}
return result;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func3(__int64 a1, unsigned __int64 a2)
{
size_t v2; // r8
__int64 v4; // rsi
unsigned __int64 result; // rax
__int64 v7; // rdi
__int64 v8; // rax
unsigned __int64 v9; // rdx
__int64 v10; // rax

if ( !a2 )
{
log_fatalx("%s: %s", "buffer_ensure", "zero size");
goto LABEL_13;
}
v2 = *(_QWORD *)(a1 + 16);
v4 = *(_QWORD *)(a1 + 24);
result = *(_QWORD *)(a1 + 8) - (v4 + v2);
if ( result >= a2 )
return result;
if ( v4 )
{
if ( v2 )
{
memmove(*(void **)a1, (const void *)(*(_QWORD *)a1 + v4), v2);
v2 = *(_QWORD *)(a1 + 16);
}
*(_QWORD *)(a1 + 24) = 0LL;
}
result = ~v2;
if ( ~v2 < a2 )
{
LABEL_13:
log_fatalx("%s: %s", "buffer_ensure", "size too big");
return func4();
}
if ( *(_QWORD *)(a1 + 8) < a2 + v2 )
{
v7 = *(_QWORD *)a1;
do
{
v8 = xrealloc(v7, 2LL);
*(_QWORD *)a1 = v8;
v7 = v8;
v9 = 2LL * *(_QWORD *)(a1 + 8);
v10 = *(_QWORD *)(a1 + 16);
*(_QWORD *)(a1 + 8) = v9;
result = a2 + v10;
}
while ( v9 < result );
}
return result;
}

original_code:
void
buffer_ensure(struct buffer *b, size_t size)
{
 if (size == 0)
  log_fatalx("%s: %s", __func__, "zero size");;
 if (((b)->space - (b)->off - (b)->size) >= size)
  return;
 if (b->off > 0) {
  if (b->size > 0)
   memmove(b->base, b->base + b->off, b->size);
  b->off = 0;
 }
 if ((18446744073709551615UL) - b->size < size)
  log_fatalx("%s: %s", __func__, "size too big");;
 while (b->space < b->size + size) {
  b->base = xrealloc(b->base, 2, b->space);
  b->space *= 2;
 }
}

canonical_original_code:
void buffer_ensure(struct buffer *b, unsigned long size)
{
 if (size == 0)
  log_fatalx("%s: %s", __func__, "zero size");;
 if (((b)->space - (b)->off - (b)->size) >= size)
  return;
 if (b->off > 0) {
  if (b->size > 0)
   memmove(b->base, b->base + b->off, b->size);
  b->off = 0;
 }
 if ((18446744073709551615UL) - b->size < size)
  log_fatalx("%s: %s", __func__, "size too big");;
 while (b->space < b->size + size) {
  b->base = xrealloc(b->base, 2, b->space);
  b->space *= 2;
 }
}

variable_types:
size
unsigned long


decompiled_code:
__int64 __fastcall buffer_add(__int64 a1, unsigned __int64 a2)
{
__int64 result; // rax

if ( a2 )
{
result = *(_QWORD *)(a1 + 16);
if ( *(_QWORD *)(a1 + 8) - result >= a2 )
{
*(_QWORD *)(a1 + 16) = result + a2;
return result;
}
}
else
{
log_fatalx("%s: %s", "buffer_add", "zero size");
}
log_fatalx("%s: %s", "buffer_add", "overflow");
return buffer_reverse_add();
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, unsigned __int64 a2)
{
__int64 result; // rax

if ( a2 )
{
result = *(_QWORD *)(a1 + 16);
if ( *(_QWORD *)(a1 + 8) - result >= a2 )
{
*(_QWORD *)(a1 + 16) = result + a2;
return result;
}
}
else
{
log_fatalx("%s: %s", "buffer_add", "zero size");
}
log_fatalx("%s: %s", "buffer_add", "overflow");
return func5();
}

original_code:
void
buffer_add(struct buffer *b, size_t size)
{
 if (size == 0)
  log_fatalx("%s: %s", __func__, "zero size");;
 if (size > b->space - b->size)
  log_fatalx("%s: %s", __func__, "overflow");;
 b->size += size;
}

canonical_original_code:
void buffer_add(struct buffer *b, unsigned long size)
{
 if (size == 0)
  log_fatalx("%s: %s", __func__, "zero size");;
 if (size > b->space - b->size)
  log_fatalx("%s: %s", __func__, "overflow");;
 b->size += size;
}


decompiled_code:
__int64 __fastcall buffer_reverse_add(__int64 a1, unsigned __int64 a2)
{
unsigned __int64 v2; // rax
__int64 result; // rax

if ( a2 )
{
v2 = *(_QWORD *)(a1 + 16);
if ( v2 >= a2 )
{
result = v2 - a2;
*(_QWORD *)(a1 + 16) = result;
return result;
}
}
else
{
log_fatalx("%s: %s", "buffer_reverse_add", "zero size");
}
log_fatalx("%s: %s", "buffer_reverse_add", "underflow");
return buffer_remove();
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, unsigned __int64 a2)
{
unsigned __int64 v2; // rax
__int64 result; // rax

if ( a2 )
{
v2 = *(_QWORD *)(a1 + 16);
if ( v2 >= a2 )
{
result = v2 - a2;
*(_QWORD *)(a1 + 16) = result;
return result;
}
}
else
{
log_fatalx("%s: %s", "buffer_reverse_add", "zero size");
}
log_fatalx("%s: %s", "buffer_reverse_add", "underflow");
return func6();
}

original_code:
void
buffer_reverse_add(struct buffer *b, size_t size)
{
 if (size == 0)
  log_fatalx("%s: %s", __func__, "zero size");;
 if (size > b->size)
  log_fatalx("%s: %s", __func__, "underflow");;
 b->size -= size;
}

canonical_original_code:
void buffer_reverse_add(struct buffer *b, unsigned long size)
{
 if (size == 0)
  log_fatalx("%s: %s", __func__, "zero size");;
 if (size > b->size)
  log_fatalx("%s: %s", __func__, "underflow");;
 b->size -= size;
}


decompiled_code:
__int64 __fastcall buffer_remove(__int64 a1, unsigned __int64 a2)
{
unsigned __int64 v2; // rax
__int64 result; // rax

if ( a2 )
{
v2 = *(_QWORD *)(a1 + 16);
if ( v2 >= a2 )
{
result = v2 - a2;
*(_QWORD *)(a1 + 24) += a2;
*(_QWORD *)(a1 + 16) = result;
return result;
}
}
else
{
log_fatalx("%s: %s", "buffer_remove", "zero size");
}
log_fatalx("%s: %s", "buffer_remove", "underflow");
return buffer_reverse_remove();
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, unsigned __int64 a2)
{
unsigned __int64 v2; // rax
__int64 result; // rax

if ( a2 )
{
v2 = *(_QWORD *)(a1 + 16);
if ( v2 >= a2 )
{
result = v2 - a2;
*(_QWORD *)(a1 + 24) += a2;
*(_QWORD *)(a1 + 16) = result;
return result;
}
}
else
{
log_fatalx("%s: %s", "buffer_remove", "zero size");
}
log_fatalx("%s: %s", "buffer_remove", "underflow");
return func7();
}

original_code:
void
buffer_remove(struct buffer *b, size_t size)
{
 if (size == 0)
  log_fatalx("%s: %s", __func__, "zero size");;
 if (size > b->size)
  log_fatalx("%s: %s", __func__, "underflow");;
 b->size -= size;
 b->off += size;
}

canonical_original_code:
void buffer_remove(struct buffer *b, unsigned long size)
{
 if (size == 0)
  log_fatalx("%s: %s", __func__, "zero size");;
 if (size > b->size)
  log_fatalx("%s: %s", __func__, "underflow");;
 b->size -= size;
 b->off += size;
}


decompiled_code:
__int64 __fastcall buffer_reverse_remove(__int64 a1, unsigned __int64 a2)
{
unsigned __int64 v2; // rax
__int64 result; // rax

if ( a2 )
{
v2 = *(_QWORD *)(a1 + 24);
if ( v2 >= a2 )
{
result = v2 - a2;
*(_QWORD *)(a1 + 16) += a2;
*(_QWORD *)(a1 + 24) = result;
return result;
}
}
else
{
log_fatalx("%s: %s", "buffer_reverse_remove", "zero size");
}
log_fatalx("%s: %s", "buffer_reverse_remove", "overflow");
return buffer_insert_range();
}

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

if ( a2 )
{
v2 = *(_QWORD *)(a1 + 24);
if ( v2 >= a2 )
{
result = v2 - a2;
*(_QWORD *)(a1 + 16) += a2;
*(_QWORD *)(a1 + 24) = result;
return result;
}
}
else
{
log_fatalx("%s: %s", "buffer_reverse_remove", "zero size");
}
log_fatalx("%s: %s", "buffer_reverse_remove", "overflow");
return func8();
}

original_code:
void
buffer_reverse_remove(struct buffer *b, size_t size)
{
 if (size == 0)
  log_fatalx("%s: %s", __func__, "zero size");;
 if (size > b->off)
  log_fatalx("%s: %s", __func__, "overflow");;
 b->size += size;
 b->off -= size;
}

canonical_original_code:
void buffer_reverse_remove(struct buffer *b, unsigned long size)
{
 if (size == 0)
  log_fatalx("%s: %s", __func__, "zero size");;
 if (size > b->off)
  log_fatalx("%s: %s", __func__, "overflow");;
 b->size += size;
 b->off -= size;
}


decompiled_code:
__int64 __fastcall buffer_read(_QWORD *a1, void *a2, size_t a3)
{
if ( a3 )
{
if ( a1[2] >= a3 )
{
memcpy(a2, (const void *)(*a1 + a1[3]), a3);
return buffer_remove((__int64)a1, a3);
}
}
else
{
log_fatalx("%s: %s", "buffer_read", "zero size");
}
log_fatalx("%s: %s", "buffer_read", "underflow");
return buffer_write8();
}

canonical_decompiled_code:
__int64 __fastcall func11(_QWORD *a1, void *a2, size_t a3)
{
if ( a3 )
{
if ( a1[2] >= a3 )
{
memcpy(a2, (const void *)(*a1 + a1[3]), a3);
return func6((__int64)a1, a3);
}
}
else
{
log_fatalx("%s: %s", "buffer_read", "zero size");
}
log_fatalx("%s: %s", "buffer_read", "underflow");
return func12();
}

original_code:
void
buffer_read(struct buffer *b, void *data, size_t size)
{
 if (size == 0)
  log_fatalx("%s: %s", __func__, "zero size");;
 if (size > b->size)
  log_fatalx("%s: %s", __func__, "underflow");;
 memcpy(data, ((b)->base + (b)->off), size);
 buffer_remove(b, size);
}

canonical_original_code:
void buffer_read(struct buffer *b, void *data, unsigned long size)
{
 if (size == 0)
  log_fatalx("%s: %s", __func__, "zero size");;
 if (size > b->size)
  log_fatalx("%s: %s", __func__, "underflow");;
 memcpy(data, ((b)->base + (b)->off), size);
 buffer_remove(b, size);
}

variable_types:
data
void *


decompiled_code:
__int64 __fastcall buffer_write16(_QWORD *a1, __int16 a2)
{
buffer_ensure((__int64)a1, 2uLL);
*(_WORD *)(a1[2] + *a1 + a1[3]) = a2;
return buffer_add((__int64)a1, 2uLL);
}

original_code:
void
buffer_write16(struct buffer *b, uint16_t n)
{
 buffer_ensure(b, 2);
 ((b)->base + (b)->off + (b)->size)[0] = n & 0xff;
 ((b)->base + (b)->off + (b)->size)[1] = n >> 8;
 buffer_add(b, 2);
}

canonical_original_code:
void buffer_write16(struct buffer *b, unsigned short n)
{
 buffer_ensure(b, 2);
 ((b)->base + (b)->off + (b)->size)[0] = n & 0xff;
 ((b)->base + (b)->off + (b)->size)[1] = n >> 8;
 buffer_add(b, 2);
}

variable_types:
n
unsigned short


decompiled_code:
__int64 __fastcall buffer_read8(_QWORD *a1)
{
unsigned int v1; // er12

v1 = *(unsigned __int8 *)(*a1 + a1[3]);
buffer_remove((__int64)a1, 1uLL);
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func14(_QWORD *a1)
{
unsigned int v1; // er12

v1 = *(unsigned __int8 *)(*a1 + a1[3]);
func6((__int64)a1, 1uLL);
return v1;
}

original_code:
uint8_t
buffer_read8(struct buffer *b)
{
 uint8_t n;
 n = ((b)->base + (b)->off)[0];
 buffer_remove(b, 1);
 return (n);
}

canonical_original_code:
unsigned char buffer_read8(struct buffer *b)
{
 unsigned char n;
 n = ((b)->base + (b)->off)[0];
 buffer_remove(b, 1);
 return (n);
}

variable_types:
n
unsigned char

return_type: unsigned char


decompiled_code:
__int64 __fastcall buffer_read16(_QWORD *a1)
{
unsigned int v1; // er12

v1 = *(unsigned __int16 *)(*a1 + a1[3]);
buffer_remove((__int64)a1, 2uLL);
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func15(_QWORD *a1)
{
unsigned int v1; // er12

v1 = *(unsigned __int16 *)(*a1 + a1[3]);
func6((__int64)a1, 2uLL);
return v1;
}

original_code:
uint16_t
buffer_read16(struct buffer *b)
{
 uint16_t n;
 n = ((b)->base + (b)->off)[0] | (((b)->base + (b)->off)[1] << 8);
 buffer_remove(b, 2);
 return (n);
}

canonical_original_code:
unsigned short buffer_read16(struct buffer *b)
{
 unsigned short n;
 n = ((b)->base + (b)->off)[0] | (((b)->base + (b)->off)[1] << 8);
 buffer_remove(b, 2);
 return (n);
}

return_type: unsigned short


decompiled_code:
__int64 __fastcall cmd_find_window_search(__int64 a1, const char *a2)
{
unsigned int v3; // er12
__int64 v4; // rax
unsigned int *v5; // rdi
const char *v6; // r15
unsigned int v7; // er14
__int64 v8; // rbp
__int64 v9; // rbx
__int64 v10; // rbx
__int64 v11; // rax
char v12; // dl
const char *v13; // rax
char *v14; // rax
__int64 v15; // r12

v3 = 0;
v4 = xmalloc(1LL);
v5 = *(unsigned int **)(a1 + 272);
v6 = (const char *)v4;
if ( v5[1] )
{
while ( 1 )
{
v7 = 0;
v8 = 0LL;
if ( *v5 )
{
do
{
v9 = grid_view_peek_cell(v5, v7, v3);
if ( (*(_BYTE *)(v9 + 1) & 8) != 0 )
{
v10 = grid_view_peek_utf8(*(_QWORD *)(a1 + 272), v7, v3) - v8;
v6 = (const char *)xrealloc(v6, 1LL);
v11 = v8;
while ( 1 )
{
v12 = *(_BYTE *)(v10 + v11 + 1);
if ( v12 == -1 )
break;
v6[v11++] = v12;
if ( v8 + 8 == v11 )
{
v8 += 8LL;
goto LABEL_5;
}
}
v8 = v11;
}
else
{
v6 = (const char *)xrealloc(v6, 1LL);
v6[v8++] = *(_BYTE *)(v9 + 4);
}
LABEL_5:
v5 = *(unsigned int **)(a1 + 272);
++v7;
}
while ( *v5 > v7 );
while ( v8 )
{
if ( v6[v8 - 1] != 32 )
{
v13 = &v6[v8];
goto LABEL_15;
}
--v8;
}
}
v13 = v6;
LABEL_15:
*v13 = 0;
v14 = strstr(v6, a2);
if ( v14 )
break;
v5 = *(unsigned int **)(a1 + 272);
if ( v5[1] <= ++v3 )
goto LABEL_17;
}
v15 = section_string(v6, v8, v14 - v6, 40LL);
xfree(v6);
}
else
{
LABEL_17:
v15 = 0LL;
xfree(v6);
}
return v15;
}

original_code:
char *
cmd_find_window_search(struct window_pane *wp, const char *searchstr)
{
 const struct grid_cell *gc;
 const struct grid_utf8 *gu;
 char *buf, *s;
 size_t off;
 u_int i, j, k;
 buf = xmalloc(1);
 for (j = 0; j < ((&wp->base)->grid->sy); j++) {
  off = 0;
  for (i = 0; i < ((&wp->base)->grid->sx); i++) {
   gc = grid_view_peek_cell(wp->base.grid, i, j);
   if (gc->flags & 0x8) {
    gu = grid_view_peek_utf8(wp->base.grid, i, j);
    buf = xrealloc(buf, 1, off + 8);
    for (k = 0; k < 8; k++) {
     if (gu->data[k] == 0xff)
      break;
     buf[off++] = gu->data[k];
    }
   } else {
    buf = xrealloc(buf, 1, off + 1);
    buf[off++] = gc->data;
   }
  }
  while (off > 0 && buf[off - 1] == ' ')
   off--;
  buf[off] = '\0';
  if ((s = strstr(buf, searchstr)) != ((void *)0)) {
   s = section_string(buf, off, s - buf, 40);
   xfree(buf);
   return (s);
  }
 }
 xfree(buf);
 return (((void *)0));
}

canonical_original_code:
char *cmd_find_window_search(struct window_pane *wp, char *searchstr)
{
 struct grid_cell *gc;
 struct grid_utf8 *gu;
 char *buf; char *s;
 unsigned long off;
 unsigned int i; unsigned int j; unsigned int k;
 buf = xmalloc(1);
 for (j = 0; j < ((&wp->base)->grid->sy); j++) {
  off = 0;
  for (i = 0; i < ((&wp->base)->grid->sx); i++) {
   gc = grid_view_peek_cell(wp->base.grid, i, j);
   if (gc->flags & 0x8) {
    gu = grid_view_peek_utf8(wp->base.grid, i, j);
    buf = xrealloc(buf, 1, off + 8);
    for (k = 0; k < 8; k++) {
     if (gu->data[k] == 0xff)
      break;
     buf[off++] = gu->data[k];
    }
   } else {
    buf = xrealloc(buf, 1, off + 1);
    buf[off++] = gc->data;
   }
  }
  while (off > 0 && buf[off - 1] == ' ')
   off--;
  buf[off] = '\0';
  if ((s = strstr(buf, searchstr)) != ((void *)0)) {
   s = section_string(buf, off, s - buf, 40);
   xfree(buf);
   return (s);
  }
 }
 xfree(buf);
 return (((void *)0));
}

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

variable_types:
searchstr
char *

variable_types:
buf
char *

variable_types:
s
char *

variable_types:
off
unsigned long

variable_types:
i
unsigned int

variable_types:
j
unsigned int

variable_types:
k
unsigned int

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

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

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

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

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

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

user_defined_types: struct tty_keys { struct tty_key *rbh_root; }

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

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

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

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


decompiled_code:
__int64 __fastcall cmd_find_window_callback(unsigned int *a1, int a2)
{
__int64 v2; // rdx
__int64 v3; // r12

if ( a2 != -1 )
{
v2 = *a1;
if ( (unsigned int)v2 <= *((_DWORD *)&sessions + 2) - 1 )
{
v3 = *(_QWORD *)(sessions + 8 * v2);
if ( v3 && !(unsigned int)session_select(*(_QWORD *)(sessions + 8 * v2)) )
server_redraw_session(v3);
recalculate_sizes();
}
}
return xfree(a1);
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned int *a1, int a2)
{
__int64 v2; // rdx
__int64 v3; // r12

if ( a2 != -1 )
{
v2 = *a1;
if ( (unsigned int)v2 <= *((_DWORD *)&sessions + 2) - 1 )
{
v3 = *(_QWORD *)(sessions + 8 * v2);
if ( v3 && !(unsigned int)session_select(*(_QWORD *)(sessions + 8 * v2)) )
server_redraw_session(v3);
recalculate_sizes();
}
}
return xfree(a1);
}

original_code:
void
cmd_find_window_callback(void *data, int idx)
{
 struct cmd_find_window_data *cdata = data;
 struct session *s;
 if (idx != -1 && cdata->session <= ((&sessions)->num) - 1) {
  s = ((&sessions)->list[cdata->session]);
  if (s != ((void *)0) && session_select(s, idx) == 0)
   server_redraw_session(s);
  recalculate_sizes();
 }
 xfree(cdata);
}

variable_types: idx int

variable_types: struct cmd_find_window_data { unsigned int session; } *

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

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


decompiled_code:
void __fastcall screen_clear_selection(__int64 a1)
{
*(_DWORD *)(a1 + 48) = 0;
}

canonical_decompiled_code:
void __fastcall func6(__int64 a1)
{
*(_DWORD *)(a1 + 48) = 0;
}

original_code:
void
screen_clear_selection(struct screen *s)
{
 struct screen_sel *sel = &s->sel;
 sel->flag = 0;
}

variable_types: 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; } *

variable_types: struct screen_sel { int flag; unsigned int sx; unsigned int sy; unsigned int ex; unsigned int ey; struct grid_cell { unsigned char attr; unsigned char flags; unsigned char fg; unsigned char bg; unsigned char data; } cell; } *


decompiled_code:
__int64 __fastcall cmd_if_shell_callback(__int64 a1)
{
int v1; // eax
int v2; // edx
__int64 result; // rax
__int64 v4; // rbx
__int64 v5; // [rsp+0h] [rbp-28h] BYREF
__int64 v6[4]; // [rsp+8h] [rbp-20h] BYREF

v1 = *(_DWORD *)(a1 + 12);
v2 = BYTE1(v1);
result = v1 & 0x7F;
if ( !((unsigned int)result | v2) )
{
v4 = *(_QWORD *)(a1 + 56);
result = cmd_string_parse(*(_QWORD *)v4, &v5, v6);
if ( (_DWORD)result )
{
if ( v6[0] )
{
(*(void (__fastcall **)(__int64, void *))(v4 + 48))(v4 + 8, &unk_166);
result = xfree(v6[0]);
}
}
else
{
cmd_list_exec(v5, v4 + 8);
result = cmd_list_free(v5);
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
int v1; // eax
int v2; // edx
__int64 result; // rax
__int64 v4; // rbx
__int64 v5; // [rsp+0h] [rbp-28h] BYREF
__int64 v6[4]; // [rsp+8h] [rbp-20h] BYREF

v1 = *(_DWORD *)(a1 + 12);
v2 = BYTE1(v1);
result = v1 & 0x7F;
if ( !((unsigned int)result | v2) )
{
v4 = *(_QWORD *)(a1 + 56);
result = cmd_string_parse(*(_QWORD *)v4, &v5, v6);
if ( (_DWORD)result )
{
if ( v6[0] )
{
(*(void (__fastcall **)(__int64, void *))(v4 + 48))(v4 + 8, &unk_166);
result = xfree(v6[0]);
}
}
else
{
cmd_list_exec(v5, v4 + 8);
result = cmd_list_free(v5);
}
}
return result;
}

original_code:
void
cmd_if_shell_callback(struct job *job)
{
 struct cmd_if_shell_data *cdata = job->data;
 struct cmd_ctx *ctx = &cdata->ctx;
 struct cmd_list *cmdlist;
 char *cause;
 if (!(((job->status) & 0x7f) == 0) || (((job->status) & 0xff00) >> 8) != 0)
  return;
 if (cmd_string_parse(cdata->cmd, &cmdlist, &cause) != 0) {
  if (cause != ((void *)0)) {
   ctx->error(ctx, "%s", cause);
   xfree(cause);
  }
  return;
 }
 if (cmd_list_exec(cmdlist, ctx) < 0) {
  cmd_list_free(cmdlist);
  return;
 }
 cmd_list_free(cmdlist);
}

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

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

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

variable_types:
cause
char *

user_defined_types: struct cmd_if_shell_data { char *cmd; struct cmd_ctx ctx; }

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

user_defined_types: struct cmd_list { struct cmd *tqh_first; struct cmd **tqh_last; }

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 cmd { struct cmd_entry *entry; void *data; struct { struct cmd *tqe_next; struct cmd **tqe_prev; } qentry; }

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 screen { char *title; struct grid *grid; unsigned int cx; unsigned int cy; unsigned int rupper; unsigned int rlower; int mode; unsigned char *tabs; struct screen_sel sel; }

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

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

user_defined_types: struct 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 cmd_entry { char *name; char *alias; char *usage; int flags; unsigned long chflags; void (*init)(struct cmd *, int); int (*parse)(struct cmd *, int, char **, char **); int (*exec)(struct cmd *, struct cmd_ctx *); void (*free)(struct cmd *); unsigned long (*print)(struct cmd *, char *, unsigned long); }

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

user_defined_types: struct mode_key_tree { struct mode_key_binding *sph_root; }

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

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

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

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

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

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

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


original_code:
int
cmd_if_shell_exec(struct cmd *self, struct cmd_ctx *ctx)
{
 struct cmd_target_data *data = self->data;
 struct cmd_if_shell_data *cdata;
 struct job *job;
 cdata = xmalloc(sizeof *cdata);
 cdata->cmd = xstrdup(data->arg2);
 memcpy(&cdata->ctx, ctx, sizeof cdata->ctx);
 if (ctx->cmdclient != ((void *)0))
  ctx->cmdclient->references++;
 if (ctx->curclient != ((void *)0))
  ctx->curclient->references++;
 job = job_add(((void *)0), 0, ((void *)0),
     data->arg, cmd_if_shell_callback, cmd_if_shell_free, cdata);
 job_run(job);
 return (1);
}

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

variable_types:
ctx
struct cmd_ctx *

variable_types: struct cmd_target_data { unsigned long chflags; char *target; char *arg; char *arg2; } *

return_type: int

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

user_defined_types: struct cmd_if_shell_data { char *cmd; struct cmd_ctx ctx; }

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

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

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

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

user_defined_types: struct tty_keys { struct tty_key *rbh_root; }

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

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

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

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

user_defined_types: struct options_tree { struct options_entry *sph_root; }


decompiled_code:
__int64 __fastcall cmd_if_shell_free(_QWORD *a1)
{
__int64 v2; // rdi
__int64 v3; // rax

v2 = a1[2];
if ( v2 )
{
--*(_DWORD *)(v2 + 66376);
server_write_client(v2, 3LL, 0LL, 0LL);
}
v3 = a1[1];
if ( v3 )
--*(_DWORD *)(v3 + 66376);
xfree(*a1);
return xfree(a1);
}

original_code:
void
cmd_if_shell_free(void *data)
{
 struct cmd_if_shell_data *cdata = data;
 struct cmd_ctx *ctx = &cdata->ctx;
 if (ctx->cmdclient != ((void *)0)) {
  ctx->cmdclient->references--;
  server_write_client(ctx->cmdclient, MSG_EXIT, ((void *)0), 0);
 }
 if (ctx->curclient != ((void *)0))
  ctx->curclient->references--;
 xfree(cdata->cmd);
 xfree(cdata);
}

variable_types:
data
void *

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

user_defined_types: struct environ { struct environ_entry *rbh_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 mode_key_data { struct mode_key_tree *tree; int mode; }

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

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

user_defined_types: struct mode_key_tree { struct mode_key_binding *sph_root; }

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

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

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