LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O0/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_dns_next_record
struct mg_dns_resource_record *mg_dns_next_record(
    struct mg_dns_message *msg, int query,
    struct mg_dns_resource_record *prev) {
  struct mg_dns_resource_record *rr;

  for (rr = (prev == NULL ? msg->answers : prev + 1);
       rr - msg->answers < msg->num_answers; rr++) {
    if (rr->rtype == query) {
      return rr;
    }
  }
  return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x17f06
movq -0x10(%rbp), %rax
addq $0x620, %rax            # imm = 0x620
movq %rax, -0x30(%rbp)
jmp 0x17f12
movq -0x20(%rbp), %rax
addq $0x30, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq -0x10(%rbp), %rcx
addq $0x620, %rcx            # imm = 0x620
subq %rcx, %rax
movl $0x30, %ecx
cqto
idivq %rcx
movq -0x10(%rbp), %rcx
movslq 0x18(%rcx), %rcx
cmpq %rcx, %rax
jge 0x17f69
movq -0x28(%rbp), %rax
movl 0x10(%rax), %eax
cmpl -0x14(%rbp), %eax
jne 0x17f59
movq -0x28(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x17f71
jmp 0x17f5b
movq -0x28(%rbp), %rax
addq $0x30, %rax
movq %rax, -0x28(%rbp)
jmp 0x17f1a
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
popq %rbp
retq
nopw (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_dns_parse_record_data
int mg_dns_parse_record_data(struct mg_dns_message *msg,
                             struct mg_dns_resource_record *rr, void *data,
                             size_t data_len) {
  switch (rr->rtype) {
    case MG_DNS_A_RECORD:
      if (data_len < sizeof(struct in_addr)) {
        return -1;
      }
      if (rr->rdata.p + data_len > msg->pkt.p + msg->pkt.len) {
        return -1;
      }
      memcpy(data, rr->rdata.p, data_len);
      return 0;
#if MG_ENABLE_IPV6
    case MG_DNS_AAAA_RECORD:
      if (data_len < sizeof(struct in6_addr)) {
        return -1; /* LCOV_EXCL_LINE */
      }
      memcpy(data, rr->rdata.p, data_len);
      return 0;
#endif
    case MG_DNS_CNAME_RECORD:
      mg_dns_uncompress_name(msg, &rr->rdata, (char *) data, data_len);
      return 0;
  }

  return -1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq -0x18(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, -0x2c(%rbp)
subl $0x1, %eax
je 0x17fb3
jmp 0x17fa9
movl -0x2c(%rbp), %eax
subl $0x5, %eax
je 0x1800a
jmp 0x1802e
cmpq $0x4, -0x28(%rbp)
jae 0x17fc3
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x18035
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
addq -0x28(%rbp), %rax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
movq -0x10(%rbp), %rdx
addq 0x8(%rdx), %rcx
cmpq %rcx, %rax
jbe 0x17fec
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x18035
movq -0x20(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rsi
movq -0x28(%rbp), %rdx
callq 0x33b0
movl $0x0, -0x4(%rbp)
jmp 0x18035
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
addq $0x20, %rsi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rax
movl %eax, %ecx
callq 0x18040
movl $0x0, -0x4(%rbp)
jmp 0x18035
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O0/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_dns_insert_header
int mg_dns_insert_header(struct mbuf *io, size_t pos,
                         struct mg_dns_message *msg) {
  struct mg_dns_header header;

  memset(&header, 0, sizeof(header));
  header.transaction_id = msg->transaction_id;
  header.flags = htons(msg->flags);
  header.num_questions = htons(msg->num_questions);
  header.num_answers = htons(msg->num_answers);

  return mbuf_insert(io, pos, &header, sizeof(header));
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
leaq -0x24(%rbp), %rdi
xorl %esi, %esi
movl $0xc, %edx
callq 0x3260
movq -0x18(%rbp), %rax
movw 0x12(%rax), %ax
movw %ax, -0x24(%rbp)
movq -0x18(%rbp), %rax
movzwl 0x10(%rax), %edi
callq 0x31a0
movw %ax, -0x22(%rbp)
movq -0x18(%rbp), %rax
movl 0x14(%rax), %eax
movzwl %ax, %edi
callq 0x31a0
movw %ax, -0x20(%rbp)
movq -0x18(%rbp), %rax
movl 0x18(%rax), %eax
movzwl %ax, %edi
callq 0x31a0
movw %ax, -0x1e(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
leaq -0x24(%rbp), %rdx
movl $0xc, %ecx
callq 0x8750
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_dns_copy_questions
int mg_dns_copy_questions(struct mbuf *io, struct mg_dns_message *msg) {
  unsigned char *begin, *end;
  struct mg_dns_resource_record *last_q;
  if (msg->num_questions <= 0) return 0;
  begin = (unsigned char *) msg->pkt.p + sizeof(struct mg_dns_header);
  last_q = &msg->questions[msg->num_questions - 1];
  end = (unsigned char *) last_q->name.p + last_q->name.len + 4;
  return mbuf_append(io, begin, end - begin);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x0, 0x14(%rax)
jg 0x18303
movl $0x0, -0x4(%rbp)
jmp 0x18364
movq -0x18(%rbp), %rax
movq (%rax), %rax
addq $0xc, %rax
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rax
addq $0x20, %rax
movq -0x18(%rbp), %rcx
movl 0x14(%rcx), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq (%rax), %rax
movq -0x30(%rbp), %rcx
addq 0x8(%rcx), %rax
addq $0x4, %rax
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x28(%rbp), %rdx
movq -0x20(%rbp), %rax
subq %rax, %rdx
callq 0x89b0
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_dns_encode_name
int mg_dns_encode_name(struct mbuf *io, const char *name, size_t len) {
  const char *s;
  unsigned char n;
  size_t pos = io->len;

  do {
    if ((s = strchr(name, '.')) == NULL) {
      s = name + len;
    }

    if (s - name > 127) {
      return -1; /* TODO(mkm) cover */
    }
    n = s - name;           /* chunk length */
    mbuf_append(io, &n, 1); /* send length */
    mbuf_append(io, name, n);

    if (*s == '.') {
      n++;
    }

    name += n;
    len -= n;
  } while (*s != '\0');
  mbuf_append(io, "\0", 1); /* Mark end of host name */

  return io->len - pos;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x18(%rbp), %rdi
movl $0x2e, %esi
callq 0x31e0
movq %rax, -0x28(%rbp)
cmpq $0x0, %rax
jne 0x183b4
movq -0x18(%rbp), %rax
addq -0x20(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq -0x18(%rbp), %rcx
subq %rcx, %rax
cmpq $0x7f, %rax
jle 0x183d1
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1846f
movq -0x28(%rbp), %rax
movq -0x18(%rbp), %rcx
subq %rcx, %rax
movb %al, -0x29(%rbp)
movq -0x10(%rbp), %rdi
leaq -0x29(%rbp), %rsi
movl $0x1, %edx
callq 0x89b0
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movzbl -0x29(%rbp), %eax
movl %eax, %edx
callq 0x89b0
movq -0x28(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2e, %eax
jne 0x18418
movb -0x29(%rbp), %al
addb $0x1, %al
movb %al, -0x29(%rbp)
movzbl -0x29(%rbp), %ecx
movq -0x18(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x18(%rbp)
movzbl -0x29(%rbp), %eax
movl %eax, %ecx
movq -0x20(%rbp), %rax
subq %rcx, %rax
movq %rax, -0x20(%rbp)
movq -0x28(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0x18390
movq -0x10(%rbp), %rdi
leaq 0x6fd6(%rip), %rsi      # 0x1f42c
movl $0x1, %edx
callq 0x89b0
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
subq -0x38(%rbp), %rax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_send_dns_query
void mg_send_dns_query(struct mg_connection *nc, const char *name,
                       int query_type) {
  struct mg_dns_message *msg =
      (struct mg_dns_message *) MG_CALLOC(1, sizeof(*msg));
  struct mbuf pkt;
  struct mg_dns_resource_record *rr = &msg->questions[0];

  DBG(("%s %d", name, query_type));

  mbuf_init(&pkt, 64 /* Start small, it'll grow as needed. */);

  msg->transaction_id = ++mg_dns_tid;
  msg->flags = 0x100;
  msg->num_questions = 1;

  mg_dns_insert_header(&pkt, 0, msg);

  rr->rtype = query_type;
  rr->rclass = 1; /* Class: inet */
  rr->kind = MG_DNS_QUESTION;

  if (mg_dns_encode_record(&pkt, rr, name, strlen(name), NULL, 0) == -1) {
    /* TODO(mkm): return an error code */
    goto cleanup; /* LCOV_EXCL_LINE */
  }

  /* TCP DNS requires messages to be prefixed with len */
  if (!(nc->flags & MG_F_UDP)) {
    uint16_t len = htons((uint16_t) pkt.len);
    mbuf_insert(&pkt, 0, &len, 2);
  }

  mg_send(nc, pkt.buf, pkt.len);
  mbuf_free(&pkt);

cleanup:
  MG_FREE(msg);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl $0x1, %edi
movl $0xc20, %esi            # imm = 0xC20
callq 0x3330
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
addq $0x20, %rax
movq %rax, -0x40(%rbp)
movl $0x4, %edi
leaq 0x7a2e(%rip), %rsi      # 0x2009c
leaq 0x6ed5(%rip), %rdx      # 0x1f54a
callq 0x4650
cmpl $0x0, %eax
je 0x18694
movq -0x10(%rbp), %rsi
movl -0x14(%rbp), %edx
leaq 0x7a21(%rip), %rdi      # 0x200ae
movb $0x0, %al
callq 0x47a0
jmp 0x18696
leaq -0x38(%rbp), %rdi
movl $0x40, %esi
callq 0x8610
movl 0xed2e(%rip), %eax      # 0x273d8
addl $0x1, %eax
movl %eax, 0xed25(%rip)      # 0x273d8
movw %ax, %cx
movq -0x20(%rbp), %rax
movw %cx, 0x12(%rax)
movq -0x20(%rbp), %rax
movw $0x100, 0x10(%rax)      # imm = 0x100
movq -0x20(%rbp), %rax
movl $0x1, 0x14(%rax)
movq -0x20(%rbp), %rdx
leaq -0x38(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x18250
movl -0x14(%rbp), %ecx
movq -0x40(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x40(%rbp), %rax
movl $0x1, 0x14(%rax)
movq -0x40(%rbp), %rax
movl $0x1, 0x1c(%rax)
movq -0x40(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x10(%rbp), %rdi
callq 0x3180
movq -0x58(%rbp), %rsi
movq -0x50(%rbp), %rdx
movq %rax, %rcx
leaq -0x38(%rbp), %rdi
xorl %eax, %eax
movl %eax, %r9d
movq %r9, %r8
callq 0x18480
cmpl $-0x1, %eax
jne 0x18740
jmp 0x18797
movq -0x8(%rbp), %rax
movq 0xc8(%rax), %rax
andq $0x2, %rax
cmpq $0x0, %rax
jne 0x1877b
movq -0x30(%rbp), %rax
movzwl %ax, %edi
callq 0x31a0
movw %ax, -0x42(%rbp)
leaq -0x38(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
leaq -0x42(%rbp), %rdx
movl $0x2, %ecx
callq 0x8750
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq -0x30(%rbp), %rax
movl %eax, %edx
callq 0xb260
leaq -0x38(%rbp), %rdi
callq 0x86e0
movq -0x20(%rbp), %rdi
callq 0x3050
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/sfeakes[P]unifi-motion/mongoose.c
// Function: dns_handler
static void dns_handler(struct mg_connection *nc, int ev,
                        void *ev_data MG_UD_ARG(void *user_data)) {
  struct mbuf *io = &nc->recv_mbuf;
  struct mg_dns_message msg;

  /* Pass low-level events to the user handler */
  nc->handler(nc, ev, ev_data MG_UD_ARG(user_data));

  switch (ev) {
    case MG_EV_RECV:
      if (!(nc->flags & MG_F_UDP)) {
        mbuf_remove(&nc->recv_mbuf, 2);
      }
      if (mg_parse_dns(nc->recv_mbuf.buf, nc->recv_mbuf.len, &msg) == -1) {
        /* reply + recursion allowed + format error */
        memset(&msg, 0, sizeof(msg));
        msg.flags = 0x8081;
        mg_dns_insert_header(io, 0, &msg);
        if (!(nc->flags & MG_F_UDP)) {
          uint16_t len = htons((uint16_t) io->len);
          mbuf_insert(io, 0, &len, 2);
        }
        mg_send(nc, io->buf, io->len);
      } else {
        /* Call user handler with parsed message */
        nc->handler(nc, MG_DNS_MESSAGE, &msg MG_UD_ARG(user_data));
      }
      mbuf_remove(io, io->len);
      break;
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc50, %rsp            # imm = 0xC50
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rax
addq $0x40, %rax
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rdi
movq 0x98(%rdi), %rax
movl -0xc(%rbp), %esi
movq -0x18(%rbp), %rdx
callq *%rax
movl -0xc(%rbp), %eax
subl $0x3, %eax
jne 0x18cd1
jmp 0x18bc4
movq -0x8(%rbp), %rax
movq 0xc8(%rax), %rax
andq $0x2, %rax
cmpq $0x0, %rax
jne 0x18beb
movq -0x8(%rbp), %rdi
addq $0x40, %rdi
movl $0x2, %esi
callq 0x89f0
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rax
movl %eax, %esi
leaq -0xc40(%rbp), %rdx
callq 0x187b0
cmpl $-0x1, %eax
jne 0x18ca3
leaq -0xc40(%rbp), %rdi
xorl %esi, %esi
movl $0xc20, %edx            # imm = 0xC20
callq 0x3260
movw $0x8081, -0xc30(%rbp)   # imm = 0x8081
movq -0x20(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
leaq -0xc40(%rbp), %rdx
callq 0x18250
movq -0x8(%rbp), %rax
movq 0xc8(%rax), %rax
andq $0x2, %rax
cmpq $0x0, %rax
jne 0x18c87
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movzwl %ax, %edi
callq 0x31a0
movw %ax, -0xc42(%rbp)
movq -0x20(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
leaq -0xc42(%rbp), %rdx
movl $0x2, %ecx
callq 0x8750
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rax
movq (%rax), %rsi
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movl %eax, %edx
callq 0xb260
jmp 0x18cc0
movq -0x8(%rbp), %rax
movq 0x98(%rax), %rax
movq -0x8(%rbp), %rdi
movl $0x64, %esi
leaq -0xc40(%rbp), %rdx
callq *%rax
movq -0x20(%rbp), %rdi
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rsi
callq 0x89f0
addq $0xc50, %rsp            # imm = 0xC50
popq %rbp
retq
nopw (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_resolve_from_hosts_file
int mg_resolve_from_hosts_file(const char *name, union socket_address *usa) {
#if MG_ENABLE_FILESYSTEM && defined(MG_HOSTS_FILE_NAME)
  /* TODO(mkm) cache /etc/hosts */
  FILE *fp;
  char line[1024];
  char *p;
  char alias[256];
  unsigned int a, b, c, d;
  int len = 0;

  if ((fp = mg_fopen(MG_HOSTS_FILE_NAME, "r")) == NULL) {
    return -1;
  }

  for (; fgets(line, sizeof(line), fp) != NULL;) {
    if (line[0] == '#') continue;

    if (sscanf(line, "%u.%u.%u.%u%n", &a, &b, &c, &d, &len) == 0) {
      /* TODO(mkm): handle ipv6 */
      continue;
    }
    for (p = line + len; sscanf(p, "%s%n", alias, &len) == 1; p += len) {
      if (strcmp(alias, name) == 0) {
        usa->sin.sin_addr.s_addr = htonl(a << 24 | b << 16 | c << 8 | d);
        fclose(fp);
        return 0;
      }
    }
  }

  fclose(fp);
#else
  (void) name;
  (void) usa;
#endif

  return -1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x550, %rsp            # imm = 0x550
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl $0x0, -0x544(%rbp)
leaq 0x73b0(%rip), %rdi      # 0x200b4
leaq 0x83fc(%rip), %rsi      # 0x21107
callq 0x12360
movq %rax, -0x20(%rbp)
cmpq $0x0, %rax
jne 0x18d26
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x18e68
jmp 0x18d28
leaq -0x420(%rbp), %rdi
movq -0x20(%rbp), %rdx
movl $0x400, %esi            # imm = 0x400
callq 0x3310
cmpq $0x0, %rax
je 0x18e58
movsbl -0x420(%rbp), %eax
cmpl $0x23, %eax
jne 0x18d55
jmp 0x18d28
leaq -0x420(%rbp), %rdi
leaq 0x735c(%rip), %rsi      # 0x200bf
leaq -0x534(%rbp), %rdx
leaq -0x538(%rbp), %rcx
leaq -0x53c(%rbp), %r8
leaq -0x540(%rbp), %r9
leaq -0x544(%rbp), %rax
movq %rax, (%rsp)
movb $0x0, %al
callq 0x3460
cmpl $0x0, %eax
jne 0x18d98
jmp 0x18d28
leaq -0x420(%rbp), %rax
movslq -0x544(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x428(%rbp)
movq -0x428(%rbp), %rdi
leaq -0x530(%rbp), %rdx
leaq 0x7308(%rip), %rsi      # 0x200cd
leaq -0x544(%rbp), %rcx
movb $0x0, %al
callq 0x3460
cmpl $0x1, %eax
jne 0x18e53
leaq -0x530(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x3340
cmpl $0x0, %eax
jne 0x18e32
movl -0x534(%rbp), %edi
shll $0x18, %edi
movl -0x538(%rbp), %eax
shll $0x10, %eax
orl %eax, %edi
movl -0x53c(%rbp), %eax
shll $0x8, %eax
orl %eax, %edi
orl -0x540(%rbp), %edi
callq 0x3250
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x20(%rbp), %rdi
callq 0x3160
movl $0x0, -0x4(%rbp)
jmp 0x18e68
jmp 0x18e34
movl -0x544(%rbp), %ecx
movq -0x428(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x428(%rbp)
jmp 0x18db0
jmp 0x18d28
movq -0x20(%rbp), %rdi
callq 0x3160
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0x550, %rsp            # imm = 0x550
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_set_nameserver
void mg_set_nameserver(struct mg_mgr *mgr, const char *nameserver) {
  MG_FREE((char *) mgr->nameserver);
  mgr->nameserver = NULL;
  if (nameserver != NULL) {
    mgr->nameserver = strdup(nameserver);
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rdi
callq 0x3050
movq -0x8(%rbp), %rax
movq $0x0, 0x30(%rax)
cmpq $0x0, -0x10(%rbp)
je 0x192f4
movq -0x10(%rbp), %rdi
callq 0x3640
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x30(%rax)
addq $0x10, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_tun_log_frame
void mg_tun_log_frame(struct mg_tun_frame *frame) {
  LOG(LL_DEBUG, ("Got TUN frame: type=0x%x, flags=0x%x stream_id=0x%x, "
                 "len=%d",
                 frame->type, frame->flags, (unsigned int) frame->stream_id,
                 (int) frame->body.len));
#if MG_ENABLE_HEXDUMP
  {
    char hex[512];
    mg_hexdump(frame->body.p, frame->body.len, hex, sizeof(hex) - 1);
    hex[sizeof(hex) - 1] = '\0';
    LOG(LL_DEBUG, ("body:\n%s", hex));
  }
#else
  LOG(LL_DEBUG, ("body: '%.*s'", (int) frame->body.len, frame->body.p));
#endif
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x210, %rsp            # imm = 0x210
movq %rdi, -0x8(%rbp)
movl $0x3, %edi
leaq 0x6de9(%rip), %rsi      # 0x20104
leaq 0x6228(%rip), %rdx      # 0x1f54a
callq 0x4650
cmpl $0x0, %eax
je 0x1935b
movq -0x8(%rbp), %rax
movzbl (%rax), %esi
movq -0x8(%rbp), %rax
movzbl 0x1(%rax), %edx
movq -0x8(%rbp), %rax
movl 0x4(%rax), %ecx
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movl %eax, %r8d
leaq 0x6dc1(%rip), %rdi      # 0x20115
movb $0x0, %al
callq 0x47a0
jmp 0x1935d
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movl %eax, %esi
leaq -0x210(%rbp), %rdx
movl $0x1ff, %ecx            # imm = 0x1FF
callq 0xf170
movb $0x0, -0x11(%rbp)
movl $0x3, %edi
leaq 0x6d74(%rip), %rsi      # 0x20104
leaq 0x61b3(%rip), %rdx      # 0x1f54a
callq 0x4650
cmpl $0x0, %eax
je 0x193b6
leaq -0x210(%rbp), %rsi
leaq 0x6da2(%rip), %rdi      # 0x20151
movb $0x0, %al
callq 0x47a0
jmp 0x193b8
addq $0x210, %rsp            # imm = 0x210
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_tun_reconnect_ev_handler
void mg_tun_reconnect_ev_handler(struct mg_connection *nc, int ev,
                                 void *ev_data MG_UD_ARG(void *user_data)) {
#if !MG_ENABLE_CALLBACK_USERDATA
  void *user_data = nc->user_data;
#else
  (void) nc;
#endif
  struct mg_tun_client *client = (struct mg_tun_client *) user_data;
  (void) ev_data;

  switch (ev) {
    case MG_EV_TIMER:
      if (!(client->listener->flags & MG_F_TUN_DO_NOT_RECONNECT)) {
        mg_tun_do_reconnect(client);
      } else {
        /* Reconnecting is suppressed, we'll check again at the next poll */
        mg_tun_reconnect(client, 0);
      }
      break;
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq 0xa0(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x28(%rbp)
movl -0xc(%rbp), %eax
subl $0x6, %eax
jne 0x19437
jmp 0x19404
movq -0x28(%rbp), %rax
movq 0x28(%rax), %rax
movq 0xc8(%rax), %rax
andq $0x8000, %rax           # imm = 0x8000
cmpq $0x0, %rax
jne 0x1942a
movq -0x28(%rbp), %rdi
callq 0x19440
jmp 0x19435
movq -0x28(%rbp), %rdi
xorl %esi, %esi
callq 0x19500
jmp 0x19437
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_tun_do_reconnect
static void mg_tun_do_reconnect(struct mg_tun_client *client) {
  struct mg_connection *dc;
  struct mg_connect_opts opts;
  memset(&opts, 0, sizeof(opts));
#if MG_ENABLE_SSL
  opts.ssl_cert = client->ssl.ssl_cert;
  opts.ssl_key = client->ssl.ssl_key;
  opts.ssl_ca_cert = client->ssl.ssl_ca_cert;
#endif
  /* HTTP/Websocket listener */
  if ((dc = mg_connect_ws_opt(client->mgr, MG_CB(mg_tun_client_handler, client),
                              opts, client->disp_url, MG_TUN_PROTO_NAME,
                              NULL)) == NULL) {
    LOG(LL_ERROR,
        ("Cannot connect to WS server on addr [%s]\n", client->disp_url));
    return;
  }

  client->disp = dc;
#if !MG_ENABLE_CALLBACK_USERDATA
  dc->user_data = client;
#endif
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
leaq -0x38(%rbp), %rdi
xorl %esi, %esi
movl $0x28, %edx
callq 0x3260
movq -0x8(%rbp), %rax
movq (%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rdx
xorl %eax, %eax
movq -0x18(%rbp), %rcx
movq %rsp, %rax
movq %rcx, 0x20(%rax)
movups -0x38(%rbp), %xmm0
movups -0x28(%rbp), %xmm1
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
leaq 0x3eb2(%rip), %rsi      # 0x1d340
leaq 0x82a7(%rip), %rcx      # 0x2173c
xorl %eax, %eax
movl %eax, %r8d
callq 0x16790
movq %rax, -0x10(%rbp)
cmpq $0x0, %rax
jne 0x194df
jmp 0x194ab
xorl %edi, %edi
leaq 0x828f(%rip), %rsi      # 0x21743
leaq 0x608f(%rip), %rdx      # 0x1f54a
callq 0x4650
cmpl $0x0, %eax
je 0x194db
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rsi
leaq 0x8283(%rip), %rdi      # 0x21757
movb $0x0, %al
callq 0x47a0
jmp 0x194dd
jmp 0x194fa
movq -0x10(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x8(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0xa0(%rax)
addq $0x60, %rsp
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O0/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_tun_reconnect
static void mg_tun_reconnect(struct mg_tun_client *client, int timeout) {
  if (client->reconnect == NULL) {
    client->reconnect = mg_add_sock(client->mgr, INVALID_SOCKET,
                                    MG_CB(mg_tun_reconnect_ev_handler, client));
#if !MG_ENABLE_CALLBACK_USERDATA
    client->reconnect->user_data = client;
#endif
  }
  client->reconnect->ev_timer_time = mg_time() + timeout;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq -0x8(%rbp), %rax
cmpq $0x0, 0x30(%rax)
jne 0x19550
movq -0x8(%rbp), %rax
movq (%rax), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
leaq -0x15d(%rip), %rdx      # 0x193d0
callq 0xd420
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x30(%rax)
movq -0x8(%rbp), %rcx
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movq %rcx, 0xa0(%rax)
callq 0xb6e0
cvtsi2sdl -0xc(%rbp), %xmm1
addsd %xmm1, %xmm0
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movsd %xmm0, 0x78(%rax)
addq $0x10, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_tun_create_client
static struct mg_tun_client *mg_tun_create_client(struct mg_mgr *mgr,
                                                  const char *dispatcher,
                                                  struct mg_tun_ssl_opts ssl) {
  struct mg_tun_client *client = NULL;
  struct mg_iface *iface = mg_find_iface(mgr, &mg_tun_iface_vtable, NULL);
  if (iface == NULL) {
    LOG(LL_ERROR, ("The tun feature requires the manager to have a tun "
                   "interface enabled"));
    return NULL;
  }

  client = (struct mg_tun_client *) MG_MALLOC(sizeof(*client));
  mg_tun_init_client(client, mgr, iface, dispatcher, ssl);
  iface->data = client;

  /*
   * We need to give application a chance to set MG_F_TUN_DO_NOT_RECONNECT on a
   * listening connection right after mg_tun_bind_opt() returned it, so we
   * should use mg_tun_reconnect() here, instead of mg_tun_do_reconnect()
   */
  mg_tun_reconnect(client, 0);
  return client;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movl %edx, -0xc(%rbp)
movq %rdi, -0x18(%rbp)
movq %rsi, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
movq -0x18(%rbp), %rdi
leaq 0xd24a(%rip), %rsi      # 0x267f0
xorl %eax, %eax
movl %eax, %edx
callq 0xd480
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x195f0
jmp 0x195bc
xorl %edi, %edi
leaq 0x8382(%rip), %rsi      # 0x21947
leaq 0x5f7e(%rip), %rdx      # 0x1f54a
callq 0x4650
cmpl $0x0, %eax
je 0x195e4
leaq 0x837f(%rip), %rdi      # 0x2195c
movb $0x0, %al
callq 0x47a0
jmp 0x195e6
movq $0x0, -0x8(%rbp)
jmp 0x19636
movl $0x38, %edi
callq 0x3420
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x30(%rbp), %rdx
movq -0x20(%rbp), %rcx
movl -0xc(%rbp), %r8d
callq 0x1d730
movq -0x28(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x28(%rbp), %rdi
xorl %esi, %esi
callq 0x19500
movq -0x28(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x30, %rsp
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O0/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_tun_do_bind
static struct mg_connection *mg_tun_do_bind(struct mg_tun_client *client,
                                            MG_CB(mg_event_handler_t handler,
                                                  void *user_data),
                                            struct mg_bind_opts opts) {
  struct mg_connection *lc;
  opts.iface = client->iface;
  lc = mg_bind_opt(client->mgr, ":1234" /* dummy port */,
                   MG_CB(handler, user_data), opts);
  client->listener = lc;
  return lc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
leaq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rcx
movq 0x8(%rcx), %rcx
movq %rcx, 0x18(%rax)
movq -0x8(%rbp), %rcx
movq (%rcx), %rdi
movq -0x10(%rbp), %rdx
leaq 0x832f(%rip), %rsi      # 0x219a1
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rcx
movq %rcx, 0x10(%rsp)
movq 0x18(%rax), %rax
movq %rax, 0x18(%rsp)
callq 0xcb30
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x18(%rbp), %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_tun_parse_frame
int mg_tun_parse_frame(void *data, size_t len, struct mg_tun_frame *frame) {
  const size_t header_size = sizeof(uint32_t) + sizeof(uint8_t) * 2;
  if (len < header_size) {
    return -1;
  }

  frame->type = *(uint8_t *) (data);
  frame->flags = *(uint8_t *) ((char *) data + 1);
  memcpy(&frame->stream_id, (char *) data + 2, sizeof(uint32_t));
  frame->stream_id = ntohl(frame->stream_id);
  frame->body.p = (char *) data + header_size;
  frame->body.len = len - header_size;
  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq $0x6, -0x28(%rbp)
cmpq $0x6, -0x18(%rbp)
jae 0x196ec
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x19750
movq -0x10(%rbp), %rax
movb (%rax), %cl
movq -0x20(%rbp), %rax
movb %cl, (%rax)
movq -0x10(%rbp), %rax
movb 0x1(%rax), %cl
movq -0x20(%rbp), %rax
movb %cl, 0x1(%rax)
movq -0x20(%rbp), %rax
movq -0x10(%rbp), %rcx
movl 0x2(%rcx), %ecx
movl %ecx, 0x4(%rax)
movq -0x20(%rbp), %rax
movl 0x4(%rax), %edi
callq 0x3630
movl %eax, %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x10(%rbp), %rcx
addq $0x6, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x18(%rbp), %rcx
subq $0x6, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x10(%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/sfeakes[P]unifi-motion/mongoose.c
// Function: cs_base64_emit_code
static void cs_base64_emit_code(struct cs_base64_ctx *ctx, int v) {
  if (v < NUM_UPPERCASES) {
    ctx->b64_putc(v + 'A', ctx->user_data);
  } else if (v < (NUM_LETTERS)) {
    ctx->b64_putc(v - NUM_UPPERCASES + 'a', ctx->user_data);
  } else if (v < (NUM_LETTERS + NUM_DIGITS)) {
    ctx->b64_putc(v - NUM_LETTERS + '0', ctx->user_data);
  } else {
    ctx->b64_putc(v - NUM_LETTERS - NUM_DIGITS == 0 ? '+' : '/',
                  ctx->user_data);
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
cmpl $0x1a, -0xc(%rbp)
jge 0x19791
movq -0x8(%rbp), %rax
movq (%rax), %rax
movl -0xc(%rbp), %ecx
addl $0x41, %ecx
movq -0x8(%rbp), %rdx
movq 0x10(%rdx), %rsi
movsbl %cl, %edi
callq *%rax
jmp 0x1980c
cmpl $0x34, -0xc(%rbp)
jge 0x197b6
movq -0x8(%rbp), %rax
movq (%rax), %rax
movl -0xc(%rbp), %ecx
subl $0x1a, %ecx
addl $0x61, %ecx
movq -0x8(%rbp), %rdx
movq 0x10(%rdx), %rsi
movsbl %cl, %edi
callq *%rax
jmp 0x1980a
cmpl $0x3e, -0xc(%rbp)
jge 0x197db
movq -0x8(%rbp), %rax
movq (%rax), %rax
movl -0xc(%rbp), %ecx
subl $0x34, %ecx
addl $0x30, %ecx
movq -0x8(%rbp), %rdx
movq 0x10(%rdx), %rsi
movsbl %cl, %edi
callq *%rax
jmp 0x19808
movq -0x8(%rbp), %rax
movq (%rax), %rax
movl -0xc(%rbp), %esi
subl $0x34, %esi
subl $0xa, %esi
movl $0x2f, %ecx
movl $0x2b, %edx
cmpl $0x0, %esi
cmovel %edx, %ecx
movq -0x8(%rbp), %rdx
movq 0x10(%rdx), %rsi
movsbl %cl, %edi
callq *%rax
jmp 0x1980a
jmp 0x1980c
addq $0x10, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_remove_conn
MG_INTERNAL void mg_remove_conn(struct mg_connection *conn) {
  if (conn->prev == NULL) conn->mgr->active_connections = conn->next;
  if (conn->prev) conn->prev->next = conn->next;
  if (conn->next) conn->next->prev = conn->prev;
  conn->prev = conn->next = NULL;
  conn->iface->vtable->remove_conn(conn);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jne 0x19849
movq -0x8(%rbp), %rax
movq (%rax), %rcx
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq %rcx, (%rax)
movq -0x8(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x19866
movq -0x8(%rbp), %rax
movq (%rax), %rcx
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq %rcx, (%rax)
movq -0x8(%rbp), %rax
cmpq $0x0, (%rax)
je 0x19883
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rcx, 0x8(%rax)
movq -0x8(%rbp), %rax
movq $0x0, (%rax)
movq -0x8(%rbp), %rax
movq $0x0, 0x8(%rax)
movq -0x8(%rbp), %rax
movq 0xc0(%rax), %rax
movq 0x10(%rax), %rax
movq 0x18(%rax), %rax
movq -0x8(%rbp), %rdi
callq *%rax
addq $0x10, %rsp
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_recvfrom
static int mg_recvfrom(struct mg_connection *nc, union socket_address *sa,
                       socklen_t *sa_len, char **buf) {
  int n;
  *buf = (char *) MG_MALLOC(MG_UDP_RECV_BUFFER_SIZE);
  if (*buf == NULL) {
    DBG(("Out of memory"));
    return -ENOMEM;
  }
  n = recvfrom(nc->sock, *buf, MG_UDP_RECV_BUFFER_SIZE, 0, &sa->sa, sa_len);
  if (n <= 0) {
    DBG(("%p recvfrom: %s", nc, strerror(mg_get_errno())));
    MG_FREE(*buf);
  }
  return n;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movl $0x5dc, %edi            # imm = 0x5DC
callq 0x3420
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, (%rax)
movq -0x28(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x19961
jmp 0x19928
movl $0x4, %edi
leaq 0x69b8(%rip), %rsi      # 0x202ec
leaq 0x5c0f(%rip), %rdx      # 0x1f54a
callq 0x4650
cmpl $0x0, %eax
je 0x19953
leaq 0x69ac(%rip), %rdi      # 0x202f8
movb $0x0, %al
callq 0x47a0
jmp 0x19955
movl $0xfffffff4, -0x4(%rbp) # imm = 0xFFFFFFF4
jmp 0x199e8
movq -0x10(%rbp), %rax
movl 0x20(%rax), %edi
movq -0x28(%rbp), %rax
movq (%rax), %rsi
movq -0x18(%rbp), %r8
movq -0x20(%rbp), %r9
movl $0x5dc, %edx            # imm = 0x5DC
xorl %ecx, %ecx
callq 0x3490
movl %eax, -0x2c(%rbp)
cmpl $0x0, -0x2c(%rbp)
jg 0x199e2
jmp 0x1998e
movl $0x4, %edi
leaq 0x6952(%rip), %rsi      # 0x202ec
leaq 0x5ba9(%rip), %rdx      # 0x1f54a
callq 0x4650
cmpl $0x0, %eax
je 0x199d4
movq -0x10(%rbp), %rax
movq %rax, -0x38(%rbp)
callq 0xd6a0
movl %eax, %edi
callq 0x3650
movq -0x38(%rbp), %rsi
movq %rax, %rdx
leaq 0x6939(%rip), %rdi      # 0x20306
movb $0x0, %al
callq 0x47a0
jmp 0x199d6
movq -0x28(%rbp), %rax
movq (%rax), %rdi
callq 0x3050
movl -0x2c(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/sfeakes[P]unifi-motion/mongoose.c
// Function: recv_avail_size
MG_INTERNAL size_t recv_avail_size(struct mg_connection *conn, size_t max) {
  size_t avail;
  if (conn->recv_mbuf_limit < conn->recv_mbuf.len) return 0;
  avail = conn->recv_mbuf_limit - conn->recv_mbuf.len;
  return avail > max ? max : avail;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rax
movq -0x10(%rbp), %rcx
cmpq 0x48(%rcx), %rax
jae 0x19a28
movq $0x0, -0x8(%rbp)
jmp 0x19a60
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rax
movq -0x10(%rbp), %rcx
subq 0x48(%rcx), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
cmpq -0x18(%rbp), %rax
jbe 0x19a50
movq -0x18(%rbp), %rax
movq %rax, -0x28(%rbp)
jmp 0x19a58
movq -0x20(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_http_conn_destructor
static void mg_http_conn_destructor(void *proto_data) {
  struct mg_http_proto_data *pd = (struct mg_http_proto_data *) proto_data;
#if MG_ENABLE_FILESYSTEM
  mg_http_free_proto_data_file(&pd->file);
#endif
#if MG_ENABLE_HTTP_CGI
  mg_http_free_proto_data_cgi(&pd->cgi);
#endif
#if MG_ENABLE_HTTP_STREAMING_MULTIPART
  mg_http_free_proto_data_mp_stream(&pd->mp_stream);
#endif
  mg_http_free_proto_data_endpoints(&pd->endpoints);
  mg_http_free_reverse_proxy_data(&pd->reverse_proxy_data);
  MG_FREE(proto_data);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rdi
callq 0x19ad0
movq -0x10(%rbp), %rdi
addq $0x20, %rdi
callq 0x19b10
movq -0x10(%rbp), %rdi
addq $0x38, %rdi
callq 0x19b80
movq -0x10(%rbp), %rdi
addq $0x48, %rdi
callq 0x19c00
movq -0x8(%rbp), %rdi
callq 0x3050
addq $0x10, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_http_free_proto_data_file
static void mg_http_free_proto_data_file(struct mg_http_proto_data_file *d) {
  if (d != NULL) {
    if (d->fp != NULL) {
      fclose(d->fp);
    }
    memset(d, 0, sizeof(struct mg_http_proto_data_file));
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
cmpq $0x0, -0x8(%rbp)
je 0x19b09
movq -0x8(%rbp), %rax
cmpq $0x0, (%rax)
je 0x19af9
movq -0x8(%rbp), %rax
movq (%rax), %rdi
callq 0x3160
movq -0x8(%rbp), %rdi
xorl %esi, %esi
movl $0x20, %edx
callq 0x3260
addq $0x10, %rsp
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O0/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_http_free_proto_data_cgi
MG_INTERNAL void mg_http_free_proto_data_cgi(struct mg_http_proto_data_cgi *d) {
  if (d == NULL) return;
  if (d->cgi_nc != NULL) {
    d->cgi_nc->flags |= MG_F_CLOSE_IMMEDIATELY;
    d->cgi_nc->user_data = NULL;
  }
  memset(d, 0, sizeof(*d));
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
cmpq $0x0, -0x8(%rbp)
jne 0x19b25
jmp 0x19b6d
movq -0x8(%rbp), %rax
cmpq $0x0, (%rax)
je 0x19b5d
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq 0xc8(%rax), %rcx
orq $0x800, %rcx            # imm = 0x800
movq %rcx, 0xc8(%rax)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq $0x0, 0xa0(%rax)
movq -0x8(%rbp), %rdi
xorl %esi, %esi
movl $0x8, %edx
callq 0x3260
addq $0x10, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_http_free_proto_data_endpoints
static void mg_http_free_proto_data_endpoints(struct mg_http_endpoint **ep) {
  struct mg_http_endpoint *current = *ep;

  while (current != NULL) {
    struct mg_http_endpoint *tmp = current->next;
    MG_FREE((void *) current->uri_pattern.p);
    MG_FREE((void *) current->auth_domain);
    MG_FREE((void *) current->auth_file);
    MG_FREE(current);
    current = tmp;
  }

  ep = NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x19be3
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x3050
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x3050
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x3050
movq -0x10(%rbp), %rdi
callq 0x3050
movq -0x18(%rbp), %rax
movq %rax, -0x10(%rbp)
jmp 0x19b97
movq $0x0, -0x8(%rbp)
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_free_reverse_proxy_data
static void mg_http_free_reverse_proxy_data(struct mg_reverse_proxy_data *rpd) {
  if (rpd->linked_conn != NULL) {
    /*
     * Connection has linked one, we have to unlink & close it
     * since _this_ connection is going to die and
     * it doesn't make sense to keep another one
     */
    struct mg_http_proto_data *pd = mg_http_get_proto_data(rpd->linked_conn);
    if (pd->reverse_proxy_data.linked_conn != NULL) {
      pd->reverse_proxy_data.linked_conn->flags |= MG_F_SEND_AND_CLOSE;
      pd->reverse_proxy_data.linked_conn = NULL;
    }
    rpd->linked_conn = NULL;
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
cmpq $0x0, (%rax)
je 0x19c65
movq -0x8(%rbp), %rax
movq (%rax), %rdi
callq 0x109b0
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x48(%rax)
je 0x19c5a
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movq 0xc8(%rax), %rcx
orq $0x400, %rcx            # imm = 0x400
movq %rcx, 0xc8(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x48(%rax)
movq -0x8(%rbp), %rax
movq $0x0, (%rax)
addq $0x10, %rsp
popq %rbp
retq
nopl (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_find_index_file
MG_INTERNAL void mg_find_index_file(const char *path, const char *list,
                                    char **index_file, cs_stat_t *stp) {
  struct mg_str vec;
  size_t path_len = strlen(path);
  int found = 0;
  *index_file = NULL;

  /* Traverse index files list. For each entry, append it to the given */
  /* path and see if the file exists. If it exists, break the loop */
  while ((list = mg_next_comma_list_entry(list, &vec, NULL)) != NULL) {
    cs_stat_t st;
    size_t len = path_len + 1 + vec.len + 1;
    *index_file = (char *) MG_REALLOC(*index_file, len);
    if (*index_file == NULL) break;
    snprintf(*index_file, len, "%s%c%.*s", path, DIRSEP, (int) vec.len, vec.p);

    /* Does it exist? Is it a file? */
    if (mg_stat(*index_file, &st) == 0 && S_ISREG(st.st_mode)) {
      /* Yes it does, break the loop */
      *stp = st;
      found = 1;
      break;
    }
  }
  if (!found) {
    MG_FREE(*index_file);
    *index_file = NULL;
  }
  LOG(LL_DEBUG, ("[%s] [%s]", path, (*index_file ? *index_file : "")));
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xf0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x8(%rbp), %rdi
callq 0x3180
movq %rax, -0x38(%rbp)
movl $0x0, -0x3c(%rbp)
movq -0x18(%rbp), %rax
movq $0x0, (%rax)
movq -0x10(%rbp), %rdi
leaq -0x30(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0xa320
movq %rax, -0x10(%rbp)
cmpq $0x0, %rax
je 0x19f4e
movq -0x38(%rbp), %rax
addq $0x1, %rax
addq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xd8(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rdi
movq -0xd8(%rbp), %rsi
callq 0x34d0
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x18(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x19ecc
jmp 0x19f4e
movq -0x18(%rbp), %rax
movq (%rax), %rdi
movq -0xd8(%rbp), %rsi
movq -0x8(%rbp), %rcx
movq -0x28(%rbp), %rax
movl %eax, %r9d
movq -0x30(%rbp), %rax
leaq 0x67fa(%rip), %rdx      # 0x206ea
movl $0x2f, %r8d
movq %rax, (%rsp)
movb $0x0, %al
callq 0x31f0
movq -0x18(%rbp), %rax
movq (%rax), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x12330
cmpl $0x0, %eax
jne 0x19f49
movl -0xb8(%rbp), %eax
andl $0xf000, %eax           # imm = 0xF000
cmpl $0x8000, %eax           # imm = 0x8000
jne 0x19f49
movq -0x20(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
movl $0x90, %edx
callq 0x33b0
movl $0x1, -0x3c(%rbp)
jmp 0x19f4e
jmp 0x19e6a
cmpl $0x0, -0x3c(%rbp)
jne 0x19f6b
movq -0x18(%rbp), %rax
movq (%rax), %rdi
callq 0x3050
movq -0x18(%rbp), %rax
movq $0x0, (%rax)
jmp 0x19f6d
movl $0x3, %edi
leaq 0x677a(%rip), %rsi      # 0x206f3
leaq 0x55ca(%rip), %rdx      # 0x1f54a
callq 0x4650
cmpl $0x0, %eax
je 0x19fdb
movq -0x8(%rbp), %rax
movq %rax, -0xe0(%rbp)
movq -0x18(%rbp), %rax
cmpq $0x0, (%rax)
je 0x19faf
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq %rax, -0xe8(%rbp)
jmp 0x19fbf
leaq 0x67f5(%rip), %rax      # 0x207ab
movq %rax, -0xe8(%rbp)
jmp 0x19fbf
movq -0xe0(%rbp), %rsi
movq -0xe8(%rbp), %rdx
leaq 0x6732(%rip), %rdi      # 0x20706
movb $0x0, %al
callq 0x47a0
jmp 0x19fdd
addq $0xf0, %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_digest_auth_request
static void mg_http_send_digest_auth_request(struct mg_connection *c,
                                             const char *domain) {
  mg_printf(c,
            "HTTP/1.1 401 Unauthorized\r\n"
            "WWW-Authenticate: Digest qop=\"auth\", "
            "realm=\"%s\", nonce=\"%lu\"\r\n"
            "Content-Length: 0\r\n\r\n",
            domain, (unsigned long) mg_time());
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x18(%rbp)
callq 0xb6e0
movq -0x20(%rbp), %rdi
movq -0x18(%rbp), %rdx
movsd 0x50d3(%rip), %xmm2     # 0x1f308
movaps %xmm0, %xmm1
subsd %xmm2, %xmm1
cvttsd2si %xmm1, %rax
cvttsd2si %xmm0, %rcx
movq %rcx, %rsi
sarq $0x3f, %rsi
andq %rsi, %rax
orq %rax, %rcx
leaq 0x64e3(%rip), %rsi      # 0x2073d
movb $0x0, %al
callq 0xb2f0
addq $0x20, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_is_file_hidden
static int mg_is_file_hidden(const char *path,
                             const struct mg_serve_http_opts *opts,
                             int exclude_specials) {
  const char *p1 = opts->per_directory_auth_file;
  const char *p2 = opts->hidden_file_pattern;

  /* Strip directory path from the file name */
  const char *pdir = strrchr(path, DIRSEP);
  if (pdir != NULL) {
    path = pdir + 1;
  }

  return (exclude_specials && (!strcmp(path, ".") || !strcmp(path, ".."))) ||
         (p1 != NULL &&
          mg_match_prefix(p1, strlen(p1), path) == (int) strlen(p1)) ||
         (p2 != NULL && mg_match_prefix(p2, strlen(p2), path) > 0);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rdi
movl $0x2f, %esi
callq 0x3200
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x1a580
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x8(%rbp)
cmpl $0x0, -0x14(%rbp)
je 0x1a5c2
movq -0x8(%rbp), %rdi
leaq 0x53fa(%rip), %rsi      # 0x1f98b
callq 0x3340
movl %eax, %ecx
movb $0x1, %al
cmpl $0x0, %ecx
movb %al, -0x31(%rbp)
je 0x1a63e
movq -0x8(%rbp), %rdi
leaq 0x53d9(%rip), %rsi      # 0x1f98a
callq 0x3340
movl %eax, %ecx
movb $0x1, %al
cmpl $0x0, %ecx
movb %al, -0x31(%rbp)
je 0x1a63e
cmpq $0x0, -0x20(%rbp)
je 0x1a603
movq -0x20(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x20(%rbp), %rdi
callq 0x3180
movq -0x40(%rbp), %rdi
movl %eax, %esi
movq -0x8(%rbp), %rdx
callq 0x4730
movl %eax, -0x38(%rbp)
movq -0x20(%rbp), %rdi
callq 0x3180
movl -0x38(%rbp), %ecx
movl %eax, %edx
movb $0x1, %al
cmpl %edx, %ecx
movb %al, -0x31(%rbp)
je 0x1a63e
xorl %eax, %eax
cmpq $0x0, -0x28(%rbp)
movb %al, -0x41(%rbp)
je 0x1a638
movq -0x28(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x28(%rbp), %rdi
callq 0x3180
movq -0x50(%rbp), %rdi
movl %eax, %esi
movq -0x8(%rbp), %rdx
callq 0x4730
cmpl $0x0, %eax
setg %al
movb %al, -0x41(%rbp)
movb -0x41(%rbp), %al
movb %al, -0x31(%rbp)
movb -0x31(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_is_not_modified
MG_INTERNAL int mg_is_not_modified(struct http_message *hm, cs_stat_t *st) {
  struct mg_str *hdr;
  if ((hdr = mg_get_http_header(hm, "If-None-Match")) != NULL) {
    char etag[64];
    mg_http_construct_etag(etag, sizeof(etag), st);
    return mg_vcasecmp(hdr, etag) == 0;
  } else if ((hdr = mg_get_http_header(hm, "If-Modified-Since")) != NULL) {
    return st->st_mtime <= mg_parse_date_string(hdr->p);
  } else {
    return 0;
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rdi
leaq 0x6873(%rip), %rsi      # 0x2109e
callq 0x10830
movq %rax, -0x20(%rbp)
cmpq $0x0, %rax
je 0x1a869
leaq -0x60(%rbp), %rdi
movq -0x18(%rbp), %rdx
movl $0x40, %esi
callq 0x12430
movq -0x20(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x8b60
cmpl $0x0, %eax
sete %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x4(%rbp)
jmp 0x1a8b9
movq -0x10(%rbp), %rdi
leaq 0x6838(%rip), %rsi      # 0x210ac
callq 0x10830
movq %rax, -0x20(%rbp)
cmpq $0x0, %rax
je 0x1a8b2
movq -0x18(%rbp), %rax
movq 0x58(%rax), %rax
movq %rax, -0x68(%rbp)
movq -0x20(%rbp), %rax
movq (%rax), %rdi
callq 0x1baf0
movq %rax, %rcx
movq -0x68(%rbp), %rax
cmpq %rcx, %rax
setle %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x4(%rbp)
jmp 0x1a8b9
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_http_serve_file2
static void mg_http_serve_file2(struct mg_connection *nc, const char *path,
                                struct http_message *hm,
                                struct mg_serve_http_opts *opts) {
#if MG_ENABLE_HTTP_SSI
  if (mg_match_prefix(opts->ssi_pattern, strlen(opts->ssi_pattern), path) > 0) {
    mg_handle_ssi_request(nc, hm, path, opts);
    return;
  }
#endif
  mg_http_serve_file(nc, hm, path, mg_get_mime_type(path, "text/plain", opts),
                     mg_mk_str(opts->extra_headers));
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x20(%rbp), %rax
movq 0x30(%rax), %rdi
callq 0x3180
movq -0x48(%rbp), %rdi
movl %eax, %esi
movq -0x10(%rbp), %rdx
callq 0x4730
cmpl $0x0, %eax
jle 0x1a92c
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x10(%rbp), %rdx
movq -0x20(%rbp), %rcx
callq 0x1bd40
jmp 0x1a9a8
movq -0x8(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rdx
leaq 0x67da(%rip), %rsi      # 0x2112d
callq 0x1be70
movq %rax, -0x30(%rbp)
movq %rdx, -0x28(%rbp)
movq -0x20(%rbp), %rax
movq 0x78(%rax), %rdi
callq 0x8a60
movq -0x60(%rbp), %rdi
movq -0x58(%rbp), %rsi
movq %rax, %rcx
movq %rdx, %rax
movq -0x50(%rbp), %rdx
movq %rcx, -0x40(%rbp)
movq %rax, -0x38(%rbp)
movq -0x30(%rbp), %rcx
movq -0x28(%rbp), %r8
leaq -0x40(%rbp), %rax
movq (%rax), %r9
movq %r9, (%rsp)
movq 0x8(%rax), %rax
movq %rax, 0x8(%rsp)
callq 0x11f10
addq $0x70, %rsp
popq %rbp
retq
nop