LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O3/coyove[P]chann/./lib/mongoose/mongoose.c
// Function: next_option
static const char *next_option(const char *list, struct vec *val,
                               struct vec *eq_val) {
  if (list == NULL || *list == '\0') {
    // End of the list
    list = NULL;
  } else {
    val->ptr = list;
    if ((list = strchr(val->ptr, ',')) != NULL) {
      // Comma found. Store length and shift the list ptr
      val->len = list - val->ptr;
      list++;
    } else {
      // This value is the last one
      list = val->ptr + strlen(val->ptr);
      val->len = list - val->ptr;
    }

    if (eq_val != NULL) {
      // Value has form "x=y", adjust pointers and lengths
      // so that val points to "x", and eq_val points to "y".
      eq_val->len = 0;
      eq_val->ptr = (const char *) memchr(val->ptr, '=', val->len);
      if (eq_val->ptr != NULL) {
        eq_val->ptr++;  // Skip over '=' character
        eq_val->len = val->ptr + val->len - eq_val->ptr;
        val->len = (eq_val->ptr - val->ptr) - 1;
      }
    }
  }

  return list;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
testq %rdi, %rdi
je 0x6bde2
movq %rdi, %r12
cmpb $0x0, (%rdi)
je 0x6bde2
movq %rdx, %r14
movq %rsi, %rbx
movq %r12, (%rsi)
movq %r12, %rdi
movl $0x2c, %esi
callq 0xc5f0
testq %rax, %rax
je 0x6bde7
movq %rax, %r15
subq %r12, %rax
incq %r15
jmp 0x6bdf5
xorl %r15d, %r15d
jmp 0x6be43
movq %r12, %rdi
callq 0xc460
movq %rax, %r15
addq %r12, %r15
movq %rax, 0x8(%rbx)
testq %r14, %r14
je 0x6be43
movq $0x0, 0x8(%r14)
movq 0x8(%rbx), %r13
movq %r12, %rdi
movl $0x3d, %esi
movq %r13, %rdx
callq 0xc4d0
movq %rax, (%r14)
testq %rax, %rax
je 0x6be43
leaq 0x1(%rax), %rcx
movq %rcx, (%r14)
movq (%rbx), %rdx
addq %rdx, %r13
subq %rcx, %r13
movq %r13, 0x8(%r14)
notq %rdx
addq %rdx, %rax
incq %rax
movq %rax, 0x8(%rbx)
movq %r15, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/coyove[P]chann/./lib/mongoose/mongoose.c
// Function: mg_wakeup_server_ex
void mg_wakeup_server_ex(struct mg_server *server, mg_handler_t cb,
                         const char *fmt, ...) {
  va_list ap;
  char buf[8 * 1024];
  int len;

  // Encode callback (cb) into a buffer
  len = snprintf(buf, sizeof(buf), "%p ", cb);
  va_start(ap, fmt);
  len += vsnprintf(buf + len, sizeof(buf) - len, fmt, ap);
  va_end(ap);

  // "len + 1" is to include terminating \0 in the message
  ns_broadcast(&server->ns_mgr, iter2, buf, len + 1);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x20c8, %rsp           # imm = 0x20C8
movq %rdx, %r15
movq %rsi, %r10
movq %rdi, %rbx
leaq -0xf0(%rbp), %r13
movq %rcx, 0x18(%r13)
movq %r8, 0x20(%r13)
movq %r9, 0x28(%r13)
testb %al, %al
je 0x6beb5
movaps %xmm0, -0xc0(%rbp)
movaps %xmm1, -0xb0(%rbp)
movaps %xmm2, -0xa0(%rbp)
movaps %xmm3, -0x90(%rbp)
movaps %xmm4, -0x80(%rbp)
movaps %xmm5, -0x70(%rbp)
movaps %xmm6, -0x60(%rbp)
movaps %xmm7, -0x50(%rbp)
leaq 0xc5ab(%rip), %rdx      # 0x78467
leaq -0x20f0(%rbp), %r14
movl $0x2000, %r12d          # imm = 0x2000
movl $0x2000, %esi           # imm = 0x2000
movq %r14, %rdi
movq %r10, %rcx
xorl %eax, %eax
callq 0xc5d0
movabsq $0x3000000018, %rdx     # imm = 0x3000000018
leaq -0x40(%rbp), %rcx
movq %rdx, (%rcx)
leaq 0x10(%rbp), %rdx
movq %rdx, 0x8(%rcx)
movq %r13, 0x10(%rcx)
movslq %eax, %r13
leaq -0x20f0(,%r13), %rdi
addq %rbp, %rdi
subq %r13, %r12
movq %r12, %rsi
movq %r15, %rdx
callq 0xcd48
addl %r13d, %eax
incl %eax
movslq %eax, %rcx
leaq 0x1d(%rip), %rsi        # 0x6bf40
movq %rbx, %rdi
movq %r14, %rdx
callq 0x67916
addq $0x20c8, %rsp           # imm = 0x20C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/coyove[P]chann/./lib/mongoose/mongoose.c
// Function: iter2
static void iter2(struct ns_connection *nc, int ev, void *param) {
  mg_handler_t func = NULL;
  struct connection *conn = (struct connection *) nc->user_data;
  const char *msg = (const char *) param;
  int n;
  (void) ev;

  //DBG(("%p [%s]", conn, msg));
  if (sscanf(msg, "%p %n", &func, &n) && func != NULL && conn != NULL) {
    conn->mg_conn.callback_param = (void *) (msg + n);
    func(&conn->mg_conn, MG_POLL);
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x18, %rsp
movq %rdx, %rbx
leaq -0x28(%rbp), %r14
movq $0x0, (%r14)
movq 0x80(%rdi), %r15
leaq 0xdadc(%rip), %rsi      # 0x79a45
leaq -0x1c(%rbp), %rcx
movq %rdx, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0xc100
testl %eax, %eax
setne %cl
movq (%r14), %rax
testq %rax, %rax
setne %dl
andb %cl, %dl
testq %r15, %r15
setne %cl
andb %dl, %cl
cmpb $0x1, %cl
jne 0x6bfb3
movslq -0x1c(%rbp), %rcx
addq %rcx, %rbx
movq %r15, %rdi
addq $0x8, %rdi
movq %rbx, 0x2a0(%r15)
movl $0x64, %esi
callq *%rax
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/coyove[P]chann/./lib/mongoose/mongoose.c
// Function: mg_create_server
struct mg_server *mg_create_server(void *server_data, mg_handler_t handler) {
  struct mg_server *server = (struct mg_server *) NS_CALLOC(1, sizeof(*server));
  ns_mgr_init(&server->ns_mgr, server_data);
  set_default_option_values(server->config_options);
  server->event_handler = handler;
  return server;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r15
movl $0x1, %edi
movl $0xd0, %esi
callq 0xc980
movq %rax, %r14
movq %rax, %rdi
movq %r15, %rsi
callq 0x67997
cmpq $0x0, 0x28911(%rip)     # 0x94950
je 0x6c07c
xorl %r15d, %r15d
leaq 0x28905(%rip), %r12     # 0x94950
movq 0x8(%r12,%r15,2), %rdi
cmpq $0x0, 0x38(%r14,%r15)
sete %al
testq %rdi, %rdi
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x6c070
callq 0x6bd6d
movq %rax, 0x38(%r14,%r15)
cmpq $0x0, 0x10(%r12,%r15,2)
leaq 0x8(%r15), %r15
jne 0x6c04b
movq %rbx, 0x30(%r14)
movq %r14, %rax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/coyove[P]chann/./lib/mongoose/mongoose.c
// Function: compare_dir_entries
static int __cdecl compare_dir_entries(const void *p1, const void *p2) {
  const struct dir_entry *a = (const struct dir_entry *) p1,
        *b = (const struct dir_entry *) p2;
  const char *qs = a->conn->mg_conn.query_string ?
    a->conn->mg_conn.query_string : "na";
  int cmp_result = 0;

  if (S_ISDIR(a->st.st_mode) && !S_ISDIR(b->st.st_mode)) {
    return -1;  // Always put directories on top
  } else if (!S_ISDIR(a->st.st_mode) && S_ISDIR(b->st.st_mode)) {
    return 1;   // Always put directories on top
  } else if (*qs == 'n') {
    cmp_result = strcmp(a->file_name, b->file_name);
  } else if (*qs == 's') {
    cmp_result = a->st.st_size == b->st.st_size ? 0 :
      a->st.st_size > b->st.st_size ? 1 : -1;
  } else if (*qs == 'd') {
    cmp_result = a->st.st_mtime == b->st.st_mtime ? 0 :
      a->st.st_mtime > b->st.st_mtime ? 1 : -1;
  }

  return qs[1] == 'd' ? -cmp_result : cmp_result;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq (%rdi), %rax
movq 0x20(%rax), %rax
testq %rax, %rax
leaq 0xc432(%rip), %rbx      # 0x78ddc
cmovneq %rax, %rbx
movl $0xf000, %eax           # imm = 0xF000
movl 0x28(%rdi), %ecx
andl %eax, %ecx
andl 0x28(%rsi), %eax
cmpl $0x4000, %ecx           # imm = 0x4000
jne 0x6c9d1
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpl $0x4000, %eax           # imm = 0x4000
je 0x6c9dd
jmp 0x6ca2f
movl $0x1, %ecx
cmpl $0x4000, %eax           # imm = 0x4000
je 0x6ca2f
movzbl (%rbx), %ecx
cmpl $0x64, %ecx
je 0x6ca0e
cmpl $0x73, %ecx
je 0x6ca00
xorl %eax, %eax
cmpl $0x6e, %ecx
jne 0x6ca24
movq 0x8(%rdi), %rdi
movq 0x8(%rsi), %rsi
callq 0xc950
jmp 0x6ca24
movq 0x40(%rdi), %rax
xorl %ecx, %ecx
xorl %edx, %edx
cmpq 0x40(%rsi), %rax
jmp 0x6ca1a
movq 0x68(%rdi), %rax
xorl %ecx, %ecx
xorl %edx, %edx
cmpq 0x68(%rsi), %rax
setg %dl
leal -0x1(%rdx,%rdx), %eax
cmovel %ecx, %eax
movl %eax, %ecx
negl %ecx
cmpb $0x64, 0x1(%rbx)
cmovnel %eax, %ecx
movl %ecx, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/coyove[P]chann/./lib/mongoose/mongoose.c
// Function: addenv
static char *addenv(struct cgi_env_block *block, const char *fmt, ...) {
  int n, space;
  char *added;
  va_list ap;

  // Calculate how much space is left in the buffer
  space = sizeof(block->buf) - block->len - 2;
  assert(space >= 0);

  // Make a pointer to the free space int the buffer
  added = block->buf + block->len;

  // Copy VARIABLE=VALUE\0 string into the free space
  va_start(ap, fmt);
  n = mg_vsnprintf(added, (size_t) space, fmt, ap);
  va_end(ap);

  // Make sure we do not overflow buffer and the envp array
  if (n > 0 && n + 1 < space &&
      block->nvars < (int) ARRAY_SIZE(block->vars) - 2) {
    // Append a pointer to the added string into the envp array
    block->vars[block->nvars++] = added;
    // Bump up used length counter. Include \0 terminator
    block->len += n + 1;
  }

  return added;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0xd0, %rsp
movq %rdx, -0xe0(%rbp)
movq %rcx, -0xd8(%rbp)
movq %r8, -0xd0(%rbp)
movq %r9, -0xc8(%rbp)
testb %al, %al
je 0x6ca96
movaps %xmm0, -0xc0(%rbp)
movaps %xmm1, -0xb0(%rbp)
movaps %xmm2, -0xa0(%rbp)
movaps %xmm3, -0x90(%rbp)
movaps %xmm4, -0x80(%rbp)
movaps %xmm5, -0x70(%rbp)
movaps %xmm6, -0x60(%rbp)
movaps %xmm7, -0x50(%rbp)
movslq 0x2208(%rdi), %r12
movl $0x1ffe, %r15d          # imm = 0x1FFE
subl %r12d, %r15d
js 0x6cb55
movq %rdi, %rbx
leaq (%rdi,%r12), %r14
addq $0x8, %r14
leaq -0xf0(%rbp), %rax
movq %rax, -0x30(%rbp)
leaq 0x10(%rbp), %rax
movq %rax, -0x38(%rbp)
movabsq $0x3000000010, %rax     # imm = 0x3000000010
movq %rax, -0x40(%rbp)
cmpl $0x1ffe, %r12d          # imm = 0x1FFE
je 0x6cb42
movq %rsi, %r10
movl %r15d, %esi
leaq -0x40(%rbp), %rcx
movq %r14, %rdi
movq %r10, %rdx
callq 0xcd48
movl $0x1ffd, %edx           # imm = 0x1FFD
subl %r12d, %edx
cmpl %r15d, %eax
cmovll %eax, %edx
xorl %ecx, %ecx
testl %eax, %eax
cmovnsl %edx, %ecx
movslq %ecx, %rax
movb $0x0, (%r14,%rax)
testl %eax, %eax
jle 0x6cb42
incl %ecx
cmpl %r15d, %ecx
jae 0x6cb42
movslq 0x220c(%rbx), %rax
cmpq $0x3d, %rax
jg 0x6cb42
leal 0x1(%rax), %edx
movl %edx, 0x220c(%rbx)
movq %r14, 0x2008(%rbx,%rax,8)
addl %ecx, 0x2208(%rbx)
movq %r14, %rax
addq $0xd0, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0xc57d(%rip), %rdi      # 0x790d9
leaq 0xb700(%rip), %rsi      # 0x78263
leaq 0xc57a(%rip), %rcx      # 0x790e4
movl $0x88a, %edx            # imm = 0x88A
callq 0xc210
// File: /workspace/github_c_makefile_star2_O3/coyove[P]chann/./lib/mongoose/mongoose.c
// Function: get_mime_type
static void get_mime_type(const struct mg_server *server, const char *path,
                          struct vec *vec) {
  struct vec ext_vec, mime_vec;
  const char *list, *ext;
  size_t path_len;

  path_len = strlen(path);

  // Scan user-defined mime types first, in case user wants to
  // override default mime types.
  list = server->config_options[EXTRA_MIME_TYPES];
  while ((list = next_option(list, &ext_vec, &mime_vec)) != NULL) {
    // ext now points to the path suffix
    ext = path + path_len - ext_vec.len;
    if (mg_strncasecmp(ext, ext_vec.ptr, ext_vec.len) == 0) {
      *vec = mime_vec;
      return;
    }
  }

  vec->ptr = mg_get_mime_type(path, "text/plain");
  vec->len = strlen(vec->ptr);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdx, -0x30(%rbp)
movq %rsi, %r14
movq %rdi, %r12
movq %rsi, %rdi
callq 0xc460
movq %rax, %r15
addq %r14, %r15
leaq -0x40(%rbp), %r13
leaq -0x50(%rbp), %rbx
movq %r12, %rdi
movq %r13, %rsi
movq %rbx, %rdx
callq 0x6bda1
testq %rax, %rax
je 0x6cc19
movq %rax, %r12
movq -0x40(%rbp), %rsi
movq -0x38(%rbp), %rdx
movq %r15, %rdi
subq %rdx, %rdi
callq 0x69234
testl %eax, %eax
jne 0x6cbdf
movups -0x50(%rbp), %xmm0
movq -0x30(%rbp), %rax
movups %xmm0, (%rax)
jmp 0x6cc3b
leaq 0x4d45(%rip), %rsi      # 0x71965
movq %r14, %rdi
callq 0x68855
movq -0x30(%rbp), %rbx
movq %rax, (%rbx)
movq %rax, %rdi
callq 0xc460
movq %rax, 0x8(%rbx)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/coyove[P]chann/./lib/mongoose/mongoose.c
// Function: do_ssi_exec
static void do_ssi_exec(struct mg_connection *conn, char *tag) {
  char cmd[IOBUF_SIZE];
  FILE *fp;

  if (sscanf(tag, " \"%[^\"]\"", cmd) != 1) {
    mg_printf(conn, "Bad SSI #exec: [%s]", tag);
  } else if ((fp = popen(cmd, "r")) == NULL) {
    mg_printf(conn, "Cannot SSI #exec: [%s]: %s", cmd, strerror(errno));
  } else {
    send_file_data(conn, fp);
    pclose(fp);
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x2000, %rsp           # imm = 0x2000
movq %rsi, %r14
movq %rdi, %rbx
leaq 0xc1af(%rip), %rsi      # 0x79277
leaq -0x2010(%rbp), %rdx
movq %r14, %rdi
xorl %eax, %eax
callq 0xc100
cmpl $0x1, %eax
jne 0x6d10e
leaq 0xc270(%rip), %rsi      # 0x79355
leaq -0x2010(%rbp), %rdi
callq 0xc930
testq %rax, %rax
je 0x6d124
movq %rax, %r14
movq %rbx, %rdi
movq %rax, %rsi
callq 0x6d157
movq %r14, %rdi
callq 0xc0c0
jmp 0x6d14b
leaq 0xc1b0(%rip), %rsi      # 0x792c5
movq %rbx, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x67a83
jmp 0x6d14b
callq 0xcb20
movl (%rax), %edi
callq 0xc8c0
leaq 0xc1a2(%rip), %rsi      # 0x792d9
leaq -0x2010(%rbp), %rdx
movq %rbx, %rdi
movq %rax, %rcx
xorl %eax, %eax
callq 0x67a83
addq $0x2000, %rsp           # imm = 0x2000
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/coyove[P]chann/./lib/mongoose/mongoose.c
// Function: send_file_data
static void send_file_data(struct mg_connection *conn, FILE *fp) {
  char buf[IOBUF_SIZE];
  size_t n;
  while ((n = fread(buf, 1, sizeof(buf), fp)) > 0) {
    mg_write(conn, buf, n);
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x2008, %rsp           # imm = 0x2008
movq %rsi, %rbx
movq %rdi, %r14
leaq -0x2020(%rbp), %rdi
movl $0x1, %esi
movl $0x2000, %edx           # imm = 0x2000
movq %rbx, %rcx
callq 0xc600
testq %rax, %rax
je 0x6d1bb
leaq -0x2020(%rbp), %r15
movq -0x8(%r14), %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0x6661a
movl $0x1, %esi
movl $0x2000, %edx           # imm = 0x2000
movq %r15, %rdi
movq %rbx, %rcx
callq 0xc600
testq %rax, %rax
jne 0x6d192
addq $0x2008, %rsp           # imm = 0x2008
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/coyove[P]chann/./lib/mongoose/mongoose.c
// Function: should_keep_alive
static int should_keep_alive(const struct mg_connection *conn) {
  struct connection *c = MG_CONN_2_CONN(conn);
  const char *method = conn->request_method;
  const char *http_version = conn->http_version;
  const char *header = mg_get_header(conn, "Connection");
  return method != NULL &&
    (!strcmp(method, "GET") || c->endpoint_type == EP_USER) &&
    ((header != NULL && !mg_strcasecmp(header, "keep-alive")) ||
     (header == NULL && http_version && !strcmp(http_version, "1.1")));
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %r12
movq (%rdi), %r13
movq 0x10(%rdi), %rbx
leaq 0x76d1(%rip), %rsi      # 0x748b9
callq 0x67c6a
xorl %r15d, %r15d
testq %r13, %r13
je 0x6d287
movq %rax, %r14
leaq 0x778a(%rip), %rsi      # 0x7498d
movq %r13, %rdi
callq 0xc950
testl %eax, %eax
je 0x6d21a
cmpl $0x3, 0x2b0(%r12)
jne 0x6d287
testq %r14, %r14
je 0x6d256
callq 0xc4a0
movq (%rax), %rax
xorl %ecx, %ecx
leaq 0xc207(%rip), %rdx      # 0x79437
movzbl (%r14,%rcx), %r8d
movl (%rax,%r8,4), %esi
movzbl (%rcx,%rdx), %edi
movl (%rax,%rdi,4), %edi
testl %r8d, %r8d
je 0x6d24c
incq %rcx
cmpl %edi, %esi
je 0x6d230
movl $0x1, %r15d
cmpl %edi, %esi
je 0x6d287
testq %r14, %r14
sete %al
testq %rbx, %rbx
setne %cl
andb %al, %cl
movl $0x0, %r15d
cmpb $0x1, %cl
jne 0x6d287
leaq 0xbc74(%rip), %rsi      # 0x78eea
movq %rbx, %rdi
callq 0xc950
xorl %r15d, %r15d
testl %eax, %eax
sete %r15b
movl %r15d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/coyove[P]chann/./lib/mongoose/mongoose.c
// Function: log_header
static void log_header(const struct mg_connection *conn, const char *header,
                       FILE *fp) {
  const char *header_value;

  if ((header_value = mg_get_header(conn, header)) == NULL) {
    (void) fprintf(fp, "%s", " -");
  } else {
    (void) fprintf(fp, " \"%s\"", header_value);
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdx, %rbx
callq 0x67c6a
testq %rax, %rax
je 0x6da3f
leaq 0xb7fc(%rip), %rsi      # 0x79228
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0xc260
leaq 0xba3a(%rip), %rdi      # 0x79480
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0xc380
// File: /workspace/github_c_makefile_star2_O3/coyove[P]chann/./lib/mongoose/mongoose.c
// Function: try_parse
static void try_parse(struct connection *conn) {
  struct iobuf *io = &conn->ns_conn->recv_iobuf;

  if (conn->request_len == 0 &&
      (conn->request_len = get_request_len(io->buf, io->len)) > 0) {
    // If request is buffered in, remove it from the iobuf. This is because
    // iobuf could be reallocated, and pointers in parsed request could
    // become invalid.
    conn->request = (char *) NS_MALLOC(conn->request_len);
    if (conn->request == NULL) {
      conn->ns_conn->flags |= NSF_CLOSE_IMMEDIATELY;
      return;
    }
    memcpy(conn->request, io->buf, conn->request_len);
    //DBG(("%p [%.*s]", conn, conn->request_len, conn->request));
    iobuf_remove(io, conn->request_len);
    conn->request_len = parse_http_message(conn->request, conn->request_len,
                                           &conn->mg_conn);
    if (conn->request_len > 0) {
      const char *cl_hdr = mg_get_header(&conn->mg_conn, "Content-Length");
      conn->cl = cl_hdr == NULL ? 0 : to64(cl_hdr);
      conn->mg_conn.content_len = (size_t) conn->cl;
    }
  }
}

// Assembly:
cmpq $0x0, 0x2e0(%rdi)
je 0x6da5f
retq
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq (%rdi), %r12
movq 0x40(%r12), %r13
movq 0x48(%r12), %r15
movq %r13, %rdi
movq %r15, %rsi
callq 0x6b930
movslq %eax, %r14
movq %r14, 0x2e0(%rbx)
testl %r14d, %r14d
jle 0x6db4b
movq %r13, -0x30(%rbp)
movq %r14, %rdi
callq 0xca00
movq %rax, 0x2c8(%rbx)
testq %rax, %rax
je 0x6db30
movq %rax, %r13
movq %rax, %rdi
movq -0x30(%rbp), %rsi
movq %r14, %rdx
callq 0xc0e0
subq %r14, %r15
jb 0x6daed
movq -0x30(%rbp), %rdi
leaq (%rdi,%r14), %rsi
movq %r15, %rdx
callq 0xc1f0
subq %r14, 0x48(%r12)
movq 0x2c8(%rbx), %r13
movq 0x2e0(%rbx), %r14
leaq 0x8(%rbx), %r15
movq %r13, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x6e3c6
movq %rax, 0x2e0(%rbx)
testq %rax, %rax
jle 0x6db4b
leaq 0x6e52(%rip), %rsi      # 0x74964
movq %r15, %rdi
callq 0x67c6a
testq %rax, %rax
je 0x6db3b
movq %rax, %rdi
xorl %esi, %esi
movl $0xa, %edx
callq 0xc8b0
jmp 0x6db3d
orb $0x10, 0xa0(%r12)
jmp 0x6db4b
xorl %eax, %eax
movq %rax, 0x2d8(%rbx)
movq %rax, 0x278(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/coyove[P]chann/./lib/mongoose/mongoose.c
// Function: parse_http_headers
static void parse_http_headers(char **buf, struct mg_connection *ri) {
  size_t i;

  for (i = 0; i < ARRAY_SIZE(ri->http_headers); i++) {
    ri->http_headers[i].name = skip(buf, ": ");
    ri->http_headers[i].value = skip(buf, "\r\n");
    if (ri->http_headers[i].name[0] == '\0')
      break;
    ri->num_headers = i + 1;
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
movl $0x1, %r13d
xorl %r15d, %r15d
leaq 0x9c6d(%rip), %r12      # 0x7838a
movq %r14, %rdi
leaq 0x5a4b(%rip), %rsi      # 0x74172
callq 0x6e689
movq %rax, 0x88(%rbx,%r15)
movq %r14, %rdi
movq %r12, %rsi
callq 0x6e689
movq %rax, 0x90(%rbx,%r15)
movq 0x88(%rbx,%r15), %rax
cmpb $0x0, (%rax)
je 0x6e76b
movl %r13d, 0x84(%rbx)
addq $0x10, %r15
incl %r13d
cmpq $0x1e0, %r15            # imm = 0x1E0
jne 0x6e71d
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/coyove[P]chann/./lib/mongoose/mongoose.c
// Function: SHA1Update
static void SHA1Update(SHA1_CTX *context, const unsigned char *data,
                       size_t len) {
  size_t i, j;

  j = context->count[0];
  if ((context->count[0] += len << 3) < j)
    context->count[1]++;
  context->count[1] += (len>>29);
  j = (j >> 3) & 63;
  if ((j + len) > 63) {
    memcpy(&context->buffer[j], data, (i = 64-j));
    SHA1Transform(context->state, context->buffer);
    for ( ; i + 63 < len; i += 64) {
      SHA1Transform(context->state, &data[i]);
    }
    j = 0;
  }
  else i = 0;
  memcpy(&context->buffer[j], &data[i], len - i);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
movl 0x14(%rdi), %r12d
leal (,%rdx,8), %eax
movq %rdx, %rcx
shrq $0x1d, %rcx
addl %r12d, %eax
movl %eax, 0x14(%rdi)
adcl %ecx, 0x18(%rdi)
shrl $0x3, %r12d
andl $0x3f, %r12d
leaq (%r12,%rdx), %rax
cmpq $0x40, %rax
jb 0x6e815
leaq 0x1c(%r15), %rax
movq %rax, -0x30(%rbp)
leaq (%r15,%r12), %rdi
addq $0x1c, %rdi
movl $0x40, %r13d
subq %r12, %r13
movq %r14, %rsi
movq %r13, %rdx
callq 0xc0e0
movq %r15, %rdi
movq -0x30(%rbp), %rsi
callq 0x6e83f
xorq $0x7f, %r12
cmpq %rbx, %r12
jae 0x6e810
movq %r13, %r12
leaq (%r14,%r13), %rsi
movq %r15, %rdi
callq 0x6e83f
addq $0x40, %r13
addq $0x7f, %r12
jmp 0x6e7f2
xorl %r12d, %r12d
jmp 0x6e818
xorl %r13d, %r13d
leaq (%r15,%r12), %rdi
addq $0x1c, %rdi
addq %r13, %r14
subq %r13, %rbx
movq %r14, %rsi
movq %rbx, %rdx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xc0e0
// File: /workspace/github_c_makefile_star2_O3/coyove[P]chann/./lib/mongoose/mongoose.c
// Function: handle_mkcol
static void handle_mkcol(struct connection *conn, const char *path) {
  int status_code = 500;

  if (conn->mg_conn.content_len > 0) {
    status_code = 415;
  } else if (!mkdir(path, 0755)) {
    status_code = 201;
  } else if (errno == EEXIST) {
    status_code = 405;
  } else if (errno == EACCES) {
    status_code = 403;
  } else if (errno == ENOENT) {
    status_code = 409;
  }
  send_http_error(conn, status_code, NULL);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rsi, %rax
movq %rdi, %rbx
movl $0x19f, %esi            # imm = 0x19F
cmpq $0x0, 0x278(%rdi)
je 0x6fb50
movq %rbx, %rdi
xorl %edx, %edx
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x6ae64
movq %rax, %rdi
movl $0x1ed, %esi            # imm = 0x1ED
callq 0xc310
testl %eax, %eax
je 0x6fb7e
callq 0xcb20
movl (%rax), %eax
cmpl $0x2, %eax
je 0x6fb8c
cmpl $0x11, %eax
je 0x6fb85
cmpl $0xd, %eax
jne 0x6fb93
movl $0x193, %esi            # imm = 0x193
jmp 0x6fb3e
movl $0xc9, %esi
jmp 0x6fb3e
movl $0x195, %esi            # imm = 0x195
jmp 0x6fb3e
movl $0x199, %esi            # imm = 0x199
jmp 0x6fb3e
movl $0x1f4, %esi            # imm = 0x1F4
jmp 0x6fb3e
// File: /workspace/github_c_makefile_star2_O3/coyove[P]chann/./lib/mongoose/mongoose.c
// Function: handle_delete
static void handle_delete(struct connection *conn, const char *path) {
  file_stat_t st;

  if (stat(path, &st) != 0) {
    send_http_error(conn, 404, NULL);
  } else if (S_ISDIR(st.st_mode)) {
    remove_directory(path);
    send_http_error(conn, 204, NULL);
  } else if (remove(path) == 0) {
    send_http_error(conn, 204, NULL);
  } else {
    send_http_error(conn, 423, NULL);
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x90, %rsp
movq %rsi, %r14
movq %rdi, %rbx
leaq -0xa0(%rbp), %rsi
movq %r14, %rdi
callq 0xcb70
movl $0x194, %esi            # imm = 0x194
testl %eax, %eax
jne 0x6fbfb
movl $0xf000, %eax           # imm = 0xF000
andl -0x88(%rbp), %eax
movq %r14, %rdi
cmpl $0x4000, %eax           # imm = 0x4000
jne 0x6fbe7
callq 0x6ff72
movl $0xcc, %esi
jmp 0x6fbfb
callq 0xc290
testl %eax, %eax
movl $0xcc, %eax
movl $0x1a7, %esi            # imm = 0x1A7
cmovel %eax, %esi
movq %rbx, %rdi
xorl %edx, %edx
xorl %eax, %eax
addq $0x90, %rsp
popq %rbx
popq %r14
popq %rbp
jmp 0x6ae64
// File: /workspace/github_c_makefile_star2_O3/coyove[P]chann/./lib/mongoose/mongoose.c
// Function: print_props
static void print_props(struct connection *conn, const char *uri,
                        file_stat_t *stp) {
  char mtime[64];
  time_t t = stp->st_mtime;  // store in local variable for NDK compile
  gmt_time_string(mtime, sizeof(mtime), &t);
  mg_printf(&conn->mg_conn,
      "<d:response>"
       "<d:href>%s</d:href>"
       "<d:propstat>"
        "<d:prop>"
         "<d:resourcetype>%s</d:resourcetype>"
         "<d:getcontentlength>%" INT64_FMT "</d:getcontentlength>"
         "<d:getlastmodified>%s</d:getlastmodified>"
        "</d:prop>"
        "<d:status>HTTP/1.1 200 OK</d:status>"
       "</d:propstat>"
      "</d:response>\n",
      uri, S_ISDIR(stp->st_mode) ? "<d:collection/>" : "",
      (int64_t) stp->st_size, mtime);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x50, %rsp
movq %rdx, %r15
movq %rsi, %rbx
movq %rdi, %r14
movq 0x58(%rdx), %rax
leaq -0x28(%rbp), %rdi
movq %rax, (%rdi)
callq 0xc2f0
leaq 0x125c(%rip), %rdx      # 0x7116e
leaq -0x70(%rbp), %r12
movl $0x40, %esi
movq %r12, %rdi
movq %rax, %rcx
callq 0xc9d0
addq $0x8, %r14
movl $0xf000, %eax           # imm = 0xF000
andl 0x18(%r15), %eax
cmpl $0x4000, %eax           # imm = 0x4000
leaq 0x987d(%rip), %rax      # 0x797bc
leaq 0x772c(%rip), %rcx      # 0x77672
cmoveq %rax, %rcx
movq 0x30(%r15), %r8
leaq 0x9773(%rip), %rsi      # 0x796c8
movq %r14, %rdi
movq %rbx, %rdx
movq %r12, %r9
xorl %eax, %eax
callq 0x67a83
addq $0x50, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/coyove[P]chann/./lib/mongoose/mongoose.c
// Function: remove_directory
static int remove_directory(const char *dir) {
  char path[MAX_PATH_SIZE];
  struct dirent *dp;
  file_stat_t st;
  DIR *dirp;

  if ((dirp = opendir(dir)) == NULL) return 0;

  while ((dp = readdir(dirp)) != NULL) {
    if (!strcmp(dp->d_name, ".") || !strcmp(dp->d_name, "..")) continue;
    mg_snprintf(path, sizeof(path), "%s%c%s", dir, '/', dp->d_name);
    stat(path, &st);
    if (S_ISDIR(st.st_mode)) {
      remove_directory(path);
    } else {
      remove(path);
    }
  }
  closedir(dirp);
  rmdir(dir);

  return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2098, %rsp           # imm = 0x2098
movq %rdi, %rbx
callq 0xc690
testq %rax, %rax
je 0x70044
movq %rax, %r14
movq %rax, %rdi
callq 0xc6a0
testq %rax, %rax
je 0x70034
leaq -0x20c0(%rbp), %r12
leaq -0xb8(%rbp), %r13
movl $0xf000, %r15d          # imm = 0xF000
cmpb $0x2e, 0x13(%rax)
jne 0x6ffd7
cmpb $0x0, 0x14(%rax)
je 0x70027
cmpb $0x2e, 0x14(%rax)
jne 0x6ffd7
cmpb $0x0, 0x15(%rax)
je 0x70027
addq $0x13, %rax
movl $0x2000, %esi           # imm = 0x2000
movq %r12, %rdi
leaq 0x8deb(%rip), %rdx      # 0x78dd5
movq %rbx, %rcx
movl $0x2f, %r8d
movq %rax, %r9
xorl %eax, %eax
callq 0x6ad62
movq %r12, %rdi
movq %r13, %rsi
callq 0xcb70
movl -0xa0(%rbp), %eax
andl %r15d, %eax
movq %r12, %rdi
cmpl $0x4000, %eax           # imm = 0x4000
jne 0x70022
callq 0x6ff72
jmp 0x70027
callq 0xc290
movq %r14, %rdi
callq 0xc6a0
testq %rax, %rax
jne 0x6ffbf
movq %r14, %rdi
callq 0xc660
movq %rbx, %rdi
callq 0xc4b0
addq $0x2098, %rsp           # imm = 0x2098
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/coyove[P]chann/./lib/mongoose/mongoose.c
// Function: on_cgi_data
static void on_cgi_data(struct ns_connection *nc) {
  struct connection *conn = (struct connection *) nc->user_data;
  const char *status = "500";
  struct mg_connection c;

  if (!conn) return;

  // Copy CGI data from CGI socket to the client send buffer
  ns_forward(nc, conn->ns_conn);

  // If reply has not been parsed yet, parse it
  if (conn->ns_conn->flags & NSF_BUFFER_BUT_DONT_SEND) {
    struct iobuf *io = &conn->ns_conn->send_iobuf;
    size_t s_len = sizeof(cgi_status) - 1;
    int len = get_request_len(io->buf + s_len, io->len - s_len);
    char buf[MAX_REQUEST_SIZE], *s = buf;

    if (len == 0) return;

    if (len < 0 || len > (int) sizeof(buf)) {
      len = io->len;
      iobuf_remove(io, io->len);
      send_http_error(conn, 500, "CGI program sent malformed headers: [%.*s]",
        len, io->buf);
    } else {
      memset(&c, 0, sizeof(c));
      memcpy(buf, io->buf + s_len, len);
      buf[len - 1] = '\0';
      parse_http_headers(&s, &c);
      if (mg_get_header(&c, "Location") != NULL) {
        status = "302";
      } else if ((status = (char *) mg_get_header(&c, "Status")) == NULL) {
        status = "200";
      }
      memcpy(io->buf + 9, status, 3);
      conn->mg_conn.status_code = atoi(status);
    }
    conn->ns_conn->flags &= ~NSF_BUFFER_BUT_DONT_SEND;
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x42b8, %rsp           # imm = 0x42B8
movq 0x80(%rdi), %rbx
testq %rbx, %rbx
je 0x701bc
movq %rdi, %r14
movq (%rbx), %rdi
movq 0x40(%r14), %rsi
movq 0x48(%r14), %rdx
callq 0x6661a
cmpq $0x0, 0x48(%r14)
je 0x7009c
movq $0x0, 0x48(%r14)
movq (%rbx), %r14
testb $0x2, 0xa0(%r14)
je 0x701bc
movq 0x58(%r14), %rax
movq 0x60(%r14), %r15
movq %rax, -0x30(%rbp)
leaq 0x11(%rax), %r12
leaq -0x11(%r15), %rsi
movq %r12, %rdi
callq 0x6b930
movl %eax, %r13d
leaq -0x42e0(%rbp), %rax
movq %rax, -0x38(%rbp)
testl %r13d, %r13d
je 0x701bc
cmpl $0x4001, %r13d          # imm = 0x4001
jb 0x70118
testq %r15, %r15
je 0x700f6
movq $0x0, 0x60(%r14)
leaq 0x9910(%rip), %rdx      # 0x79a0d
movq %rbx, %rdi
movl $0x1f4, %esi            # imm = 0x1F4
movl %r15d, %ecx
movq -0x30(%rbp), %r8
xorl %eax, %eax
callq 0x6ae64
jmp 0x701b2
leaq -0x2d8(%rbp), %r15
movl $0x2a0, %edx            # imm = 0x2A0
movq %r15, %rdi
xorl %esi, %esi
callq 0xc360
movl %r13d, %edx
leaq -0x42e0(%rbp), %rdi
movq %r12, %rsi
callq 0xc0e0
decl %r13d
movb $0x0, -0x42e0(%rbp,%r13)
leaq -0x38(%rbp), %rdi
movq %r15, %rsi
callq 0x6e6f9
leaq 0x98d9(%rip), %rsi      # 0x79a38
movq %r15, %rdi
callq 0x67c6a
testq %rax, %rax
je 0x70175
leaq 0x98ce(%rip), %rdi      # 0x79a41
jmp 0x70196
leaq 0x83de(%rip), %rsi      # 0x7855a
leaq -0x2d8(%rbp), %rdi
callq 0x67c6a
testq %rax, %rax
leaq 0x8d85(%rip), %rdi      # 0x78f17
cmovneq %rax, %rdi
movq 0x58(%r14), %rax
movb 0x2(%rdi), %cl
movb %cl, 0xb(%rax)
movzwl (%rdi), %ecx
movw %cx, 0x9(%rax)
callq 0xc370
movl %eax, 0x284(%rbx)
movq (%rbx), %rax
andl $-0x3, 0xa0(%rax)
addq $0x42b8, %rsp           # imm = 0x42B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/coyove[P]chann/./lib/mongoose/mongoose.c
// Function: process_response
static void process_response(struct connection *conn) {
  struct iobuf *io = &conn->ns_conn->recv_iobuf;

  try_parse(conn);
  DBG(("%p %d %lu", conn, conn->request_len, (unsigned long)io->len));
  if (conn->request_len < 0 ||
      (conn->request_len == 0 && io->len > MAX_REQUEST_SIZE)) {
    call_http_client_handler(conn);
  } else if ((int64_t) io->len >= conn->cl) {
    call_http_client_handler(conn);
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
movq (%rdi), %r14
callq 0x6da54
cmpq $0x0, 0x2e0(%rbx)
js 0x7020c
sete %cl
movq 0x48(%r14), %rax
cmpq $0x4001, %rax           # imm = 0x4001
setae %dl
testb %dl, %cl
jne 0x7020c
cmpq 0x2d8(%rbx), %rax
jge 0x7020c
popq %rbx
popq %r14
popq %rbp
retq
movq %rbx, %rdi
popq %rbx
popq %r14
popq %rbp
jmp 0x70215
// File: /workspace/github_c_makefile_star2_O3/coyove[P]chann/./lib/mongoose/mongoose.c
// Function: call_http_client_handler
static void call_http_client_handler(struct connection *conn) {
  //conn->mg_conn.status_code = code;
  // For responses without Content-Lengh, use the whole buffer
  if (conn->cl == 0) {
    conn->mg_conn.content_len = conn->ns_conn->recv_iobuf.len;
  }
  conn->mg_conn.content = conn->ns_conn->recv_iobuf.buf;
  if (call_user(conn, MG_REPLY) == MG_FALSE) {
    conn->ns_conn->flags |= NSF_CLOSE_IMMEDIATELY;
  }
  iobuf_remove(&conn->ns_conn->recv_iobuf, conn->mg_conn.content_len);
  conn->mg_conn.status_code = 0;
  conn->cl = conn->num_bytes_recv = conn->request_len = 0;
  NS_FREE(conn->request);
  conn->request = NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
cmpq $0x0, 0x2d8(%rdi)
movq (%rdi), %r14
jne 0x7023a
movq 0x48(%r14), %rax
movq %rax, 0x278(%rbx)
movq 0x40(%r14), %rax
movq %rax, 0x270(%rbx)
movq 0x2a8(%rbx), %rax
testq %rax, %rax
je 0x7026c
movq 0x30(%rax), %rax
testq %rax, %rax
je 0x7026c
leaq 0x8(%rbx), %rdi
movl $0x68, %esi
callq *%rax
movq (%rbx), %r14
testl %eax, %eax
jne 0x70274
orb $0x10, 0xa0(%r14)
movq 0x278(%rbx), %r15
testq %r15, %r15
je 0x7029a
movq 0x48(%r14), %rdx
subq %r15, %rdx
jb 0x7029a
movq 0x40(%r14), %rdi
leaq (%rdi,%r15), %rsi
callq 0xc1f0
subq %r15, 0x48(%r14)
movl $0x0, 0x284(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x2d0(%rbx)
xorl %r14d, %r14d
movq %r14, 0x2e0(%rbx)
movq 0x2c8(%rbx), %rdi
callq 0xc250
movq %r14, 0x2c8(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/coyove[P]chann/./lib/mongoose/mongoose.c
// Function: transfer_file_data
static void transfer_file_data(struct connection *conn) {
  char buf[IOBUF_SIZE];
  size_t n;

  // If output buffer is too big, don't send anything. Wait until
  // mongoose drains already buffered data to the client.
  if (conn->ns_conn->send_iobuf.len > sizeof(buf) * 2) return;

  // Do not send anyt
  n = read(conn->endpoint.fd, buf, conn->cl < (int64_t) sizeof(buf) ?
           (int) conn->cl : (int) sizeof(buf));

  if (n <= 0) {
    close_local_endpoint(conn);
  } else if (n > 0) {
    conn->cl -= n;
    ns_send(conn->ns_conn, buf, n);
    if (conn->cl <= 0) {
      close_local_endpoint(conn);
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
subq $0x2008, %rsp           # imm = 0x2008
movq (%rdi), %rax
cmpq $0x4000, 0x60(%rax)     # imm = 0x4000
ja 0x7034a
movq %rdi, %rbx
movl 0x2b0(%rdi), %edi
movq 0x2d8(%rbx), %rax
movl $0x2000, %ecx           # imm = 0x2000
cmpq %rcx, %rax
movslq %eax, %rdx
cmovgeq %rcx, %rdx
leaq -0x2010(%rbp), %rsi
callq 0xc890
testq %rax, %rax
je 0x70354
subq %rax, 0x2d8(%rbx)
movq (%rbx), %rdi
leaq -0x2010(%rbp), %rsi
movq %rax, %rdx
callq 0x6661a
cmpq $0x0, 0x2d8(%rbx)
jg 0x7034a
movq %rbx, %rdi
callq 0x68a64
addq $0x2008, %rsp           # imm = 0x2008
popq %rbx
popq %rbp
retq
movq %rbx, %rdi
addq $0x2008, %rsp           # imm = 0x2008
popq %rbx
popq %rbp
jmp 0x68a64
// File: /workspace/github_c_makefile_star2_O3/mikeakohn[P]print_pe/build/../src/print_lib.c
// Function: read_coff_header
int read_coff_header(FILE *in, struct coff_header_t *coff_header)
{
  coff_header->offset = ftell(in);

  coff_header->magic = read_uint16(in);
  coff_header->section_count = read_uint16(in);

  // It seems like if the magic number is 0 (and I guess section count
  // is 0xffff) that this isn't a COFF section.
  if (coff_header->magic == 0 && coff_header->section_count == 0xffff)
  {
    return -2;
  }

  coff_header->timestamp = read_uint32(in);
  coff_header->symbol_table_pointer = read_uint32(in);
  coff_header->symbol_count = read_uint32(in);
  coff_header->optional_header_size = read_uint16(in);
  coff_header->flags = read_uint16(in);

  return 0;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
callq 0x10c0
movq %rax, (%rbx)
movq %r14, %rdi
callq 0x250c
movw %ax, 0x8(%rbx)
movq %r14, %rdi
callq 0x250c
movl %eax, %ecx
movw %cx, 0xa(%rbx)
notl %ecx
movl $0xfffffffe, %eax       # imm = 0xFFFFFFFE
orw 0x8(%rbx), %cx
je 0x13d9
movq %r14, %rdi
callq 0x24ca
movl %eax, 0xc(%rbx)
movq %r14, %rdi
callq 0x24ca
movl %eax, 0x10(%rbx)
movq %r14, %rdi
callq 0x24ca
movl %eax, 0x14(%rbx)
movq %r14, %rdi
callq 0x250c
movw %ax, 0x18(%rbx)
movq %r14, %rdi
callq 0x250c
movw %ax, 0x1a(%rbx)
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O3/mikeakohn[P]print_pe/build/../src/print_lib.c
// Function: read_coff_optional_header
int read_coff_optional_header(
  FILE *in,
  struct coff_optional_header_t *optional_header)
{
  optional_header->offset = ftell(in);

  optional_header->magic = read_uint16(in);
  optional_header->version = read_uint16(in);
  optional_header->text_size = read_uint32(in);
  optional_header->data_size = read_uint32(in);
  optional_header->uninit_size = read_uint32(in);
  optional_header->entry_point = read_uint32(in);
  optional_header->text_start = read_uint32(in);
  optional_header->data_start = read_uint32(in);

  return 0;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
callq 0x10c0
movq %rax, (%rbx)
movq %r14, %rdi
callq 0x250c
movw %ax, 0x8(%rbx)
movq %r14, %rdi
callq 0x250c
movw %ax, 0xa(%rbx)
movq %r14, %rdi
callq 0x24ca
movl %eax, 0xc(%rbx)
movq %r14, %rdi
callq 0x24ca
movl %eax, 0x10(%rbx)
movq %r14, %rdi
callq 0x24ca
movl %eax, 0x14(%rbx)
movq %r14, %rdi
callq 0x24ca
movl %eax, 0x18(%rbx)
movq %r14, %rdi
callq 0x24ca
movl %eax, 0x1c(%rbx)
movq %r14, %rdi
callq 0x24ca
movl %eax, 0x20(%rbx)
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O3/mikeakohn[P]print_pe/build/../src/print_lib.c
// Function: print_symbol
int print_symbol(FILE *in)
{
  while (1)
  {
    int ch = getc(in);
    if (ch == 0 || ch == EOF) { break; }
    printf("%c", ch);
  }

  return 0;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
callq 0x1150
leal 0x1(%rax), %ecx
cmpl $0x2, %ecx
jb 0x17bc
movl %eax, %edi
callq 0x1040
movq %rbx, %rdi
callq 0x1150
movl %eax, %ecx
incl %ecx
cmpl $0x1, %ecx
ja 0x17a4
xorl %eax, %eax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O3/mikeakohn[P]print_pe/build/../src/print_lib.c
// Function: print_symbol_offsets
int print_symbol_offsets(FILE *in, uint32_t size)
{
  long marker = ftell(in);
  int symbol_count = read_uint32_be(in);
  uint32_t *offsets = (uint32_t *)malloc(symbol_count * sizeof(uint32_t));
  int n;

  printf(" --- symbol_count: %d ---\n", symbol_count);

  for (n = 0; n < symbol_count; n++)
  {
    offsets[n] = read_uint32_be(in);
  }

  for (n = 0; n < symbol_count; n++)
  {
    printf("   0x%06x  ", offsets[n]);
    print_symbol(in);
    printf("\n");
  }

  printf("\n");

  free(offsets);

  long total = ftell(in) - marker;

  if (total != size)
  {
    printf("Error: Bad archive members size %ld vs %d.\n", total, size);
    return -1;
  }

  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %esi, 0xc(%rsp)
movq %rdi, %r14
callq 0x10c0
movq %rax, 0x10(%rsp)
movq %r14, %rdi
callq 0x25b0
movl %eax, %r13d
movslq %eax, %r15
leaq (,%r15,4), %rdi
callq 0x10e0
movq %rax, %r12
leaq 0x3be2(%rip), %rdi      # 0x53e6
xorl %ebp, %ebp
movl %r15d, %esi
xorl %eax, %eax
callq 0x1090
testl %r15d, %r15d
jle 0x1864
movl %r13d, %r15d
xorl %ebx, %ebx
movq %r14, %rdi
callq 0x25b0
movl %eax, (%r12,%rbx,4)
incq %rbx
cmpq %rbx, %r15
jne 0x181a
testl %r13d, %r13d
jle 0x1864
leaq 0x3bc7(%rip), %r13      # 0x5401
xorl %ebx, %ebx
movl (%r12,%rbx,4), %esi
movq %r13, %rdi
xorl %eax, %eax
callq 0x1090
movq %r14, %rdi
callq 0x1793
movl $0xa, %edi
callq 0x1040
incq %rbx
cmpq %rbx, %r15
jne 0x183c
movl $0xa, %edi
callq 0x1040
movq %r12, %rdi
callq 0x1030
movq %r14, %rdi
callq 0x10c0
subq 0x10(%rsp), %rax
movl 0xc(%rsp), %edx
movl %edx, %ecx
cmpq %rcx, %rax
je 0x18a4
leaq 0x3b78(%rip), %rdi      # 0x540d
movq %rax, %rsi
xorl %eax, %eax
callq 0x1090
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/mikeakohn[P]print_pe/build/../src/print_lib.c
// Function: print_symbol_header
int print_symbol_header(FILE *in)
{
  struct coff_symbol_header_t symbol_header;

  symbol_header.offset = ftell(in);
  symbol_header.version = read_uint16(in);
  symbol_header.machine = read_uint16(in);
  symbol_header.timestamp = read_uint32(in);
  symbol_header.size = read_uint32(in);
  symbol_header.unknown_0 = read_uint16(in);
  symbol_header.unknown_1 = read_uint16(in);

  printf("--- symbol %06lx ---\n", symbol_header.offset);
  printf("        version: 0x%04x\n", symbol_header.version);
  printf("        machine: 0x%04x\n", symbol_header.machine);
  printf("      timestamp: %d\n", symbol_header.timestamp);
  printf("           size: %d\n", symbol_header.size);
  printf("      unknown_0: %d\n", symbol_header.unknown_0);
  printf("      unknown_1: %d\n", symbol_header.unknown_1);
  printf("           name: ");
  print_symbol(in);
  printf("\n");
  printf("            DLL: ");
  print_symbol(in);
  printf("\n\n");

  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
callq 0x10c0
movq %rax, %r12
movq %rbx, %rdi
callq 0x250c
movl %eax, %r15d
movq %rbx, %rdi
callq 0x250c
movl %eax, %r13d
movq %rbx, %rdi
callq 0x24ca
movl %eax, (%rsp)
movq %rbx, %rdi
callq 0x24ca
movl %eax, 0x4(%rsp)
movq %rbx, %rdi
callq 0x250c
movl %eax, %r14d
movq %rbx, %rdi
callq 0x250c
movl %eax, %ebp
leaq 0x3b25(%rip), %rdi      # 0x5439
movq %r12, %rsi
xorl %eax, %eax
callq 0x1090
movl $0xffff, %r12d          # imm = 0xFFFF
andl %r12d, %r15d
leaq 0x38ae(%rip), %rdi      # 0x51dc
movl %r15d, %esi
xorl %eax, %eax
callq 0x1090
andl %r12d, %r13d
leaq 0x4653(%rip), %rdi      # 0x5f95
movl %r13d, %esi
xorl %eax, %eax
callq 0x1090
leaq 0x37f8(%rip), %rdi      # 0x514b
movl (%rsp), %esi
xorl %eax, %eax
callq 0x1090
leaq 0x39ba(%rip), %rdi      # 0x531e
movl 0x4(%rsp), %esi
xorl %eax, %eax
callq 0x1090
andl %r12d, %r14d
leaq 0x3ad6(%rip), %rdi      # 0x544f
movl %r14d, %esi
xorl %eax, %eax
callq 0x1090
andl %r12d, %ebp
leaq 0x3ad7(%rip), %rdi      # 0x5464
movl %ebp, %esi
xorl %eax, %eax
callq 0x1090
leaq 0x3adc(%rip), %rdi      # 0x5479
xorl %eax, %eax
callq 0x1090
movq %rbx, %rdi
callq 0x1793
movl $0xa, %edi
callq 0x1040
leaq 0x3ace(%rip), %rdi      # 0x548b
xorl %eax, %eax
callq 0x1090
movq %rbx, %rdi
callq 0x1793
leaq 0x4e49(%rip), %rdi      # 0x681c
callq 0x1060
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/mikeakohn[P]print_pe/build/../src/print_lib.c
// Function: print_public_symbols
int print_public_symbols(FILE *in, uint32_t size)
{
  long marker = ftell(in);
  int offset_count = read_uint32(in);
  int n;

  printf(" --- offset_count: %d ---\n", offset_count);

  for (n = 0; n < offset_count; n++)
  {
    printf("  %02x %06x\n", n, read_uint32(in));
  }

  printf("\n");

  int symbol_count = read_uint32(in);
  uint16_t *offsets = (uint16_t *)malloc(symbol_count * sizeof(uint16_t));

  printf(" --- symbol_count: %d ---\n", symbol_count);

  for (n = 0; n < symbol_count; n++)
  {
    offsets[n] = read_uint16(in);
  }

  for (n = 0; n < symbol_count; n++)
  {
    printf("   0x%04x  ", offsets[n]);
	    print_symbol(in);
	    printf("\n");
	  }

	  printf("\n");

	  long total = ftell(in) - marker;

	  if (total != size)
	  {
	    printf("Error: Bad archive members size %ld vs %d.\n", total, size);
	    return -1;
	  }

	  return 0;
	}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %esi, 0xc(%rsp)
movq %rdi, %r14
callq 0x10c0
movq %rax, 0x10(%rsp)
movq %r14, %rdi
callq 0x24ca
movl %eax, %ebp
leaq 0x3a84(%rip), %rdi      # 0x549d
movl %eax, %esi
xorl %eax, %eax
callq 0x1090
testl %ebp, %ebp
jle 0x1a4f
leaq 0x3a8b(%rip), %r12      # 0x54b8
xorl %r13d, %r13d
movq %r14, %rdi
callq 0x24ca
movq %r12, %rdi
movl %r13d, %esi
movl %eax, %edx
xorl %eax, %eax
callq 0x1090
incl %r13d
cmpl %r13d, %ebp
jne 0x1a30
movl $0xa, %edi
callq 0x1040
movq %r14, %rdi
callq 0x24ca
movl %eax, %r13d
movslq %eax, %r15
leaq (%r15,%r15), %rdi
callq 0x10e0
movq %rax, %r12
leaq 0x396c(%rip), %rdi      # 0x53e6
xorl %ebp, %ebp
movl %r15d, %esi
xorl %eax, %eax
callq 0x1090
testl %r15d, %r15d
jle 0x1adc
movl %r13d, %r15d
xorl %ebx, %ebx
movq %r14, %rdi
callq 0x250c
movw %ax, (%r12,%rbx,2)
incq %rbx
cmpq %rbx, %r15
jne 0x1a90
testl %r13d, %r13d
jle 0x1adc
leaq 0x3a14(%rip), %r13      # 0x54c5
xorl %ebx, %ebx
movzwl (%r12,%rbx,2), %esi
movq %r13, %rdi
xorl %eax, %eax
callq 0x1090
movq %r14, %rdi
callq 0x1793
movl $0xa, %edi
callq 0x1040
incq %rbx
cmpq %rbx, %r15
jne 0x1ab3
movl $0xa, %edi
callq 0x1040
movq %r14, %rdi
callq 0x10c0
subq 0x10(%rsp), %rax
movl 0xc(%rsp), %edx
movl %edx, %ecx
cmpq %rcx, %rax
je 0x1b14
leaq 0x3908(%rip), %rdi      # 0x540d
movq %rax, %rsi
xorl %eax, %eax
callq 0x1090
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/mikeakohn[P]print_pe/build/../src/print_lib.c
// Function: print_name
int print_name(FILE *in, uint32_t size)
	{
	  long marker = ftell(in);

	  printf("   name: ");
	  print_symbol(in);
  printf("\n\n");

  long total = ftell(in) - marker;

  if (total != size)
  {
    printf("Error: Bad archive members size %ld vs %d.\n", total, size);
    return -1;
  }

  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %esi, %ebx
movq %rdi, %r14
callq 0x10c0
movq %rax, %r15
leaq 0x3941(%rip), %rdi      # 0x5481
xorl %ebp, %ebp
xorl %eax, %eax
callq 0x1090
movq %r14, %rdi
callq 0x1793
leaq 0x4cc4(%rip), %rdi      # 0x681c
callq 0x1060
movq %r14, %rdi
callq 0x10c0
subq %r15, %rax
movl %ebx, %ecx
cmpq %rcx, %rax
je 0x1b87
leaq 0x3897(%rip), %rdi      # 0x540d
movq %rax, %rsi
movl %ebx, %edx
xorl %eax, %eax
callq 0x1090
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/mikeakohn[P]print_pe/build/../src/print_lib.c
// Function: print_raw
int print_raw(FILE *in, long offset, uint32_t size)
{
  long marker = ftell(in);
  fseek(in, offset, SEEK_SET);
  int n, i;

  uint8_t data[16];
  int total = 0;

  for (n = 0; n < size; n += 16)
  {
    int length = fread(data, 1, 16, in);
    printf("  %06x: ", n);

    total += length;
    if (total > size) { length -= total - size; }

    for (i = 0; i < length; i++)
    {
      printf("%02x ", data[i]);
    }

    for (i = length; i < 16; i++) { printf("   "); }

    for (i = 0; i < length; i++)
    {
      printf("%c", data[i] >= 32 && data[i] < 126 ? data[i] : '.');
    }

    printf("\n");
  }

  printf("\n");

  fseek(in, marker, SEEK_SET);

  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %edx, %r15d
movq %rsi, %r14
movq %rdi, %rbx
callq 0x10c0
movq %rax, 0x18(%rsp)
movq %rbx, 0x10(%rsp)
movq %rbx, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x10f0
testl %r15d, %r15d
je 0x1cc4
leaq 0x3903(%rip), %r13      # 0x54da
leaq 0x3918(%rip), %r14      # 0x54f6
xorl %ebx, %ebx
xorl %ebp, %ebp
movl %r15d, 0x8(%rsp)
movl $0x1, %esi
movl $0x10, %edx
leaq 0x20(%rsp), %rdi
movq 0x10(%rsp), %rcx
callq 0x1070
movq %rax, %r12
leaq 0x38c7(%rip), %rdi      # 0x54d1
movl %ebp, 0xc(%rsp)
movl %ebp, %esi
xorl %eax, %eax
callq 0x1090
leal (%rbx,%r12), %eax
movl %eax, 0x4(%rsp)
subl %r15d, %eax
movl $0x0, %ecx
cmovbl %ecx, %eax
subl %eax, %r12d
movl %r12d, %ebp
testl %r12d, %r12d
jle 0x1c5b
xorl %r15d, %r15d
movzbl 0x20(%rsp,%r15), %esi
movq %r13, %rdi
xorl %eax, %eax
callq 0x1090
incq %r15
cmpq %rbp, %r15
jb 0x1c38
cmpl $0xf, %r12d
movl 0x8(%rsp), %r15d
jg 0x1c80
movl 0x4(%rsp), %eax
cmpl %eax, %r15d
cmovbl %r15d, %eax
notl %ebx
addl %eax, %ebx
movq %r14, %rdi
xorl %eax, %eax
callq 0x1090
incl %ebx
cmpl $0xf, %ebx
jl 0x1c6a
testl %r12d, %r12d
jle 0x1ca4
xorl %ebx, %ebx
movzbl 0x20(%rsp,%rbx), %eax
leal -0x20(%rax), %ecx
cmpb $0x5e, %cl
jb 0x1c94
movl $0x2e, %eax
movzbl %al, %edi
callq 0x1040
incq %rbx
cmpq %rbp, %rbx
jb 0x1c82
movl $0xa, %edi
callq 0x1040
movl 0xc(%rsp), %ebp
addl $0x10, %ebp
movl 0x4(%rsp), %eax
movl %eax, %ebx
cmpl %r15d, %ebp
jb 0x1be7
movl $0xa, %edi
callq 0x1040
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rsi
xorl %edx, %edx
callq 0x10f0
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq