LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O3/coyove[P]chann/./lib/mongoose/mongoose.c
// Function: ns_hexdump
int ns_hexdump(const void *buf, int len, char *dst, int dst_len) {
  const unsigned char *p = (const unsigned char *) buf;
  char ascii[17] = "";
  int i, idx, n = 0;

  for (i = 0; i < len; i++) {
    idx = i % 16;
    if (idx == 0) {
      if (i > 0) n += snprintf(dst + n, dst_len - n, "  %s\n", ascii);
      n += snprintf(dst + n, dst_len - n, "%04x ", i);
    }
    n += snprintf(dst + n, dst_len - n, " %02x", p[i]);
    ascii[idx] = p[i] < 0x20 || p[i] > 0x7e ? '.' : p[i];
    ascii[idx + 1] = '\0';
  }

  while (i++ % 16) n += snprintf(dst + n, dst_len - n, "%s", "   ");
  n += snprintf(dst + n, dst_len - n, "  %s\n\n", ascii);

  return n;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdx, %r8
movq %rdi, -0x60(%rbp)
xorps %xmm0, %xmm0
movaps %xmm0, -0x50(%rbp)
movb $0x0, -0x40(%rbp)
testl %esi, %esi
jle 0x66f10
movl %esi, %r15d
movl %ecx, -0x2c(%rbp)
movq %r8, -0x38(%rbp)
movl %esi, %eax
movq %rax, -0x58(%rbp)
xorl %r13d, %r13d
xorl %eax, %eax
movq %r13, %rbx
andq $0xf, %rbx
je 0x66dfe
movq -0x38(%rbp), %rcx
movl -0x2c(%rbp), %r12d
jmp 0x66e62
testq %r13, %r13
movq -0x38(%rbp), %rcx
je 0x66e36
movslq %eax, %r14
leaq (%rcx,%r14), %rdi
movl -0x2c(%rbp), %r12d
movl %r12d, %eax
subl %r14d, %eax
movslq %eax, %rsi
leaq 0xa252(%rip), %rdx      # 0x71074
leaq -0x50(%rbp), %rcx
xorl %eax, %eax
callq 0xc5d0
movq -0x38(%rbp), %rcx
addl %r14d, %eax
jmp 0x66e3a
movl -0x2c(%rbp), %r12d
movslq %eax, %r14
leaq (%rcx,%r14), %rdi
movl %r12d, %eax
subl %r14d, %eax
movslq %eax, %rsi
leaq 0x1147f(%rip), %rdx     # 0x782d0
movl %r13d, %ecx
xorl %eax, %eax
callq 0xc5d0
movq -0x38(%rbp), %rcx
addl %r14d, %eax
movslq %eax, %r14
leaq (%rcx,%r14), %rdi
subl %r14d, %r12d
movslq %r12d, %rsi
movq -0x60(%rbp), %r12
movzbl (%r12,%r13), %ecx
leaq 0x11457(%rip), %rdx     # 0x782d6
xorl %eax, %eax
callq 0xc5d0
addl %r14d, %eax
movzbl (%r12,%r13), %ecx
leal -0x7f(%rcx), %edx
cmpb $-0x5f, %dl
movl $0x2e, %edx
cmovbl %edx, %ecx
movl %r13d, %edx
andl $0xf, %edx
movb %cl, -0x50(%rbp,%rdx)
leaq -0x50(%rbp), %rcx
movb $0x0, 0x1(%rbx,%rcx)
incq %r13
cmpq %r13, -0x58(%rbp)
jne 0x66deb
testb $0xf, %r15b
je 0x66f14
incl %r15d
leaq 0xf483(%rip), %r12      # 0x7634f
leaq 0x10c4c(%rip), %r13     # 0x77b1f
movl %r15d, %ebx
movq -0x38(%rbp), %r8
movl -0x2c(%rbp), %ecx
movslq %eax, %r14
leaq (%r8,%r14), %rdi
movl %ecx, %eax
subl %r14d, %eax
movslq %eax, %rsi
movq %r12, %rdx
movq %r13, %rcx
xorl %eax, %eax
callq 0xc5d0
movl -0x2c(%rbp), %ecx
movq -0x38(%rbp), %r8
addl %r14d, %eax
incl %ebx
testb $0xf, %r15b
movl %ebx, %r15d
jne 0x66edd
jmp 0x66f1b
xorl %eax, %eax
jmp 0x66f1b
movq -0x38(%rbp), %r8
movl -0x2c(%rbp), %ecx
movslq %eax, %rbx
addq %rbx, %r8
subl %ebx, %ecx
movslq %ecx, %rsi
leaq 0x113af(%rip), %rdx     # 0x782dc
leaq -0x50(%rbp), %rcx
movq %r8, %rdi
xorl %eax, %eax
callq 0xc5d0
addl %ebx, %eax
addq $0x38, %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: ns_call
static void ns_call(struct ns_connection *nc, int ev, void *p) {
  if (nc->mgr->hexdump_file != NULL && ev != NS_POLL) {
    int len = (ev == NS_RECV || ev == NS_SEND) ? * (int *) p : 0;
    hexdump(nc, nc->mgr->hexdump_file, len, ev);
  }

  nc->callback(nc, ev, p);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rdx, %rbx
movl %esi, %r15d
movq %rdi, %r14
movq 0x18(%rdi), %rax
movq 0x8(%rax), %rdi
testq %rdi, %rdi
sete %al
testl %esi, %esi
sete %cl
orb %al, %cl
jne 0x67637
leal -0x3(%r15), %r12d
xorl %eax, %eax
cmpl $0x1, %r12d
ja 0x674f3
movl (%rbx), %eax
movq %rax, -0x40(%rbp)
cmpl $0x4, %r15d
movl $0x58, %eax
movl $0x40, %r13d
cmoveq %rax, %r13
leaq 0xa605(%rip), %rsi      # 0x71b16
callq 0xcb90
movq %rax, -0x30(%rbp)
testq %rax, %rax
je 0x67637
movl 0x20(%r14), %edi
leaq -0xc0(%rbp), %rsi
movl $0x3c, %edx
movl $0x3, %ecx
callq 0x66ce6
movl 0x20(%r14), %edi
leaq -0x80(%rbp), %rsi
movl $0x3c, %edx
movl $0x7, %ecx
callq 0x66ce6
xorl %edi, %edi
callq 0xc820
movq 0x80(%r14), %rcx
cmpl $0x3, %r15d
leaq 0x10f55(%rip), %rdx     # 0x784c2
leaq 0x10f51(%rip), %r9      # 0x784c5
cmoveq %rdx, %r9
cmpl $0x2, %r12d
jb 0x675a3
cmpl $0x1, %r15d
jne 0x6758d
leaq 0x10f3d(%rip), %r9      # 0x784c8
jmp 0x675a3
cmpl $0x2, %r15d
leaq 0x10f33(%rip), %rdx     # 0x784cb
leaq 0x10f2f(%rip), %r9      # 0x784ce
cmoveq %rdx, %r9
leaq 0x10f04(%rip), %rsi     # 0x784ae
leaq -0xc0(%rbp), %r8
movq -0x30(%rbp), %rdi
movq %rax, %rdx
xorl %eax, %eax
movq -0x40(%rbp), %r12
pushq %r12
leaq -0x80(%rbp), %r10
pushq %r10
callq 0xc260
movq %r12, %rax
addq $0x10, %rsp
testl %eax, %eax
jle 0x6762e
leal (%rax,%rax,4), %eax
addl $0x64, %eax
movl %eax, -0x34(%rbp)
movl %eax, %edi
callq 0xca00
movq -0x40(%rbp), %rsi
testq %rax, %rax
je 0x6762e
movq %rax, %r12
movq (%r14,%r13), %rdi
cmpl $0x4, %r15d
jne 0x67602
xorl %eax, %eax
xorl %ecx, %ecx
jmp 0x67609
movq 0x8(%r14,%r13), %rcx
movl %esi, %eax
addq %rcx, %rdi
subq %rax, %rdi
movq %r12, %rdx
movl -0x34(%rbp), %ecx
callq 0x66dab
movq %r12, %rdi
movq -0x30(%rbp), %rsi
callq 0xc380
movq %r12, %rdi
callq 0xc250
movq -0x30(%rbp), %rdi
callq 0xc4c0
movq %r14, %rdi
movl %r15d, %esi
movq %rbx, %rdx
callq *0x98(%r14)
addq $0x98, %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: ns_close_conn
static void ns_close_conn(struct ns_connection *conn) {
  DBG(("%p %d", conn, conn->flags));
  ns_call(conn, NS_CLOSE, NULL);
  ns_remove_conn(conn);
  ns_destroy_conn(conn);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl $0x5, %esi
xorl %edx, %edx
callq 0x674ad
movq (%rbx), %rax
movq 0x8(%rbx), %rcx
movq %rcx, %rdx
testq %rcx, %rcx
jne 0x67681
movq 0x18(%rbx), %rdx
movq %rax, (%rdx)
testq %rax, %rax
je 0x6768d
movq %rcx, 0x8(%rax)
movl 0x20(%rbx), %edi
callq 0xc2b0
leaq 0x40(%rbx), %rdi
callq 0x66379
leaq 0x58(%rbx), %rdi
callq 0x66379
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0xc250
// File: /workspace/github_c_makefile_star2_O3/coyove[P]chann/./lib/mongoose/mongoose.c
// Function: ns_connect
struct ns_connection *ns_connect(struct ns_mgr *mgr, const char *address,
                                 ns_callback_t callback, void *user_data) {
  sock_t sock = INVALID_SOCKET;
  struct ns_connection *nc = NULL;
  union socket_address sa;
  char cert[100], ca_cert[100];
  int rc, use_ssl, proto;

  ns_parse_address(address, &sa, &proto, &use_ssl, cert, ca_cert);
  if ((sock = socket(AF_INET, proto, 0)) == INVALID_SOCKET) {
    return NULL;
  }
  ns_set_non_blocking_mode(sock);
  rc = (proto == SOCK_DGRAM) ? 0 : connect(sock, &sa.sa, sizeof(sa.sin));

  if (rc != 0 && ns_is_error(rc)) {
    closesocket(sock);
    return NULL;
  } else if ((nc = ns_add_sock(mgr, sock, callback, user_data)) == NULL) {
    closesocket(sock);
    return NULL;
  }

  nc->sa = sa;   // Important, cause UDP conns will use sendto()
  nc->flags = (proto == SOCK_DGRAM) ? NSF_UDP : NSF_CONNECTING;

#ifdef NS_ENABLE_SSL
  if (use_ssl) {
    if ((nc->ssl_ctx = SSL_CTX_new(SSLv23_client_method())) == NULL ||
        ns_use_cert(nc->ssl_ctx, cert) != 0 ||
        ns_use_ca_cert(nc->ssl_ctx, ca_cert) != 0 ||
        (nc->ssl = SSL_new(nc->ssl_ctx)) == NULL) {
      ns_close_conn(nc);
      return NULL;
    } else {
      SSL_set_fd(nc->ssl, sock);
    }
  }
#endif

  return nc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xf8, %rsp
movq %rcx, -0x30(%rbp)
movq %rdx, %r14
movq %rsi, %rax
movq %rdi, %r15
leaq -0x48(%rbp), %rsi
leaq -0x34(%rbp), %rbx
leaq -0x38(%rbp), %rcx
leaq -0x120(%rbp), %r8
leaq -0xb0(%rbp), %r9
movq %rax, %rdi
movq %rbx, %rdx
callq 0x66a3e
movl (%rbx), %r12d
xorl %ebx, %ebx
movl $0x2, %edi
movl %r12d, %esi
xorl %edx, %edx
callq 0xc550
cmpl $-0x1, %eax
je 0x678c6
movl %eax, %r13d
movl %eax, %edi
movl $0x3, %esi
xorl %edx, %edx
xorl %eax, %eax
callq 0xc220
orl $0x800, %eax            # imm = 0x800
movl %r13d, %edi
movl $0x4, %esi
movl %eax, %edx
xorl %eax, %eax
callq 0xc220
cmpl $0x2, %r12d
je 0x67881
leaq -0x48(%rbp), %rsi
movl %r13d, %edi
movl $0x10, %edx
callq 0xc420
testl %eax, %eax
je 0x67881
movl %eax, %edi
callq 0x678db
testl %eax, %eax
jne 0x678bc
movq %r15, %rdi
movl %r13d, %esi
movq %r14, %rdx
movq -0x30(%rbp), %rcx
callq 0x66c32
testq %rax, %rax
je 0x678bc
movq %rax, %rbx
cmpl $0x2, %r12d
movups -0x48(%rbp), %xmm0
movups %xmm0, 0x24(%rax)
movl $0x100, %eax            # imm = 0x100
movl $0x8, %ecx
cmovel %eax, %ecx
movl %ecx, 0xa0(%rbx)
jmp 0x678c6
movl %r13d, %edi
callq 0xc2b0
xorl %ebx, %ebx
movq %rbx, %rax
addq $0xf8, %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: ns_is_error
static int ns_is_error(int n) {
  return n == 0 ||
    (n < 0 && errno != EINTR && errno != EINPROGRESS &&
     errno != EAGAIN && errno != EWOULDBLOCK
#ifdef _WIN32
     && WSAGetLastError() != WSAEINTR && WSAGetLastError() != WSAEWOULDBLOCK
#endif
    );
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movl $0x1, %ebx
testl %edi, %edi
je 0x678f0
xorl %ebx, %ebx
testl %edi, %edi
js 0x678f9
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
callq 0xcb20
movl (%rax), %eax
cmpl $0x4, %eax
je 0x678f0
cmpl $0xb, %eax
je 0x678f0
cmpl $0x73, %eax
je 0x678f0
movl $0x1, %ebx
jmp 0x678f0
// File: /workspace/github_c_makefile_star2_O3/coyove[P]chann/./lib/mongoose/mongoose.c
// Function: ns_broadcast
void ns_broadcast(struct ns_mgr *mgr, ns_callback_t cb,void *data, size_t len) {
  struct ctl_msg ctl_msg;
  if (mgr->ctl[0] != INVALID_SOCKET && data != NULL &&
      len < sizeof(ctl_msg.message)) {
    ctl_msg.callback = cb;
    memcpy(ctl_msg.message, data, len);
    send(mgr->ctl[0], (char *) &ctl_msg,
         offsetof(struct ctl_msg, message) + len, 0);
    recv(mgr->ctl[0], (char *) &len, 1, 0);
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x2018, %rsp           # imm = 0x2018
movq %rcx, -0x20(%rbp)
cmpq $0x1fff, %rcx           # imm = 0x1FFF
ja 0x67989
testq %rdx, %rdx
je 0x67989
movq %rdi, %rbx
movl 0x10(%rdi), %r15d
cmpl $-0x1, %r15d
je 0x67989
movq %rcx, %r14
leaq -0x2020(%rbp), %rdi
movq %rsi, -0x8(%rdi)
movq %rdx, %rsi
movq %rcx, %rdx
callq 0xc0e0
addq $0x8, %r14
leaq -0x2028(%rbp), %rsi
movl %r15d, %edi
movq %r14, %rdx
xorl %ecx, %ecx
callq 0xc3d0
movl 0x10(%rbx), %edi
leaq -0x20(%rbp), %rsi
movl $0x1, %edx
xorl %ecx, %ecx
callq 0xca80
addq $0x2018, %rsp           # imm = 0x2018
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/coyove[P]chann/./lib/mongoose/mongoose.c
// Function: ns_mgr_init
void ns_mgr_init(struct ns_mgr *s, void *user_data) {
  memset(s, 0, sizeof(*s));
  s->ctl[0] = s->ctl[1] = INVALID_SOCKET;
  s->user_data = user_data;

#ifdef _WIN32
  { WSADATA data; WSAStartup(MAKEWORD(2, 2), &data); }
#else
  // Ignore SIGPIPE signal, so if client cancels the request, it
  // won't kill the whole process.
  signal(SIGPIPE, SIG_IGN);
#endif

#ifndef NS_DISABLE_SOCKETPAIR
  {
    int attempts = 0, max_attempts = NS_MAX_SOCKETPAIR_ATTEMPTS;
    do {
      ns_socketpair2(s->ctl, SOCK_DGRAM);
    } while (s->ctl[0] == INVALID_SOCKET && ++attempts < max_attempts);
  }
#endif

#ifdef NS_ENABLE_SSL
  {static int init_done; if (!init_done) { SSL_library_init(); init_done++; }}
#endif
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
xorps %xmm0, %xmm0
movups %xmm0, (%rdi)
leaq 0x10(%rdi), %rbx
movq $-0x1, 0x10(%rdi)
movq %rsi, 0x18(%rdi)
movl $0x1, %esi
movl $0xd, %edi
callq 0xc3f0
xorl %r14d, %r14d
movq %rbx, %rdi
movl $0x2, %esi
callq 0x666ea
cmpl $-0x1, (%rbx)
jne 0x679e5
leal 0x1(%r14), %eax
cmpl $0x9, %r14d
movl %eax, %r14d
jb 0x679c6
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/coyove[P]chann/./lib/mongoose/mongoose.c
// Function: ns_mgr_free
void ns_mgr_free(struct ns_mgr *s) {
  struct ns_connection *conn, *tmp_conn;

  DBG(("%p", s));
  if (s == NULL) return;
  // Do one last poll, see https://github.com/cesanta/mongoose/issues/286
  ns_mgr_poll(s, 0);

  if (s->ctl[0] != INVALID_SOCKET) closesocket(s->ctl[0]);
  if (s->ctl[1] != INVALID_SOCKET) closesocket(s->ctl[1]);
  s->ctl[0] = s->ctl[1] = INVALID_SOCKET;

  for (conn = s->active_connections; conn != NULL; conn = tmp_conn) {
    tmp_conn = conn->next;
    ns_close_conn(conn);
  }
}

// Assembly:
testq %rdi, %rdi
je 0x67a3f
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
xorl %esi, %esi
callq 0x66f56
movl 0x10(%rbx), %edi
cmpl $-0x1, %edi
je 0x67a0c
callq 0xc2b0
movl 0x14(%rbx), %edi
cmpl $-0x1, %edi
je 0x67a19
callq 0xc2b0
movq $-0x1, 0x10(%rbx)
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x67a39
movq (%rdi), %rbx
callq 0x67659
movq %rbx, %rdi
testq %rbx, %rbx
jne 0x67a29
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/coyove[P]chann/./lib/mongoose/mongoose.c
// Function: mg_url_decode
int mg_url_decode(const char *src, size_t src_len, char *dst,
                  size_t dst_len, int is_form_url_encoded) {
  size_t i, j = 0;
  int a, b;
#define HEXTOI(x) (isdigit(x) ? (x) - '0' : (x) - 'W')

  for (i = j = 0; i < src_len && j < dst_len - 1; i++, j++) {
    if (src[i] == '%' && i + 2 < src_len &&
        isxdigit(* (const unsigned char *) (src + i + 1)) &&
        isxdigit(* (const unsigned char *) (src + i + 2))) {
      a = tolower(* (const unsigned char *) (src + i + 1));
      b = tolower(* (const unsigned char *) (src + i + 2));
      dst[j] = (char) ((HEXTOI(a) << 4) | HEXTOI(b));
      i += 2;
    } else if (is_form_url_encoded && src[i] == '+') {
      dst[j] = ' ';
    } else {
      dst[j] = src[i];
    }
  }

  dst[j] = '\0'; // Null-terminate the destination

  return i >= src_len ? j : -1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %r8d, -0x2c(%rbp)
testq %rsi, %rsi
setne %al
sete %r9b
decq %rcx
sete %r8b
orb %r9b, %r8b
jne 0x67c48
xorl %ebx, %ebx
xorl %r14d, %r14d
movq %rdx, -0x50(%rbp)
movq %rcx, -0x48(%rbp)
movq %rsi, -0x40(%rbp)
movq %rdi, -0x38(%rbp)
movb (%rdi,%rbx), %r13b
cmpb $0x25, %r13b
jne 0x67c1c
leaq 0x2(%rbx), %r15
cmpq %rsi, %r15
jae 0x67c2b
callq 0xc170
movq -0x38(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq -0x48(%rbp), %rcx
movq -0x50(%rbp), %rdx
movq (%rax), %rax
movzbl 0x1(%rdi,%rbx), %r12d
testb $0x10, 0x1(%rax,%r12,2)
je 0x67c2b
movzbl 0x2(%rdi,%rbx), %r8d
testb $0x10, 0x1(%rax,%r8,2)
je 0x67c2b
movq %rax, %rbx
movq %r8, %r13
callq 0xc4a0
movq -0x38(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq -0x48(%rbp), %rcx
movq -0x50(%rbp), %rdx
movq (%rax), %rax
movslq (%rax,%r12,4), %r9
movslq (%rax,%r13,4), %rax
xorl %r8d, %r8d
testb $0x8, 0x1(%rbx,%r9,2)
sete %r8b
leal (%r8,%r8,8), %r8d
addl %r9d, %r8d
shll $0x4, %r8d
leal 0xd0(%rax), %r9d
leal 0xa9(%rax), %r13d
testb $0x8, 0x1(%rbx,%rax,2)
cmovnel %r9d, %r13d
orl %r8d, %r13d
movq %r15, %rbx
jmp 0x67c2b
cmpl $0x0, -0x2c(%rbp)
je 0x67c2b
cmpb $0x2b, %r13b
jne 0x67c2b
movb $0x20, %r13b
movb %r13b, (%rdx,%r14)
incq %rbx
incq %r14
cmpq %rsi, %rbx
setb %al
jae 0x67c4b
cmpq %rcx, %r14
jb 0x67b70
jmp 0x67c4b
xorl %r14d, %r14d
movb $0x0, (%rdx,%r14)
testb %al, %al
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmovel %r14d, %eax
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: mg_get_header
const char *mg_get_header(const struct mg_connection *ri, const char *s) {
  int i;

  for (i = 0; i < ri->num_headers; i++)
    if (!mg_strcasecmp(s, ri->http_headers[i].name))
      return ri->http_headers[i].value;

  return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movslq 0x84(%rdi), %r15
testq %r15, %r15
jle 0x67cd9
movq %rsi, %rbx
movq %rdi, %r14
addq $0x88, %r14
callq 0xc4a0
movq (%rax), %rcx
xorl %eax, %eax
xorl %edx, %edx
movq %rdx, %rdi
shlq $0x4, %rdi
leaq (%r14,%rdi), %rsi
movq (%r14,%rdi), %rdi
xorl %r8d, %r8d
movzbl (%rbx,%r8), %r11d
movl (%rcx,%r11,4), %r9d
movzbl (%rdi,%r8), %r10d
movl (%rcx,%r10,4), %r10d
testl %r11d, %r11d
je 0x67cca
incq %r8
cmpl %r10d, %r9d
je 0x67cab
cmpl %r10d, %r9d
je 0x67cdd
incq %rdx
cmpq %r15, %rdx
jne 0x67c99
jmp 0x67ce1
xorl %eax, %eax
jmp 0x67ce1
movq 0x8(%rsi), %rax
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: mg_template
void mg_template(struct mg_connection *conn, const char *s,
                 struct mg_expansion *expansions) {
  int i, j, pos = 0, inside_marker = 0;

  for (i = 0; s[i] != '\0'; i++) {
    if (inside_marker == 0 && !memcmp(&s[i], "{{", 2)) {
      if (i > pos) {
        mg_send_data(conn, &s[pos], i - pos);
      }
      pos = i;
      inside_marker = 1;
    }
    if (inside_marker == 1 && !memcmp(&s[i], "}}", 2)) {
      for (j = 0; expansions[j].keyword != NULL; j++) {
        const char *kw = expansions[j].keyword;
        if ((int) strlen(kw) == i - (pos + 2) &&
            memcmp(kw, &s[pos + 2], i - (pos + 2)) == 0) {
          expansions[j].handler(conn);
          pos = i + 2;
          break;
        }
      }
      inside_marker = 0;
    }
  }
  if (i > pos) {
    mg_send_data(conn, &s[pos], i - pos);
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
cmpb $0x0, (%rsi)
je 0x67fea
movq %rsi, %r12
movq %rdi, %rbx
leaq -0x8(%rdi), %rax
movq %rax, -0x40(%rbp)
leaq 0x10(%rdx), %rax
movq %rax, -0x60(%rbp)
xorl %r14d, %r14d
xorl %esi, %esi
xorl %eax, %eax
movq %rdx, -0x30(%rbp)
movq %r12, -0x50(%rbp)
movq %rdi, -0x48(%rbp)
movq %r14, %rcx
testl %esi, %esi
je 0x67f4a
cmpw $0x7d7d, (%r12,%rcx)    # imm = 0x7D7D
movl $0x1, %esi
jne 0x67fab
movq (%rdx), %r13
xorl %esi, %esi
testq %r13, %r13
je 0x67fab
movq %rcx, -0x58(%rbp)
movl %ecx, %ebx
subl %eax, %ebx
addl $-0x2, %ebx
movl %eax, -0x34(%rbp)
cltq
leaq (%rax,%r12), %r15
addq $0x2, %r15
movslq %ebx, %r14
movq -0x60(%rbp), %r12
movq %r13, %rdi
callq 0xc460
cmpl %eax, %ebx
jne 0x67f28
movq %r13, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0xc7c0
testl %eax, %eax
je 0x67f8e
movq (%r12), %r13
addq $0x10, %r12
testq %r13, %r13
jne 0x67f0a
movq -0x50(%rbp), %r12
movq -0x48(%rbp), %rbx
movq -0x30(%rbp), %rdx
movq -0x58(%rbp), %rcx
movl -0x34(%rbp), %eax
jmp 0x67fa9
xorl %esi, %esi
cmpw $0x7b7b, (%r12,%rcx)    # imm = 0x7B7B
jne 0x67fab
cltq
cmpq %rax, %rcx
jle 0x67f87
leaq (%r12,%rax), %r14
movl %ecx, %r15d
subl %eax, %r15d
movq %rbx, %rdi
movq %rcx, %r13
callq 0x6846e
movq -0x40(%rbp), %rdi
movq %r14, %rsi
movl %r15d, %edx
callq 0x684c1
movq %r13, %rcx
movq -0x30(%rbp), %rdx
movl %ecx, %eax
jmp 0x67ecb
movq -0x48(%rbp), %rbx
movq %rbx, %rdi
callq *-0x8(%r12)
movq -0x58(%rbp), %rcx
leal 0x2(%rcx), %eax
movq -0x50(%rbp), %r12
movq -0x30(%rbp), %rdx
xorl %esi, %esi
leaq 0x1(%rcx), %r14
cmpb $0x0, 0x1(%r12,%rcx)
jne 0x67ec4
subl %eax, %r14d
jle 0x67fea
cltq
addq %rax, %r12
movq %rbx, %rdi
callq 0x6846e
movq -0x40(%rbp), %rdi
movq %r12, %rsi
movl %r14d, %edx
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x684c1
addq $0x38, %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_send_data
size_t mg_send_data(struct mg_connection *c, const void *data, int data_len) {
  struct connection *conn = MG_CONN_2_CONN(c);
  terminate_headers(c);
  write_chunk(MG_CONN_2_CONN(c), (const char *) data, data_len);
  return conn->ns_conn->send_iobuf.len;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %edx, %ebx
movq %rsi, %r14
movq %rdi, %r15
leaq -0x8(%rdi), %r12
callq 0x6846e
movq %r12, %rdi
movq %r14, %rsi
movl %ebx, %edx
callq 0x684c1
movq -0x8(%r15), %rax
movq 0x60(%rax), %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: mg_send_status
void mg_send_status(struct mg_connection *c, int status) {
  struct connection *conn = MG_CONN_2_CONN(c);
  if (c->status_code == 0) {
    c->status_code = status;
    mg_printf(c, "HTTP/1.1 %d %s\r\n", status, status_code_to_str(status));
  }
  conn->ns_conn->flags |= MG_USING_CHUNKED_API;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
cmpl $0x0, 0x27c(%rdi)
jne 0x6808e
movl %esi, %r14d
movl %esi, 0x27c(%rbx)
movl %esi, %edi
callq 0x680a1
leaq 0x1026b(%rip), %rsi     # 0x782e9
movq %rbx, %rdi
movl %r14d, %edx
movq %rax, %rcx
xorl %eax, %eax
callq 0x67a83
movq -0x8(%rbx), %rax
orl $0x200000, 0xa0(%rax)   # imm = 0x200000
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/coyove[P]chann/./lib/mongoose/mongoose.c
// Function: mg_send_header
void mg_send_header(struct mg_connection *c, const char *name, const char *v) {
  struct connection *conn = MG_CONN_2_CONN(c);
  if (c->status_code == 0) {
    c->status_code = 200;
    mg_printf(c, "HTTP/1.1 %d %s\r\n", 200, status_code_to_str(200));
  }
  mg_printf(c, "%s: %s\r\n", name, v);
  conn->ns_conn->flags |= MG_USING_CHUNKED_API;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
cmpl $0x0, 0x27c(%rdi)
jne 0x6843e
movl $0xc8, 0x27c(%rbx)
leaq 0xfec1(%rip), %rsi      # 0x782e9
leaq 0x100ca(%rip), %rcx     # 0x784f9
movq %rbx, %rdi
movl $0xc8, %edx
xorl %eax, %eax
callq 0x67a83
leaq 0xfeb5(%rip), %rsi      # 0x782fa
movq %rbx, %rdi
movq %r15, %rdx
movq %r14, %rcx
xorl %eax, %eax
callq 0x67a83
movq -0x8(%rbx), %rax
orl $0x200000, 0xa0(%rax)   # imm = 0x200000
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: terminate_headers
static void terminate_headers(struct mg_connection *c) {
  struct connection *conn = MG_CONN_2_CONN(c);
  if (!(conn->ns_conn->flags & MG_HEADERS_SENT)) {
    mg_send_header(c, "Transfer-Encoding", "chunked");
    mg_write(c, "\r\n", 2);
    conn->ns_conn->flags |= MG_HEADERS_SENT;
  }
}

// Assembly:
movq -0x8(%rdi), %rax
testb $0x10, 0xa2(%rax)
jne 0x684c0
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x1041a(%rip), %rsi     # 0x788a5
leaq 0x10425(%rip), %rdx     # 0x788b7
callq 0x683fb
movq -0x8(%rbx), %rdi
leaq 0xfee8(%rip), %rsi      # 0x7838a
movl $0x2, %edx
callq 0x6661a
movq -0x8(%rbx), %rax
orl $0x100000, 0xa0(%rax)   # imm = 0x100000
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/coyove[P]chann/./lib/mongoose/mongoose.c
// Function: write_chunk
static void write_chunk(struct connection *conn, const char *buf, int len) {
  char chunk_size[50];
  int n = mg_snprintf(chunk_size, sizeof(chunk_size), "%X\r\n", len);
  ns_send(conn->ns_conn, chunk_size, n);
  ns_send(conn->ns_conn, buf, len);
  ns_send(conn->ns_conn, "\r\n", 2);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x40, %rsp
movl %edx, %r14d
movq %rsi, %r15
movq %rdi, %rbx
leaq 0x103df(%rip), %rdx     # 0x788bf
leaq -0x60(%rbp), %r12
movl $0x32, %esi
movq %r12, %rdi
movl %r14d, %ecx
xorl %eax, %eax
callq 0x6ad62
movq (%rbx), %rdi
movslq %eax, %rdx
movq %r12, %rsi
callq 0x6661a
movq (%rbx), %rdi
movslq %r14d, %rdx
movq %r15, %rsi
callq 0x6661a
movq (%rbx), %rdi
leaq 0xfe6e(%rip), %rsi      # 0x7838a
movl $0x2, %edx
callq 0x6661a
addq $0x40, %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: mg_vprintf_data
size_t mg_vprintf_data(struct mg_connection *c, const char *fmt, va_list ap) {
  struct connection *conn = MG_CONN_2_CONN(c);
  int len;
  char mem[IOBUF_SIZE], *buf = mem;

  terminate_headers(c);

  len = ns_avprintf(&buf, sizeof(mem), fmt, ap);

  if (len >= 0) {
    write_chunk((struct connection *) conn, buf, len);
  }
  if (buf != mem && buf != NULL) {
    NS_FREE(buf);
  }
  return conn->ns_conn->send_iobuf.len;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2008, %rsp           # imm = 0x2008
movq %rdx, %r14
movq %rsi, %r15
leaq -0x8(%rdi), %rbx
leaq -0x2030(%rbp), %r13
leaq -0x30(%rbp), %r12
movq %r13, (%r12)
callq 0x6846e
movl $0x2000, %esi           # imm = 0x2000
movq %r12, %rdi
movq %r15, %rdx
movq %r14, %rcx
callq 0x664b7
movq (%r12), %r14
testl %eax, %eax
js 0x68606
movq %rbx, %rdi
movq %r14, %rsi
movl %eax, %edx
callq 0x684c1
cmpq %r13, %r14
sete %al
testq %r14, %r14
sete %cl
orb %al, %cl
jne 0x6861e
movq %r14, %rdi
callq 0xc250
movq (%rbx), %rax
movq 0x60(%rax), %rax
addq $0x2008, %rsp           # imm = 0x2008
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_websocket_printf
size_t mg_websocket_printf(struct mg_connection *conn, int opcode,
                           const char *fmt, ...) {
  char mem[4192], *buf = mem;
  va_list ap;
  int len;

  va_start(ap, fmt);
  if ((len = ns_avprintf(&buf, sizeof(mem), fmt, ap)) > 0) {
    mg_websocket_write(conn, opcode, buf, len);
  }
  va_end(ap);

  if (buf != mem && buf != NULL) {
    NS_FREE(buf);
  }

  return MG_CONN_2_CONN(conn)->ns_conn->send_iobuf.len;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x1130, %rsp           # imm = 0x1130
movl %esi, %r14d
movq %rdi, %rbx
leaq -0xf0(%rbp), %rsi
movq %rcx, 0x18(%rsi)
movq %r8, 0x20(%rsi)
movq %r9, 0x28(%rsi)
testb %al, %al
je 0x687d6
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 -0x1150(%rbp), %r12
leaq -0x28(%rbp), %r15
movq %r12, (%r15)
leaq -0x40(%rbp), %rcx
movq %rsi, 0x10(%rcx)
leaq 0x10(%rbp), %rax
movq %rax, 0x8(%rcx)
movabsq $0x3000000018, %rax     # imm = 0x3000000018
movq %rax, (%rcx)
movl $0x1060, %esi           # imm = 0x1060
movq %r15, %rdi
callq 0x664b7
movq (%r15), %r15
testl %eax, %eax
jle 0x68825
movl %eax, %ecx
movq %rbx, %rdi
movl %r14d, %esi
movq %r15, %rdx
callq 0x68637
cmpq %r12, %r15
sete %al
testq %r15, %r15
sete %cl
orb %al, %cl
jne 0x6883d
movq %r15, %rdi
callq 0xc250
movq -0x8(%rbx), %rax
movq 0x60(%rax), %rax
addq $0x1130, %rsp           # imm = 0x1130
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: mg_get_mime_type
const char *mg_get_mime_type(const char *path, const char *default_mime_type) {
  const char *ext;
  size_t i, path_len;

  path_len = strlen(path);

  for (i = 0; static_builtin_mime_types[i].extension != NULL; i++) {
    ext = path + (path_len - static_builtin_mime_types[i].ext_len);
    if (path_len > static_builtin_mime_types[i].ext_len &&
        mg_strcasecmp(ext, static_builtin_mime_types[i].extension) == 0) {
      return static_builtin_mime_types[i].mime_type;
    }
  }

  return default_mime_type;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, -0x30(%rbp)
movq %rdi, -0x40(%rbp)
callq 0xc460
leaq 0x2b066(%rip), %r14     # 0x938e0
leaq 0x10043(%rip), %rbx     # 0x788c4
xorl %r13d, %r13d
movq %r14, %r12
movq %rax, -0x38(%rbp)
movq %rax, %r15
subq 0x8(%r12), %r15
jbe 0x688c5
addq -0x40(%rbp), %r15
callq 0xc4a0
movq (%rax), %rax
xorl %ecx, %ecx
movzbl (%r15,%rcx), %edi
movl (%rax,%rdi,4), %edx
movzbl (%rbx,%rcx), %esi
movl (%rax,%rsi,4), %esi
testl %edi, %edi
je 0x688bd
incq %rcx
cmpl %esi, %edx
je 0x688a3
cmpl %esi, %edx
movq -0x38(%rbp), %rax
je 0x688e7
incq %r13
leaq (,%r13,2), %rcx
addq %r13, %rcx
leaq (%r14,%rcx,8), %r12
movq (%r12), %rbx
cmpq $0x2f, %r13
jne 0x6888b
movq -0x30(%rbp), %rax
jmp 0x688ec
movq 0x10(%r12), %rax
addq $0x18, %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_url_encode
size_t mg_url_encode(const char *src, size_t s_len, char *dst, size_t dst_len) {
  static const char *dont_escape = "._-$,;~()";
  static const char *hex = "0123456789abcdef";
  size_t i = 0, j = 0;

  for (i = j = 0; dst_len > 0 && i < s_len && j + 2 < dst_len - 1; i++, j++) {
    if (isalnum(* (const unsigned char *) (src + i)) ||
        strchr(dont_escape, * (const unsigned char *) (src + i)) != NULL) {
      dst[j] = src[i];
    } else if (j + 3 < dst_len) {
      dst[j] = '%';
      dst[j + 1] = hex[(* (const unsigned char *) (src + i)) >> 4];
      dst[j + 2] = hex[(* (const unsigned char *) (src + i)) & 0xf];
      j += 2;
    }
  }

  dst[j] = '\0';
  return j;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdx, -0x30(%rbp)
testq %rcx, %rcx
sete %al
movq %rsi, -0x48(%rbp)
testq %rsi, %rsi
sete %dl
orb %al, %dl
jne 0x689f3
movq %rdi, %r12
movq %rcx, -0x38(%rbp)
leaq -0x1(%rcx), %rax
movq %rax, -0x40(%rbp)
xorl %r13d, %r13d
xorl %r14d, %r14d
leaq 0x2(%r13), %rbx
cmpq -0x40(%rbp), %rbx
jae 0x689f6
callq 0xc170
movq (%rax), %rax
movb (%r12,%r14), %r15b
movzbl %r15b, %esi
testb $0x8, (%rax,%rsi,2)
jne 0x6899f
movl $0xa, %edx
leaq 0xf96e(%rip), %rdi      # 0x78303
callq 0xc4d0
testq %rax, %rax
je 0x689bb
movq %r13, %rbx
movq -0x30(%rbp), %rax
movb %r15b, (%rax,%rbx)
movq %rbx, %r13
incq %r14
incq %r13
cmpq -0x48(%rbp), %r14
jb 0x68965
jmp 0x689f6
leaq 0x3(%r13), %rax
cmpq -0x38(%rbp), %rax
jae 0x689ad
movq -0x30(%rbp), %rcx
movb $0x25, (%rcx,%r13)
movzbl (%r12,%r14), %eax
shrl $0x4, %eax
leaq 0xf930(%rip), %rdx      # 0x7830d
movb (%rax,%rdx), %al
movb %al, 0x1(%rcx,%r13)
movzbl (%r12,%r14), %eax
andl $0xf, %eax
movb (%rax,%rdx), %r15b
jmp 0x689a2
xorl %r13d, %r13d
movq -0x30(%rbp), %rax
movb $0x0, (%rax,%r13)
movq %r13, %rax
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: mg_send_digest_auth_request
void mg_send_digest_auth_request(struct mg_connection *c) {
  struct connection *conn = MG_CONN_2_CONN(c);
  c->status_code = 401;
  mg_printf(c,
            "HTTP/1.1 401 Unauthorized\r\n"
            "Content-Length: 0\r\n"
            "WWW-Authenticate: Digest qop=\"auth\", "
            "realm=\"%s\", nonce=\"%lu\"\r\n\r\n",
            conn->server->config_options[AUTH_DOMAIN],
            (unsigned long) time(NULL));
  close_local_endpoint(conn);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq -0x8(%rdi), %r14
movl $0x191, 0x27c(%rdi)     # imm = 0x191
movq 0x2a0(%rdi), %rax
movq 0x48(%rax), %r15
xorl %edi, %edi
callq 0xc820
leaq 0xf8d9(%rip), %rsi      # 0x7831e
movq %rbx, %rdi
movq %r15, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x67a83
movq %r14, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x68a64
// File: /workspace/github_c_makefile_star2_O3/coyove[P]chann/./lib/mongoose/mongoose.c
// Function: mg_strncasecmp
static int mg_strncasecmp(const char *s1, const char *s2, size_t len) {
  int diff = 0;

  if (len > 0)
    do {
      diff = lowercase(s1++) - lowercase(s2++);
    } while (diff == 0 && s1[-1] != '\0' && --len > 0);

  return diff;
}

// Assembly:
testq %rdx, %rdx
je 0x69289
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
callq 0xc4a0
movq (%rax), %rcx
decq %rbx
xorl %edx, %edx
movzbl (%r15,%rdx), %esi
movl (%rcx,%rsi,4), %eax
movzbl (%r14,%rdx), %edi
subl (%rcx,%rdi,4), %eax
jne 0x6927e
xorl %eax, %eax
testb %sil, %sil
je 0x6927e
leaq 0x1(%rdx), %rsi
cmpq %rdx, %rbx
movq %rsi, %rdx
jne 0x69259
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
xorl %eax, %eax
retq
// File: /workspace/github_c_makefile_star2_O3/coyove[P]chann/./lib/mongoose/mongoose.c
// Function: check_password
static int check_password(const char *method, const char *ha1, const char *uri,
                          const char *nonce, const char *nc, const char *cnonce,
                          const char *qop, const char *response) {
  char ha2[32 + 1], expected_response[32 + 1];

#if 0
  // Check for authentication timeout
  if ((unsigned long) time(NULL) - (unsigned long) to64(nonce) > 3600 * 2) {
    return 0;
  }
#endif

  mg_md5(ha2, method, ":", uri, NULL);
  mg_md5(expected_response, ha1, ":", nonce, ":", nc,
      ":", cnonce, ":", qop, ":", ha2, NULL);

  return mg_strcasecmp(response, expected_response) == 0 ? MG_TRUE : MG_FALSE;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %r9, -0x38(%rbp)
movq %r8, -0x30(%rbp)
movq %rcx, %r15
movq %rdx, %rcx
movq %rsi, %r12
movq %rdi, %rsi
movq 0x18(%rbp), %rbx
leaq 0x895b(%rip), %r13      # 0x71c72
xorl %r14d, %r14d
leaq -0x90(%rbp), %rdi
movq %r13, %rdx
xorl %r8d, %r8d
xorl %eax, %eax
callq 0x68d1f
subq $0x8, %rsp
leaq -0x60(%rbp), %rdi
movq %r12, %rsi
movq %r13, %rdx
movq %r15, %rcx
movq %r13, %r8
movq -0x30(%rbp), %r9
xorl %eax, %eax
pushq $0x0
leaq -0x90(%rbp), %r10
pushq %r10
pushq %r13
pushq 0x10(%rbp)
pushq %r13
pushq -0x38(%rbp)
pushq %r13
callq 0x68d1f
addq $0x40, %rsp
callq 0xc4a0
movq (%rax), %rax
movzbl (%rbx,%r14), %esi
movl (%rax,%rsi,4), %ecx
movzbl -0x60(%rbp,%r14), %edx
movl (%rax,%rdx,4), %edx
testl %esi, %esi
je 0x6938c
incq %r14
cmpl %edx, %ecx
je 0x69370
xorl %eax, %eax
cmpl %edx, %ecx
sete %al
addq $0x68, %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: must_hide_file
static int must_hide_file(struct connection *conn, const char *path) {
  const char *pw_pattern = "**" PASSWORDS_FILE_NAME "$";
  const char *pattern = conn->server->config_options[HIDE_FILES_PATTERN];
  return mg_match_prefix(pw_pattern, strlen(pw_pattern), path) > 0 ||
    (pattern != NULL && mg_match_prefix(pattern, strlen(pattern), path) > 0);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r14
leaq 0xdde6(%rip), %rdi      # 0x78c05
movl $0xc, %esi
movq %rbx, %rdx
callq 0x67cec
movl %eax, %ecx
movl $0x1, %eax
testl %ecx, %ecx
jg 0x6ae5f
testq %r14, %r14
je 0x6ae5d
movq %r14, %rdi
callq 0xc460
movq %r14, %rdi
movq %rax, %rsi
movq %rbx, %rdx
callq 0x67cec
movl %eax, %ecx
xorl %eax, %eax
testl %ecx, %ecx
setg %al
jmp 0x6ae5f
xorl %eax, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/coyove[P]chann/./lib/mongoose/mongoose.c
// Function: mg_connect
struct mg_connection *mg_connect(struct mg_server *server, const char *addr) {
  struct ns_connection *nsconn;
  struct connection *conn;

  nsconn = ns_connect(&server->ns_mgr, addr, mg_ev_handler, NULL);
  if (nsconn == NULL) return 0;

  if ((conn = (struct connection *) NS_CALLOC(1, sizeof(*conn))) == NULL) {
    nsconn->flags |= NSF_CLOSE_IMMEDIATELY;
    return 0;
  }

  // Interlink two structs
  conn->ns_conn = nsconn;
  nsconn->user_data = conn;

  conn->server = server;
  conn->endpoint_type = EP_CLIENT;
  //conn->handler = handler;
  conn->mg_conn.server_param = server->ns_mgr.user_data;
  conn->ns_conn->flags = NSF_CONNECTING;

  return &conn->mg_conn;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq -0x1c92(%rip), %rdx     # 0x69768
xorl %r15d, %r15d
xorl %ecx, %ecx
callq 0x677cf
testq %rax, %rax
je 0x6b465
movq %rax, %r14
movl $0x1, %edi
movl $0x2e8, %esi            # imm = 0x2E8
callq 0xc980
testq %rax, %rax
je 0x6b45a
movq %r14, (%rax)
movq %rax, 0x80(%r14)
movq %rbx, 0x2a8(%rax)
movl $0x5, 0x2b8(%rax)
movq 0x18(%rbx), %rcx
movq %rax, %r15
addq $0x8, %r15
movq %rcx, 0x290(%rax)
movl $0x8, 0xa0(%r14)
jmp 0x6b465
orb $0x10, 0xa0(%r14)
xorl %r15d, %r15d
movq %r15, %rax
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: mg_destroy_server
void mg_destroy_server(struct mg_server **server) {
  if (server != NULL && *server != NULL) {
    struct mg_server *s = *server;
    int i;

    ns_mgr_free(&s->ns_mgr);
    for (i = 0; i < (int) ARRAY_SIZE(s->config_options); i++) {
      NS_FREE(s->config_options[i]);  // It is OK to free(NULL)
    }
    NS_FREE(s);
    *server = NULL;
  }
}

// Assembly:
testq %rdi, %rdi
je 0x6b4d0
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq (%rdi), %r14
testq %r14, %r14
je 0x6b4c6
movq %r14, %rdi
callq 0x679ea
movl $0x7, %r15d
movq (%r14,%r15,8), %rdi
callq 0xc250
incq %r15
cmpq $0x1a, %r15
jne 0x6b4a5
movq %r14, %rdi
callq 0xc250
movq $0x0, (%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: mg_next
struct mg_connection *mg_next(struct mg_server *s, struct mg_connection *c) {
  struct ns_connection *nc = ns_next(&s->ns_mgr, c == NULL ? NULL :
                                     MG_CONN_2_CONN(c)->ns_conn);
  if (nc != NULL && nc->user_data != NULL) {
    return & ((struct connection *) nc->user_data)->mg_conn;
  } else {
    return NULL;
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
testq %rsi, %rsi
je 0x6b4e0
movq -0x8(%rsi), %rax
jmp 0x6b4e2
xorl %eax, %eax
testq %rax, %rax
cmovneq %rax, %rdi
movq (%rdi), %rax
testq %rax, %rax
je 0x6b505
movq 0x80(%rax), %rcx
leaq 0x8(%rcx), %rax
testq %rcx, %rcx
cmoveq %rcx, %rax
jmp 0x6b507
xorl %eax, %eax
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/coyove[P]chann/./lib/mongoose/mongoose.c
// Function: mg_get_var_n
int mg_get_var_n(const struct mg_connection *conn, const char *name,
               char *dst, size_t dst_len, int n) {
  int len = get_var(conn->query_string, conn->query_string == NULL ? 0 :
                    strlen(conn->query_string), name, dst, dst_len, n);
  if (len == -1) {
    len = get_var(conn->content, conn->content_len, name, dst, dst_len, n);
  }
  return len;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %r8d, %r12d
movq %rcx, %r15
movq %rdx, %r13
movq %rsi, %r14
movq %rdi, %rsi
movq 0x18(%rdi), %rbx
testq %rbx, %rbx
je 0x6b55d
movq %rbx, %rdi
movq %rsi, -0x30(%rbp)
callq 0xc460
movq %rbx, %rdi
movq %rax, %rsi
movq %r14, %rdx
movq %r13, %rcx
movq %r15, %r8
movl %r12d, %r9d
callq 0x6b5b0
movq -0x30(%rbp), %rsi
cmpl $-0x1, %eax
jne 0x6b572
jmp 0x6b586
testq %r13, %r13
sete %al
testq %r15, %r15
sete %cl
orb %al, %cl
movl $0xfffffffe, %eax       # imm = 0xFFFFFFFE
je 0x6b581
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movb $0x0, (%r13)
movq 0x268(%rsi), %rdi
movq 0x270(%rsi), %rsi
movq %r14, %rdx
movq %r13, %rcx
movq %r15, %r8
movl %r12d, %r9d
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x6b5b0
// File: /workspace/github_c_makefile_star2_O3/coyove[P]chann/./lib/mongoose/mongoose.c
// Function: get_var
static int get_var(const char *data, size_t data_len, const char *name,
                   char *dst, size_t dst_len, int n) {
  const char *p, *e = data + data_len, *s;
  size_t name_len;
  int i = 0, len = -1;

  if (dst == NULL || dst_len == 0) {
    len = -2;
  } else if (data == NULL || name == NULL || data_len == 0) {
    dst[0] = '\0';
  } else {
    name_len = strlen(name);
    dst[0] = '\0';

    // data is "var1=val1&var2=val2...". Find variable first
    for (p = data; p + name_len < e; p++) {
      if ((p == data || p[-1] == '&') && p[name_len] == '=' &&
          !mg_strncasecmp(name, p, name_len)) {

        if (n != i++) continue;

        // Point p to variable value
        p += name_len + 1;

        // Point s to the end of the value
        s = (const char *) memchr(p, '&', (size_t)(e - p));
        if (s == NULL) {
          s = e;
        }
        assert(s >= p);

        // Decode variable into destination buffer
        len = mg_url_decode(p, (size_t)(s - p), dst, dst_len, 1);

        // Redirect error code from -1 to -2 (destination buffer too small).
        if (len == -1) {
          len = -2;
        }
        break;
      }
    }
  }

  return len;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %r9d, -0x3c(%rbp)
movq %rcx, %r14
movq %rdx, -0x38(%rbp)
testq %rcx, %rcx
sete %al
testq %r8, %r8
sete %cl
orb %al, %cl
movl $0xfffffffe, %eax       # imm = 0xFFFFFFFE
jne 0x6b691
movq %rsi, %r13
testq %rsi, %rsi
je 0x6b688
movq %rdi, %r12
testq %rdi, %rdi
je 0x6b688
cmpq $0x0, -0x38(%rbp)
je 0x6b688
movq %r8, %rbx
movq -0x38(%rbp), %rdi
callq 0xc460
movb $0x0, (%r14)
cmpq %r13, %rax
jge 0x6b68c
movq %r14, -0x48(%rbp)
movq %rbx, -0x50(%rbp)
movq %r13, -0x58(%rbp)
leaq (%r12,%r13), %rbx
leaq (%r12,%rax), %r13
xorl %r14d, %r14d
movl $0x0, -0x2c(%rbp)
testq %r14, %r14
je 0x6b648
cmpb $0x26, -0x1(%r12,%r14)
jne 0x6b677
cmpb $0x3d, (%r13,%r14)
jne 0x6b677
leaq (%r12,%r14), %rsi
movq -0x38(%rbp), %rdi
movq %rax, %r15
movq %rax, %rdx
callq 0x69234
testl %eax, %eax
jne 0x6b674
movl -0x2c(%rbp), %eax
cmpl -0x3c(%rbp), %eax
je 0x6b6a0
incl %eax
movl %eax, -0x2c(%rbp)
movq %r15, %rax
leaq (%r14,%r13), %rcx
incq %rcx
incq %r14
cmpq %rbx, %rcx
jb 0x6b63b
jmp 0x6b68c
movb $0x0, (%r14)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq (%r14,%r13), %r12
incq %r12
notq %r15
addq -0x58(%rbp), %r15
subq %r14, %r15
movq %r12, %rdi
movl $0x26, %esi
movq %r15, %rdx
callq 0xc4d0
testq %rax, %rax
cmovneq %rax, %rbx
cmpq %r12, %rbx
jb 0x6b6fc
notq %r13
addq %r13, %rbx
subq %r14, %rbx
movq %r12, %rdi
movq %rbx, %rsi
movq -0x48(%rbp), %rdx
movq -0x50(%rbp), %rcx
movl $0x1, %r8d
callq 0x67b2c
cmpl $-0x2, %eax
movl $0xfffffffe, %ecx       # imm = 0xFFFFFFFE
cmovael %ecx, %eax
jmp 0x6b691
leaq 0xe11c(%rip), %rdi      # 0x7981f
leaq 0xcb59(%rip), %rsi      # 0x78263
leaq 0xe115(%rip), %rcx      # 0x79826
movl $0x13c4, %edx           # imm = 0x13C4
callq 0xc210
// File: /workspace/github_c_makefile_star2_O3/coyove[P]chann/./lib/mongoose/mongoose.c
// Function: get_request_len
static int get_request_len(const char *s, size_t buf_len) {
  const unsigned char *buf = (unsigned char *) s;
  size_t i;

  for (i = 0; i < buf_len; i++) {
    // Control characters are not allowed but >=128 are.
    // Abort scan as soon as one malformed character is found.
    if (!isprint(buf[i]) && buf[i] != '\r' && buf[i] != '\n' && buf[i] < 128) {
      return -1;
    } else if (buf[i] == '\n' && i + 1 < buf_len && buf[i + 1] == '\n') {
      return i + 2;
    } else if (buf[i] == '\n' && i + 2 < buf_len && buf[i + 1] == '\r' &&
               buf[i + 2] == '\n') {
      return i + 3;
    }
  }

  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
xorl %ebx, %ebx
testq %rsi, %rsi
je 0x6b9cb
movq %rsi, %r14
movq %rdi, %r15
callq 0xc170
movq (%rax), %rcx
movq %r14, %rdx
negq %rdx
movl $0xfffffffd, %eax       # imm = 0xFFFFFFFD
movl $0x2, %esi
movzbl -0x2(%r15,%rsi), %edi
cmpl $0xa, %edi
je 0x6b987
testb %dil, %dil
js 0x6b987
cmpb $0xd, %dil
je 0x6b987
movzwl (%rcx,%rdi,2), %r8d
andl $0x4000, %r8d           # imm = 0x4000
je 0x6b9c6
cmpb $0xa, %dil
jne 0x6b9b2
leaq -0x1(%rsi), %rdi
cmpq %r14, %rdi
jae 0x6b99e
cmpb $0xa, -0x1(%r15,%rsi)
je 0x6b9d8
cmpq %r14, %rsi
jae 0x6b9b2
cmpb $0xd, -0x1(%r15,%rsi)
jne 0x6b9b2
cmpb $0xa, (%r15,%rsi)
je 0x6b9dc
decl %eax
leaq (%rdx,%rsi), %rdi
incq %rdi
incq %rsi
cmpq $0x2, %rdi
jne 0x6b963
jmp 0x6b9cb
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movl %esi, %ebx
jmp 0x6b9cb
negl %eax
movl %eax, %ebx
jmp 0x6b9cb
// File: /workspace/github_c_makefile_star2_O3/coyove[P]chann/./lib/mongoose/mongoose.c
// Function: mg_copy_listeners
void mg_copy_listeners(struct mg_server *s, struct mg_server *to) {
  struct ns_connection *c;
  for (c = ns_next(&s->ns_mgr, NULL); c != NULL; c = ns_next(&s->ns_mgr, c)) {
    struct ns_connection *tmp;
    if ((c->flags & NSF_LISTENING) &&
        (tmp = (struct ns_connection *) NS_MALLOC(sizeof(*tmp))) != NULL) {
      memcpy(tmp, c, sizeof(*tmp));

#if defined(NS_ENABLE_SSL) && defined(HEADER_SSL_H)
      /* OpenSSL only. See https://github.com/cesanta/mongoose/issues/441 */
      if (tmp->ssl_ctx != NULL) {
        tmp->ssl_ctx->references++;
      }
#endif

      tmp->mgr = &to->ns_mgr;
      ns_add_conn(tmp->mgr, tmp);
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq (%rdi), %r14
testq %r14, %r14
je 0x6ba56
movq %rsi, %rbx
testb $-0x80, 0xa0(%r14)
je 0x6ba4e
movl $0xa8, %edi
callq 0xca00
testq %rax, %rax
je 0x6ba4e
movq %rax, %r15
movl $0xa8, %edx
movq %rax, %rdi
movq %r14, %rsi
callq 0xc0e0
movq %rbx, 0x18(%r15)
movq (%rbx), %rax
movq %rax, (%r15)
movq %r15, (%rbx)
movq $0x0, 0x8(%r15)
testq %rax, %rax
je 0x6ba4e
movq %r15, 0x8(%rax)
movq (%r14), %r14
testq %r14, %r14
jne 0x6ba04
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: get_option_index
static int get_option_index(const char *name) {
  int i;

  for (i = 0; static_config_options[i * 2] != NULL; i++) {
    if (strcmp(static_config_options[i * 2], name) == 0) {
      return i;
    }
  }
  return -1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdi, %r14
movq 0x28c23(%rip), %rdi     # 0x94950
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
testq %rdi, %rdi
je 0x6bd62
xorl %r15d, %r15d
leaq 0x28c1f(%rip), %r12     # 0x94960
movq %r14, %rsi
callq 0xc950
testl %eax, %eax
je 0x6bd5f
movq (%r12), %rdi
incl %r15d
addq $0x10, %r12
testq %rdi, %rdi
jne 0x6bd41
jmp 0x6bd62
movl %r15d, %ebx
movl %ebx, %eax
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: mg_strdup
static char *mg_strdup(const char *str) {
  char *copy = (char *) NS_MALLOC(strlen(str) + 1);
  if (copy != NULL) {
    strcpy(copy, str);
  }
  return copy;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
callq 0xc460
leaq 0x1(%rax), %rdi
callq 0xca00
testq %rax, %rax
je 0x6bd9a
movq %rax, %rdi
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0xc490
addq $0x8, %rsp
popq %rbx
popq %rbp
retq