LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O0/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_tun_send_frame
void mg_tun_send_frame(struct mg_connection *ws, uint32_t stream_id,
                       uint8_t type, uint8_t flags, struct mg_str msg) {
  stream_id = htonl(stream_id);
  {
    struct mg_str parts[] = {
        {(char *) &type, sizeof(type)},
        {(char *) &flags, sizeof(flags)},
        {(char *) &stream_id, sizeof(stream_id)},
        {msg.p, msg.len} /* vc6 doesn't like just `msg` here */};
    mg_send_websocket_framev(ws, WEBSOCKET_OP_BINARY, parts,
                             sizeof(parts) / sizeof(parts[0]));
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movb %cl, %al
movb %dl, %cl
movq %r8, -0x10(%rbp)
movq %r9, -0x8(%rbp)
movq %rdi, -0x18(%rbp)
movl %esi, -0x1c(%rbp)
movb %cl, -0x1d(%rbp)
movb %al, -0x1e(%rbp)
movl -0x1c(%rbp), %edi
callq 0x3250
movl %eax, -0x1c(%rbp)
leaq -0x1d(%rbp), %rax
movq %rax, -0x60(%rbp)
movq $0x1, -0x58(%rbp)
leaq -0x1e(%rbp), %rax
movq %rax, -0x50(%rbp)
movq $0x1, -0x48(%rbp)
leaq -0x1c(%rbp), %rax
movq %rax, -0x40(%rbp)
movq $0x4, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x18(%rbp), %rdi
leaq -0x60(%rbp), %rdx
movl $0x2, %esi
movl $0x4, %ecx
callq 0x16080
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_tun_if_destroy_conn
void mg_tun_if_destroy_conn(struct mg_connection *nc) {
  struct mg_tun_client *client = (struct mg_tun_client *) nc->iface->data;

  if (nc->flags & MG_F_LISTENING) {
    mg_tun_destroy_client(client);
  } else if (client->disp) {
    uint32_t stream_id = (uint32_t)(uintptr_t) nc->mgr_data;
    struct mg_str msg = {NULL, 0};

    LOG(LL_DEBUG, ("closing 0x%x:", (unsigned int) stream_id));
    mg_tun_send_frame(client->disp, stream_id, MG_TUN_DATA_FRAME,
                      MG_TUN_F_END_STREAM, msg);
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq 0xc0(%rax), %rax
movq 0x8(%rax), %rax
movq %rax, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq 0xc8(%rax), %rax
andq $0x1, %rax
cmpq $0x0, %rax
je 0xf2bf
movq -0x10(%rbp), %rdi
callq 0xf340
jmp 0xf339
movq -0x10(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0xf337
movq -0x8(%rbp), %rax
movq 0xb8(%rax), %rax
movl %eax, -0x14(%rbp)
leaq -0x28(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x3260
movl $0x3, %edi
leaq 0x10614(%rip), %rsi     # 0x1f908
leaq 0x1024f(%rip), %rdx     # 0x1f54a
callq 0x4650
cmpl $0x0, %eax
je 0xf316
movl -0x14(%rbp), %esi
leaq 0x10610(%rip), %rdi     # 0x1f91f
movb $0x0, %al
callq 0x47a0
jmp 0xf318
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rdi
movl -0x14(%rbp), %esi
movq -0x28(%rbp), %r8
movq -0x20(%rbp), %r9
xorl %edx, %edx
movl $0x1, %ecx
callq 0xf1b0
jmp 0xf339
addq $0x30, %rsp
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O0/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_tun_destroy_client
void mg_tun_destroy_client(struct mg_tun_client *client) {
  /*
   *  NOTE:
   * `client` is NULL in case of OOM
   * `client->disp` is NULL if connection failed
   * `client->iface is NULL is `mg_find_iface` failed
   */

  if (client != NULL && client->disp != NULL) {
    /* the dispatcher connection handler will in turn close all tunnels */
    client->disp->flags |= MG_F_CLOSE_IMMEDIATELY;
    /* this is used as a signal to other tun handlers that the party is over */
    client->disp->user_data = NULL;
  }

  if (client != NULL && client->reconnect != NULL) {
    client->reconnect->flags |= MG_F_CLOSE_IMMEDIATELY;
  }

  if (client != NULL && client->iface != NULL) {
    client->iface->data = NULL;
  }

  MG_FREE(client);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
cmpq $0x0, -0x8(%rbp)
je 0xf38e
movq -0x8(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0xf38e
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movq 0xc8(%rax), %rcx
orq $0x800, %rcx            # imm = 0x800
movq %rcx, 0xc8(%rax)
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movq $0x0, 0xa0(%rax)
cmpq $0x0, -0x8(%rbp)
je 0xf3bd
movq -0x8(%rbp), %rax
cmpq $0x0, 0x30(%rax)
je 0xf3bd
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movq 0xc8(%rax), %rcx
orq $0x800, %rcx            # imm = 0x800
movq %rcx, 0xc8(%rax)
cmpq $0x0, -0x8(%rbp)
je 0xf3df
movq -0x8(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0xf3df
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq $0x0, 0x8(%rax)
movq -0x8(%rbp), %rdi
callq 0x3050
addq $0x10, %rsp
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O0/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_tun_if_find_conn
struct mg_connection *mg_tun_if_find_conn(struct mg_tun_client *client,
                                          uint32_t stream_id) {
  struct mg_connection *nc = NULL;

  for (nc = client->mgr->active_connections; nc != NULL; nc = nc->next) {
    if (nc->iface != client->iface || (nc->flags & MG_F_LISTENING)) {
      continue;
    }
    if (stream_id == (uint32_t)(uintptr_t) nc->mgr_data) {
      return nc;
    }
  }

  if (stream_id > client->last_stream_id) {
    /* create a new connection */
    LOG(LL_DEBUG, ("new stream 0x%x, accepting", (unsigned int) stream_id));
    nc = mg_if_accept_new_conn(client->listener);
    nc->mgr_data = (void *) (uintptr_t) stream_id;
    client->last_stream_id = stream_id;
  } else {
    LOG(LL_DEBUG,
        ("Ignoring stream 0x%x (last_stream_id 0x%x)", (unsigned int) stream_id,
         (unsigned int) client->last_stream_id));
  }

  return nc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq $0x0, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq (%rax), %rax
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0xf516
movq -0x20(%rbp), %rax
movq 0xc0(%rax), %rax
movq -0x10(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jne 0xf4e6
movq -0x20(%rbp), %rax
movq 0xc8(%rax), %rax
andq $0x1, %rax
cmpq $0x0, %rax
je 0xf4e8
jmp 0xf509
movl -0x14(%rbp), %eax
movq -0x20(%rbp), %rcx
movq 0xb8(%rcx), %rcx
cmpl %ecx, %eax
jne 0xf507
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0xf5c4
jmp 0xf509
movq -0x20(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x20(%rbp)
jmp 0xf4b5
movl -0x14(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x1c(%rcx), %eax
jbe 0xf581
jmp 0xf524
movl $0x3, %edi
leaq 0x103fd(%rip), %rsi     # 0x1f92d
leaq 0x10013(%rip), %rdx     # 0x1f54a
callq 0x4650
cmpl $0x0, %eax
je 0xf552
movl -0x14(%rbp), %esi
leaq 0x103f6(%rip), %rdi     # 0x1f941
movb $0x0, %al
callq 0x47a0
jmp 0xf554
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rdi
callq 0xb390
movq %rax, -0x20(%rbp)
movl -0x14(%rbp), %eax
movl %eax, %ecx
movq -0x20(%rbp), %rax
movq %rcx, 0xb8(%rax)
movl -0x14(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x1c(%rax)
jmp 0xf5bc
jmp 0xf583
movl $0x3, %edi
leaq 0x1039e(%rip), %rsi     # 0x1f92d
leaq 0xffb4(%rip), %rdx      # 0x1f54a
callq 0x4650
cmpl $0x0, %eax
je 0xf5b8
movl -0x14(%rbp), %esi
movq -0x10(%rbp), %rax
movl 0x1c(%rax), %edx
leaq 0x103ab(%rip), %rdi     # 0x1f95c
movb $0x0, %al
callq 0x47a0
jmp 0xf5ba
jmp 0xf5bc
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x20, %rsp
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O0/sfeakes[P]unifi-motion/mongoose.c
// Function: parse_uri_component
static void parse_uri_component(const char **p, const char *end,
                                const char *seps, struct mg_str *res) {
  const char *q;
  res->p = *p;
  for (; *p < end; (*p)++) {
    for (q = seps; *q != '\0'; q++) {
      if (**p == *q) break;
    }
    if (*q != '\0') break;
  }
  res->len = (*p) - res->p;
  if (*p < end) (*p)++;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movq -0x8(%rbp), %rax
movq (%rax), %rax
cmpq -0x10(%rbp), %rax
jae 0xfc9a
movq -0x18(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0xfc7a
movq -0x8(%rbp), %rax
movq (%rax), %rax
movsbl (%rax), %eax
movq -0x28(%rbp), %rcx
movsbl (%rcx), %ecx
cmpl %ecx, %eax
jne 0xfc6a
jmp 0xfc7a
jmp 0xfc6c
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
jmp 0xfc47
movq -0x28(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0xfc88
jmp 0xfc9a
jmp 0xfc8a
movq -0x8(%rbp), %rax
movq (%rax), %rcx
addq $0x1, %rcx
movq %rcx, (%rax)
jmp 0xfc32
movq -0x8(%rbp), %rax
movq (%rax), %rcx
movq -0x20(%rbp), %rax
movq (%rax), %rax
subq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x8(%rbp), %rax
movq (%rax), %rax
cmpq -0x10(%rbp), %rax
jae 0xfcce
movq -0x8(%rbp), %rax
movq (%rax), %rcx
addq $0x1, %rcx
movq %rcx, (%rax)
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O0/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_normalize_uri_path
int mg_normalize_uri_path(const struct mg_str *in, struct mg_str *out) {
  const char *s = in->p, *se = s + in->len;
  char *cp = (char *) out->p, *d;

  if (in->len == 0 || *s != '/') {
    out->len = 0;
    return 0;
  }

  d = cp;

  while (s < se) {
    const char *next = s;
    struct mg_str component;
    parse_uri_component(&next, se, "/", &component);
    if (mg_vcmp(&component, ".") == 0) {
      /* Yum. */
    } else if (mg_vcmp(&component, "..") == 0) {
      /* Backtrack to previous slash. */
      if (d > cp + 1 && *(d - 1) == '/') d--;
      while (d > cp && *(d - 1) != '/') d--;
    } else {
      memmove(d, s, next - s);
      d += next - s;
    }
    s = next;
  }
  if (d == cp) *d++ = '/';

  out->p = cp;
  out->len = d - cp;
  return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq -0x10(%rbp), %rcx
addq 0x8(%rcx), %rax
movq %rax, -0x28(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0xfd1d
movq -0x20(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2f, %eax
je 0xfd35
movq -0x18(%rbp), %rax
movq $0x0, 0x8(%rax)
movl $0x0, -0x4(%rbp)
jmp 0xfe7a
movq -0x30(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x20(%rbp), %rax
cmpq -0x28(%rbp), %rax
jae 0xfe39
movq -0x20(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x28(%rbp), %rsi
leaq -0x40(%rbp), %rdi
leaq 0x10336(%rip), %rdx     # 0x20098
leaq -0x50(%rbp), %rcx
callq 0xfc10
leaq -0x50(%rbp), %rdi
leaq 0xfc15(%rip), %rsi      # 0x1f98b
callq 0x8ad0
cmpl $0x0, %eax
jne 0xfd85
jmp 0xfe2c
leaq -0x50(%rbp), %rdi
leaq 0xfbfa(%rip), %rsi      # 0x1f98a
callq 0x8ad0
cmpl $0x0, %eax
jne 0xfdff
movq -0x38(%rbp), %rax
movq -0x30(%rbp), %rcx
addq $0x1, %rcx
cmpq %rcx, %rax
jbe 0xfdc4
movq -0x38(%rbp), %rax
movsbl -0x1(%rax), %eax
cmpl $0x2f, %eax
jne 0xfdc4
movq -0x38(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0xfdc6
movq -0x38(%rbp), %rcx
xorl %eax, %eax
cmpq -0x30(%rbp), %rcx
movb %al, -0x51(%rbp)
jbe 0xfde6
movq -0x38(%rbp), %rax
movsbl -0x1(%rax), %eax
cmpl $0x2f, %eax
setne %al
movb %al, -0x51(%rbp)
movb -0x51(%rbp), %al
testb $0x1, %al
jne 0xfdef
jmp 0xfdfd
movq -0x38(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0xfdc6
jmp 0xfe2a
movq -0x38(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x40(%rbp), %rdx
movq -0x20(%rbp), %rax
subq %rax, %rdx
callq 0x3540
movq -0x40(%rbp), %rax
movq -0x20(%rbp), %rcx
subq %rcx, %rax
addq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
jmp 0xfe2c
movq -0x40(%rbp), %rax
movq %rax, -0x20(%rbp)
jmp 0xfd3d
movq -0x38(%rbp), %rax
cmpq -0x30(%rbp), %rax
jne 0xfe55
movq -0x38(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x38(%rbp)
movb $0x2f, (%rax)
movq -0x30(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x38(%rbp), %rcx
movq -0x30(%rbp), %rax
subq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x8(%rax)
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_http_get_request_len
static int mg_http_get_request_len(const char *s, int buf_len) {
  const unsigned char *buf = (unsigned char *) s;
  int i;

  for (i = 0; i < buf_len; i++) {
    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
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x10594
callq 0x36a0
movq (%rax), %rax
movq -0x20(%rbp), %rcx
movslq -0x24(%rbp), %rdx
movzbl (%rcx,%rdx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x4000, %eax           # imm = 0x4000
cmpl $0x0, %eax
jne 0x104f0
movq -0x20(%rbp), %rax
movslq -0x24(%rbp), %rcx
movzbl (%rax,%rcx), %eax
cmpl $0xd, %eax
je 0x104f0
movq -0x20(%rbp), %rax
movslq -0x24(%rbp), %rcx
movzbl (%rax,%rcx), %eax
cmpl $0xa, %eax
je 0x104f0
movq -0x20(%rbp), %rax
movslq -0x24(%rbp), %rcx
movzbl (%rax,%rcx), %eax
cmpl $0x80, %eax
jge 0x104f0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1059b
movq -0x20(%rbp), %rax
movslq -0x24(%rbp), %rcx
movzbl (%rax,%rcx), %eax
cmpl $0xa, %eax
jne 0x1052d
movl -0x24(%rbp), %eax
addl $0x1, %eax
cmpl -0x14(%rbp), %eax
jge 0x1052d
movq -0x20(%rbp), %rax
movl -0x24(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movzbl (%rax,%rcx), %eax
cmpl $0xa, %eax
jne 0x1052d
movl -0x24(%rbp), %eax
addl $0x2, %eax
movl %eax, -0x4(%rbp)
jmp 0x1059b
movq -0x20(%rbp), %rax
movslq -0x24(%rbp), %rcx
movzbl (%rax,%rcx), %eax
cmpl $0xa, %eax
jne 0x10580
movl -0x24(%rbp), %eax
addl $0x2, %eax
cmpl -0x14(%rbp), %eax
jge 0x10580
movq -0x20(%rbp), %rax
movl -0x24(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movzbl (%rax,%rcx), %eax
cmpl $0xd, %eax
jne 0x10580
movq -0x20(%rbp), %rax
movl -0x24(%rbp), %ecx
addl $0x2, %ecx
movslq %ecx, %rcx
movzbl (%rax,%rcx), %eax
cmpl $0xa, %eax
jne 0x10580
movl -0x24(%rbp), %eax
addl $0x3, %eax
movl %eax, -0x4(%rbp)
jmp 0x1059b
jmp 0x10582
jmp 0x10584
jmp 0x10586
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x1047e
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_skip
const char *mg_skip(const char *s, const char *end, const char *delims,
                    struct mg_str *v) {
  v->p = s;
  while (s < end && strchr(delims, *(unsigned char *) s) == NULL) s++;
  v->len = s - v->p;
  while (s < end && strchr(delims, *(unsigned char *) s) != NULL) s++;
  return s;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x8(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movq -0x8(%rbp), %rcx
xorl %eax, %eax
cmpq -0x10(%rbp), %rcx
movb %al, -0x21(%rbp)
jae 0x105fc
movq -0x18(%rbp), %rdi
movq -0x8(%rbp), %rax
movzbl (%rax), %esi
callq 0x31e0
cmpq $0x0, %rax
sete %al
movb %al, -0x21(%rbp)
movb -0x21(%rbp), %al
testb $0x1, %al
jne 0x10605
jmp 0x10613
movq -0x8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x8(%rbp)
jmp 0x105d3
movq -0x8(%rbp), %rcx
movq -0x20(%rbp), %rax
movq (%rax), %rax
subq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x8(%rbp), %rcx
xorl %eax, %eax
cmpq -0x10(%rbp), %rcx
movb %al, -0x22(%rbp)
jae 0x10652
movq -0x18(%rbp), %rdi
movq -0x8(%rbp), %rax
movzbl (%rax), %esi
callq 0x31e0
cmpq $0x0, %rax
setne %al
movb %al, -0x22(%rbp)
movb -0x22(%rbp), %al
testb $0x1, %al
jne 0x1065b
jmp 0x10669
movq -0x8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x8(%rbp)
jmp 0x10629
movq -0x8(%rbp), %rax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_get_http_header
struct mg_str *mg_get_http_header(struct http_message *hm, const char *name) {
  size_t i, len = strlen(name);

  for (i = 0; hm->header_names[i].len > 0; i++) {
    struct mg_str *h = &hm->header_names[i], *v = &hm->header_values[i];
    if (h->p != NULL && h->len == len && !mg_ncasecmp(h->p, name, len))
      return v;
  }

  return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x18(%rbp), %rdi
callq 0x3180
movq %rax, -0x28(%rbp)
movq $0x0, -0x20(%rbp)
movq -0x10(%rbp), %rax
addq $0x78, %rax
movq -0x20(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
cmpq $0x0, 0x8(%rax)
jbe 0x108ed
movq -0x10(%rbp), %rax
addq $0x78, %rax
movq -0x20(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rax
addq $0x2f8, %rax            # imm = 0x2F8
movq -0x20(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
movq -0x30(%rbp), %rax
cmpq $0x0, (%rax)
je 0x108da
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rax
cmpq -0x28(%rbp), %rax
jne 0x108da
movq -0x30(%rbp), %rax
movq (%rax), %rdi
movq -0x18(%rbp), %rsi
movq -0x28(%rbp), %rdx
callq 0x8bf0
cmpl $0x0, %eax
jne 0x108da
movq -0x38(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x108f5
jmp 0x108dc
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0x10855
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O0/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_http_get_endpoint_handler
struct mg_http_endpoint *mg_http_get_endpoint_handler(struct mg_connection *nc,
                                                      struct mg_str *uri_path) {
  struct mg_http_proto_data *pd;
  struct mg_http_endpoint *ret = NULL;
  int matched, matched_max = 0;
  struct mg_http_endpoint *ep;

  if (nc == NULL) {
    return NULL;
  }

  pd = mg_http_get_proto_data(nc);

  ep = pd->endpoints;
  while (ep != NULL) {
    if ((matched = mg_match_prefix_n(ep->uri_pattern, *uri_path)) != -1) {
      if (matched > matched_max) {
        /* Looking for the longest suitable handler */
        ret = ep;
        matched_max = matched;
      }
    }

    ep = ep->next;
  }

  return ret;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq $0x0, -0x28(%rbp)
movl $0x0, -0x30(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x10930
movq $0x0, -0x8(%rbp)
jmp 0x109a1
movq -0x10(%rbp), %rdi
callq 0x109b0
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq 0x38(%rax), %rax
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0x10999
movq -0x38(%rbp), %rcx
movq -0x18(%rbp), %rax
movq 0x8(%rcx), %rdi
movq 0x10(%rcx), %rsi
movq (%rax), %rdx
movq 0x8(%rax), %rcx
callq 0xa510
movl %eax, -0x2c(%rbp)
cmpl $-0x1, %eax
je 0x1098c
movl -0x2c(%rbp), %eax
cmpl -0x30(%rbp), %eax
jle 0x1098a
movq -0x38(%rbp), %rax
movq %rax, -0x28(%rbp)
movl -0x2c(%rbp), %eax
movl %eax, -0x30(%rbp)
jmp 0x1098c
movq -0x38(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x38(%rbp)
jmp 0x10949
movq -0x28(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_http_get_proto_data
static struct mg_http_proto_data *mg_http_get_proto_data(
    struct mg_connection *c) {
  if (c->proto_data == NULL) {
    c->proto_data = MG_CALLOC(1, sizeof(struct mg_http_proto_data));
    c->proto_data_destructor = mg_http_conn_destructor;
  }

  return (struct mg_http_proto_data *) c->proto_data;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
cmpq $0x0, 0x88(%rax)
jne 0x109f9
movl $0x1, %edi
movl $0x58, %esi
callq 0x3330
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x88(%rax)
movq -0x8(%rbp), %rax
leaq 0x907e(%rip), %rcx      # 0x19a70
movq %rcx, 0x90(%rax)
movq -0x8(%rbp), %rax
movq 0x88(%rax), %rax
addq $0x10, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/sfeakes[P]unifi-motion/mongoose.c
// Function: deliver_chunk
static void deliver_chunk(struct mg_connection *c, struct http_message *hm,
                          int req_len) {
  /* Incomplete message received. Send MG_EV_HTTP_CHUNK event */
  hm->body.len = c->recv_mbuf.len - req_len;
  c->flags &= ~MG_F_DELETE_CHUNK;
  mg_call(c, c->handler, c->user_data, MG_EV_HTTP_CHUNK, hm);
  /* Delete processed data if user set MG_F_DELETE_CHUNK flag */
  if (c->flags & MG_F_DELETE_CHUNK) c->recv_mbuf.len = req_len;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rcx
movslq -0x14(%rbp), %rax
subq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x8(%rbp), %rax
movq 0xc8(%rax), %rcx
andq $-0x2001, %rcx          # imm = 0xDFFF
movq %rcx, 0xc8(%rax)
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x98(%rax), %rsi
movq -0x8(%rbp), %rax
movq 0xa0(%rax), %rdx
movq -0x10(%rbp), %r8
movl $0x66, %ecx
callq 0xa8e0
movq -0x8(%rbp), %rax
movq 0xc8(%rax), %rax
andq $0x2000, %rax           # imm = 0x2000
cmpq $0x0, %rax
je 0x110ee
movslq -0x14(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x48(%rax)
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_http_call_endpoint_handler
static void mg_http_call_endpoint_handler(struct mg_connection *nc, int ev,
                                          struct http_message *hm) {
  struct mg_http_proto_data *pd = mg_http_get_proto_data(nc);
  void *user_data = nc->user_data;

  if (ev == MG_EV_HTTP_REQUEST
#if MG_ENABLE_HTTP_STREAMING_MULTIPART
      || ev == MG_EV_HTTP_MULTIPART_REQUEST
#endif
      ) {
    struct mg_http_endpoint *ep =
        mg_http_get_endpoint_handler(nc->listener, &hm->uri);
    if (ep != NULL) {
#if MG_ENABLE_FILESYSTEM && !MG_DISABLE_HTTP_DIGEST_AUTH
      if (!mg_http_is_authorized(hm, hm->uri, 0 /* is_directory */,
                                 ep->auth_domain, ep->auth_file,
                                 1 /* is_global_pass_file */)) {
        mg_http_send_digest_auth_request(nc, ep->auth_domain);
        return;
      }
#endif
      pd->endpoint_handler = ep->handler;
#if MG_ENABLE_CALLBACK_USERDATA
      user_data = ep->user_data;
#endif
    }
  }
  mg_call(nc, pd->endpoint_handler ? pd->endpoint_handler : nc->handler,
          user_data, ev, hm);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rdi
callq 0x109b0
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq 0xa0(%rax), %rax
movq %rax, -0x28(%rbp)
cmpl $0x64, -0xc(%rbp)
jne 0x111ad
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x18(%rbp), %rsi
addq $0x30, %rsi
callq 0x10900
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x111ab
movq -0x18(%rbp), %rdi
movq -0x18(%rbp), %rax
movq -0x30(%rbp), %rcx
movq 0x18(%rcx), %r8
movq -0x30(%rbp), %rcx
movq 0x20(%rcx), %r9
movq 0x30(%rax), %rsi
movq 0x38(%rax), %rdx
xorl %ecx, %ecx
movl $0x1, (%rsp)
callq 0x19ff0
cmpl $0x0, %eax
jne 0x1119b
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rsi
callq 0x1a200
jmp 0x111f5
movq -0x30(%rbp), %rax
movq 0x28(%rax), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x40(%rax)
jmp 0x111ad
movq -0x8(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x20(%rbp), %rax
cmpq $0x0, 0x40(%rax)
je 0x111ce
movq -0x20(%rbp), %rax
movq 0x40(%rax), %rax
movq %rax, -0x40(%rbp)
jmp 0x111dd
movq -0x8(%rbp), %rax
movq 0x98(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x38(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq -0x28(%rbp), %rdx
movl -0xc(%rbp), %ecx
movq -0x18(%rbp), %r8
callq 0xa8e0
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_ws_handler
MG_INTERNAL void mg_ws_handler(struct mg_connection *nc, int ev,
                               void *ev_data MG_UD_ARG(void *user_data)) {
  mg_call(nc, nc->handler, nc->user_data, ev, ev_data);

  switch (ev) {
    case MG_EV_RECV:
      do {
      } while (mg_deliver_websocket_data(nc));
      break;
    case MG_EV_POLL:
      /* Ping idle websocket connections */
      {
        time_t now = *(time_t *) ev_data;
        if (nc->flags & MG_F_IS_WEBSOCKET &&
            now > nc->last_io_time + MG_WEBSOCKET_PING_INTERVAL_SECONDS) {
          mg_send_websocket_frame(nc, WEBSOCKET_OP_PING, "", 0);
        }
      }
      break;
    default:
      break;
  }
#if MG_ENABLE_CALLBACK_USERDATA
  (void) user_data;
#endif
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rdi
movq 0x98(%rdi), %rsi
movq 0xa0(%rdi), %rdx
movl -0xc(%rbp), %ecx
movq -0x18(%rbp), %r8
callq 0xa8e0
movl -0xc(%rbp), %eax
movl %eax, -0x24(%rbp)
testl %eax, %eax
je 0x1184b
jmp 0x1182d
movl -0x24(%rbp), %eax
subl $0x3, %eax
jne 0x1189d
jmp 0x11837
jmp 0x11839
jmp 0x1183b
movq -0x8(%rbp), %rdi
callq 0x1c780
cmpl $0x0, %eax
jne 0x11839
jmp 0x1189f
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq 0xc8(%rax), %rax
andq $0x100, %rax            # imm = 0x100
cmpq $0x0, %rax
je 0x1189b
movq -0x20(%rbp), %rax
movq -0x8(%rbp), %rcx
movq 0x70(%rcx), %rcx
addq $0x5, %rcx
cmpq %rcx, %rax
jle 0x1189b
movq -0x8(%rbp), %rdi
movl $0x9, %esi
leaq 0xef19(%rip), %rdx      # 0x207ab
xorl %eax, %eax
movl %eax, %ecx
callq 0x15e10
jmp 0x1189f
jmp 0x1189f
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_ws_handshake
MG_INTERNAL void mg_ws_handshake(struct mg_connection *nc,
                                 const struct mg_str *key,
                                 struct http_message *hm) {
  static const char *magic = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
  const uint8_t *msgs[2] = {(const uint8_t *) key->p, (const uint8_t *) magic};
  const size_t msg_lens[2] = {key->len, 36};
  unsigned char sha[20];
  char b64_sha[30];
  struct mg_str *s;

  mg_hash_sha1_v(2, msgs, msg_lens, sha);
  mg_base64_encode(sha, sizeof(sha), b64_sha);
  mg_printf(nc, "%s",
            "HTTP/1.1 101 Switching Protocols\r\n"
            "Upgrade: websocket\r\n"
            "Connection: Upgrade\r\n");

  s = mg_get_http_header(hm, "Sec-WebSocket-Protocol");
  if (s != NULL) {
    mg_printf(nc, "Sec-WebSocket-Protocol: %.*s\r\n", (int) s->len, s->p);
  }
  mg_printf(nc, "Sec-WebSocket-Accept: %s%s", b64_sha, "\r\n\r\n");

  DBG(("%p %.*s %s", nc, (int) key->len, key->p, b64_sha));
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x30(%rbp)
movq 0x15b77(%rip), %rax     # 0x27450
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x40(%rbp)
movq $0x24, -0x38(%rbp)
leaq -0x30(%rbp), %rsi
leaq -0x40(%rbp), %rdx
leaq -0x60(%rbp), %rcx
movl $0x2, %edi
callq 0x16280
leaq -0x60(%rbp), %rdi
leaq -0x80(%rbp), %rdx
movl $0x14, %esi
callq 0x166a0
movq -0x8(%rbp), %rdi
leaq 0xe66e(%rip), %rsi      # 0x1ff92
leaq 0xfc1c(%rip), %rdx      # 0x21547
movb $0x0, %al
callq 0xb2f0
movq -0x18(%rbp), %rdi
leaq 0xfc56(%rip), %rsi      # 0x21593
callq 0x10830
movq %rax, -0x88(%rbp)
cmpq $0x0, -0x88(%rbp)
je 0x1197c
movq -0x8(%rbp), %rdi
movq -0x88(%rbp), %rax
movq 0x8(%rax), %rax
movl %eax, %edx
movq -0x88(%rbp), %rax
movq (%rax), %rcx
leaq 0xe6b8(%rip), %rsi      # 0x2002d
movb $0x0, %al
callq 0xb2f0
movq -0x8(%rbp), %rdi
leaq -0x80(%rbp), %rdx
leaq 0xfc1f(%rip), %rsi      # 0x215aa
leaq 0xee15(%rip), %rcx      # 0x207a7
movb $0x0, %al
callq 0xb2f0
movl $0x4, %edi
leaq 0xfc20(%rip), %rsi      # 0x215c5
leaq 0xdb9e(%rip), %rdx      # 0x1f54a
callq 0x4650
cmpl $0x0, %eax
je 0x119dd
movq -0x8(%rbp), %rsi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movl %eax, %edx
movq -0x10(%rbp), %rax
movq (%rax), %rcx
leaq -0x80(%rbp), %r8
leaq 0xfbff(%rip), %rdi      # 0x215d5
movb $0x0, %al
callq 0x47a0
jmp 0x119df
addq $0x90, %rsp
popq %rbp
retq
nopl (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_send_response_line_s
void mg_send_response_line_s(struct mg_connection *nc, int status_code,
                             const struct mg_str extra_headers) {
  mg_printf(nc, "HTTP/1.1 %d %s\r\nServer: %s\r\n", status_code,
            mg_status_message(status_code), mg_version_header);
  if (extra_headers.len > 0) {
    mg_printf(nc, "%.*s\r\n", (int) extra_headers.len, extra_headers.p);
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdx, -0x10(%rbp)
movq %rcx, -0x8(%rbp)
movq %rdi, -0x18(%rbp)
movl %esi, -0x1c(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x28(%rbp)
movl -0x1c(%rbp), %eax
movl %eax, -0x20(%rbp)
movl -0x1c(%rbp), %edi
callq 0x11a10
movq -0x28(%rbp), %rdi
movl -0x20(%rbp), %edx
movq %rax, %rcx
movq 0x157e2(%rip), %r8      # 0x273c0
leaq 0xdecf(%rip), %rsi      # 0x1fab4
movb $0x0, %al
callq 0xb2f0
cmpq $0x0, -0x8(%rbp)
jbe 0x11c0f
movq -0x18(%rbp), %rdi
movq -0x8(%rbp), %rax
movl %eax, %edx
movq -0x10(%rbp), %rcx
leaq 0xee0b(%rip), %rsi      # 0x20a13
movb $0x0, %al
callq 0xb2f0
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_http_send_redirect
void mg_http_send_redirect(struct mg_connection *nc, int status_code,
                           const struct mg_str location,
                           const struct mg_str extra_headers) {
  char bbody[100], *pbody = bbody;
  int bl = mg_asprintf(&pbody, sizeof(bbody),
                       "<p>Moved <a href='%.*s'>here</a>.\r\n",
                       (int) location.len, location.p);
  char bhead[150], *phead = bhead;
  mg_asprintf(&phead, sizeof(bhead),
              "Location: %.*s\r\n"
              "Content-Type: text/html\r\n"
              "Content-Length: %d\r\n"
              "Cache-Control: no-cache\r\n"
              "%.*s%s",
              (int) location.len, location.p, bl, (int) extra_headers.len,
              extra_headers.p, (extra_headers.len > 0 ? "\r\n" : ""));
  mg_send_response_line(nc, status_code, phead);
  if (phead != bhead) MG_FREE(phead);
  mg_send(nc, pbody, bl);
  if (pbody != bbody) MG_FREE(pbody);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x160, %rsp            # imm = 0x160
movq %rdx, -0x10(%rbp)
movq %rcx, -0x8(%rbp)
movq %r8, -0x20(%rbp)
movq %r9, -0x18(%rbp)
movq %rdi, -0x28(%rbp)
movl %esi, -0x2c(%rbp)
leaq -0x90(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0x8(%rbp), %rax
movl %eax, %ecx
movq -0x10(%rbp), %r8
leaq -0x98(%rbp), %rdi
movl $0x64, %esi
leaq 0xde14(%rip), %rdx      # 0x1fad1
movb $0x0, %al
callq 0xa0f0
movl %eax, -0x9c(%rbp)
leaq -0x140(%rbp), %rax
movq %rax, -0x148(%rbp)
movq -0x8(%rbp), %rax
movl %eax, %ecx
movq -0x10(%rbp), %r8
movl -0x9c(%rbp), %r9d
movq -0x18(%rbp), %rax
movl %eax, %r11d
movq -0x20(%rbp), %r10
movq -0x18(%rbp), %rsi
leaq 0xeaac(%rip), %rax      # 0x207ab
leaq 0xeaa3(%rip), %rdx      # 0x207a9
cmpq $0x0, %rsi
cmovaq %rdx, %rax
leaq -0x148(%rbp), %rdi
movl $0x96, %esi
leaq 0xddd4(%rip), %rdx      # 0x1faf5
movl %r11d, (%rsp)
movq %r10, 0x8(%rsp)
movq %rax, 0x10(%rsp)
movb $0x0, %al
callq 0xa0f0
movq -0x28(%rbp), %rdi
movl -0x2c(%rbp), %esi
movq -0x148(%rbp), %rdx
callq 0x11c20
movq -0x148(%rbp), %rax
leaq -0x140(%rbp), %rcx
cmpq %rcx, %rax
je 0x11d68
movq -0x148(%rbp), %rdi
callq 0x3050
movq -0x28(%rbp), %rdi
movq -0x98(%rbp), %rsi
movl -0x9c(%rbp), %edx
callq 0xb260
movq -0x98(%rbp), %rax
leaq -0x90(%rbp), %rcx
cmpq %rcx, %rax
je 0x11d9d
movq -0x98(%rbp), %rdi
callq 0x3050
addq $0x160, %rsp            # imm = 0x160
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_send_head
void mg_send_head(struct mg_connection *c, int status_code,
                  int64_t content_length, const char *extra_headers) {
  mg_send_response_line(c, status_code, extra_headers);
  if (content_length < 0) {
    mg_printf(c, "%s", "Transfer-Encoding: chunked\r\n");
  } else {
    mg_printf(c, "Content-Length: %" INT64_FMT "\r\n", content_length);
  }
  mg_send(c, "\r\n", 2);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
movq -0x20(%rbp), %rdx
callq 0x11c20
cmpq $0x0, -0x18(%rbp)
jge 0x11df9
movq -0x8(%rbp), %rdi
leaq 0xe1a9(%rip), %rsi      # 0x1ff92
leaq 0xdd62(%rip), %rdx      # 0x1fb52
movb $0x0, %al
callq 0xb2f0
jmp 0x11e0f
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rdx
leaq 0xdd67(%rip), %rsi      # 0x1fb6f
movb $0x0, %al
callq 0xb2f0
movq -0x8(%rbp), %rdi
leaq 0xe98f(%rip), %rsi      # 0x207a9
movl $0x2, %edx
callq 0xb260
addq $0x20, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_http_send_error
void mg_http_send_error(struct mg_connection *nc, int code,
                        const char *reason) {
  if (!reason) reason = mg_status_message(code);
  LOG(LL_DEBUG, ("%p %d %s", nc, code, reason));
  mg_send_head(nc, code, strlen(reason),
               "Content-Type: text/plain\r\nConnection: close");
  mg_send(nc, reason, strlen(reason));
  nc->flags |= MG_F_SEND_AND_CLOSE;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x11e56
movl -0xc(%rbp), %edi
callq 0x11a10
movq %rax, -0x18(%rbp)
jmp 0x11e58
movl $0x3, %edi
leaq 0xdd21(%rip), %rsi      # 0x1fb85
leaq 0xd6df(%rip), %rdx      # 0x1f54a
callq 0x4650
cmpl $0x0, %eax
je 0x11e8e
movq -0x8(%rbp), %rsi
movl -0xc(%rbp), %edx
movq -0x18(%rbp), %rcx
leaq 0xdd11(%rip), %rdi      # 0x1fb98
movb $0x0, %al
callq 0x47a0
jmp 0x11e90
movq -0x8(%rbp), %rax
movq %rax, -0x38(%rbp)
movl -0xc(%rbp), %eax
movl %eax, -0x2c(%rbp)
movq -0x18(%rbp), %rdi
callq 0x3180
movq -0x38(%rbp), %rdi
movl -0x2c(%rbp), %esi
movq %rax, %rdx
leaq 0xdce9(%rip), %rcx      # 0x1fba1
callq 0x11db0
movq -0x8(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rdi
callq 0x3180
movq -0x28(%rbp), %rdi
movq -0x20(%rbp), %rsi
movl %eax, %edx
callq 0xb260
movq -0x8(%rbp), %rax
movq 0xc8(%rax), %rcx
orq $0x400, %rcx            # imm = 0x400
movq %rcx, 0xc8(%rax)
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_http_parse_range_header
static int mg_http_parse_range_header(const struct mg_str *header, int64_t *a,
                                      int64_t *b) {
  /*
   * There is no snscanf. Headers are not guaranteed to be NUL-terminated,
   * so we have this. Ugh.
   */
  int result;
  char *p = (char *) MG_MALLOC(header->len + 1);
  if (p == NULL) return 0;
  memcpy(p, header->p, header->len);
  p[header->len] = '\0';
  result = sscanf(p, "bytes=%" INT64_FMT "-%" INT64_FMT, a, b);
  MG_FREE(p);
  return result;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
addq $0x1, %rdi
callq 0x3420
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x123c9
movl $0x0, -0x4(%rbp)
jmp 0x1241d
movq -0x30(%rbp), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rsi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdx
callq 0x33b0
movq -0x30(%rbp), %rax
movq -0x10(%rbp), %rcx
movq 0x8(%rcx), %rcx
movb $0x0, (%rax,%rcx)
movq -0x30(%rbp), %rdi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
leaq 0xe0f3(%rip), %rsi      # 0x204f7
movb $0x0, %al
callq 0x3460
movl %eax, -0x24(%rbp)
movq -0x30(%rbp), %rdi
callq 0x3050
movl -0x24(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_send_http_chunk
void mg_send_http_chunk(struct mg_connection *nc, const char *buf, size_t len) {
  char chunk_size[50];
  int n;

  n = snprintf(chunk_size, sizeof(chunk_size), "%lX\r\n", (unsigned long) len);
  mg_send(nc, chunk_size, n);
  mg_send(nc, buf, len);
  mg_send(nc, "\r\n", 2);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
leaq -0x50(%rbp), %rdi
movq -0x18(%rbp), %rcx
movl $0x32, %esi
leaq 0xd43b(%rip), %rdx      # 0x1fcd3
movb $0x0, %al
callq 0x31f0
movl %eax, -0x54(%rbp)
movq -0x8(%rbp), %rdi
leaq -0x50(%rbp), %rsi
movl -0x54(%rbp), %edx
callq 0xb260
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rax
movl %eax, %edx
callq 0xb260
movq -0x8(%rbp), %rdi
leaq 0xded9(%rip), %rsi      # 0x207a9
movl $0x2, %edx
callq 0xb260
addq $0x60, %rsp
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O0/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_printf_http_chunk
void mg_printf_http_chunk(struct mg_connection *nc, const char *fmt, ...) {
  char mem[MG_VPRINTF_BUFFER_SIZE], *buf = mem;
  int len;
  va_list ap;

  va_start(ap, fmt);
  len = mg_avprintf(&buf, sizeof(mem), fmt, ap);
  va_end(ap);

  if (len >= 0) {
    mg_send_http_chunk(nc, buf, len);
  }

  /* LCOV_EXCL_START */
  if (buf != mem && buf != NULL) {
    MG_FREE(buf);
  }
  /* LCOV_EXCL_STOP */
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x160, %rsp            # imm = 0x160
testb %al, %al
je 0x12927
movaps %xmm0, -0x130(%rbp)
movaps %xmm1, -0x120(%rbp)
movaps %xmm2, -0x110(%rbp)
movaps %xmm3, -0x100(%rbp)
movaps %xmm4, -0xf0(%rbp)
movaps %xmm5, -0xe0(%rbp)
movaps %xmm6, -0xd0(%rbp)
movaps %xmm7, -0xc0(%rbp)
movq %r9, -0x138(%rbp)
movq %r8, -0x140(%rbp)
movq %rcx, -0x148(%rbp)
movq %rdx, -0x150(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
leaq -0x80(%rbp), %rax
movq %rax, -0x88(%rbp)
leaq -0xb0(%rbp), %rax
leaq -0x160(%rbp), %rcx
movq %rcx, 0x10(%rax)
leaq 0x10(%rbp), %rcx
movq %rcx, 0x8(%rax)
movl $0x30, 0x4(%rax)
movl $0x10, (%rax)
movq -0x10(%rbp), %rdx
leaq -0xb0(%rbp), %rcx
leaq -0x88(%rbp), %rdi
movl $0x64, %esi
callq 0xa1a0
movl %eax, -0x8c(%rbp)
leaq -0xb0(%rbp), %rax
cmpl $0x0, -0x8c(%rbp)
jl 0x129c6
movq -0x8(%rbp), %rdi
movq -0x88(%rbp), %rsi
movslq -0x8c(%rbp), %rdx
callq 0x12870
movq -0x88(%rbp), %rax
leaq -0x80(%rbp), %rcx
cmpq %rcx, %rax
je 0x129ec
cmpq $0x0, -0x88(%rbp)
je 0x129ec
movq -0x88(%rbp), %rdi
callq 0x3050
addq $0x160, %rsp            # imm = 0x160
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_printf_html_escape
void mg_printf_html_escape(struct mg_connection *nc, const char *fmt, ...) {
  char mem[MG_VPRINTF_BUFFER_SIZE], *buf = mem;
  int i, j, len;
  va_list ap;

  va_start(ap, fmt);
  len = mg_avprintf(&buf, sizeof(mem), fmt, ap);
  va_end(ap);

  if (len >= 0) {
    for (i = j = 0; i < len; i++) {
      if (buf[i] == '<' || buf[i] == '>') {
        mg_send(nc, buf + j, i - j);
        mg_send(nc, buf[i] == '<' ? "&lt;" : "&gt;", 4);
        j = i + 1;
      }
    }
    mg_send(nc, buf + j, i - j);
  }

  /* LCOV_EXCL_START */
  if (buf != mem && buf != NULL) {
    MG_FREE(buf);
  }
  /* LCOV_EXCL_STOP */
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x160, %rsp            # imm = 0x160
testb %al, %al
je 0x12a47
movaps %xmm0, -0x130(%rbp)
movaps %xmm1, -0x120(%rbp)
movaps %xmm2, -0x110(%rbp)
movaps %xmm3, -0x100(%rbp)
movaps %xmm4, -0xf0(%rbp)
movaps %xmm5, -0xe0(%rbp)
movaps %xmm6, -0xd0(%rbp)
movaps %xmm7, -0xc0(%rbp)
movq %r9, -0x138(%rbp)
movq %r8, -0x140(%rbp)
movq %rcx, -0x148(%rbp)
movq %rdx, -0x150(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
leaq -0x80(%rbp), %rax
movq %rax, -0x88(%rbp)
leaq -0xb0(%rbp), %rax
leaq -0x160(%rbp), %rcx
movq %rcx, 0x10(%rax)
leaq 0x10(%rbp), %rcx
movq %rcx, 0x8(%rax)
movl $0x30, 0x4(%rax)
movl $0x10, (%rax)
movq -0x10(%rbp), %rdx
leaq -0xb0(%rbp), %rcx
leaq -0x88(%rbp), %rdi
movl $0x64, %esi
callq 0xa1a0
movl %eax, -0x94(%rbp)
leaq -0xb0(%rbp), %rax
cmpl $0x0, -0x94(%rbp)
jl 0x12bcd
movl $0x0, -0x90(%rbp)
movl $0x0, -0x8c(%rbp)
movl -0x8c(%rbp), %eax
cmpl -0x94(%rbp), %eax
jge 0x12ba7
movq -0x88(%rbp), %rax
movslq -0x8c(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x3c, %eax
je 0x12b27
movq -0x88(%rbp), %rax
movslq -0x8c(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x3e, %eax
jne 0x12b91
movq -0x8(%rbp), %rdi
movq -0x88(%rbp), %rsi
movslq -0x90(%rbp), %rax
addq %rax, %rsi
movl -0x8c(%rbp), %edx
subl -0x90(%rbp), %edx
callq 0xb260
movq -0x8(%rbp), %rdi
movq -0x88(%rbp), %rax
movslq -0x8c(%rbp), %rcx
movsbl (%rax,%rcx), %ecx
leaq 0xd174(%rip), %rsi      # 0x1fcde
leaq 0xd168(%rip), %rax      # 0x1fcd9
cmpl $0x3c, %ecx
cmoveq %rax, %rsi
movl $0x4, %edx
callq 0xb260
movl -0x8c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x90(%rbp)
jmp 0x12b93
movl -0x8c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8c(%rbp)
jmp 0x12ae7
movq -0x8(%rbp), %rdi
movq -0x88(%rbp), %rsi
movslq -0x90(%rbp), %rax
addq %rax, %rsi
movl -0x8c(%rbp), %edx
subl -0x90(%rbp), %edx
callq 0xb260
movq -0x88(%rbp), %rax
leaq -0x80(%rbp), %rcx
cmpq %rcx, %rax
je 0x12bf3
cmpq $0x0, -0x88(%rbp)
je 0x12bf3
movq -0x88(%rbp), %rdi
callq 0x3050
addq $0x160, %rsp            # imm = 0x160
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_parse_http_basic_auth
int mg_parse_http_basic_auth(struct mg_str *hdr, char *user, size_t user_len,
                             char *pass, size_t pass_len) {
  char *buf = NULL;
  char fmt[64];
  int res = 0;

  if (mg_strncmp(*hdr, mg_mk_str("Basic "), 6) != 0) return -1;

  buf = (char *) MG_MALLOC(hdr->len);
  cs_base64_decode((unsigned char *) hdr->p + 6, hdr->len, buf, NULL);

  /* e.g. "%123[^:]:%321[^\n]" */
  snprintf(fmt, sizeof(fmt), "%%%" SIZE_T_FMT "[^:]:%%%" SIZE_T_FMT "[^\n]",
           user_len - 1, pass_len - 1);
  if (sscanf(buf, fmt, user, pass) == 0) {
    res = -1;
  }

  MG_FREE(buf);
  return res;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
movl $0x0, -0x84(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xa0(%rbp)
leaq 0xd0f5(%rip), %rdi      # 0x20088
callq 0x8a60
movq %rax, %rcx
movq -0xa0(%rbp), %rax
movq %rcx, -0x98(%rbp)
movq %rdx, -0x90(%rbp)
movq (%rax), %rdi
movq 0x8(%rax), %rsi
movq -0x98(%rbp), %rdx
movq -0x90(%rbp), %rcx
movl $0x6, %r8d
callq 0x8ee0
cmpl $0x0, %eax
je 0x12fe1
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x13073
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x3420
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
addq $0x6, %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movl %eax, %esi
movq -0x38(%rbp), %rdx
xorl %eax, %eax
movl %eax, %ecx
callq 0x4e50
leaq -0x80(%rbp), %rdi
movq -0x20(%rbp), %rcx
subq $0x1, %rcx
movq -0x30(%rbp), %r8
subq $0x1, %r8
movl $0x40, %esi
leaq 0xccbd(%rip), %rdx      # 0x1fcf1
movb $0x0, %al
callq 0x31f0
movq -0x38(%rbp), %rdi
leaq -0x80(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x28(%rbp), %rcx
movb $0x0, %al
callq 0x3460
cmpl $0x0, %eax
jne 0x13061
movl $0xffffffff, -0x84(%rbp) # imm = 0xFFFFFFFF
movq -0x38(%rbp), %rdi
callq 0x3050
movl -0x84(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xa0, %rsp
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O0/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_hash_md5_v
void mg_hash_md5_v(size_t num_msgs, const uint8_t *msgs[],
                   const size_t *msg_lens, uint8_t *digest) {
  size_t i;
  cs_md5_ctx md5_ctx;
  cs_md5_init(&md5_ctx);
  for (i = 0; i < num_msgs; i++) {
    cs_md5_update(&md5_ctx, msgs[i], msg_lens[i]);
  }
  cs_md5_final(digest, &md5_ctx);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x51a0
movq $0x0, -0x28(%rbp)
movq -0x28(%rbp), %rax
cmpq -0x8(%rbp), %rax
jae 0x130e5
movq -0x10(%rbp), %rax
movq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
movq -0x18(%rbp), %rax
movq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
leaq -0x80(%rbp), %rdi
callq 0x51f0
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
jmp 0x130ac
movq -0x20(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x62e0
addq $0x80, %rsp
popq %rbp
retq
nopl (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/sfeakes[P]unifi-motion/mongoose.c
// Function: cs_md5
void cs_md5(char buf[33], ...) {
  unsigned char hash[16];
  const uint8_t *msgs[20], *p;
  size_t msg_lens[20];
  size_t num_msgs = 0;
  va_list ap;

  va_start(ap, buf);
  while ((p = va_arg(ap, const unsigned char *) ) != NULL) {
    msgs[num_msgs] = p;
    msg_lens[num_msgs] = va_arg(ap, size_t);
    num_msgs++;
  }
  va_end(ap);

  mg_hash_md5_v(num_msgs, msgs, msg_lens, hash);
  cs_to_hex(buf, hash, sizeof(hash));
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x280, %rsp            # imm = 0x280
testb %al, %al
je 0x13147
movaps %xmm0, -0x210(%rbp)
movaps %xmm1, -0x200(%rbp)
movaps %xmm2, -0x1f0(%rbp)
movaps %xmm3, -0x1e0(%rbp)
movaps %xmm4, -0x1d0(%rbp)
movaps %xmm5, -0x1c0(%rbp)
movaps %xmm6, -0x1b0(%rbp)
movaps %xmm7, -0x1a0(%rbp)
movq %r9, -0x218(%rbp)
movq %r8, -0x220(%rbp)
movq %rcx, -0x228(%rbp)
movq %rdx, -0x230(%rbp)
movq %rsi, -0x238(%rbp)
movq %rdi, -0x8(%rbp)
movq $0x0, -0x178(%rbp)
leaq -0x190(%rbp), %rax
leaq -0x240(%rbp), %rcx
movq %rcx, 0x10(%rax)
leaq 0x10(%rbp), %rcx
movq %rcx, 0x8(%rax)
movl $0x30, 0x4(%rax)
movl $0x8, (%rax)
leaq -0x190(%rbp), %rax
movq %rax, -0x250(%rbp)
movl -0x190(%rbp), %eax
movl %eax, -0x244(%rbp)
cmpl $0x28, %eax
ja 0x131e1
movq -0x250(%rbp), %rcx
movl -0x244(%rbp), %edx
movslq %edx, %rax
addq 0x10(%rcx), %rax
addl $0x8, %edx
movl %edx, (%rcx)
movq %rax, -0x258(%rbp)
jmp 0x131fe
movq -0x250(%rbp), %rcx
movq 0x8(%rcx), %rax
movq %rax, %rdx
addq $0x8, %rdx
movq %rdx, 0x8(%rcx)
movq %rax, -0x258(%rbp)
movq -0x258(%rbp), %rax
movq (%rax), %rax
movq %rax, -0xc8(%rbp)
cmpq $0x0, %rax
je 0x132bd
movq -0xc8(%rbp), %rcx
movq -0x178(%rbp), %rax
movq %rcx, -0xc0(%rbp,%rax,8)
leaq -0x190(%rbp), %rax
movq %rax, -0x268(%rbp)
movl -0x190(%rbp), %eax
movl %eax, -0x25c(%rbp)
cmpl $0x28, %eax
ja 0x13270
movq -0x268(%rbp), %rcx
movl -0x25c(%rbp), %edx
movslq %edx, %rax
addq 0x10(%rcx), %rax
addl $0x8, %edx
movl %edx, (%rcx)
movq %rax, -0x270(%rbp)
jmp 0x1328d
movq -0x268(%rbp), %rcx
movq 0x8(%rcx), %rax
movq %rax, %rdx
addq $0x8, %rdx
movq %rdx, 0x8(%rcx)
movq %rax, -0x270(%rbp)
movq -0x270(%rbp), %rax
movq (%rax), %rcx
movq -0x178(%rbp), %rax
movq %rcx, -0x170(%rbp,%rax,8)
movq -0x178(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x178(%rbp)
jmp 0x131a0
movq -0x178(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
leaq -0x170(%rbp), %rdx
leaq -0x20(%rbp), %rcx
movq %rcx, -0x278(%rbp)
callq 0x13080
movq -0x278(%rbp), %rsi
movq -0x8(%rbp), %rdi
movl $0x10, %edx
callq 0x9f10
addq $0x280, %rsp            # imm = 0x280
popq %rbp
retq