LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O3/stetre[P]moonsndfile/src/structs.c
// Function: moonsndfile_checkchunk
chunknode_t *checkchunk(lua_State *L, int arg)
    {
    const char *id;
    const char *data;
    size_t id_size, datalen;
    chunknode_t *p;
    if(lua_isnoneornil(L, arg))
        { luaL_argerror(L, arg, errstring(ERR_NOTPRESENT)); return NULL; }
    if(lua_type(L, arg) != LUA_TTABLE)
        { luaL_argerror(L, arg, errstring(ERR_TABLE)); return NULL; }

    lua_getfield(L, arg, "id");
    id = luaL_checklstring(L, -1, &id_size);
    if(!id || id_size == 0 || id_size > 64)
        { lua_pop(L, 1); luaL_argerror(L, arg, "missing or invalid 'id' field"); return NULL; }
    lua_pop(L, 1);
    
    lua_getfield(L, arg, "data");
    data = luaL_optlstring(L, -1, NULL, &datalen);
    lua_pop(L, 1);
    
    p = (chunknode_t*)Malloc(L, sizeof(chunknode_t));
    if(id) memcpy(p->chunk.id, id, id_size);
    if(data && datalen > 0)
        {
        p->chunk.data = MallocNoErr(L, datalen);
        if(!p->chunk.data)
            { 
            freechunk(L, p);
            luaL_argerror(L, arg, errstring(ERR_MEMORY)); 
            return NULL;
            }
        memcpy(p->chunk.data, data, datalen);
        }
    return p;
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %esi, %ebx
movq %rdi, %r14
callq 0x4730
testl %eax, %eax
jle 0xaeb4
movq %r14, %rdi
movl %ebx, %esi
callq 0x4730
cmpl $0x5, %eax
jne 0xaebb
leaq 0x2bdf(%rip), %rdx      # 0xd9b7
movq %r14, %rdi
movl %ebx, %esi
callq 0x47e0
leaq 0x10(%rsp), %r15
movq %r14, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movq %r15, %rdx
callq 0x4380
movq %rax, %r12
movq (%r15), %r15
movq %r14, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x4080
testq %r12, %r12
je 0xaee7
addq $-0x41, %r15
cmpq $-0x41, %r15
jbe 0xaee7
leaq 0x34f8(%rip), %rdx      # 0xe320
movq %r14, %rdi
movl %ebx, %esi
callq 0x47e0
leaq 0x8(%rsp), %rbp
movq %r14, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
xorl %edx, %edx
movq %rbp, %rcx
callq 0x4270
movq %rax, %r13
movq %r14, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x4080
movl $0x58, %esi
movq %r14, %rdi
callq 0x41e0
movq %rax, %r15
leaq 0x8(%rax), %rdi
movq 0x10(%rsp), %rdx
movq %r12, %rsi
callq 0x44b0
testq %r13, %r13
setne %al
movq (%rbp), %rsi
testq %rsi, %rsi
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0xaed5
movq %r14, %rdi
callq 0x4390
movq %rax, 0x50(%r15)
testq %rax, %rax
je 0xaef5
movq 0x8(%rsp), %rdx
movq %rax, %rdi
movq %r13, %rsi
callq 0x44b0
jmp 0xaed5
movl $0x1, %edi
jmp 0xaec0
movl $0xfffffffc, %edi       # imm = 0xFFFFFFFC
callq 0x4660
movq %r14, %rdi
movl %ebx, %esi
movq %rax, %rdx
callq 0x4110
xorl %r15d, %r15d
movq %r15, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x37c2(%rip), %rdx      # 0xe6b0
movq %r14, %rdi
movl %ebx, %esi
jmp 0xaecd
movq %r14, %rdi
movq %r15, %rsi
callq 0x4240
movl $0xfffffffa, %edi       # imm = 0xFFFFFFFA
jmp 0xaec0
// File: /workspace/github_c_makefile_star2_O3/stetre[P]moonsndfile/src/structs.c
// Function: moonsndfile_pushchunk
int pushchunk(lua_State *L, chunk_t *p)
    {
    lua_newtable(L);
    lua_pushlstring(L, p->id, p->id_size);
    lua_setfield(L, -2, "id");
    if(p->data && p->datalen > 0)
        {
        lua_pushlstring(L, (const char*)p->data, p->datalen);
        lua_setfield(L, -2, "data");
        }
    return 1;
    }

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
xorl %esi, %esi
xorl %edx, %edx
callq 0x4220
movl 0x40(%r14), %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x4650
leaq 0x2a87(%rip), %rdx      # 0xd9b7
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x4300
movq 0x48(%r14), %rsi
testq %rsi, %rsi
je 0xaf6b
movl 0x44(%r14), %edx
testq %rdx, %rdx
je 0xaf6b
movq %rbx, %rdi
callq 0x4650
leaq 0x33c2(%rip), %rdx      # 0xe320
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x4300
movl $0x1, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O3/stetre[P]moonsndfile/src/utils.c
// Function: moonsndfile_tablelen
int tablelen(lua_State *L, int arg)
/* counts the elements of the table at arg */
    {
    int n = 0;
    if(!lua_istable(L, arg))
        return luaL_error(L, errstring(ERR_TABLE));
    lua_pushnil(L);
    while(lua_next(L, arg) != 0)
        { lua_pop(L, 1); n++; }
    return n;
    }

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movl %esi, %ebp
movq %rdi, %rbx
callq 0x4730
cmpl $0x5, %eax
jne 0xbcb5
movq %rbx, %rdi
callq 0x46d0
movq %rbx, %rdi
movl %ebp, %esi
callq 0x4150
xorl %r14d, %r14d
testl %eax, %eax
je 0xbcca
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x4080
incl %r14d
movq %rbx, %rdi
movl %ebp, %esi
callq 0x4150
jmp 0xbc95
leaq 0x2b5c(%rip), %rsi      # 0xe818
movq %rbx, %rdi
xorl %eax, %eax
popq %rbx
popq %r14
popq %rbp
jmp 0x46c0
movl %r14d, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/stetre[P]moonsndfile/src/utils.c
// Function: moonsndfile_testboolean
int testboolean(lua_State *L, int arg, int *err)
    {
    if(!lua_isboolean(L, arg))
        { *err = ERR_TYPE; return 0; }
    *err = 0;
    return lua_toboolean(L, arg);
    }

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rdx, %rbx
movl %esi, %ebp
movq %rdi, %r14
callq 0x4730
cmpl $0x1, %eax
jne 0xbf5f
movl $0x0, (%rbx)
movq %r14, %rdi
movl %ebp, %esi
popq %rbx
popq %r14
popq %rbp
jmp 0x40d0
movl $0xfffffffe, (%rbx)     # imm = 0xFFFFFFFE
xorl %eax, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/stetre[P]moonsndfile/src/utils.c
// Function: moonsndfile_nil_sndfileerror
int nil_sndfileerror(lua_State *L, sndfile_t sndfile)
    { 
    const char *str = sf.strerror(sndfile);
    lua_pushnil(L);
    lua_pushstring(L, str ? str : "unknown error");
    return 2;
    }

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x700c(%rip), %rax      # 0x12fe0
movq %rsi, %rdi
callq *0x20(%rax)
movq %rax, %r14
movq %rbx, %rdi
callq 0x46d0
testq %r14, %r14
leaq 0x28c1(%rip), %rsi      # 0xe8b0
cmovneq %r14, %rsi
movq %rbx, %rdi
callq 0x4780
movl $0x2, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O3/stetre[P]moonsndfile/src/version.c
// Function: VersionNumbers
static int VersionNumbers(lua_State *L)
    {
    lua_pushinteger(L, VerMajor);
    lua_pushinteger(L, VerMinor);
    lua_pushinteger(L, VerPatch);
    return 3;
    }

// Assembly:
pushq %rbx
movq %rdi, %rbx
movl 0x7450(%rip), %esi      # 0x1358c
callq 0x4320
movl 0x7449(%rip), %esi      # 0x13590
movq %rbx, %rdi
callq 0x4320
movl 0x743f(%rip), %esi      # 0x13594
movq %rbx, %rdi
callq 0x4320
movl $0x3, %eax
popq %rbx
retq
nopw %cs:(%rax,%rax)
nop
// File: /workspace/github_c_makefile_star2_O3/agl[P]obstcp/obstcp-redir.c
// Function: connect_cb
static void
connect_cb(int fd, short events, void *arg) {
  struct connection *conn = (struct connection *) arg;

  int err;
  socklen_t errlen = sizeof(err);
  if (getsockopt(conn->outfd, SOL_SOCKET, SO_ERROR, &err, &errlen)) {
    perror("getsockopt for connection result");
    connection_free(conn);
    return;
  }

  if (err) {
    fprintf(stderr, "Connection error: %s\n", strerror(err));
    connection_free(conn);
    return;
  }

  connection_setevents(conn);

  return;
}

// Assembly:
pushq %rbx
subq $0x10, %rsp
movq %rdx, %rbx
leaq 0xc(%rsp), %r8
movl $0x4, (%r8)
movl 0x1cc(%rdx), %edi
leaq 0x8(%rsp), %rcx
movl $0x1, %esi
movl $0x4, %edx
callq 0x1100
testl %eax, %eax
jne 0x18b1
movl 0x8(%rsp), %edi
testl %edi, %edi
jne 0x18c7
movq %rbx, %rdi
callq 0x18d1
addq $0x10, %rsp
popq %rbx
retq
leaq 0x6876(%rip), %rdi      # 0x812e
callq 0x11c0
movq %rbx, %rdi
callq 0x19c5
jmp 0x18ab
movq %rbx, %rsi
callq 0x130c
jmp 0x18ab
// File: /workspace/github_c_makefile_star2_O3/agl[P]obstcp/obstcp-redir.c
// Function: connection_setevents
static void
connection_setevents(struct connection *conn) {
  const short outev = (conn->outqlen < QUEUE_MAX ? EV_READ : 0) |
                      EV_PERSIST |
                      (conn->outqhead ? EV_WRITE : 0);
  const short obsev = (conn->obsqlen < QUEUE_MAX ? EV_READ : 0) |
                      EV_PERSIST |
                      (conn->obsqhead ? EV_WRITE : 0);

  if (conn->outevent.ev_events != outev) {
    if (conn->outevent.ev_events) {
      event_del(&conn->outevent);
    }
    event_set(&conn->outevent, conn->outfd, outev, connection_out_cb, conn);
    event_add(&conn->outevent, NULL);
  }

  if (conn->obsevent.ev_events != obsev) {
    if (conn->obsevent.ev_events) {
      event_del(&conn->obsevent);
    }
    event_set(&conn->obsevent, conn->fd, obsev, connection_obs_cb, conn);
    event_add(&conn->obsevent, NULL);
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl $0x8000, %eax           # imm = 0x8000
xorl %ecx, %ecx
cmpl %eax, 0x300(%rdi)
setb %cl
xorl %edx, %edx
cmpq $0x0, 0x2d0(%rdi)
setne %dl
shll $0x2, %edx
leal (%rdx,%rcx,2), %r15d
addl $0x10, %r15d
xorl %ecx, %ecx
cmpl %eax, 0x304(%rdi)
setb %cl
xorl %eax, %eax
cmpq $0x0, 0x2e0(%rdi)
setne %al
shll $0x2, %eax
leal (%rax,%rcx,2), %ebp
addl $0x10, %ebp
movzwl 0x2b8(%rdi), %eax
cmpw %r15w, %ax
je 0x196b
leaq 0x250(%rbx), %r14
testw %ax, %ax
je 0x1945
movq %r14, %rdi
callq 0x10a0
movl 0x1cc(%rbx), %esi
movzwl %r15w, %edx
leaq 0x10b(%rip), %rcx       # 0x1a61
movq %r14, %rdi
movq %rbx, %r8
callq 0x1190
movq %r14, %rdi
xorl %esi, %esi
callq 0x1120
movzwl 0x238(%rbx), %eax
cmpw %bp, %ax
jne 0x1982
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1d0(%rbx), %r14
testw %ax, %ax
je 0x1996
movq %r14, %rdi
callq 0x10a0
movl 0x1c8(%rbx), %esi
movzwl %bp, %edx
leaq 0x28d(%rip), %rcx       # 0x1c33
movq %r14, %rdi
movq %rbx, %r8
callq 0x1190
movq %r14, %rdi
xorl %esi, %esi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x1120
// File: /workspace/github_c_makefile_star2_O3/agl[P]obstcp/obstcp-redir.c
// Function: connection_free
static void
connection_free(struct connection *conn) {
  struct chunk *c, *next;

  if (conn->outevent.ev_events) {
    event_del(&conn->outevent);
  }

  if (conn->obsevent.ev_events) {
    event_del(&conn->obsevent);
  }

  close(conn->fd);
  close(conn->outfd);

  for (c = conn->outqhead; c; c = next) {
    next = c->next;
    free(c);
  }

  for (c = conn->obsqhead; c; c = next) {
    next = c->next;
    free(c);
  }

  obstcp_rbuf_free(&conn->rbuf);

  free(conn);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
cmpw $0x0, 0x2b8(%rdi)
je 0x19e2
leaq 0x250(%rbx), %rdi
callq 0x10a0
cmpw $0x0, 0x238(%rbx)
je 0x19f8
leaq 0x1d0(%rbx), %rdi
callq 0x10a0
movl 0x1c8(%rbx), %edi
callq 0x10e0
movl 0x1cc(%rbx), %edi
callq 0x10e0
movq 0x2d0(%rbx), %rdi
testq %rdi, %rdi
je 0x1a2a
movq (%rdi), %r14
callq 0x1030
movq %r14, %rdi
testq %r14, %r14
jne 0x1a1a
movq 0x2e0(%rbx), %rdi
testq %rdi, %rdi
je 0x1a46
movq (%rdi), %r14
callq 0x1030
movq %r14, %rdi
testq %r14, %r14
jne 0x1a36
leaq 0x198(%rbx), %rdi
callq 0x3c9b
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x1030
// File: /workspace/github_c_makefile_star2_O3/agl[P]obstcp/obstcp-redir.c
// Function: connection_obs_cb
static void
connection_obs_cb(int fd, short events, void *arg) {
  struct connection *conn = (struct connection *) arg;

  if (EV_READ & events) {
    int queued;
    if (ioctl(conn->fd, SIOCINQ, &queued)) {
      perror("ioctl");
      connection_free(conn);
      return;
    }
    if (!queued) queued = 16;

    struct chunk *c = malloc(sizeof(struct chunk) + queued);
    if (!c) return;
    memset(c, 0, sizeof(struct chunk));

    const ssize_t n =
      obstcp_rbuf_read_fd(&conn->rbuf, conn->fd, c->data, queued);

    if (n < 0) {
      if (errno == EAGAIN || errno == EWOULDBLOCK) return;
      perror("read");
      free(c);
      connection_free(conn);
      return;
    } else if (n == 0) {
      free(c);
      connection_free(conn);
      return;
    } else {
      c->length = n;
      const char was_empty_q = conn->outqhead ? 0 : 1;

      conn->outqlen += c->length;
      if (conn->pendingqhead) {
        chunks_move(&conn->outqhead, &conn->outqtail,
                    &conn->pendingqhead, &conn->pendingqtail);
      }
      chunk_nq(c, &conn->outqhead, &conn->outqtail);
      if (was_empty_q) if (!connection_out_write(conn)) return;
    }
  }

  if (EV_WRITE & events) {
    if (!connection_obs_write(conn)) return;
  }

  connection_setevents(conn);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdx, %rbx
movl %esi, %ebp
testb $0x2, %bpl
jne 0x1c69
movzwl %bp, %eax
testb $0x4, %al
je 0x1c5c
movq %rbx, %rdi
callq 0x1de0
testl %eax, %eax
je 0x1dd5
movq %rbx, %rdi
callq 0x18d1
jmp 0x1dd5
movl 0x1c8(%rbx), %edi
leaq 0x4(%rsp), %rdx
movl $0x541b, %esi           # imm = 0x541B
xorl %eax, %eax
callq 0x10d0
testl %eax, %eax
jne 0x1dc1
movl 0x4(%rsp), %eax
testl %eax, %eax
jne 0x1c9d
movl $0x10, 0x4(%rsp)
movl $0x10, %eax
movslq %eax, %r15
leaq 0x18(%r15), %rdi
callq 0x1160
testq %rax, %rax
je 0x1dd5
movq %rax, %r14
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movq $0x0, 0x10(%rax)
leaq 0x198(%rbx), %rdi
movl 0x1c8(%rbx), %esi
movq %rax, %rdx
addq $0x18, %rdx
movq %r15, %rcx
callq 0x40bb
testq %rax, %rax
js 0x1d6d
je 0x1d83
movl %eax, 0x10(%r14)
movq 0x2d0(%rbx), %rcx
movq 0x2d8(%rbx), %rdi
addl %eax, 0x300(%rbx)
movq 0x2f0(%rbx), %rdx
testq %rdx, %rdx
je 0x1d8d
leaq 0x2f0(%rbx), %rax
movq %rdx, %rsi
movq (%rdx), %rdx
movq %rdi, 0x8(%rsi)
movq $0x0, (%rsi)
movq %rsi, 0x2d8(%rbx)
cmpq $0x0, 0x2d0(%rbx)
jne 0x1d42
movq %rsi, 0x2d0(%rbx)
movq %rsi, %rdi
testq %rdx, %rdx
jne 0x1d19
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movq %rsi, 0x8(%r14)
movq $0x0, (%r14)
movq %r14, 0x2d8(%rbx)
testq %rcx, %rcx
jne 0x1c45
jmp 0x1daf
callq 0x1050
cmpl $0xb, (%rax)
je 0x1dd5
leaq 0x63ed(%rip), %rdi      # 0x816b
callq 0x11c0
movq %r14, %rdi
callq 0x1030
jmp 0x1dcd
movq %rdi, 0x8(%r14)
movq $0x0, (%r14)
movq %r14, 0x2d8(%rbx)
testq %rcx, %rcx
jne 0x1c45
movq %r14, 0x2d0(%rbx)
movq %rbx, %rdi
callq 0x1e65
testl %eax, %eax
jne 0x1c45
jmp 0x1dd5
leaq 0x639d(%rip), %rdi      # 0x8165
callq 0x11c0
movq %rbx, %rdi
callq 0x19c5
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/agl[P]obstcp/obstcp-redir.c
// Function: connection_obs_write
static int
connection_obs_write(struct connection *conn) {
  struct chunk *c, *next;
  for (c = conn->obsqhead; c; c = next) {
    next = c->next;
    if (!connection_write(c, conn->fd)) {
      connection_free(conn);
      return 0;
    }
    if (c->done == c->length) {
      conn->obsqlen -= c->length;
      chunk_free(&conn->obsqhead, &conn->obsqtail);
    } else {
      break;
    }
  }

  return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq 0x2e0(%rdi), %r13
movl $0x1, %ebx
testq %r13, %r13
je 0x1e54
movq %rdi, %r14
leaq 0x2e0(%rdi), %r15
leaq 0x2e8(%rdi), %r12
movq (%r13), %rbp
movl 0x1c8(%r14), %esi
movq %r13, %rdi
callq 0x1eea
testl %eax, %eax
je 0x1e4a
movl 0x14(%r13), %eax
cmpl 0x10(%r13), %eax
jne 0x1e54
subl %eax, 0x304(%r14)
movq %r15, %rdi
movq %r12, %rsi
callq 0x1f58
movq %rbp, %r13
testq %rbp, %rbp
jne 0x1e0d
jmp 0x1e54
movq %r14, %rdi
callq 0x19c5
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/agl[P]obstcp/obstcp-redir.c
// Function: connection_out_write
static int
connection_out_write(struct connection *conn) {
  struct chunk *c, *next;
  for (c = conn->outqhead; c; c = next) {
    next = c->next;
    if (!connection_write(c, conn->outfd)) {
      connection_free(conn);
      return 0;
    }
    if (c->done == c->length) {
      conn->outqlen -= c->length;
      chunk_free(&conn->outqhead, &conn->outqtail);
    } else {
      break;
    }
  }

  return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq 0x2d0(%rdi), %r13
movl $0x1, %ebx
testq %r13, %r13
je 0x1ed9
movq %rdi, %r14
leaq 0x2d0(%rdi), %r15
leaq 0x2d8(%rdi), %r12
movq (%r13), %rbp
movl 0x1cc(%r14), %esi
movq %r13, %rdi
callq 0x1eea
testl %eax, %eax
je 0x1ecf
movl 0x14(%r13), %eax
cmpl 0x10(%r13), %eax
jne 0x1ed9
subl %eax, 0x300(%r14)
movq %r15, %rdi
movq %r12, %rsi
callq 0x1f58
movq %rbp, %r13
testq %rbp, %rbp
jne 0x1e92
jmp 0x1ed9
movq %r14, %rdi
callq 0x19c5
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/agl[P]obstcp/obstcp-redir.c
// Function: connection_write
static int
connection_write(struct chunk *c, int fd) {
  if (c->length == c->done) return 1;

  ssize_t n;
  do {
    n = write(fd, c->data + c->done, c->length - c->done);
  } while (n == -1 && errno == EINTR);

  if (n < 0) {
    if (errno == EAGAIN || errno == EWOULDBLOCK) return 1;
    return 0;
  } else if (n == 0) {
    return 0;
  } else {
    c->done += n;
    return 1;
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl 0x10(%rdi), %eax
movl $0x1, %ebx
cmpl 0x14(%rdi), %eax
je 0x1f47
movl %esi, %ebp
movq %rdi, %r14
leaq 0x18(%rdi), %r15
movl 0x10(%r14), %edx
movl 0x14(%r14), %esi
subl %esi, %edx
addq %r15, %rsi
movl %ebp, %edi
callq 0x1090
cmpq $-0x1, %rax
jne 0x1f2d
callq 0x1050
cmpl $0x4, (%rax)
je 0x1f07
jmp 0x1f3f
testq %rax, %rax
js 0x1f3a
je 0x1f54
addl %eax, 0x14(%r14)
jmp 0x1f47
callq 0x1050
xorl %ebx, %ebx
cmpl $0xb, (%rax)
sete %bl
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
xorl %ebx, %ebx
jmp 0x1f47
// File: /workspace/github_c_makefile_star2_O3/agl[P]obstcp/obstcp-redir.c
// Function: chunk_free
static void
chunk_free(struct chunk **head, struct chunk **tail) {
  if ((*head)->next)
    (*head)->next->last = NULL;

  struct chunk *next = (*head)->next;
  free(*head);

  if (*tail == *head) *tail = NULL;
  *head = next;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rsi, %r14
movq %rdi, %rbx
movq (%rdi), %rdi
movq (%rdi), %rax
testq %rax, %rax
je 0x1f7e
movq $0x0, 0x8(%rax)
movq (%rbx), %rdi
movq (%rdi), %r15
jmp 0x1f81
xorl %r15d, %r15d
callq 0x1030
movq (%r14), %rax
cmpq (%rbx), %rax
jne 0x1f95
movq $0x0, (%r14)
movq %r15, (%rbx)
popq %rbx
popq %r14
popq %r15
retq
nop
// File: /workspace/github_c_makefile_star2_O3/qq-smart[P]qq_sh_server/os/qq_alloc.c
// Function: qq_alloc
void *
qq_alloc(size_t size)
{
    void  *p;

    p = malloc(size);
    if (p == NULL) {
        qq_log_error(errno, "malloc(%uz) failed", size);
    }

    return p;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rdi, %r14
callq 0x2340
movq %rax, %rbx
testq %rax, %rax
jne 0x246b
callq 0x2030
movl (%rax), %edi
leaq 0x7ba3(%rip), %rsi      # 0xa004
movq %r14, %rdx
xorl %eax, %eax
callq 0x6b27
movq %rbx, %rax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/qq-smart[P]qq_sh_server/app/qq_android_app.c
// Function: qq_android_app_init
qq_int_t
qq_android_app_init(qq_cycle_t *cycle)
{
    if (qq_add_listening_config(SOCK_STREAM,
        QQ_ANDROID_APP_TCP_LISTENING_PORT,
        QQ_ANDROID_APP_TCP_LISTENING_POOL_SIZE,
        qq_android_app_init_connection_handler) == QQ_ERROR)
    {
        qq_log_error(0, "qq_android_app_init()->qq_add_listening_config() failed");
        return QQ_ERROR;
    }

    return QQ_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
leaq 0x37(%rip), %rcx        # 0x252a
movl $0x400, %edx            # imm = 0x400
movl $0x1, %edi
movl $0x2af8, %esi           # imm = 0x2AF8
callq 0x6464
cmpq $-0x1, %rax
je 0x2511
xorl %eax, %eax
jmp 0x2528
leaq 0x7b19(%rip), %rsi      # 0xa031
xorl %edi, %edi
xorl %eax, %eax
callq 0x6b27
movq $-0x1, %rax
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/qq-smart[P]qq_sh_server/app/qq_android_app.c
// Function: qq_android_app_init_connection_handler
static void
qq_android_app_init_connection_handler(qq_connection_t *c)
{
    qq_event_t   *rev, *wev;

    qq_log_debug("qq_android_app_init_connection_handler()");

    rev = c->read;
    rev->handler = qq_android_app_read_event_handler;

    wev = c->write;
    wev->handler = qq_android_app_write_event_handler;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x7b45(%rip), %rdi      # 0xa07f
xorl %eax, %eax
callq 0x6c74
movq 0x8(%rbx), %rax
leaq 0x3b(%rip), %rcx        # 0x2587
movq %rcx, 0x10(%rax)
movq 0x10(%rbx), %rax
leaq 0x74(%rip), %rcx        # 0x25cf
movq %rcx, 0x10(%rax)
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/qq-smart[P]qq_sh_server/app/qq_app.c
// Function: qq_app_init
qq_int_t
qq_app_init(qq_cycle_t *cycle)
{
    if (qq_mysql_init() == QQ_ERROR) {
        qq_log_error(0, "qq_mysql_init() failed");
        return QQ_ERROR;
    }

    if (qq_ios_app_init(cycle) == QQ_ERROR) {
        qq_log_error(0, "qq_ios_app_init() failed");
        return QQ_ERROR;
    }

    if (qq_android_app_init(cycle) == QQ_ERROR) {
        qq_log_error(0, "qq_android_app_init() failed");
        return QQ_ERROR;
    }

    if (qq_wifi_device_init(cycle) == QQ_ERROR) {
        qq_log_error(0, "qq_wifi_device_init() failed");
        return QQ_ERROR;
    }

    if (qq_video_audio_device_init(cycle) == QQ_ERROR) {
        qq_log_error(0, "qq_video_audio_device_init() failed");
        return QQ_ERROR;
    }

    return QQ_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
callq 0x79b8
cmpq $-0x1, %rax
je 0x2634
movq %rbx, %rdi
callq 0x3bec
cmpq $-0x1, %rax
je 0x263d
movq %rbx, %rdi
callq 0x24e8
cmpq $-0x1, %rax
je 0x2646
movq %rbx, %rdi
callq 0x8d1c
cmpq $-0x1, %rax
je 0x264f
movq %rbx, %rdi
callq 0x8c88
cmpq $-0x1, %rax
je 0x2658
xorl %eax, %eax
jmp 0x266f
leaq 0x7ab6(%rip), %rsi      # 0xa0f1
jmp 0x265f
leaq 0x7ac4(%rip), %rsi      # 0xa108
jmp 0x265f
leaq 0x7ad4(%rip), %rsi      # 0xa121
jmp 0x265f
leaq 0x7ae8(%rip), %rsi      # 0xa13e
jmp 0x265f
leaq 0x7afc(%rip), %rsi      # 0xa15b
xorl %edi, %edi
xorl %eax, %eax
callq 0x6b27
movq $-0x1, %rax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/qq-smart[P]qq_sh_server/app/qq_app.c
// Function: qq_app_done
void
qq_app_done(qq_cycle_t *cycle)
{
    qq_log_debug("qq_app_done()");

    qq_mysql_close();
    qq_ios_app_done();
    qq_android_app_done();
    qq_wifi_device_done();
    qq_video_audio_device_done();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
leaq 0x7afe(%rip), %rdi      # 0xa17f
xorl %eax, %eax
callq 0x6c74
callq 0x7a53
callq 0x3cc7
callq 0x2566
callq 0x8ec9
popq %rbp
jmp 0x8d07
// File: /workspace/github_c_makefile_star2_O3/qq-smart[P]qq_sh_server/app/qq_app.c
// Function: qq_app_close_connection
void
qq_app_close_connection(qq_connection_t *c)
{
    qq_pool_t  *pool;

    qq_log_debug("qq_app_close_connection(fd:%d)", c->fd);

    c->destroyed = 1;

    pool = c->pool;

    qq_close_connection(c);

    qq_destroy_pool(pool);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
movl 0x18(%rdi), %esi
leaq 0x7ad7(%rip), %rdi      # 0xa18d
xorl %eax, %eax
callq 0x6c74
orb $0x4, 0x98(%rbx)
movq 0x40(%rbx), %r14
movq %rbx, %rdi
callq 0x285c
movq %r14, %rdi
popq %rbx
popq %r14
popq %rbp
jmp 0x2338
// File: /workspace/github_c_makefile_star2_O3/qq-smart[P]qq_sh_server/core/qq_buf.c
// Function: qq_create_temp_buf
qq_buf_t *
qq_create_temp_buf(qq_pool_t *pool, size_t size)
{
    qq_buf_t *b;

    b = qq_calloc_buf(pool);
    if (b == NULL) {
        return NULL;
    }

    b->start = qq_palloc(pool, size);
    if (b->start == NULL) {
        return NULL;
    }

    b->pos = b->start;
    b->last = b->start;
    b->end = b->last + size;
    b->temporary = 1;

    return b;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %r15
movl $0x38, %esi
callq 0x7d16
testq %rax, %rax
je 0x2726
movq %rax, %rbx
movq %r15, %rdi
movq %r14, %rsi
callq 0x7cd0
movq %rax, 0x20(%rbx)
testq %rax, %rax
je 0x2726
movq %rax, (%rbx)
movq %rax, 0x8(%rbx)
addq %rax, %r14
movq %r14, 0x28(%rbx)
orb $0x1, 0x30(%rbx)
jmp 0x2728
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O3/qq-smart[P]qq_sh_server/core/qq_connection.c
// Function: qq_close_connection
void
qq_close_connection(qq_connection_t *c)
{
    qq_socket_t  fd;

    if (c->fd == (qq_socket_t) -1) {
        qq_log_error(0, "qq_close_connection() connection already closed");
        return;
    }

    if (c->read->timer_set) {
        qq_event_del_timer(c->read);
    }

    if (c->write->timer_set) {
        qq_event_del_timer(c->write);
    }

    qq_epoll_del_connection(c);

    if (c->read->posted) {
        qq_delete_posted_event(c->read);
    }

    if (c->write->posted) {
        qq_delete_posted_event(c->write);
    }

    c->read->closed = 1;
    c->write->closed = 1;

    qq_free_connection(c);

    fd = c->fd;
    c->fd = (qq_socket_t) -1;

    if (close(fd) == -1) {
        qq_log_error(errno, "qq_close_connection(fd:%d) failed", fd);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
cmpl $-0x1, 0x18(%rdi)
je 0x2970
movq %rdi, %rbx
movq 0x8(%rdi), %r14
testb $0x8, 0x9(%r14)
je 0x2890
leaq 0x20(%r14), %rsi
leaq 0xca8a(%rip), %rdi      # 0xf310
callq 0x81c4
andb $-0x9, 0x9(%r14)
movq 0x10(%rbx), %r14
testb $0x8, 0x9(%r14)
je 0x28b0
leaq 0x20(%r14), %rsi
leaq 0xca6a(%rip), %rdi      # 0xf310
callq 0x81c4
andb $-0x9, 0x9(%r14)
movq %rbx, %rdi
callq 0x2df1
movq 0x8(%rbx), %rax
movl 0x8(%rax), %ecx
testw %cx, %cx
jns 0x28ee
andl $0xffff7fff, %ecx       # imm = 0xFFFF7FFF
movl %ecx, 0x8(%rax)
movq 0x8(%rbx), %rsi
movq 0x48(%rsi), %rax
movq 0x50(%rsi), %rcx
movq %rax, (%rcx)
movq %rcx, 0x8(%rax)
leaq 0x793a(%rip), %rdi      # 0xa221
xorl %eax, %eax
callq 0x6c74
movq 0x10(%rbx), %rax
movl 0x8(%rax), %ecx
testw %cx, %cx
jns 0x2924
andl $0xffff7fff, %ecx       # imm = 0xFFFF7FFF
movl %ecx, 0x8(%rax)
movq 0x10(%rbx), %rsi
movq 0x48(%rsi), %rax
movq 0x50(%rsi), %rcx
movq %rax, (%rcx)
movq %rcx, 0x8(%rax)
leaq 0x7904(%rip), %rdi      # 0xa221
xorl %eax, %eax
callq 0x6c74
movq 0x8(%rbx), %rax
movl $0x10000, %ecx          # imm = 0x10000
orl %ecx, 0x8(%rax)
movq 0x10(%rbx), %rax
orl %ecx, 0x8(%rax)
leaq 0xc972(%rip), %rax      # 0xf2b0
movq (%rax), %rcx
movq 0x18(%rcx), %rcx
movq %rcx, (%rbx)
movq (%rax), %rax
movq %rbx, 0x18(%rax)
incq 0x20(%rax)
movl 0x18(%rbx), %r14d
movl $0xffffffff, 0x18(%rbx) # imm = 0xFFFFFFFF
movl %r14d, %edi
callq 0x2320
cmpl $-0x1, %eax
je 0x2984
popq %rbx
popq %r14
popq %rbp
retq
leaq 0x787a(%rip), %rsi      # 0xa1f1
xorl %edi, %edi
xorl %eax, %eax
popq %rbx
popq %r14
popq %rbp
jmp 0x6b27
callq 0x2030
movl (%rax), %edi
leaq 0x78ad(%rip), %rsi      # 0xa23f
movl %r14d, %edx
xorl %eax, %eax
popq %rbx
popq %r14
popq %rbp
jmp 0x6b27
// File: /workspace/github_c_makefile_star2_O3/qq-smart[P]qq_sh_server/core/qq_cycle.c
// Function: qq_cycle_init
qq_int_t
qq_cycle_init(void)
{
    qq_pool_t          *pool;
    qq_cycle_t         *cycle;

    pool = qq_create_pool(QQ_CYCLE_POOL_SIZE);
    if (pool == NULL) {
        qq_log_error(0, "qq_create_pool(%d) failed", QQ_CYCLE_POOL_SIZE);
        return QQ_ERROR;
    }

    cycle = qq_pcalloc(pool, sizeof(qq_cycle_t));
    if (cycle == NULL) {
        qq_log_error(0, "qq_pcalloc() failed");
        qq_destroy_pool(pool);
        return QQ_ERROR;
    }
    cycle->pool = pool;
    qq_cycle = cycle;

    if (qq_app_init(cycle) == QQ_ERROR) {
        qq_log_error(0, "qq_app_init() failed");
        return QQ_ERROR;
    }

    if (qq_create_listening(cycle) == QQ_ERROR) {
        qq_log_error(0, "qq_create_listening() failed");
        return QQ_ERROR;
    }

    if (qq_open_listening_sockets(cycle) == QQ_ERROR) {
        qq_log_error(0, "qq_open_listening_sockets() failed");
        return QQ_ERROR;
    }

    if (qq_configure_listening_sockets(cycle) == QQ_ERROR) {
        qq_log_error(0, "qq_configure_listening_sockets() failed");
        return QQ_ERROR;
    }

    if (qq_event_init(cycle) == QQ_ERROR) {
        qq_log_error(0, "qq_event_init() failed");
        return QQ_ERROR;
    }

    return QQ_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movl $0x4000, %edi           # imm = 0x4000
callq 0x7ca0
testq %rax, %rax
je 0x2a22
movq %rax, %r14
movl $0x58, %esi
movq %rax, %rdi
callq 0x7d16
testq %rax, %rax
je 0x2a39
movq %rax, %rbx
movq %r14, (%rax)
movq %rax, 0xc8d8(%rip)      # 0xf2b0
movq %rax, %rdi
callq 0x25e4
cmpq $-0x1, %rax
je 0x2a53
movq %rbx, %rdi
callq 0x64f1
cmpq $-0x1, %rax
je 0x2a5c
movq %rbx, %rdi
callq 0x661e
cmpq $-0x1, %rax
je 0x2a65
movq %rbx, %rdi
callq 0x68bb
cmpq $-0x1, %rax
je 0x2a6e
movq %rbx, %rdi
callq 0x3114
cmpq $-0x1, %rax
je 0x2a77
xorl %eax, %eax
jmp 0x2a8e
leaq 0x7838(%rip), %rsi      # 0xa261
xorl %edi, %edi
movl $0x4000, %edx           # imm = 0x4000
xorl %eax, %eax
callq 0x6b27
jmp 0x2a87
leaq 0x783b(%rip), %rsi      # 0xa27b
xorl %edi, %edi
xorl %eax, %eax
callq 0x6b27
movq %r14, %rdi
callq 0x2338
jmp 0x2a87
leaq 0x7835(%rip), %rsi      # 0xa28f
jmp 0x2a7e
leaq 0x7841(%rip), %rsi      # 0xa2a4
jmp 0x2a7e
leaq 0x7855(%rip), %rsi      # 0xa2c1
jmp 0x2a7e
leaq 0x786f(%rip), %rsi      # 0xa2e4
jmp 0x2a7e
leaq 0x788e(%rip), %rsi      # 0xa30c
xorl %edi, %edi
xorl %eax, %eax
callq 0x6b27
movq $-0x1, %rax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/qq-smart[P]qq_sh_server/core/qq_cycle.c
// Function: qq_cycle_done
void
qq_cycle_done(void)
{
    qq_log_debug("qq_cycle_done()");

    qq_close_listening_sockets(qq_cycle);

    qq_app_done(qq_cycle);

    qq_event_done(qq_cycle);

    qq_destroy_pool(qq_cycle->pool);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
leaq 0x7885(%rip), %rdi      # 0xa323
xorl %eax, %eax
callq 0x6c74
movq 0xc804(%rip), %rdi      # 0xf2b0
callq 0x695d
movq 0xc7f8(%rip), %rdi      # 0xf2b0
callq 0x2676
movq 0xc7ec(%rip), %rdi      # 0xf2b0
callq 0x3396
movq 0xc7e0(%rip), %rax      # 0xf2b0
movq (%rax), %rdi
popq %rbp
jmp 0x2338
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O3/qq-smart[P]qq_sh_server/event/qq_epoll.c
// Function: qq_epoll_init
qq_int_t
qq_epoll_init(void)
{
    if (ep == -1) {
        ep = epoll_create(QQ_CONNECTION_NUMBER);

        if (ep == -1) {
            qq_log_error(errno, "epoll_create() failed");
            return QQ_ERROR;
        }
    }

    nevents = QQ_EPOLL_EVENT_NUMBER;
    if (event_list) {
        free(event_list);
    }
    event_list = qq_alloc(sizeof(struct epoll_event) * nevents);
    if (event_list == NULL) {
        qq_log_error(0, "epoll_event malloc(%d) failed", nevents);
        return QQ_ERROR;
    }

    return QQ_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
cmpl $-0x1, 0xc6c9(%rip)     # 0xf1b0
jne 0x2afe
movl $0x4e20, %edi           # imm = 0x4E20
callq 0x2310
movl %eax, 0xc6b7(%rip)      # 0xf1b0
cmpl $-0x1, %eax
je 0x2b47
movb $0x1, 0xc7b3(%rip)      # 0xf2b8
movq 0xc7b4(%rip), %rdi      # 0xf2c0
testq %rdi, %rdi
je 0x2b16
callq 0x2338
movl $0x1d4c0, %edi          # imm = 0x1D4C0
callq 0x243c
movq %rax, 0xc799(%rip)      # 0xf2c0
testq %rax, %rax
je 0x2b30
xorl %eax, %eax
jmp 0x2b63
leaq 0x7812(%rip), %rsi      # 0xa349
movl $0x2710, %edx           # imm = 0x2710
xorl %edi, %edi
xorl %eax, %eax
callq 0x6b27
jmp 0x2b5c
callq 0x2030
movl (%rax), %edi
leaq 0x77de(%rip), %rsi      # 0xa333
xorl %eax, %eax
callq 0x6b27
movq $-0x1, %rax
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/qq-smart[P]qq_sh_server/event/qq_epoll.c
// Function: qq_epoll_done
void
qq_epoll_done(void)
{
    qq_log_debug("qq_epoll_done()");

    if (close(ep) == -1) {
        qq_log_error(errno, "epoll close() failed");
    }
    ep = -1;

    free(event_list);
    event_list = NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
leaq 0x77f7(%rip), %rdi      # 0xa367
xorl %eax, %eax
callq 0x6c74
movl 0xc633(%rip), %edi      # 0xf1b0
callq 0x2320
cmpl $-0x1, %eax
jne 0x2b9c
callq 0x2030
movl (%rax), %edi
leaq 0x77e2(%rip), %rsi      # 0xa377
xorl %eax, %eax
callq 0x6b27
movl $0xffffffff, 0xc60a(%rip) # imm = 0xFFFFFFFF
movq 0xc713(%rip), %rdi      # 0xf2c0
callq 0x2338
movq $0x0, 0xc703(%rip) # 0xf2c0
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/qq-smart[P]qq_sh_server/event/qq_epoll.c
// Function: qq_epoll_add_event
qq_int_t
qq_epoll_add_event(qq_event_t *ev, qq_int_t event)
{
    int                  op;
    uint32_t             events, prev;
    qq_event_t          *e;
    qq_connection_t     *c;
    struct epoll_event   ee;

    c = ev->data;

    if (event == QQ_READ_EVENT) {
        e = c->write;
        prev = EPOLLOUT;
        events = EPOLLIN|EPOLLRDHUP;
    } else {
        e = c->read;
        prev = EPOLLIN|EPOLLRDHUP;
        events = EPOLLOUT;
    }

    if (e->active) {
        op = EPOLL_CTL_MOD;
        events |= prev;
    } else {
        op = EPOLL_CTL_ADD;
    }

    ee.events = events | EPOLLET;
    ee.data.ptr = (void *) ((uintptr_t) c | ev->instance);

    qq_log_debug("epoll add event: fd:%d op:%d ev:%08XD", c->fd, op, ee.events);

    if (epoll_ctl(ep, op, c->fd, &ee) == -1) {
        qq_log_error(errno, "epoll_ctl(%d, %d) failed", op, c->fd);
        return QQ_ERROR;
    }

    ev->active = 1;

    return QQ_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
movq (%rdi), %r12
xorl %eax, %eax
cmpq $0x1, %rsi
sete %al
movl $0x80002001, %ecx       # imm = 0x80002001
movl $0x80000004, %edx       # imm = 0x80000004
cmovel %ecx, %edx
movq 0x8(%r12,%rax,8), %rax
movl 0x8(%rax), %eax
andl $0x8, %eax
movl %eax, %r14d
shrl $0x2, %r14d
incl %r14d
testl %eax, %eax
movl $0x80002005, %ecx       # imm = 0x80002005
cmovel %edx, %ecx
leaq -0x2c(%rbp), %r15
movl %ecx, (%r15)
movl 0x8(%rdi), %eax
shrl $0x2, %eax
andl $0x1, %eax
orq %r12, %rax
movq %rax, 0x4(%r15)
movl 0x18(%r12), %esi
leaq 0x7760(%rip), %rdi      # 0xa38c
movl %r14d, %edx
xorl %eax, %eax
callq 0x6c74
movl 0xc574(%rip), %edi      # 0xf1b0
movl 0x18(%r12), %edx
movl %r14d, %esi
movq %r15, %rcx
callq 0x2270
cmpl $-0x1, %eax
je 0x2c59
orb $0x8, 0x8(%rbx)
xorl %eax, %eax
jmp 0x2c7d
callq 0x2030
movl (%rax), %edi
movl 0x18(%r12), %ecx
leaq 0x7746(%rip), %rsi      # 0xa3b2
movl %r14d, %edx
xorl %eax, %eax
callq 0x6b27
movq $-0x1, %rax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/qq-smart[P]qq_sh_server/event/qq_epoll.c
// Function: qq_epoll_del_event
qq_int_t
qq_epoll_del_event(qq_event_t *ev, qq_int_t event)
{
    int                  op;
    uint32_t             prev;
    qq_event_t          *e;
    qq_connection_t     *c;
    struct epoll_event   ee;

    c = ev->data;

    if (event == QQ_READ_EVENT) {
        e = c->write;
        prev = EPOLLOUT;
    } else {
        e = c->read;
        prev = EPOLLIN|EPOLLRDHUP;
    }

    if (e->active) {
        op = EPOLL_CTL_MOD;
        ee.events = prev | EPOLLET;
        ee.data.ptr = (void *) ((uintptr_t) c | ev->instance);
    } else {
        op = EPOLL_CTL_DEL;
        ee.events = 0;
        ee.data.ptr = NULL;
    }

    qq_log_debug("epoll del event: fd:%d op:%d ev:%08XD", c->fd, op, ee.events);

    if (epoll_ctl(ep, op, c->fd, &ee) == -1) {
        qq_log_error(errno, "epoll_ctl(%d, %d) failed", op, c->fd);
        return QQ_ERROR;
    }

    ev->active = 0;

    return QQ_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
movq (%rdi), %r12
xorl %eax, %eax
cmpq $0x1, %rsi
sete %al
movq 0x8(%r12,%rax,8), %rax
testb $0x8, 0x8(%rax)
jne 0x2cbf
movl $0x2, %r14d
xorl %ecx, %ecx
xorl %eax, %eax
jmp 0x2ce2
cmpq $0x1, %rsi
movl $0x80000004, %eax       # imm = 0x80000004
movl $0x80002001, %ecx       # imm = 0x80002001
cmovel %eax, %ecx
movl 0x8(%rbx), %eax
shrl $0x2, %eax
andl $0x1, %eax
orq %r12, %rax
movl $0x3, %r14d
leaq -0x2c(%rbp), %r15
movl %ecx, (%r15)
movq %rax, 0x4(%r15)
movl 0x18(%r12), %esi
leaq 0x76d2(%rip), %rdi      # 0xa3cb
movl %r14d, %edx
xorl %eax, %eax
callq 0x6c74
movl 0xc4a7(%rip), %edi      # 0xf1b0
movl 0x18(%r12), %edx
movl %r14d, %esi
movq %r15, %rcx
callq 0x2270
cmpl $-0x1, %eax
je 0x2d26
andb $-0x9, 0x8(%rbx)
xorl %eax, %eax
jmp 0x2d4a
callq 0x2030
movl (%rax), %edi
movl 0x18(%r12), %ecx
leaq 0x7679(%rip), %rsi      # 0xa3b2
movl %r14d, %edx
xorl %eax, %eax
callq 0x6b27
movq $-0x1, %rax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/qq-smart[P]qq_sh_server/event/qq_epoll.c
// Function: qq_epoll_add_connection
qq_int_t
qq_epoll_add_connection(qq_connection_t *c)
{
    struct epoll_event  ee;

    ee.events = EPOLLIN|EPOLLOUT|EPOLLET|EPOLLRDHUP;
    ee.data.ptr = (void *) ((uintptr_t) c | c->read->instance);

    qq_log_debug("epoll add connection: fd:%d ev:%08XD", c->fd, ee.events);

    if (epoll_ctl(ep, EPOLL_CTL_ADD, c->fd, &ee) == -1) {
        qq_log_error(errno, "epoll_ctl(EPOLL_CTL_ADD, %d) failed", c->fd);
        return QQ_ERROR;
    }

    c->read->active = 1;
    c->write->active = 1;

    return QQ_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
leaq -0x1c(%rbp), %r14
movl $0x80002005, (%r14)     # imm = 0x80002005
movq 0x8(%rdi), %rax
movl 0x8(%rax), %eax
shrl $0x2, %eax
andl $0x1, %eax
orq %rdi, %rax
movq %rax, 0x4(%r14)
movl 0x18(%rdi), %esi
leaq 0x7663(%rip), %rdi      # 0xa3f1
movl $0x80002005, %edx       # imm = 0x80002005
xorl %eax, %eax
callq 0x6c74
movl 0xc410(%rip), %edi      # 0xf1b0
movl 0x18(%rbx), %edx
movl $0x1, %esi
movq %r14, %rcx
callq 0x2270
cmpl $-0x1, %eax
je 0x2dc9
movq 0x8(%rbx), %rax
orl $0x8, 0x8(%rax)
movq 0x10(%rbx), %rax
orl $0x8, 0x8(%rax)
xorl %eax, %eax
jmp 0x2de8
callq 0x2030
movl (%rax), %edi
movl 0x18(%rbx), %edx
leaq 0x763c(%rip), %rsi      # 0xa416
xorl %eax, %eax
callq 0x6b27
movq $-0x1, %rax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/qq-smart[P]qq_sh_server/event/qq_epoll.c
// Function: qq_epoll_del_connection
qq_int_t
qq_epoll_del_connection(qq_connection_t *c)
{
    struct epoll_event  ee;

    qq_log_debug("epoll del connection: fd:%d", c->fd);

    ee.events = 0;
    ee.data.ptr = NULL;

    if (epoll_ctl(ep, EPOLL_CTL_DEL, c->fd, &ee) == -1) {
        qq_log_error(errno, "epoll_ctl(EPOLL_CTL_DEL, %d) failed", c->fd);
        return QQ_ERROR;
    }

    c->read->active = 0;
    c->write->active = 0;

    return QQ_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
movl 0x18(%rdi), %esi
leaq 0x7633(%rip), %rdi      # 0xa43a
xorl %eax, %eax
callq 0x6c74
leaq -0x14(%rbp), %rcx
movl $0x0, (%rcx)
movq $0x0, 0x4(%rcx)
movl 0xc38a(%rip), %edi      # 0xf1b0
movl 0x18(%rbx), %edx
movl $0x2, %esi
callq 0x2270
cmpl $-0x1, %eax
je 0x2e4c
movq 0x8(%rbx), %rax
andl $-0x9, 0x8(%rax)
movq 0x10(%rbx), %rax
andl $-0x9, 0x8(%rax)
xorl %eax, %eax
jmp 0x2e6b
callq 0x2030
movl (%rax), %edi
movl 0x18(%rbx), %edx
leaq 0x75f9(%rip), %rsi      # 0xa456
xorl %eax, %eax
callq 0x6b27
movq $-0x1, %rax
addq $0x18, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/qq-smart[P]qq_sh_server/event/qq_event.c
// Function: qq_events_process
void
qq_events_process(void)
{
    qq_msec_t  delta;

    delta = qq_current_msec;

    qq_epoll_process_events(qq_event_find_timer(), QQ_UPDATE_TIME);

    delta = qq_current_msec - delta;
    qq_log_debug("timer delta: %d", delta);

    qq_event_process_posted(&qq_posted_accept_events);

    if (delta) {
        qq_event_expire_timers();
    }

    qq_event_process_posted(&qq_posted_events);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
leaq 0xc37c(%rip), %rbx      # 0xf6c0
movq (%rbx), %r14
callq 0x3ad2
movl $0x1, %esi
movq %rax, %rdi
callq 0x2e72
movq (%rbx), %rbx
leaq 0x72c3(%rip), %rdi      # 0xa626
movq %rbx, %rsi
subq %r14, %rsi
xorl %eax, %eax
callq 0x6c74
leaq 0xbf51(%rip), %rdi      # 0xf2c8
callq 0x3a28
cmpq %r14, %rbx
je 0x3386
callq 0x3b1c
leaq 0xbf4b(%rip), %rdi      # 0xf2d8
popq %rbx
popq %r14
popq %rbp
jmp 0x3a28
// File: /workspace/github_c_makefile_star2_O3/qq-smart[P]qq_sh_server/event/qq_event.c
// Function: qq_event_done
void
qq_event_done(qq_cycle_t *cycle)
{
    qq_log_debug("qq_event_done()");

    qq_epoll_done();

    free(cycle->connections);

    free(cycle->read_events);

    free(cycle->write_events);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x7290(%rip), %rdi      # 0xa636
xorl %eax, %eax
callq 0x6c74
callq 0x2b65
movq 0x10(%rbx), %rdi
callq 0x2338
movq 0x28(%rbx), %rdi
callq 0x2338
movq 0x30(%rbx), %rdi
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x2338
// File: /workspace/github_c_makefile_star2_O3/qq-smart[P]qq_sh_server/event/qq_event.c
// Function: qq_handle_read_event
qq_int_t
qq_handle_read_event(qq_event_t *rev)
{
    if (!rev->active && !rev->ready) {
        if (qq_epoll_add_event(rev, QQ_READ_EVENT)
            == QQ_ERROR)
        {
            return QQ_ERROR;
        }
    }

    return QQ_OK;
}

// Assembly:
testb $0x28, 0x8(%rdi)
jne 0x33ee
pushq %rbp
movq %rsp, %rbp
movl $0x1, %esi
callq 0x2bbf
cmpq $-0x1, %rax
popq %rbp
je 0x33f1
xorl %eax, %eax
retq
movq $-0x1, %rax
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O3/qq-smart[P]qq_sh_server/event/qq_event_accept.c
// Function: qq_enable_accept_events
static qq_int_t
qq_enable_accept_events(qq_cycle_t *cycle)
{
    qq_uint_t         i;
    qq_listening_t   *ls;
    qq_connection_t  *c;

    ls = cycle->listening;
    for (i = 0; i < cycle->nlistening; i++) {
        c = ls[i].connection;
        if (c == NULL || c->read->active) {
            continue;
        }

        if (qq_epoll_add_event(c->read, QQ_READ_EVENT) == QQ_ERROR) {
            return QQ_ERROR;
        }
    }

    return QQ_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq 0x38(%rdi), %rax
testq %rax, %rax
je 0x372b
movq %rdi, %r14
movq 0x40(%rdi), %r15
addq $0x58, %r15
xorl %ebx, %ebx
xorl %r12d, %r12d
movq (%r15), %rcx
testq %rcx, %rcx
je 0x371d
movq 0x8(%rcx), %rdi
testb $0x8, 0x8(%rdi)
jne 0x371d
movl $0x1, %esi
callq 0x2bbf
cmpq $-0x1, %rax
je 0x372f
movq 0x38(%r14), %rax
incq %r12
addq $0x60, %r15
cmpq %rax, %r12
jb 0x36f7
jmp 0x3736
xorl %ebx, %ebx
jmp 0x3736
movq $-0x1, %rbx
movq %rbx, %rax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/qq-smart[P]qq_sh_server/event/qq_event_accept.c
// Function: qq_close_accepted_connection
static void
qq_close_accepted_connection(qq_connection_t *c)
{
    qq_socket_t  fd;

    qq_free_connection(c);

    fd = c->fd;
    c->fd = (qq_socket_t) -1;

    if (close(fd) == -1) {
        qq_log_error(errno, "close sockets failed");
    }

    if (c->pool) {
        qq_destroy_pool(c->pool);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
callq 0x283a
movl 0x18(%rbx), %edi
movl $0xffffffff, 0x18(%rbx) # imm = 0xFFFFFFFF
callq 0x2320
cmpl $-0x1, %eax
jne 0x3779
callq 0x2030
movl (%rax), %edi
leaq 0x6f32(%rip), %rsi      # 0xa6a4
xorl %eax, %eax
callq 0x6b27
movq 0x40(%rbx), %rdi
addq $0x8, %rsp
testq %rdi, %rdi
je 0x378d
popq %rbx
popq %rbp
jmp 0x2338
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/qq-smart[P]qq_sh_server/event/qq_event_posted.c
// Function: qq_event_process_posted
void
qq_event_process_posted(qq_queue_t *posted)
{
    qq_queue_t  *q;
    qq_event_t  *ev;

    while (!qq_queue_empty(posted)) {
        q = qq_queue_head(posted);
        ev = qq_queue_data(q, qq_event_t, queue);

        qq_log_debug("qq_event_process_posted(ev:%p)", ev);

        qq_delete_posted_event(ev);

        ev->handler(ev);
    }
}

// Assembly:
cmpq %rdi, (%rdi)
je 0x3a9c
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x6d28(%rip), %r14      # 0xa76d
leaq 0x67d5(%rip), %r15      # 0xa221
movq 0x8(%rbx), %r13
leaq -0x48(%r13), %r12
movq %r14, %rdi
movq %r12, %rsi
xorl %eax, %eax
callq 0x6c74
andb $0x7f, -0x3f(%r13)
movq (%r13), %rax
movq 0x8(%r13), %rcx
movq %rax, (%rcx)
movq %rcx, 0x8(%rax)
movq %r15, %rdi
movq %r12, %rsi
xorl %eax, %eax
callq 0x6c74
movq %r12, %rdi
callq *-0x38(%r13)
cmpq %rbx, (%rbx)
jne 0x3a4c
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O3/qq-smart[P]qq_sh_server/event/qq_event_timer.c
// Function: qq_event_find_timer
qq_msec_t
qq_event_find_timer(void)
{
    qq_msec_int_t      timer;
    qq_rbtree_node_t  *node, *root, *sentinel;

    if (qq_event_timer_rbtree.root == &qq_event_timer_sentinel) {
        return QQ_TIMER_INFINITE;
    }

    root     = qq_event_timer_rbtree.root;
    sentinel = qq_event_timer_rbtree.sentinel;

    node = qq_rbtree_min(root, sentinel);
    timer = (qq_msec_int_t) (node->key - qq_current_msec);

    return (qq_msec_t) (timer > 0 ? timer : 0);
}

// Assembly:
movq 0xb837(%rip), %rax      # 0xf310
leaq 0xb808(%rip), %rcx      # 0xf2e8
cmpq %rcx, %rax
je 0x3b14
pushq %rbp
movq %rsp, %rbp
movq 0xb828(%rip), %rcx      # 0xf318
movq %rax, %rdx
movq 0x8(%rax), %rax
cmpq %rcx, %rax
jne 0x3af0
movq (%rdx), %rcx
leaq 0xbbba(%rip), %rax      # 0xf6c0
subq (%rax), %rcx
xorl %eax, %eax
testq %rcx, %rcx
cmovgq %rcx, %rax
popq %rbp
retq
movq $-0x1, %rax
retq
// File: /workspace/github_c_makefile_star2_O3/qq-smart[P]qq_sh_server/event/qq_event_timer.c
// Function: qq_event_expire_timers
void
qq_event_expire_timers(void)
{
    qq_event_t        *ev;
    qq_rbtree_node_t  *node, *root, *sentinel;

    sentinel = qq_event_timer_rbtree.sentinel;

    for ( ;; ) {
        root = qq_event_timer_rbtree.root;

        if (root == sentinel) {
            return;
        }

        node = qq_rbtree_min(root, sentinel);

        /* node->key > qq_current_msec */

        if ((qq_msec_int_t) (node->key - qq_current_msec) > 0) {
            return;
        }

        ev = (qq_event_t *) ((char *) node - offsetof(qq_event_t, timer));
        qq_rbtree_delete(&qq_event_timer_rbtree, &ev->timer);

        ev->timer_set = 0;
        ev->timedout = 1;
        ev->handler(ev);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq 0xb7e7(%rip), %r12      # 0xf318
movq 0xb7d8(%rip), %rax      # 0xf310
cmpq %r12, %rax
je 0x3b96
leaq 0xbb7c(%rip), %r13      # 0xf6c0
movl $0xfffff3ff, %ebx       # imm = 0xFFFFF3FF
movq %rax, %r14
movq 0x8(%rax), %rax
cmpq %r12, %rax
jne 0x3b49
movq (%r14), %rax
subq (%r13), %rax
testq %rax, %rax
jg 0x3b96
leaq -0x20(%r14), %r15
leaq 0xb7a4(%rip), %rdi      # 0xf310
movq %r14, %rsi
callq 0x81c4
movl -0x18(%r14), %eax
andl %ebx, %eax
orl $0x400, %eax            # imm = 0x400
movl %eax, -0x18(%r14)
movq %r15, %rdi
callq *-0x10(%r14)
movq 0xb77f(%rip), %rax      # 0xf310
cmpq %r12, %rax
jne 0x3b49
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O3/qq-smart[P]qq_sh_server/app/qq_ios_app.c
// Function: qq_ios_app_init
qq_int_t
qq_ios_app_init(qq_cycle_t *cycle)
{
    if (qq_add_listening_config(SOCK_STREAM,
        QQ_IOS_APP_TCP_LISTENING_PORT,
        QQ_IOS_APP_TCP_LISTENING_POOL_SIZE,
        qq_ios_app_init_connection_handler) == QQ_ERROR)
    {
        qq_log_error(0, "qq_ios_app_init()->qq_add_listening_config() failed");
        return QQ_ERROR;
    }

    return QQ_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
leaq 0x37(%rip), %rcx        # 0x3c2e
movl $0x400, %edx            # imm = 0x400
movl $0x1, %edi
movl $0x2710, %esi           # imm = 0x2710
callq 0x6464
cmpq $-0x1, %rax
je 0x3c15
xorl %eax, %eax
jmp 0x3c2c
leaq 0x6b7f(%rip), %rsi      # 0xa79b
xorl %edi, %edi
xorl %eax, %eax
callq 0x6b27
movq $-0x1, %rax
popq %rbp
retq