LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O2/sfeakes[P]unifi-motion/mongoose.c
// Function: cs_sha1_final
void cs_sha1_final(unsigned char digest[20], cs_sha1_ctx *context) {
  unsigned i;
  unsigned char finalcount[8], c;

  for (i = 0; i < 8; i++) {
    finalcount[i] = (unsigned char) ((context->count[(i >= 4 ? 0 : 1)] >>
                                      ((3 - (i & 3)) * 8)) &
                                     255);
  }
  c = 0200;
  cs_sha1_update(context, &c, 1);
  while ((context->count[0] & 504) != 448) {
    c = 0000;
    cs_sha1_update(context, &c, 1);
  }
  cs_sha1_update(context, finalcount, 8);
  for (i = 0; i < 20; i++) {
    digest[i] =
        (unsigned char) ((context->state[i >> 2] >> ((3 - (i & 3)) * 8)) & 255);
  }
  memset(context, '\0', sizeof(*context));
  memset(&finalcount, '\0', sizeof(finalcount));
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rsi, %rbx
movq %rdi, %r14
xorl %eax, %eax
xorl %edx, %edx
cmpq $0x8, %rdx
je 0x642e
xorl %ecx, %ecx
cmpq $0x4, %rdx
setb %cl
movl 0x14(%rbx,%rcx,4), %esi
movl %eax, %ecx
notb %cl
andb $0x18, %cl
shrl %cl, %esi
movb %sil, 0x8(%rsp,%rdx)
incq %rdx
addl $0x8, %eax
jmp 0x6405
leaq 0x7(%rsp), %r15
movb $-0x80, (%r15)
pushq $0x1
popq %rbp
movq %rbx, %rdi
movq %r15, %rsi
movl %ebp, %edx
callq 0x6347
movl $0x1f8, %r12d           # imm = 0x1F8
movl 0x14(%rbx), %eax
andl %r12d, %eax
cmpl $0x1c0, %eax            # imm = 0x1C0
je 0x646e
movb $0x0, 0x7(%rsp)
movq %rbx, %rdi
movq %r15, %rsi
movl %ebp, %edx
callq 0x6347
jmp 0x644d
leaq 0x8(%rsp), %rsi
pushq $0x8
popq %rdx
movq %rbx, %rdi
callq 0x6347
xorl %eax, %eax
xorl %edx, %edx
cmpq $0x14, %rdx
je 0x64a5
movl %edx, %ecx
andl $-0x4, %ecx
movl (%rbx,%rcx), %esi
movl %eax, %ecx
notb %cl
andb $0x18, %cl
shrl %cl, %esi
movb %sil, (%r14,%rdx)
incq %rdx
addl $0x8, %eax
jmp 0x6482
xorps %xmm0, %xmm0
movups %xmm0, 0x4c(%rbx)
movups %xmm0, 0x40(%rbx)
movups %xmm0, 0x30(%rbx)
movups %xmm0, 0x20(%rbx)
movups %xmm0, 0x10(%rbx)
movups %xmm0, (%rbx)
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/sfeakes[P]unifi-motion/mongoose.c
// Function: cs_hmac_sha1
void cs_hmac_sha1(const unsigned char *key, size_t keylen,
                  const unsigned char *data, size_t datalen,
                  unsigned char out[20]) {
  cs_sha1_ctx ctx;
  unsigned char buf1[64], buf2[64], tmp_key[20], i;

  if (keylen > sizeof(buf1)) {
    cs_sha1_init(&ctx);
    cs_sha1_update(&ctx, key, keylen);
    cs_sha1_final(tmp_key, &ctx);
    key = tmp_key;
    keylen = sizeof(tmp_key);
  }

  memset(buf1, 0, sizeof(buf1));
  memset(buf2, 0, sizeof(buf2));
  memcpy(buf1, key, keylen);
  memcpy(buf2, key, keylen);

  for (i = 0; i < sizeof(buf1); i++) {
    buf1[i] ^= 0x36;
    buf2[i] ^= 0x5c;
  }

  cs_sha1_init(&ctx);
  cs_sha1_update(&ctx, buf1, sizeof(buf1));
  cs_sha1_update(&ctx, data, datalen);
  cs_sha1_final(out, &ctx);

  cs_sha1_init(&ctx);
  cs_sha1_update(&ctx, buf2, sizeof(buf2));
  cs_sha1_update(&ctx, out, 20);
  cs_sha1_final(out, &ctx);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
movq %r8, %rbx
movq %rcx, %r14
movq %rdx, %r15
movq %rsi, %r13
movq %rdi, %r12
cmpq $0x41, %rsi
jb 0x6532
movaps 0xde57(%rip), %xmm0     # 0x14350
leaq 0xa0(%rsp), %rbp
movaps %xmm0, (%rbp)
movl $0xc3d2e1f0, %eax       # imm = 0xC3D2E1F0
movq %rax, 0x10(%rbp)
andl $0x0, 0x18(%rbp)
movq %rbp, %rdi
movq %r12, %rsi
movl %r13d, %edx
callq 0x6347
movq %rsp, %r12
movq %r12, %rdi
movq %rbp, %rsi
callq 0x63ef
pushq $0x14
popq %r13
xorps %xmm0, %xmm0
leaq 0x60(%rsp), %rdi
movaps %xmm0, 0x30(%rdi)
movaps %xmm0, 0x20(%rdi)
movaps %xmm0, 0x10(%rdi)
movaps %xmm0, (%rdi)
leaq 0x20(%rsp), %rbp
movaps %xmm0, (%rbp)
movaps %xmm0, 0x10(%rbp)
movaps %xmm0, 0x20(%rbp)
movaps %xmm0, 0x30(%rbp)
movq %r12, %rsi
movq %r13, %rdx
callq 0x3380
movq %rbp, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x3380
xorl %eax, %eax
cmpq $0x40, %rax
je 0x658e
xorb $0x36, 0x60(%rsp,%rax)
xorb $0x5c, 0x20(%rsp,%rax)
incq %rax
jmp 0x6579
movaps 0xddbb(%rip), %xmm0     # 0x14350
leaq 0xa0(%rsp), %r12
movaps %xmm0, (%r12)
movl $0xc3d2e1f0, %r13d      # imm = 0xC3D2E1F0
movq %r13, 0x10(%r12)
andl $0x0, 0x18(%r12)
leaq 0x60(%rsp), %rsi
pushq $0x40
popq %rbp
movq %r12, %rdi
movl %ebp, %edx
callq 0x6347
movq %r12, %rdi
movq %r15, %rsi
movl %r14d, %edx
callq 0x6347
movq %rbx, %rdi
movq %r12, %rsi
callq 0x63ef
movaps 0xdd6b(%rip), %xmm0     # 0x14350
movaps %xmm0, (%r12)
movq %r13, 0x10(%r12)
andl $0x0, 0x18(%r12)
leaq 0x20(%rsp), %rsi
movq %r12, %rdi
movl %ebp, %edx
callq 0x6347
pushq $0x14
popq %rdx
movq %r12, %rdi
movq %rbx, %rsi
callq 0x6347
movq %rbx, %rdi
movq %r12, %rsi
callq 0x63ef
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/sfeakes[P]unifi-motion/mongoose.c
// Function: mbuf_resize
void mbuf_resize(struct mbuf *a, size_t new_size) {
  if (new_size > a->size || (new_size < a->size && new_size >= a->len)) {
    char *buf = (char *) MBUF_REALLOC(a->buf, new_size);
    /*
     * In case realloc fails, there's not much we can do, except keep things as
     * they are. Note that NULL is a valid return value from realloc when
     * size == 0, but that is covered too.
     */
    if (buf == NULL && new_size != 0) return;
    a->buf = buf;
    a->size = new_size;
  }
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
cmpq %rsi, 0x10(%rdi)
jae 0x6673
movq (%r14), %rdi
movq %rbx, %rsi
callq 0x34a0
testq %rax, %rax
sete %cl
testq %rbx, %rbx
setne %dl
testb %cl, %dl
jne 0x667b
movq %rax, (%r14)
movq %rbx, 0x10(%r14)
jmp 0x667b
jbe 0x667b
cmpq %rbx, 0x8(%r14)
jbe 0x664f
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/sfeakes[P]unifi-motion/mongoose.c
// Function: mbuf_insert
size_t mbuf_insert(struct mbuf *a, size_t off, const void *buf, size_t len) {
  char *p = NULL;

  assert(a != NULL);
  assert(a->len <= a->size);
  assert(off <= a->len);

  /* check overflow */
  if (~(size_t) 0 - (size_t) a->buf < len) return 0;

  if (a->len + len <= a->size) {
    memmove(a->buf + off + len, a->buf + off, a->len - off);
    if (buf != NULL) {
      memcpy(a->buf + off, buf, len);
    }
    a->len += len;
  } else {
    size_t new_size = (size_t)((a->len + len) * MBUF_SIZE_MULTIPLIER);
    if ((p = (char *) MBUF_REALLOC(a->buf, new_size)) != NULL) {
      a->buf = p;
      memmove(a->buf + off + len, a->buf + off, a->len - off);
      if (buf != NULL) memcpy(a->buf + off, buf, len);
      a->len += len;
      a->size = new_size;
    } else {
      len = 0;
    }
  }

  return len;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
testq %rdi, %rdi
je 0x67d9
movq %rcx, %rbx
movq %rdi, %r14
movq 0x8(%rdi), %rax
movq 0x10(%rdi), %rcx
cmpq %rcx, %rax
ja 0x67f8
movq %rdx, %r15
movq %rsi, %r12
movq %rax, %rdx
subq %rsi, %rdx
jb 0x6817
movq (%r14), %rsi
movq %rsi, %rdi
addq %rbx, %rdi
jae 0x66f9
xorl %ebx, %ebx
jmp 0x67c7
addq %rbx, %rax
cmpq %rcx, %rax
jbe 0x67a1
movq %rax, %xmm0
punpckldq 0xdc4e(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0xdc56(%rip), %xmm0     # 0x14370
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
mulsd 0xdbd2(%rip), %xmm1     # 0x14300
cvttsd2si %xmm1, %rax
movq %rax, %rcx
sarq $0x3f, %rcx
subsd 0xdbc6(%rip), %xmm1     # 0x14308
cvttsd2si %xmm1, %r13
andq %rcx, %r13
orq %rax, %r13
movq %rsi, %rdi
movq %r13, %rsi
callq 0x34a0
testq %rax, %rax
je 0x66f2
movq %rax, %rbp
movq %rax, (%r14)
addq %r12, %rbp
leaq (%rbx,%rbp), %rdi
movq %r15, (%rsp)
movq 0x8(%r14), %r15
movq %r15, %rdx
subq %r12, %rdx
movq %rbp, %rsi
callq 0x3500
movq (%rsp), %rsi
testq %rsi, %rsi
je 0x6794
movq %rbp, %rdi
movq %rbx, %rdx
callq 0x3380
addq %rbx, %r15
movq %r15, 0x8(%r14)
movq %r13, 0x10(%r14)
jmp 0x67c7
addq %r12, %rsi
leaq (%rsi,%rbx), %rdi
callq 0x3500
testq %r15, %r15
je 0x67c3
addq (%r14), %r12
movq %r12, %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x3380
addq %rbx, 0x8(%r14)
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xddc4(%rip), %rdi      # 0x145a4
leaq 0xddc7(%rip), %rsi      # 0x145ae
leaq 0xddcb(%rip), %rcx      # 0x145b9
movl $0x568, %edx            # imm = 0x568
callq 0x3220
leaq 0xddfa(%rip), %rdi      # 0x145f9
leaq 0xdda8(%rip), %rsi      # 0x145ae
leaq 0xddac(%rip), %rcx      # 0x145b9
movl $0x569, %edx            # imm = 0x569
callq 0x3220
leaq 0xdded(%rip), %rdi      # 0x1460b
leaq 0xdd89(%rip), %rsi      # 0x145ae
leaq 0xdd8d(%rip), %rcx      # 0x145b9
movl $0x56a, %edx            # imm = 0x56A
callq 0x3220
// File: /workspace/github_c_makefile_star2_O2/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_ncasecmp
int mg_ncasecmp(const char *s1, const char *s2, size_t len) {
  int diff = 0;

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

  return diff;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
testq %rdx, %rdx
je 0x695a
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
decq %rbx
movq %r15, %rdi
callq 0x718f
movl %eax, %ebp
movq %r14, %rdi
callq 0x718f
subl %eax, %ebp
jne 0x695c
subq $0x1, %rbx
setb %al
cmpb $0x0, (%r15)
je 0x695a
incq %r14
incq %r15
testb %al, %al
je 0x692d
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_strdup_common
static struct mg_str mg_strdup_common(const struct mg_str s,
                                      int nul_terminate) {
  struct mg_str r = {NULL, 0};
  if (s.len > 0 && s.p != NULL) {
    char *sc = (char *) MG_MALLOC(s.len + (nul_terminate ? 1 : 0));
    if (sc != NULL) {
      memcpy(sc, s.p, s.len);
      if (nul_terminate) sc[s.len] = '\0';
      r.p = sc;
      r.len = s.len;
    }
  }
  return r;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edx, %ebp
testq %rsi, %rsi
setne %al
testq %rdi, %rdi
setne %cl
andb %al, %cl
xorl %edx, %edx
movl $0x0, %r15d
cmpb $0x1, %cl
jne 0x69cf
movq %rsi, %rbx
movq %rdi, %r14
cmpl $0x1, %ebp
movq %rsi, %rdi
sbbq $-0x1, %rdi
callq 0x33e0
testq %rax, %rax
je 0x69ca
movq %rax, %r15
movq %rax, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x3380
testl %ebp, %ebp
je 0x69c5
movb $0x0, (%r15,%rbx)
movq %rbx, %rdx
jmp 0x69cf
xorl %edx, %edx
xorl %r15d, %r15d
movq %r15, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_strchr
const char *mg_strchr(const struct mg_str s, int c) {
  size_t i;
  for (i = 0; i < s.len; i++) {
    if (s.p[i] == c) return &s.p[i];
  }
  return NULL;
}

// Assembly:
movq %rdi, %rax
subq $0x1, %rsi
jb 0x69f7
movsbl (%rax), %ecx
cmpl %edx, %ecx
je 0x69f9
incq %rax
jmp 0x69e5
xorl %eax, %eax
retq
// File: /workspace/github_c_makefile_star2_O2/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_strcmp
int mg_strcmp(const struct mg_str str1, const struct mg_str str2) {
  size_t i = 0;
  while (i < str1.len && i < str2.len) {
    if (str1.p[i] < str2.p[i]) return -1;
    if (str1.p[i] > str2.p[i]) return 1;
    i++;
  }
  if (i < str1.len) return 1;
  if (i < str2.len) return -1;
  return 0;
}

// Assembly:
pushq %rbx
cmpq %rsi, %rcx
movq %rsi, %r9
cmovbq %rcx, %r9
xorl %r8d, %r8d
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl $0x1, %r10d
cmpq %r8, %r9
je 0x6a32
movb (%rdi,%r8), %r11b
movb (%rdx,%r8), %bl
cmpb %bl, %r11b
jl 0x6a44
incq %r8
cmpb %bl, %r11b
jle 0x6a13
movl %r10d, %eax
jmp 0x6a44
xorl %edx, %edx
cmpq %rcx, %r8
sbbl %edx, %edx
cmpq %rsi, %r8
movl $0x1, %eax
cmovael %edx, %eax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_strstr
const char *mg_strstr(const struct mg_str haystack,
                      const struct mg_str needle) {
  size_t i;
  if (needle.len > haystack.len) return NULL;
  for (i = 0; i <= haystack.len - needle.len; i++) {
    if (memcmp(haystack.p + i, needle.p, needle.len) == 0) {
      return haystack.p + i;
    }
  }
  return NULL;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r13
subq %rcx, %r13
jae 0x6a70
xorl %ebx, %ebx
jmp 0x6aa0
movq %rcx, %r15
movq %rdx, %r12
movq %rdi, %r14
xorl %ebx, %ebx
xorl %ebp, %ebp
cmpq %r13, %rbp
ja 0x6aa0
movq %r14, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x3470
incq %rbp
incq %r14
testl %eax, %eax
jne 0x6a7d
decq %r14
movq %r14, %rbx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/sfeakes[P]unifi-motion/mongoose.c
// Function: c_itoa
static int c_itoa(char *buf, size_t buf_size, int64_t num, int base, int flags,
                  int field_width) {
  char tmp[40];
  int i = 0, k = 0, neg = 0;

  if (num < 0) {
    neg++;
    num = -num;
  }

  /* Print into temporary buffer - in reverse order */
  do {
    int rem = num % base;
    if (rem < 10) {
      tmp[k++] = '0' + rem;
    } else {
      tmp[k++] = 'a' + (rem - 10);
    }
    num /= base;
  } while (num > 0);

  /* Zero padding */
  if (flags && C_SNPRINTF_FLAG_ZERO) {
    while (k < field_width && k < (int) sizeof(tmp) - 1) {
      tmp[k++] = '0';
    }
  }

  /* And sign */
  if (neg) {
    tmp[k++] = '-';
  }

  /* Now output */
  while (--k >= 0) {
    C_SNPRINTF_APPEND_CHAR(tmp[k]);
  }

  return i;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rdx, %r11
movq %rdx, %r10
negq %r10
cmovsq %rdx, %r10
movl %ecx, %ebx
xorl %ecx, %ecx
movq %r10, %rax
xorl %edx, %edx
divq %rbx
movl %edx, %ebp
orb $0x30, %bpl
leal 0x57(%rdx), %r14d
cmpq $0xa, %rdx
movzbl %bpl, %edx
movzbl %r14b, %ebp
cmovbl %edx, %ebp
movb %bpl, -0x30(%rsp,%rcx)
incq %rcx
cmpq %rbx, %r10
movq %rax, %r10
jae 0x6f7e
testl %r8d, %r8d
je 0x6fc9
cmpl %r9d, %ecx
jge 0x6fc9
cmpq $0x26, %rcx
ja 0x6fc9
movb $0x30, -0x30(%rsp,%rcx)
incq %rcx
jmp 0x6fb4
testq %r11, %r11
jns 0x6fd8
movslq %ecx, %rax
incl %ecx
movb $0x2d, -0x30(%rsp,%rax)
movslq %esi, %rdx
movl %ecx, %ecx
xorl %eax, %eax
testl %ecx, %ecx
jle 0x6ff9
cmpq %rdx, %rax
jge 0x6ff1
movb -0x31(%rsp,%rcx), %sil
movb %sil, (%rdi,%rax)
incq %rax
decq %rcx
jmp 0x6fdf
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/sfeakes[P]unifi-motion/mongoose.c
// Function: c_strnstr
const char *c_strnstr(const char *s, const char *find, size_t slen) {
  size_t find_length = strlen(find);
  size_t i;

  for (i = 0; i < slen; i++) {
    if (i + find_length > slen) {
      return NULL;
    }

    if (strncmp(&s[i], find, find_length) == 0) {
      return &s[i];
    }
  }

  return NULL;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, %r14
movq %rsi, %rdi
callq 0x3180
movq %rax, %r13
xorl %r12d, %r12d
xorl %ebp, %ebp
cmpq %rbx, %rbp
jae 0x70cf
movq %r13, %rax
addq %rbp, %rax
cmpq %rbx, %rax
ja 0x70cf
leaq (%r14,%rbp), %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x30c0
incq %rbp
testl %eax, %eax
jne 0x70a2
leaq (%r14,%rbp), %r12
decq %r12
movq %r12, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/sfeakes[P]unifi-motion/mongoose.c
// Function: cs_to_hex
void cs_to_hex(char *to, const unsigned char *p, size_t len) {
  static const char *hex = "0123456789abcdef";

  for (; len--; p++) {
    *to++ = hex[p[0] >> 4];
    *to++ = hex[p[0] & 0x0f];
  }
  *to = '\0';
}

// Assembly:
xorl %eax, %eax
leaq 0xd52f(%rip), %rcx      # 0x14619
cmpq %rax, %rdx
je 0x7117
movzbl (%rsi,%rax), %r8d
shrl $0x4, %r8d
movb (%r8,%rcx), %r8b
movb %r8b, (%rdi,%rax,2)
movzbl (%rsi,%rax), %r8d
andl $0xf, %r8d
movb (%r8,%rcx), %r8b
movb %r8b, 0x1(%rdi,%rax,2)
incq %rax
jmp 0x70ea
movb $0x0, (%rdi,%rax,2)
retq
// File: /workspace/github_c_makefile_star2_O2/sfeakes[P]unifi-motion/mongoose.c
// Function: cs_from_hex
void cs_from_hex(char *to, const char *p, size_t len) {
  size_t i;

  for (i = 0; i < len; i += 2) {
    *to++ = (fourbit(p[i]) << 4) + fourbit(p[i + 1]);
  }
  *to = '\0';
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, %r14
xorl %r12d, %r12d
cmpq %rbx, %r12
jae 0x715d
movsbl (%r15,%r12), %edi
callq 0x716a
movl %eax, %ebp
shll $0x4, %ebp
movsbl 0x1(%r15,%r12), %edi
callq 0x716a
orl %ebp, %eax
movb %al, (%r14)
incq %r14
addq $0x2, %r12
jmp 0x7130
movb $0x0, (%r14)
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/sfeakes[P]unifi-motion/mongoose.c
// Function: fourbit
static int fourbit(int ch) {
  if (ch >= '0' && ch <= '9') {
    return ch - '0';
  } else if (ch >= 'a' && ch <= 'f') {
    return ch - 'a' + 10;
  } else if (ch >= 'A' && ch <= 'F') {
    return ch - 'A' + 10;
  }
  return 0;
}

// Assembly:
leal -0x30(%rdi), %eax
cmpl $0xa, %eax
jb 0x718e
leal -0x61(%rdi), %eax
cmpl $0x5, %eax
ja 0x7180
addl $-0x57, %edi
movl %edi, %eax
retq
leal -0x41(%rdi), %ecx
addl $-0x37, %edi
xorl %eax, %eax
cmpl $0x6, %ecx
cmovbl %edi, %eax
retq
// File: /workspace/github_c_makefile_star2_O2/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_asprintf
int mg_asprintf(char **buf, size_t size, const char *fmt, ...) {
  int ret;
  va_list ap;
  va_start(ap, fmt);
  ret = mg_avprintf(buf, size, fmt, ap);
  va_end(ap);
  return ret;
}

// Assembly:
subq $0xd8, %rsp
leaq 0x20(%rsp), %r10
movq %rcx, 0x18(%r10)
movq %r8, 0x20(%r10)
movq %r9, 0x28(%r10)
testb %al, %al
je 0x71fe
movaps %xmm0, 0x50(%rsp)
movaps %xmm1, 0x60(%rsp)
movaps %xmm2, 0x70(%rsp)
movaps %xmm3, 0x80(%rsp)
movaps %xmm4, 0x90(%rsp)
movaps %xmm5, 0xa0(%rsp)
movaps %xmm6, 0xb0(%rsp)
movaps %xmm7, 0xc0(%rsp)
movq %rsp, %rcx
movq %r10, 0x10(%rcx)
leaq 0xe0(%rsp), %rax
movq %rax, 0x8(%rcx)
movabsq $0x3000000018, %rax     # imm = 0x3000000018
movq %rax, (%rcx)
callq 0x722b
addq $0xd8, %rsp
retq
// File: /workspace/github_c_makefile_star2_O2/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_avprintf
int mg_avprintf(char **buf, size_t size, const char *fmt, va_list ap) {
  va_list ap_copy;
  int len;

  va_copy(ap_copy, ap);
  len = vsnprintf(*buf, size, fmt, ap_copy);
  va_end(ap_copy);

  if (len < 0) {
    /* eCos and Windows are not standard-compliant and return -1 when
     * the buffer is too small. Keep allocating larger buffers until we
     * succeed or out of memory. */
    *buf = NULL; /* LCOV_EXCL_START */
    while (len < 0) {
      MG_FREE(*buf);
      if (size == 0) {
        size = 5;
      }
      size *= 2;
      if ((*buf = (char *) MG_MALLOC(size)) == NULL) {
        len = -1;
        break;
      }
      va_copy(ap_copy, ap);
      len = vsnprintf(*buf, size - 1, fmt, ap_copy);
      va_end(ap_copy);
    }

    /*
     * Microsoft version of vsnprintf() is not always null-terminated, so put
     * the terminator manually
     */
    (*buf)[len] = 0;
    /* LCOV_EXCL_STOP */
  } else if (len >= (int) size) {
    /* Standard-compliant code path. Allocate a buffer that is large enough. */
    if ((*buf = (char *) MG_MALLOC(len + 1)) == NULL) {
      len = -1; /* LCOV_EXCL_LINE */
    } else {    /* LCOV_EXCL_LINE */
      va_copy(ap_copy, ap);
      len = vsnprintf(*buf, len + 1, fmt, ap_copy);
      va_end(ap_copy);
    }
  }

  return len;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rcx, %r14
movq %rdx, %rbx
movq %rsi, %rbp
movq %rdi, %r15
movq 0x10(%rcx), %rax
movq %rsp, %rcx
movq %rax, 0x10(%rcx)
movups (%r14), %xmm0
movaps %xmm0, (%rcx)
movq (%rdi), %rdi
callq 0x3110
movl %eax, %r12d
testl %eax, %eax
js 0x72ab
cmpl %ebp, %r12d
jl 0x7313
incl %r12d
movq %r12, %rdi
callq 0x33e0
movq %rax, (%r15)
testq %rax, %rax
je 0x730f
movq 0x10(%r14), %rax
movq %rsp, %rcx
movq %rax, 0x10(%rcx)
movups (%r14), %xmm0
movaps %xmm0, (%rcx)
movq (%r15), %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x3110
movl %eax, %r12d
jmp 0x7313
andq $0x0, (%r15)
xorl %edi, %edi
testl %r12d, %r12d
jns 0x7306
callq 0x3060
leaq (,%rbp,2), %r13
testq %rbp, %rbp
pushq $0xa
popq %rax
cmoveq %rax, %r13
movq %r13, %rdi
callq 0x33e0
movq %rax, (%r15)
movups (%r14), %xmm0
movaps %xmm0, (%rsp)
movq 0x10(%r14), %rax
movq %rax, 0x10(%rsp)
movq (%r15), %rdi
leaq -0x1(%r13), %rsi
movq %rbx, %rdx
movq %rsp, %rcx
callq 0x3110
movl %eax, %r12d
movq (%r15), %rdi
movq %r13, %rbp
jmp 0x72b1
movl %r12d, %eax
movb $0x0, (%rdi,%rax)
jmp 0x7313
pushq $-0x1
popq %r12
movl %r12d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_next_comma_list_entry_n
struct mg_str mg_next_comma_list_entry_n(struct mg_str list, struct mg_str *val,
                                         struct mg_str *eq_val) {
  if (list.len == 0) {
    /* End of the list */
    list = mg_mk_str(NULL);
  } else {
    const char *chr = NULL;
    *val = list;

    if ((chr = mg_strchr(*val, ',')) != NULL) {
      /* Comma found. Store length and shift the list ptr */
      val->len = chr - val->p;
      chr++;
      list.len -= (chr - list.p);
      list.p = chr;
    } else {
      /* This value is the last one */
      list = mg_mk_str_n(list.p + list.len, 0);
    }

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

  return list;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
testq %rsi, %rsi
je 0x7395
movq %rcx, %r15
movq %rdx, %r14
movq %rsi, %r13
movq %rdi, %rbx
movq %rdi, (%rdx)
movq %rsi, 0x8(%rdx)
pushq $0x2c
popq %rdx
callq 0x69e2
testq %rax, %rax
je 0x73a4
movq %rax, %r12
movq (%r14), %rax
movq %r12, %rcx
subq %rax, %rcx
movq %rcx, 0x8(%r14)
incq %r12
addq %r13, %rbx
subq %r12, %rbx
jmp 0x73b7
xorl %edi, %edi
callq 0x6875
movq %rax, %r12
movq %rdx, %rbx
jmp 0x73fc
addq %r13, %rbx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x6892
movq %rax, %r12
movq %rdx, %rbx
testq %r15, %r15
je 0x73fc
andq $0x0, 0x8(%r15)
movq (%r14), %rdi
movq 0x8(%r14), %r13
pushq $0x3d
popq %rsi
movq %r13, %rdx
callq 0x32c0
movq %rax, (%r15)
testq %rax, %rax
je 0x73fc
leaq 0x1(%rax), %rcx
movq %rcx, (%r15)
movq (%r14), %rdx
addq %rdx, %r13
subq %rcx, %r13
movq %r13, 0x8(%r15)
notq %rdx
addq %rdx, %rax
incq %rax
movq %rax, 0x8(%r14)
movq %r12, %rax
movq %rbx, %rdx
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_if_timer
void mg_if_timer(struct mg_connection *c, double now) {
  if (c->ev_timer_time > 0 && now >= c->ev_timer_time) {
    double old_value = c->ev_timer_time;
    c->ev_timer_time = 0;
    mg_call(c, NULL, c->user_data, MG_EV_TIMER, &old_value);
  }
}

// Assembly:
movsd 0x78(%rdi), %xmm1
xorpd %xmm2, %xmm2
ucomisd %xmm2, %xmm1
jbe 0x75bc
ucomisd %xmm1, %xmm0
jb 0x75bc
pushq %rax
movq %rsp, %rcx
movsd %xmm1, (%rcx)
andq $0x0, 0x78(%rdi)
pushq $0x6
popq %rdx
xorl %esi, %esi
callq 0x75bd
addq $0x8, %rsp
retq
// File: /workspace/github_c_makefile_star2_O2/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_destroy_conn
void mg_destroy_conn(struct mg_connection *conn, int destroy_if) {
  if (destroy_if) conn->iface->vtable->destroy_conn(conn);
  if (conn->proto_data != NULL && conn->proto_data_destructor != NULL) {
    conn->proto_data_destructor(conn->proto_data);
  }
#if MG_ENABLE_SSL
  mg_ssl_if_conn_free(conn);
#endif
  mbuf_free(&conn->recv_mbuf);
  mbuf_free(&conn->send_mbuf);

  memset(conn, 0, sizeof(*conn));
  MG_FREE(conn);
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
testl %esi, %esi
je 0x77a4
movq 0xc0(%rbx), %rax
movq 0x10(%rax), %rax
movq %rbx, %rdi
callq *0x68(%rax)
movq 0x88(%rbx), %rdi
testq %rdi, %rdi
je 0x77be
movq 0x90(%rbx), %rax
testq %rax, %rax
je 0x77be
callq *%rax
leaq 0x40(%rbx), %rdi
callq 0x6683
leaq 0x58(%rbx), %rdi
callq 0x6683
movq %rbx, %rdi
popq %rbx
jmp 0x3060
// File: /workspace/github_c_makefile_star2_O2/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_mgr_init_opt
void mg_mgr_init_opt(struct mg_mgr *m, void *user_data,
                     struct mg_mgr_init_opts opts) {
  memset(m, 0, sizeof(*m));
#if MG_ENABLE_BROADCAST
  m->ctl[0] = m->ctl[1] = INVALID_SOCKET;
#endif
  m->user_data = user_data;

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

#if MG_ENABLE_SSL
  {
    static int init_done;
    if (!init_done) {
      mg_ssl_if_init();
      init_done++;
    }
  }
#endif
  {
    int i;
    if (opts.num_ifaces == 0) {
      opts.num_ifaces = mg_num_ifaces;
      opts.ifaces = mg_ifaces;
    }
    if (opts.main_iface != NULL) {
      opts.ifaces[MG_MAIN_IFACE] = opts.main_iface;
    }
    m->num_ifaces = opts.num_ifaces;
    m->ifaces =
        (struct mg_iface **) MG_MALLOC(sizeof(*m->ifaces) * opts.num_ifaces);
    for (i = 0; i < mg_num_ifaces; i++) {
      m->ifaces[i] = mg_if_create_iface(opts.ifaces[i], m);
      m->ifaces[i]->vtable->init(m->ifaces[i]);
    }
  }
  if (opts.nameserver != NULL) {
    m->nameserver = strdup(opts.nameserver);
  }
  DBG(("=================================="));
  DBG(("init mgr=%p", m));
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x30(%rsp), %r14
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rdi)
movups %xmm0, 0x20(%rdi)
movups %xmm0, (%rdi)
andq $0x0, 0x30(%rdi)
orq $-0x1, 0x10(%rdi)
movq %rsi, 0x18(%rdi)
pushq $0xd
popq %rdi
pushq $0x1
popq %rsi
callq 0x3390
movl 0x8(%r14), %eax
testl %eax, %eax
jne 0x7857
movl 0x16b18(%rip), %eax     # 0x1e364
leaq 0x16b1d(%rip), %rcx     # 0x1e370
movq %rcx, 0x10(%r14)
movq (%r14), %rcx
movq 0x10(%r14), %r15
testq %rcx, %rcx
je 0x7866
movq %rcx, (%r15)
movl %eax, 0x20(%rbx)
movslq %eax, %rdi
shlq $0x3, %rdi
callq 0x33e0
movq %rax, 0x28(%rbx)
xorl %r12d, %r12d
movslq 0x16ae1(%rip), %rax     # 0x1e364
cmpq %rax, %r12
jge 0x78af
movq (%r15,%r12,8), %rdi
movq %rbx, %rsi
callq 0x792b
movq 0x28(%rbx), %rcx
movq %rax, (%rcx,%r12,8)
movq 0x28(%rbx), %rax
movq (%rax,%r12,8), %rdi
movq 0x10(%rdi), %rax
callq *(%rax)
incq %r12
jmp 0x787c
movq 0x18(%r14), %rdi
testq %rdi, %rdi
je 0x78c1
callq 0x35f0
movq %rax, 0x30(%rbx)
leaq 0xcd62(%rip), %rsi      # 0x1462a
leaq 0xccdf(%rip), %rdx      # 0x145ae
pushq $0x4
popq %rdi
callq 0x4227
testl %eax, %eax
je 0x78e9
leaq 0xcd58(%rip), %rdi      # 0x1463a
xorl %eax, %eax
callq 0x430a
leaq 0xcd3a(%rip), %rsi      # 0x1462a
leaq 0xccb7(%rip), %rdx      # 0x145ae
pushq $0x4
popq %rdi
callq 0x4227
testl %eax, %eax
je 0x791f
leaq 0xcd53(%rip), %rdi      # 0x1465d
movq %rbx, %rsi
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x430a
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_if_create_iface
struct mg_iface *mg_if_create_iface(const struct mg_iface_vtable *vtable,
                                    struct mg_mgr *mgr) {
  struct mg_iface *iface = (struct mg_iface *) MG_CALLOC(1, sizeof(*iface));
  iface->mgr = mgr;
  iface->data = NULL;
  iface->vtable = vtable;
  return iface;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
pushq $0x1
popq %rdi
pushq $0x18
popq %rsi
callq 0x3300
movq %rbx, (%rax)
movq %r14, 0x10(%rax)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_mgr_free
void mg_mgr_free(struct mg_mgr *m) {
  struct mg_connection *conn, *tmp_conn;

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

#if MG_ENABLE_BROADCAST
  if (m->ctl[0] != INVALID_SOCKET) closesocket(m->ctl[0]);
  if (m->ctl[1] != INVALID_SOCKET) closesocket(m->ctl[1]);
  m->ctl[0] = m->ctl[1] = INVALID_SOCKET;
#endif

  for (conn = m->active_connections; conn != NULL; conn = tmp_conn) {
    tmp_conn = conn->next;
    mg_close_conn(conn);
  }

  {
    int i;
    for (i = 0; i < m->num_ifaces; i++) {
      m->ifaces[i]->vtable->free(m->ifaces[i]);
      MG_FREE(m->ifaces[i]);
    }
    MG_FREE(m->ifaces);
  }

  MG_FREE((char *) m->nameserver);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0xcd0c(%rip), %rsi      # 0x14669
leaq 0xcc4a(%rip), %rdx      # 0x145ae
pushq $0x4
popq %rdi
callq 0x4227
testl %eax, %eax
je 0x7981
leaq 0xd7d7(%rip), %rdi      # 0x1514e
movq %rbx, %rsi
xorl %eax, %eax
callq 0x430a
testq %rbx, %rbx
je 0x7a0a
movq %rbx, %rdi
xorl %esi, %esi
callq 0x7a12
movl 0x10(%rbx), %edi
cmpl $-0x1, %edi
je 0x79a1
callq 0x3280
movl 0x14(%rbx), %edi
cmpl $-0x1, %edi
je 0x79ae
callq 0x3280
orq $-0x1, 0x10(%rbx)
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x79c8
movq (%rdi), %r14
callq 0x7a87
movq %r14, %rdi
jmp 0x79b6
xorl %r14d, %r14d
movslq 0x20(%rbx), %rax
movq 0x28(%rbx), %rdi
cmpq %rax, %r14
jge 0x79f5
movq (%rdi,%r14,8), %rdi
movq 0x10(%rdi), %rax
callq *0x8(%rax)
movq 0x28(%rbx), %rax
movq (%rax,%r14,8), %rdi
callq 0x3060
incq %r14
jmp 0x79cb
callq 0x3060
movq 0x30(%rbx), %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x3060
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_mgr_poll
time_t mg_mgr_poll(struct mg_mgr *m, int timeout_ms) {
  int i;
  time_t now = 0; /* oh GCC, seriously ? */

  if (m->num_ifaces == 0) {
    LOG(LL_ERROR, ("cannot poll: no interfaces"));
    return 0;
  }

  for (i = 0; i < m->num_ifaces; i++) {
    now = m->ifaces[i]->vtable->poll(m->ifaces[i], timeout_ms);
  }
  return now;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl 0x20(%rdi), %eax
testl %eax, %eax
je 0x7a4e
movl %esi, %ebp
movq %rdi, %r14
xorl %r15d, %r15d
xorl %ebx, %ebx
cltq
cmpq %rax, %r15
jge 0x7a79
movq 0x28(%r14), %rax
movq (%rax,%r15,8), %rdi
movq 0x10(%rdi), %rax
movl %ebp, %esi
callq *0x20(%rax)
movq %rax, %rbx
incq %r15
movl 0x20(%r14), %eax
jmp 0x7a2a
leaq 0xcc20(%rip), %rsi      # 0x14675
leaq 0xcb52(%rip), %rdx      # 0x145ae
xorl %ebx, %ebx
xorl %edi, %edi
callq 0x4227
testl %eax, %eax
je 0x7a79
leaq 0xcc11(%rip), %rdi      # 0x14681
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x430a
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_close_conn
void mg_close_conn(struct mg_connection *conn) {
  DBG(("%p %lu %d", conn, conn->flags, conn->sock));
#if MG_ENABLE_SSL
  if (conn->flags & MG_F_SSL_HANDSHAKE_DONE) {
    mg_ssl_if_conn_close_notify(conn);
  }
#endif
  mg_remove_conn(conn);
  conn->iface->vtable->destroy_conn(conn);
  mg_call(conn, NULL, conn->user_data, MG_EV_CLOSE, NULL);
  mg_destroy_conn(conn, 0 /* destroy_if */);
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
leaq 0xd78e(%rip), %rsi      # 0x15220
leaq 0xcb15(%rip), %rdx      # 0x145ae
pushq $0x4
popq %rdi
callq 0x4227
testl %eax, %eax
je 0x7ac0
movq 0xc8(%rbx), %rdx
movl 0x20(%rbx), %ecx
leaq 0xd778(%rip), %rdi      # 0x1522e
movq %rbx, %rsi
xorl %eax, %eax
callq 0x430a
movq (%rbx), %rax
movq 0x8(%rbx), %rcx
movq %rcx, %rdx
testq %rcx, %rcx
jne 0x7ad3
movq 0x18(%rbx), %rdx
movq %rax, (%rdx)
testq %rax, %rax
je 0x7adf
movq %rcx, 0x8(%rax)
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
movq 0xc0(%rbx), %rax
movq 0x10(%rax), %rax
movq %rbx, %rdi
callq *0x18(%rax)
movq 0xc0(%rbx), %rax
movq 0x10(%rax), %rax
movq %rbx, %rdi
callq *0x68(%rax)
pushq $0x5
popq %rdx
movq %rbx, %rdi
xorl %esi, %esi
xorl %ecx, %ecx
callq 0x75bd
movq %rbx, %rdi
xorl %esi, %esi
popq %rbx
jmp 0x778b
// File: /workspace/github_c_makefile_star2_O2/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_vprintf
int mg_vprintf(struct mg_connection *nc, const char *fmt, va_list ap) {
  char mem[MG_VPRINTF_BUFFER_SIZE], *buf = mem;
  int len;

  if ((len = mg_avprintf(&buf, sizeof(mem), fmt, ap)) > 0) {
    mg_send(nc, buf, len);
  }
  if (buf != mem && buf != NULL) {
    MG_FREE(buf); /* LCOV_EXCL_LINE */
  }               /* LCOV_EXCL_LINE */

  return len;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x80, %rsp
movq %rdx, %rcx
movq %rsi, %rdx
movq %rdi, %r14
leaq 0x10(%rsp), %r15
leaq 0x8(%rsp), %rdi
movq %r15, (%rdi)
pushq $0x64
popq %rsi
callq 0x722b
movl %eax, %ebx
testl %eax, %eax
jle 0x7b60
movq 0x8(%rsp), %rsi
movq %r14, %rdi
movl %ebx, %edx
callq 0x7b89
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
sete %al
testq %rdi, %rdi
sete %cl
orb %al, %cl
jne 0x7b7a
callq 0x3060
movl %ebx, %eax
addq $0x80, %rsp
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_send
void mg_send(struct mg_connection *nc, const void *buf, int len) {
  nc->last_io_time = (time_t) mg_time();
  if (nc->flags & MG_F_UDP) {
    nc->iface->vtable->udp_send(nc, buf, len);
  } else {
    nc->iface->vtable->tcp_send(nc, buf, len);
  }
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movl %edx, %ebx
movq %rsi, %r14
movq %rdi, %r15
callq 0x483c
cvttsd2si %xmm0, %rax
movq %rax, 0x70(%r15)
movl 0xc8(%r15), %eax
andl $0x2, %eax
movq 0xc0(%r15), %rcx
movq 0x10(%rcx), %rcx
movslq %ebx, %rdx
movq 0x48(%rcx,%rax,4), %rax
movq %r15, %rdi
movq %r14, %rsi
popq %rbx
popq %r14
popq %r15
jmpq *%rax
// File: /workspace/github_c_makefile_star2_O2/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_if_accept_new_conn
struct mg_connection *mg_if_accept_new_conn(struct mg_connection *lc) {
  struct mg_add_sock_opts opts;
  struct mg_connection *nc;
  memset(&opts, 0, sizeof(opts));
  nc = mg_create_connection(lc->mgr, lc->handler, opts);
  if (nc == NULL) return NULL;
  nc->listener = lc;
  nc->proto_handler = lc->proto_handler;
  nc->user_data = lc->user_data;
  nc->recv_mbuf_limit = lc->recv_mbuf_limit;
  nc->iface = lc->iface;
  if (lc->flags & MG_F_SSL) nc->flags |= MG_F_SSL;
  mg_add_conn(nc->mgr, nc);
  DBG(("%p %p %d %d", lc, nc, nc->sock, (int) nc->flags));
  return nc;
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x48, %rsp
movq %rdi, %rbx
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
movaps %xmm0, 0x20(%rsp)
movq 0x18(%rdi), %rdi
movq 0x98(%rbx), %rsi
movaps 0x20(%rsp), %xmm0
movaps 0x30(%rsp), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
callq 0x7d2f
movq %rax, %r14
testq %rax, %rax
je 0x7d24
movq %rbx, 0x10(%r14)
movq 0x80(%rbx), %rax
movq %rax, 0x80(%r14)
movq 0xa0(%rbx), %rax
movq %rax, 0xa0(%r14)
movq 0x38(%rbx), %rax
movq %rax, 0x38(%r14)
movq 0xc0(%rbx), %rax
movq %rax, 0xc0(%r14)
testb $0x10, 0xc8(%rbx)
je 0x7cdf
orb $0x10, 0xc8(%r14)
movq 0x18(%r14), %rdi
movq %r14, %rsi
callq 0x7da5
leaq 0xc9aa(%rip), %rsi      # 0x1469c
leaq 0xc8b5(%rip), %rdx      # 0x145ae
pushq $0x4
popq %rdi
callq 0x4227
testl %eax, %eax
je 0x7d24
movl 0x20(%r14), %ecx
movl 0xc8(%r14), %r8d
leaq 0xc99b(%rip), %rdi      # 0x146b2
movq %rbx, %rsi
movq %r14, %rdx
xorl %eax, %eax
callq 0x430a
movq %r14, %rax
addq $0x48, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_create_connection
mg_connection *mg_create_connection(
    struct mg_mgr *mgr, mg_event_handler_t callback,
    struct mg_add_sock_opts opts) {
  struct mg_connection *conn = mg_create_connection_base(mgr, callback, opts);

  if (conn != NULL && !conn->iface->vtable->create_conn(conn)) {
    MG_FREE(conn);
    conn = NULL;
  }
  if (conn == NULL) {
    MG_SET_PTRPTR(opts.error_string, "failed to init connection");
  }

  return conn;
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x28, %rsp
leaq 0x40(%rsp), %r14
movaps (%r14), %xmm0
movaps 0x10(%r14), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
callq 0x8316
testq %rax, %rax
je 0x7d77
movq %rax, %rbx
movq 0xc0(%rax), %rax
movq 0x10(%rax), %rax
movq %rbx, %rdi
callq *0x60(%rax)
testl %eax, %eax
jne 0x7d79
movq %rbx, %rdi
callq 0x3060
xorl %ebx, %ebx
testq %rbx, %rbx
sete %cl
movq 0x10(%r14), %rax
testq %rax, %rax
setne %dl
andb %cl, %dl
cmpb $0x1, %dl
jne 0x7d9a
leaq 0xd4a1(%rip), %rcx      # 0x15238
movq %rcx, (%rax)
movq %rbx, %rax
addq $0x28, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_add_conn
MG_INTERNAL void mg_add_conn(struct mg_mgr *mgr, struct mg_connection *c) {
  DBG(("%p %p", mgr, c));
  c->mgr = mgr;
  c->next = mgr->active_connections;
  mgr->active_connections = c;
  c->prev = NULL;
  if (c->next != NULL) c->next->prev = c;
  if (c->sock != INVALID_SOCKET) {
    c->iface->vtable->add_conn(c);
  }
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
leaq 0xd49c(%rip), %rsi      # 0x15252
leaq 0xc7f1(%rip), %rdx      # 0x145ae
pushq $0x4
popq %rdi
callq 0x4227
testl %eax, %eax
je 0x7ddd
leaq 0xd48e(%rip), %rdi      # 0x1525e
movq %r14, %rsi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x430a
movq %r14, 0x18(%rbx)
movq (%r14), %rax
movq %rax, (%rbx)
movq %rbx, (%r14)
andq $0x0, 0x8(%rbx)
testq %rax, %rax
je 0x7df8
movq %rbx, 0x8(%rax)
cmpl $-0x1, 0x20(%rbx)
je 0x7e16
movq 0xc0(%rbx), %rax
movq 0x10(%rax), %rax
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmpq *0x10(%rax)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_if_sent_cb
void mg_if_sent_cb(struct mg_connection *nc, int num_sent) {
  DBG(("%p %d", nc, num_sent));
#if !defined(NO_LIBC) && MG_ENABLE_HEXDUMP
  if (nc->mgr && nc->mgr->hexdump_file != NULL) {
    char *buf = nc->send_mbuf.buf;
    mg_hexdump_connection(nc, nc->mgr->hexdump_file, buf, num_sent, MG_EV_SEND);
  }
#endif
  if (num_sent < 0) {
    nc->flags |= MG_F_CLOSE_IMMEDIATELY;
  } else {
    mbuf_remove(&nc->send_mbuf, num_sent);
    mbuf_trim(&nc->send_mbuf);
  }
  mg_call(nc, NULL, nc->user_data, MG_EV_SEND, &num_sent);
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
movl %esi, %ebp
movq %rdi, %rbx
movl %esi, 0xc(%rsp)
leaq 0xc86e(%rip), %rsi      # 0x146be
leaq 0xc757(%rip), %rdx      # 0x145ae
pushq $0x4
popq %rdi
callq 0x4227
testl %eax, %eax
je 0x7e76
leaq 0xc862(%rip), %rdi      # 0x146cc
movq %rbx, %rsi
movl %ebp, %edx
xorl %eax, %eax
callq 0x430a
movq 0x18(%rbx), %rax
testq %rax, %rax
je 0x7e9a
movq 0x8(%rax), %rsi
testq %rsi, %rsi
je 0x7e9a
movq 0x58(%rbx), %rdx
pushq $0x4
popq %r8
movq %rbx, %rdi
movl %ebp, %ecx
callq 0x7ed8
testl %ebp, %ebp
js 0x7eb6
leaq 0x58(%rbx), %r14
movl %ebp, %esi
movq %r14, %rdi
callq 0x6845
movq %r14, %rdi
callq 0x66a1
jmp 0x7ebd
orb $0x8, 0xc9(%rbx)
pushq $0x4
popq %rdx
leaq 0xc(%rsp), %rcx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x75bd
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_hexdump_connection
void mg_hexdump_connection(struct mg_connection *nc, const char *path,
                           const void *buf, int num_bytes, int ev) {
  FILE *fp = NULL;
  char src[60], dst[60];
  const char *tag = NULL;
  switch (ev) {
    case MG_EV_RECV:
      tag = "<-";
      break;
    case MG_EV_SEND:
      tag = "->";
      break;
    case MG_EV_ACCEPT:
      tag = "<A";
      break;
    case MG_EV_CONNECT:
      tag = "C>";
      break;
    case MG_EV_CLOSE:
      tag = "XX";
      break;
  }
  if (tag == NULL) return; /* Don't log MG_EV_TIMER, etc */

  if (strcmp(path, "-") == 0) {
    fp = stdout;
  } else if (strcmp(path, "--") == 0) {
    fp = stderr;
#if MG_ENABLE_FILESYSTEM
  } else {
    fp = mg_fopen(path, "a");
#endif
  }
  if (fp == NULL) return;

  mg_conn_addr_to_str(nc, src, sizeof(src),
                      MG_SOCK_STRINGIFY_IP | MG_SOCK_STRINGIFY_PORT);
  mg_conn_addr_to_str(nc, dst, sizeof(dst), MG_SOCK_STRINGIFY_IP |
                                                MG_SOCK_STRINGIFY_PORT |
                                                MG_SOCK_STRINGIFY_REMOTE);
  fprintf(fp, "%lu %p %s %s %s %d\n", (unsigned long) mg_time(), (void *) nc,
          src, tag, dst, (int) num_bytes);
  if (num_bytes > 0) {
    mg_hexdumpf(fp, buf, num_bytes);
  }
  if (fp != stdout && fp != stderr) fclose(fp);
}

// Assembly:
decl %r8d
cmpl $0x4, %r8d
ja 0x800d
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movl %ecx, %ebx
movq %rdx, %r14
movq %rdi, %r15
movl %r8d, %eax
leaq 0xc640(%rip), %r13      # 0x14548
movslq (%r13,%rax,4), %rbp
cmpb $0x2d, (%rsi)
jne 0x7f24
cmpb $0x0, 0x1(%rsi)
je 0x7f3b
cmpb $0x2d, 0x1(%rsi)
jne 0x7f24
cmpb $0x0, 0x2(%rsi)
je 0x7f44
leaq 0xe472(%rip), %rax      # 0x1639d
movq %rsi, %rdi
movq %rax, %rsi
callq 0x3370
movq %rax, %r12
jmp 0x7f4e
movq 0x1608e(%rip), %rax     # 0x1dfd0
jmp 0x7f4b
movq 0x160a5(%rip), %rax     # 0x1dff0
movq (%rax), %r12
testq %r12, %r12
je 0x7ffc
addq %rbp, %r13
leaq 0x40(%rsp), %rsi
pushq $0x3c
popq %rbp
pushq $0x3
popq %rcx
movq %r15, %rdi
movq %rbp, %rdx
callq 0x100ba
movq %rsp, %rsi
pushq $0x7
popq %rcx
movq %r15, %rdi
movq %rbp, %rdx
callq 0x100ba
callq 0x483c
cvttsd2si %xmm0, %rax
movq %rax, %rcx
sarq $0x3f, %rcx
subsd 0xc36e(%rip), %xmm0     # 0x14308
cvttsd2si %xmm0, %rdx
andq %rcx, %rdx
orq %rax, %rdx
leaq 0xd11a(%rip), %rsi      # 0x150c6
movq %r12, %rdi
movq %r15, %rcx
leaq 0x40(%rsp), %r8
movq %r13, %r9
xorl %eax, %eax
pushq %rbx
leaq 0x8(%rsp), %r10
pushq %r10
callq 0x3340
popq %rcx
popq %rdx
testl %ebx, %ebx
jle 0x7fdc
movq %r12, %rdi
movq %r14, %rsi
movl %ebx, %edx
callq 0x102bc
movq 0x15fed(%rip), %rax     # 0x1dfd0
cmpq (%rax), %r12
je 0x7ffc
movq 0x16001(%rip), %rax     # 0x1dff0
cmpq (%rax), %r12
je 0x7ffc
movq %r12, %rdi
callq 0x3160
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_recv_common
MG_INTERNAL void mg_recv_common(struct mg_connection *nc, void *buf, int len,
                                int own) {
  DBG(("%p %d %u", nc, len, (unsigned int) nc->recv_mbuf.len));

#if !defined(NO_LIBC) && MG_ENABLE_HEXDUMP
  if (nc->mgr && nc->mgr->hexdump_file != NULL) {
    mg_hexdump_connection(nc, nc->mgr->hexdump_file, buf, len, MG_EV_RECV);
  }
#endif

  if (nc->flags & MG_F_CLOSE_IMMEDIATELY) {
    DBG(("%p discarded %d bytes", nc, len));
    /*
     * This connection will not survive next poll. Do not deliver events,
     * send data to /dev/null without acking.
     */
    if (own) {
      MG_FREE(buf);
    }
    return;
  }
  nc->last_io_time = (time_t) mg_time();
  if (!own) {
    mbuf_append(&nc->recv_mbuf, buf, len);
  } else if (nc->recv_mbuf.len == 0) {
    /* Adopt buf as recv_mbuf's backing store. */
    mbuf_free(&nc->recv_mbuf);
    nc->recv_mbuf.buf = (char *) buf;
    nc->recv_mbuf.size = nc->recv_mbuf.len = len;
  } else {
    mbuf_append(&nc->recv_mbuf, buf, len);
    MG_FREE(buf);
  }
  mg_call(nc, NULL, nc->user_data, MG_EV_RECV, &len);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %ecx, %r15d
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %rbx
movl %edx, 0x4(%rsp)
leaq 0xd237(%rip), %rsi      # 0x15264
leaq 0xc57a(%rip), %rdx      # 0x145ae
pushq $0x4
popq %rdi
callq 0x4227
testl %eax, %eax
je 0x8056
movl 0x48(%rbx), %ecx
leaq 0xd229(%rip), %rdi      # 0x15273
movq %rbx, %rsi
movl %ebp, %edx
xorl %eax, %eax
callq 0x430a
movq 0x18(%rbx), %rax
testq %rax, %rax
je 0x8079
movq 0x8(%rax), %rsi
testq %rsi, %rsi
je 0x8079
pushq $0x3
popq %r8
movq %rbx, %rdi
movq %r14, %rdx
movl %ebp, %ecx
callq 0x7ed8
testb $0x8, 0xc9(%rbx)
jne 0x80b5
callq 0x483c
cvttsd2si %xmm0, %rax
movq %rax, 0x70(%rbx)
leaq 0x40(%rbx), %rdi
testl %r15d, %r15d
je 0x80f9
cmpq $0x0, 0x48(%rbx)
je 0x8106
movslq %ebp, %rdx
movq %r14, %rsi
callq 0x6836
movq %r14, %rdi
callq 0x3060
jmp 0x811a
leaq 0xd1a8(%rip), %rsi      # 0x15264
leaq 0xc4eb(%rip), %rdx      # 0x145ae
pushq $0x4
popq %rdi
callq 0x4227
testl %eax, %eax
je 0x80e2
leaq 0xd1a6(%rip), %rdi      # 0x1527c
movq %rbx, %rsi
movl %ebp, %edx
xorl %eax, %eax
callq 0x430a
testl %r15d, %r15d
je 0x812c
movq %r14, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x3060
movslq %ebp, %rdx
movq %r14, %rsi
callq 0x6836
jmp 0x811a
callq 0x6683
movq %r14, 0x40(%rbx)
movslq %ebp, %rax
movq %rax, 0x48(%rbx)
movq %rax, 0x50(%rbx)
pushq $0x3
popq %rdx
leaq 0x4(%rsp), %rcx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x75bd
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_create_connection_base
mg_connection *mg_create_connection_base(
    struct mg_mgr *mgr, mg_event_handler_t callback,
    struct mg_add_sock_opts opts) {
  struct mg_connection *conn;

  if ((conn = (struct mg_connection *) MG_CALLOC(1, sizeof(*conn))) != NULL) {
    conn->sock = INVALID_SOCKET;
    conn->handler = callback;
    conn->mgr = mgr;
    conn->last_io_time = (time_t) mg_time();
    conn->iface =
        (opts.iface != NULL ? opts.iface : mgr->ifaces[MG_MAIN_IFACE]);
    conn->flags = opts.flags & _MG_ALLOWED_CONNECT_FLAGS_MASK;
    conn->user_data = opts.user_data;
    /*
     * SIZE_MAX is defined as a long long constant in
     * system headers on some platforms and so it
     * doesn't compile with pedantic ansi flags.
     */
    conn->recv_mbuf_limit = ~0;
  } else {
    MG_SET_PTRPTR(opts.error_string, "failed to create connection");
  }

  return conn;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r15
movq %rdi, %r14
leaq 0x30(%rsp), %r12
pushq $0x1
popq %rdi
movl $0xd0, %esi
callq 0x3300
movq %rax, %rbx
testq %rax, %rax
je 0x8396
orl $-0x1, 0x20(%rbx)
movq %r15, 0x98(%rbx)
movq %r14, 0x18(%rbx)
callq 0x483c
cvttsd2si %xmm0, %rax
movq %rax, 0x70(%rbx)
movq 0x18(%r12), %rax
testq %rax, %rax
jne 0x836c
movq 0x28(%r14), %rax
movq (%rax), %rax
movq %rax, 0xc0(%rbx)
movl 0x8(%r12), %eax
andl $0x3f05000, %eax        # imm = 0x3F05000
movq %rax, 0xc8(%rbx)
movq (%r12), %rax
movq %rax, 0xa0(%rbx)
orq $-0x1, 0x38(%rbx)
jmp 0x83aa
movq 0x10(%r12), %rax
testq %rax, %rax
je 0x83aa
leaq 0xceeb(%rip), %rcx      # 0x15292
movq %rcx, (%rax)
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_if_connect_cb
void mg_if_connect_cb(struct mg_connection *nc, int err) {
  DBG(("%p connect, err=%d", nc, err));
  nc->flags &= ~MG_F_CONNECTING;
  if (err != 0) {
    nc->flags |= MG_F_CLOSE_IMMEDIATELY;
  }
  mg_call(nc, NULL, nc->user_data, MG_EV_CONNECT, &err);
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movl %esi, %ebp
movq %rdi, %rbx
movl %esi, 0x4(%rsp)
leaq 0xc393(%rip), %rsi      # 0x1475f
leaq 0xc1db(%rip), %rdx      # 0x145ae
pushq $0x4
popq %rdi
callq 0x4227
testl %eax, %eax
je 0x83f2
leaq 0xc38a(%rip), %rdi      # 0x14770
movq %rbx, %rsi
movl %ebp, %edx
xorl %eax, %eax
callq 0x430a
movq 0xc8(%rbx), %rax
andq $-0x9, %rax
movq %rax, %rcx
orq $0x800, %rcx            # imm = 0x800
testl %ebp, %ebp
cmoveq %rax, %rcx
movq %rcx, 0xc8(%rbx)
pushq $0x2
popq %rdx
leaq 0x4(%rsp), %rcx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x75bd
addq $0x8, %rsp
popq %rbx
popq %rbp
retq