LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O0/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_mkmd5resp
static void mg_mkmd5resp(const char *method, size_t method_len, const char *uri,
                         size_t uri_len, const char *ha1, size_t ha1_len,
                         const char *nonce, size_t nonce_len, const char *nc,
                         size_t nc_len, const char *cnonce, size_t cnonce_len,
                         const char *qop, size_t qop_len, char *resp) {
  static const char colon[] = ":";
  static const size_t one = 1;
  char ha2[33];
  cs_md5(ha2, method, method_len, colon, one, uri, uri_len, NULL);
  cs_md5(resp, ha1, ha1_len, colon, one, nonce, nonce_len, colon, one, nc,
         nc_len, colon, one, cnonce, cnonce_len, colon, one, qop, qop_len,
         colon, one, ha2, sizeof(ha2) - 1, NULL);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xf8, %rsp
movq 0x50(%rbp), %rax
movq 0x48(%rbp), %rax
movq 0x40(%rbp), %rax
movq 0x38(%rbp), %rax
movq 0x30(%rbp), %rax
movq 0x28(%rbp), %rax
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x30(%rbp)
movq %rsi, -0x38(%rbp)
movq %rdx, -0x40(%rbp)
movq %rcx, -0x48(%rbp)
movq %r8, -0x50(%rbp)
movq %r9, -0x58(%rbp)
leaq -0x80(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x38(%rbp), %rdx
movq -0x40(%rbp), %r9
movq -0x48(%rbp), %rax
leaq 0xbee5(%rip), %rcx      # 0x1f4b0
movl $0x1, %r8d
xorl %r10d, %r10d
movq %rax, (%rsp)
movq $0x0, 0x8(%rsp)
movb $0x0, %al
callq 0x13100
movq 0x50(%rbp), %rdi
movq -0x50(%rbp), %rsi
movq -0x58(%rbp), %rdx
movq 0x10(%rbp), %r9
movq 0x18(%rbp), %rax
movq 0x20(%rbp), %r13
movq 0x28(%rbp), %r12
movq 0x30(%rbp), %r15
movq 0x38(%rbp), %r14
movq 0x40(%rbp), %rbx
movq 0x48(%rbp), %r11
leaq -0x80(%rbp), %rcx
movq %rcx, -0x88(%rbp)
leaq 0xbe8a(%rip), %r10      # 0x1f4b0
movl $0x1, %r8d
xorl %ecx, %ecx
movq %r10, %rcx
movq %rax, (%rsp)
movq -0x88(%rbp), %rax
movq %r10, 0x8(%rsp)
movq $0x1, 0x10(%rsp)
movq %r13, 0x18(%rsp)
movq %r12, 0x20(%rsp)
movq %r10, 0x28(%rsp)
movq $0x1, 0x30(%rsp)
movq %r15, 0x38(%rsp)
movq %r14, 0x40(%rsp)
movq %r10, 0x48(%rsp)
movq $0x1, 0x50(%rsp)
movq %rbx, 0x58(%rsp)
movq %r11, 0x60(%rsp)
movq %r10, 0x68(%rsp)
movq $0x1, 0x70(%rsp)
movq %rax, 0x78(%rsp)
movq $0x20, 0x80(%rsp)
movq $0x0, 0x88(%rsp)
movb $0x0, %al
callq 0x13100
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_reverse_proxy_handler
static void mg_reverse_proxy_handler(struct mg_connection *nc, int ev,
                                     void *ev_data MG_UD_ARG(void *user_data)) {
  struct http_message *hm = (struct http_message *) ev_data;
  struct mg_http_proto_data *pd = mg_http_get_proto_data(nc);

  if (pd == NULL || pd->reverse_proxy_data.linked_conn == NULL) {
    DBG(("%p: upstream closed", nc));
    return;
  }

  switch (ev) {
    case MG_EV_CONNECT:
      if (*(int *) ev_data != 0) {
        mg_http_send_error(pd->reverse_proxy_data.linked_conn, 502, NULL);
      }
      break;
    /* TODO(mkm): handle streaming */
    case MG_EV_HTTP_REPLY:
      mg_send(pd->reverse_proxy_data.linked_conn, hm->message.p,
              hm->message.len);
      pd->reverse_proxy_data.linked_conn->flags |= MG_F_SEND_AND_CLOSE;
      nc->flags |= MG_F_CLOSE_IMMEDIATELY;
      break;
    case MG_EV_CLOSE:
      pd->reverse_proxy_data.linked_conn->flags |= MG_F_SEND_AND_CLOSE;
      break;
  }

#if MG_ENABLE_CALLBACK_USERDATA
  (void) user_data;
#endif
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rdi
callq 0x109b0
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x144ca
movq -0x28(%rbp), %rax
cmpq $0x0, 0x48(%rax)
jne 0x14502
jmp 0x144cc
movl $0x4, %edi
leaq 0xc051(%rip), %rsi      # 0x20529
leaq 0xb06b(%rip), %rdx      # 0x1f54a
callq 0x4650
cmpl $0x0, %eax
je 0x144fb
movq -0x8(%rbp), %rsi
leaq 0xc04e(%rip), %rdi      # 0x20542
movb $0x0, %al
callq 0x47a0
jmp 0x144fd
jmp 0x145be
movl -0xc(%rbp), %eax
movl %eax, -0x2c(%rbp)
subl $0x2, %eax
je 0x1452a
jmp 0x1450f
movl -0x2c(%rbp), %eax
subl $0x5, %eax
je 0x145a1
jmp 0x1451d
movl -0x2c(%rbp), %eax
subl $0x65, %eax
je 0x1454b
jmp 0x145be
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x14549
movq -0x28(%rbp), %rax
movq 0x48(%rax), %rdi
movl $0x1f6, %esi            # imm = 0x1F6
xorl %eax, %eax
movl %eax, %edx
callq 0x11e30
jmp 0x145be
movq -0x28(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x20(%rbp), %rax
movq (%rax), %rsi
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movl %eax, %edx
callq 0xb260
movq -0x28(%rbp), %rax
movq 0x48(%rax), %rax
movq 0xc8(%rax), %rcx
orq $0x400, %rcx            # imm = 0x400
movq %rcx, 0xc8(%rax)
movq -0x8(%rbp), %rax
movq 0xc8(%rax), %rcx
orq $0x800, %rcx            # imm = 0x800
movq %rcx, 0xc8(%rax)
jmp 0x145be
movq -0x28(%rbp), %rax
movq 0x48(%rax), %rax
movq 0xc8(%rax), %rcx
orq $0x400, %rcx            # imm = 0x400
movq %rcx, 0xc8(%rax)
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_http_handle_forwarding
static int mg_http_handle_forwarding(struct mg_connection *nc,
                                     struct http_message *hm,
                                     const struct mg_serve_http_opts *opts) {
  const char *rewrites = opts->url_rewrites;
  struct mg_str a, b;
  struct mg_str p1 = MG_MK_STR("http://"), p2 = MG_MK_STR("https://");

  while ((rewrites = mg_next_comma_list_entry(rewrites, &a, &b)) != NULL) {
    if (mg_strncmp(a, hm->uri, a.len) == 0) {
      if (mg_strncmp(b, p1, p1.len) == 0 || mg_strncmp(b, p2, p2.len) == 0) {
        mg_http_reverse_proxy(nc, hm, a, b);
        return 1;
      }
    }
  }

  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq 0x40(%rax), %rax
movq %rax, -0x28(%rbp)
movq 0x120d9(%rip), %rax     # 0x268f0
movq %rax, -0x58(%rbp)
movq 0x120d6(%rip), %rax     # 0x268f8
movq %rax, -0x50(%rbp)
movq 0x120d3(%rip), %rax     # 0x26900
movq %rax, -0x68(%rbp)
movq 0x120d0(%rip), %rax     # 0x26908
movq %rax, -0x60(%rbp)
movq -0x28(%rbp), %rdi
leaq -0x38(%rbp), %rsi
leaq -0x48(%rbp), %rdx
callq 0xa320
movq %rax, -0x28(%rbp)
cmpq $0x0, %rax
je 0x148e6
movq -0x18(%rbp), %rax
movq -0x30(%rbp), %r8
movq -0x38(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq 0x30(%rax), %rdx
movq 0x38(%rax), %rcx
callq 0x8ee0
cmpl $0x0, %eax
jne 0x148e1
movq -0x50(%rbp), %r8
movq -0x48(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq -0x58(%rbp), %rdx
movq -0x50(%rbp), %rcx
callq 0x8ee0
cmpl $0x0, %eax
je 0x148b9
movq -0x60(%rbp), %r8
movq -0x48(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq -0x68(%rbp), %rdx
movq -0x60(%rbp), %rcx
callq 0x8ee0
cmpl $0x0, %eax
jne 0x148df
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x38(%rbp), %rdx
movq -0x30(%rbp), %rcx
movq -0x48(%rbp), %r8
movq -0x40(%rbp), %r9
callq 0x13d80
movl $0x1, -0x4(%rbp)
jmp 0x148ed
jmp 0x148e1
jmp 0x1483c
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_send_port_based_redirect
static int mg_http_send_port_based_redirect(
    struct mg_connection *c, struct http_message *hm,
    const struct mg_serve_http_opts *opts) {
  const char *rewrites = opts->url_rewrites;
  struct mg_str a, b;
  char local_port[20] = {'%'};

  mg_conn_addr_to_str(c, local_port + 1, sizeof(local_port) - 1,
                      MG_SOCK_STRINGIFY_PORT);

  while ((rewrites = mg_next_comma_list_entry(rewrites, &a, &b)) != NULL) {
    if (mg_vcmp(&a, local_port) == 0) {
      mg_send_response_line(c, 301, NULL);
      mg_printf(c, "Content-Length: 0\r\nLocation: %.*s%.*s\r\n\r\n",
                (int) b.len, b.p, (int) (hm->proto.p - hm->uri.p - 1),
                hm->uri.p);
      return 1;
    }
  }

  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq 0x40(%rax), %rax
movq %rax, -0x28(%rbp)
movq 0xab99(%rip), %rax      # 0x1f4c0
movq %rax, -0x60(%rbp)
movq 0xab96(%rip), %rax      # 0x1f4c8
movq %rax, -0x58(%rbp)
movl 0xab94(%rip), %eax      # 0x1f4d0
movl %eax, -0x50(%rbp)
movq -0x10(%rbp), %rdi
leaq -0x60(%rbp), %rsi
addq $0x1, %rsi
movl $0x13, %edx
movl $0x2, %ecx
callq 0x16a80
movq -0x28(%rbp), %rdi
leaq -0x38(%rbp), %rsi
leaq -0x48(%rbp), %rdx
callq 0xa320
movq %rax, -0x28(%rbp)
cmpq $0x0, %rax
je 0x149e5
leaq -0x60(%rbp), %rsi
leaq -0x38(%rbp), %rdi
callq 0x8ad0
cmpl $0x0, %eax
jne 0x149e0
movq -0x10(%rbp), %rdi
movl $0x12d, %esi            # imm = 0x12D
xorl %eax, %eax
movl %eax, %edx
callq 0x11c20
movq -0x10(%rbp), %rdi
movq -0x40(%rbp), %rax
movl %eax, %edx
movq -0x48(%rbp), %rcx
movq -0x18(%rbp), %rax
movq 0x40(%rax), %rax
movq -0x18(%rbp), %rsi
movq 0x30(%rsi), %rsi
subq %rsi, %rax
subq $0x1, %rax
movl %eax, %r8d
movq -0x18(%rbp), %rax
movq 0x30(%rax), %r9
leaq 0xbb97(%rip), %rsi      # 0x20567
movb $0x0, %al
callq 0xb2f0
movl $0x1, -0x4(%rbp)
jmp 0x149ec
jmp 0x1495a
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_basic_auth_header
void mg_basic_auth_header(const struct mg_str user, const struct mg_str pass,
                          struct mbuf *buf) {
  const char *header_prefix = "Authorization: Basic ";
  const char *header_suffix = "\r\n";

  struct cs_base64_ctx ctx;
  cs_base64_init(&ctx, mg_mbuf_append_base64_putc, buf);

  mbuf_append(buf, header_prefix, strlen(header_prefix));

  cs_base64_update(&ctx, user.p, user.len);
  if (pass.len > 0) {
    cs_base64_update(&ctx, ":", 1);
    cs_base64_update(&ctx, pass.p, pass.len);
  }
  cs_base64_finish(&ctx);
  mbuf_append(buf, header_suffix, strlen(header_suffix));
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x8(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x18(%rbp)
movq %r8, -0x28(%rbp)
leaq 0xa7d6(%rip), %rax      # 0x20079
movq %rax, -0x30(%rbp)
leaq 0xaefb(%rip), %rax      # 0x207a9
movq %rax, -0x38(%rbp)
movq -0x28(%rbp), %rdx
leaq -0x50(%rbp), %rdi
leaq 0x15af(%rip), %rsi      # 0x16e70
callq 0x48b0
movq -0x28(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x30(%rbp), %rdi
callq 0x3180
movq -0x60(%rbp), %rdi
movq -0x58(%rbp), %rsi
movq %rax, %rdx
callq 0x89b0
movq -0x10(%rbp), %rsi
movq -0x8(%rbp), %rdx
leaq -0x50(%rbp), %rdi
callq 0x48f0
cmpq $0x0, -0x18(%rbp)
jbe 0x1592d
leaq -0x50(%rbp), %rdi
leaq 0xa019(%rip), %rsi      # 0x1f92b
movl $0x1, %edx
callq 0x48f0
movq -0x20(%rbp), %rsi
movq -0x18(%rbp), %rdx
leaq -0x50(%rbp), %rdi
callq 0x48f0
leaq -0x50(%rbp), %rdi
callq 0x4a20
movq -0x28(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x38(%rbp), %rdi
callq 0x3180
movq -0x70(%rbp), %rdi
movq -0x68(%rbp), %rsi
movq %rax, %rdx
callq 0x89b0
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_connect_http
struct mg_connection *mg_connect_http(
    struct mg_mgr *mgr, MG_CB(mg_event_handler_t ev_handler, void *user_data),
    const char *url, const char *extra_headers, const char *post_data) {
  struct mg_connect_opts opts;
  memset(&opts, 0, sizeof(opts));
  return mg_connect_http_opt(mgr, MG_CB(ev_handler, user_data), opts, url,
                             extra_headers, post_data);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
leaq -0x50(%rbp), %rdi
xorl %esi, %esi
movl $0x28, %edx
callq 0x3260
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
movq -0x28(%rbp), %r8
movq -0x30(%rbp), %r9
movq %rsp, %rax
movq %r9, 0x20(%rax)
movups -0x50(%rbp), %xmm0
movups -0x40(%rbp), %xmm1
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
callq 0x155b0
addq $0x80, %rsp
popq %rbp
retq
nopl (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_register_http_endpoint_opt
void mg_register_http_endpoint_opt(struct mg_connection *nc,
                                   const char *uri_path,
                                   mg_event_handler_t handler,
                                   struct mg_http_endpoint_opts opts) {
  struct mg_http_proto_data *pd = NULL;
  struct mg_http_endpoint *new_ep = NULL;

  if (nc == NULL) return;
  new_ep = (struct mg_http_endpoint *) MG_CALLOC(1, sizeof(*new_ep));
  if (new_ep == NULL) return;

  pd = mg_http_get_proto_data(nc);
  new_ep->uri_pattern = mg_strdup(mg_mk_str(uri_path));
  if (opts.auth_domain != NULL && opts.auth_file != NULL) {
    new_ep->auth_domain = strdup(opts.auth_domain);
    new_ep->auth_file = strdup(opts.auth_file);
  }
  new_ep->handler = handler;
#if MG_ENABLE_CALLBACK_USERDATA
  new_ep->user_data = opts.user_data;
#endif
  new_ep->next = pd->endpoints;
  pd->endpoints = new_ep;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
leaq 0x10(%rbp), %rax
movq %rax, -0x50(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
cmpq $0x0, -0x8(%rbp)
jne 0x15cc8
jmp 0x15da6
movl $0x1, %edi
movl $0x30, %esi
callq 0x3330
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x15ce7
jmp 0x15da6
movq -0x8(%rbp), %rdi
callq 0x109b0
movq %rax, -0x20(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x10(%rbp), %rdi
callq 0x8a60
movq %rax, -0x48(%rbp)
movq %rdx, -0x40(%rbp)
movq -0x48(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0x8c90
movq -0x58(%rbp), %rcx
movq %rax, %rsi
movq -0x50(%rbp), %rax
movq %rsi, -0x38(%rbp)
movq %rdx, -0x30(%rbp)
movq -0x38(%rbp), %rdx
movq %rdx, 0x8(%rcx)
movq -0x30(%rbp), %rdx
movq %rdx, 0x10(%rcx)
cmpq $0x0, 0x8(%rax)
je 0x15d7f
movq -0x50(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x15d7f
movq -0x50(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x3640
movq %rax, %rdx
movq -0x50(%rbp), %rax
movq -0x28(%rbp), %rcx
movq %rdx, 0x18(%rcx)
movq 0x10(%rax), %rdi
callq 0x3640
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x18(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x20(%rbp), %rax
movq 0x38(%rax), %rcx
movq -0x28(%rbp), %rax
movq %rcx, (%rax)
movq -0x28(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x38(%rax)
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_send_websocket_frame
void mg_send_websocket_frame(struct mg_connection *nc, int op, const void *data,
                             size_t len) {
  struct ws_mask_ctx ctx;
  DBG(("%p %d %d", nc, op, (int) len));
  mg_send_ws_header(nc, op, len, &ctx);
  mg_send(nc, data, len);

  mg_ws_mask_frame(&nc->send_mbuf, &ctx);

  if (op == WEBSOCKET_OP_CLOSE) {
    nc->flags |= MG_F_SEND_AND_CLOSE;
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movl $0x4, %edi
leaq 0xa16f(%rip), %rsi      # 0x1ffa2
leaq 0x9710(%rip), %rdx      # 0x1f54a
callq 0x4650
cmpl $0x0, %eax
je 0x15e5f
movq -0x8(%rbp), %rsi
movl -0xc(%rbp), %edx
movq -0x20(%rbp), %rax
movl %eax, %ecx
leaq 0x97f9(%rip), %rdi      # 0x1f651
movb $0x0, %al
callq 0x47a0
jmp 0x15e61
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
movq -0x20(%rbp), %rdx
leaq -0x30(%rbp), %rcx
callq 0x15ec0
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rax
movl %eax, %edx
callq 0xb260
movq -0x8(%rbp), %rdi
addq $0x58, %rdi
leaq -0x30(%rbp), %rsi
callq 0x16000
cmpl $0x8, -0xc(%rbp)
jne 0x15eb8
movq -0x8(%rbp), %rax
movq 0xc8(%rax), %rcx
orq $0x400, %rcx            # imm = 0x400
movq %rcx, 0xc8(%rax)
addq $0x30, %rsp
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O0/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_send_ws_header
static void mg_send_ws_header(struct mg_connection *nc, int op, size_t len,
                              struct ws_mask_ctx *ctx) {
  int header_len;
  unsigned char header[10];

  header[0] = (op & WEBSOCKET_DONT_FIN ? 0x0 : 0x80) + (op & 0x0f);
  if (len < 126) {
    header[1] = (unsigned char) len;
    header_len = 2;
  } else if (len < 65535) {
    uint16_t tmp = htons((uint16_t) len);
    header[1] = 126;
    memcpy(&header[2], &tmp, sizeof(tmp));
    header_len = 4;
  } else {
    uint32_t tmp;
    header[1] = 127;
    tmp = htonl((uint32_t)((uint64_t) len >> 32));
    memcpy(&header[2], &tmp, sizeof(tmp));
    tmp = htonl((uint32_t)(len & 0xffffffff));
    memcpy(&header[6], &tmp, sizeof(tmp));
    header_len = 10;
  }

  /* client connections enable masking */
  if (nc->listener == NULL) {
    header[1] |= 1 << 7; /* set masking flag */
    mg_send(nc, header, header_len);
    ctx->mask = mg_ws_random_mask();
    mg_send(nc, &ctx->mask, sizeof(ctx->mask));
    ctx->pos = nc->send_mbuf.len;
  } else {
    mg_send(nc, header, header_len);
    ctx->pos = 0;
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movl -0xc(%rbp), %edx
andl $0x100, %edx            # imm = 0x100
movl $0x80, %eax
xorl %ecx, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
movl -0xc(%rbp), %ecx
andl $0xf, %ecx
addl %ecx, %eax
movb %al, -0x2e(%rbp)
cmpq $0x7e, -0x18(%rbp)
jae 0x15f0f
movq -0x18(%rbp), %rax
movb %al, -0x2d(%rbp)
movl $0x2, -0x24(%rbp)
jmp 0x15f81
cmpq $0xffff, -0x18(%rbp)    # imm = 0xFFFF
jae 0x15f3e
movq -0x18(%rbp), %rax
movzwl %ax, %edi
callq 0x31a0
movw %ax, -0x30(%rbp)
movb $0x7e, -0x2d(%rbp)
movw -0x30(%rbp), %ax
movw %ax, -0x2c(%rbp)
movl $0x4, -0x24(%rbp)
jmp 0x15f7f
movb $0x7f, -0x2d(%rbp)
movq -0x18(%rbp), %rax
shrq $0x20, %rax
movl %eax, %edi
callq 0x3250
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %eax
movl %eax, -0x2c(%rbp)
movabsq $0xffffffff, %rax       # imm = 0xFFFFFFFF
andq -0x18(%rbp), %rax
movl %eax, %edi
callq 0x3250
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %eax
movl %eax, -0x28(%rbp)
movl $0xa, -0x24(%rbp)
jmp 0x15f81
movq -0x8(%rbp), %rax
cmpq $0x0, 0x10(%rax)
jne 0x15fdd
movzbl -0x2d(%rbp), %eax
orl $0x80, %eax
movb %al, -0x2d(%rbp)
movq -0x8(%rbp), %rdi
leaq -0x2e(%rbp), %rsi
movl -0x24(%rbp), %edx
callq 0xb260
callq 0x16680
movl %eax, %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
addq $0x8, %rsi
movl $0x4, %edx
callq 0xb260
movq -0x8(%rbp), %rax
movq 0x60(%rax), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
jmp 0x15ff8
movq -0x8(%rbp), %rdi
leaq -0x2e(%rbp), %rsi
movl -0x24(%rbp), %edx
callq 0xb260
movq -0x20(%rbp), %rax
movq $0x0, (%rax)
addq $0x40, %rsp
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O0/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_ws_mask_frame
static void mg_ws_mask_frame(struct mbuf *mbuf, struct ws_mask_ctx *ctx) {
  size_t i;
  if (ctx->pos == 0) return;
  for (i = 0; i < (mbuf->len - ctx->pos); i++) {
    mbuf->buf[ctx->pos + i] ^= ((char *) &ctx->mask)[i % 4];
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x16018
jmp 0x16072
movq $0x0, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq -0x8(%rbp), %rcx
movq 0x8(%rcx), %rcx
movq -0x10(%rbp), %rdx
subq (%rdx), %rcx
cmpq %rcx, %rax
jae 0x16072
movq -0x10(%rbp), %rax
movq -0x18(%rbp), %rcx
andq $0x3, %rcx
movsbl 0x8(%rax,%rcx), %esi
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
addq -0x18(%rbp), %rcx
movsbl (%rax,%rcx), %edx
xorl %esi, %edx
movb %dl, (%rax,%rcx)
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0x16020
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_send_websocket_framev
void mg_send_websocket_framev(struct mg_connection *nc, int op,
                              const struct mg_str *strv, int strvcnt) {
  struct ws_mask_ctx ctx;
  int i;
  int len = 0;
  for (i = 0; i < strvcnt; i++) {
    len += strv[i].len;
  }

  mg_send_ws_header(nc, op, len, &ctx);

  for (i = 0; i < strvcnt; i++) {
    mg_send(nc, strv[i].p, strv[i].len);
  }

  mg_ws_mask_frame(&nc->send_mbuf, &ctx);

  if (op == WEBSOCKET_OP_CLOSE) {
    nc->flags |= MG_F_SEND_AND_CLOSE;
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movl $0x0, -0x38(%rbp)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x160d4
movq -0x18(%rbp), %rax
movslq -0x34(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rcx
movslq -0x38(%rbp), %rax
addq %rcx, %rax
movl %eax, -0x38(%rbp)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x160a4
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
movslq -0x38(%rbp), %rdx
leaq -0x30(%rbp), %rcx
callq 0x15ec0
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x16132
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movslq -0x34(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rsi
movq -0x18(%rbp), %rax
movslq -0x34(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movl %eax, %edx
callq 0xb260
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x160ef
movq -0x8(%rbp), %rdi
addq $0x58, %rdi
leaq -0x30(%rbp), %rsi
callq 0x16000
cmpl $0x8, -0xc(%rbp)
jne 0x16162
movq -0x8(%rbp), %rax
movq 0xc8(%rax), %rcx
orq $0x400, %rcx            # imm = 0x400
movq %rcx, 0xc8(%rax)
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_printf_websocket_frame
void mg_printf_websocket_frame(struct mg_connection *nc, int op,
                               const char *fmt, ...) {
  char mem[MG_VPRINTF_BUFFER_SIZE], *buf = mem;
  va_list ap;
  int len;

  va_start(ap, fmt);
  if ((len = mg_avprintf(&buf, sizeof(mem), fmt, ap)) > 0) {
    mg_send_websocket_frame(nc, op, buf, len);
  }
  va_end(ap);

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

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x160, %rsp            # imm = 0x160
testb %al, %al
je 0x161b7
movaps %xmm0, -0x130(%rbp)
movaps %xmm1, -0x120(%rbp)
movaps %xmm2, -0x110(%rbp)
movaps %xmm3, -0x100(%rbp)
movaps %xmm4, -0xf0(%rbp)
movaps %xmm5, -0xe0(%rbp)
movaps %xmm6, -0xd0(%rbp)
movaps %xmm7, -0xc0(%rbp)
movq %r9, -0x138(%rbp)
movq %r8, -0x140(%rbp)
movq %rcx, -0x148(%rbp)
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
leaq -0x80(%rbp), %rax
movq %rax, -0x88(%rbp)
leaq -0xa0(%rbp), %rax
leaq -0x160(%rbp), %rcx
movq %rcx, 0x10(%rax)
leaq 0x10(%rbp), %rcx
movq %rcx, 0x8(%rax)
movl $0x30, 0x4(%rax)
movl $0x18, (%rax)
movq -0x18(%rbp), %rdx
leaq -0xa0(%rbp), %rcx
leaq -0x88(%rbp), %rdi
movl $0x64, %esi
callq 0xa1a0
movl %eax, -0xa4(%rbp)
cmpl $0x0, %eax
jle 0x1624a
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
movq -0x88(%rbp), %rdx
movslq -0xa4(%rbp), %rcx
callq 0x15e10
leaq -0xa0(%rbp), %rax
movq -0x88(%rbp), %rax
leaq -0x80(%rbp), %rcx
cmpq %rcx, %rax
je 0x16277
cmpq $0x0, -0x88(%rbp)
je 0x16277
movq -0x88(%rbp), %rdi
callq 0x3050
addq $0x160, %rsp            # imm = 0x160
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O0/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_hash_sha1_v
void mg_hash_sha1_v(size_t num_msgs, const uint8_t *msgs[],
                    const size_t *msg_lens, uint8_t *digest) {
  size_t i;
  cs_sha1_ctx sha_ctx;
  cs_sha1_init(&sha_ctx);
  for (i = 0; i < num_msgs; i++) {
    cs_sha1_update(&sha_ctx, msgs[i], msg_lens[i]);
  }
  cs_sha1_final(digest, &sha_ctx);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
leaq -0x84(%rbp), %rdi
callq 0x81c0
movq $0x0, -0x28(%rbp)
movq -0x28(%rbp), %rax
cmpq -0x8(%rbp), %rax
jae 0x162ed
movq -0x10(%rbp), %rax
movq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
movq -0x18(%rbp), %rax
movq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl %eax, %edx
leaq -0x84(%rbp), %rdi
callq 0x8220
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
jmp 0x162af
movq -0x20(%rbp), %rdi
leaq -0x84(%rbp), %rsi
callq 0x8330
addq $0x90, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_send_websocket_handshake
void mg_send_websocket_handshake(struct mg_connection *nc, const char *path,
                                 const char *extra_headers) {
  struct mg_str null_str = MG_NULL_STR;
  mg_send_websocket_handshake3v(
      nc, mg_mk_str(path), null_str /* host */, null_str /* protocol */,
      mg_mk_str(extra_headers), null_str /* user */, null_str /* pass */);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
leaq -0x28(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x3260
movq -0x8(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x10(%rbp), %rdi
callq 0x8a60
movq %rax, -0x38(%rbp)
movq %rdx, -0x30(%rbp)
movq -0x18(%rbp), %rdi
callq 0x8a60
movq -0x50(%rbp), %rdi
movq %rax, -0x48(%rbp)
movq %rdx, -0x40(%rbp)
movq -0x38(%rbp), %rsi
movq -0x30(%rbp), %rdx
movq -0x28(%rbp), %rcx
movq -0x20(%rbp), %r8
leaq -0x28(%rbp), %rax
leaq -0x48(%rbp), %r9
movq (%rax), %r10
movq %r10, (%rsp)
movq 0x8(%rax), %r10
movq %r10, 0x8(%rsp)
movq (%r9), %r10
movq %r10, 0x10(%rsp)
movq 0x8(%r9), %r9
movq %r9, 0x18(%rsp)
movq (%rax), %r9
movq %r9, 0x20(%rsp)
movq 0x8(%rax), %r9
movq %r9, 0x28(%rsp)
movq (%rax), %r9
movq %r9, 0x30(%rsp)
movq 0x8(%rax), %rax
movq %rax, 0x38(%rsp)
callq 0x16490
addq $0x90, %rsp
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O0/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_connect_ws_opt
struct mg_connection *mg_connect_ws_opt(
    struct mg_mgr *mgr, MG_CB(mg_event_handler_t ev_handler, void *user_data),
    struct mg_connect_opts opts, const char *url, const char *protocol,
    const char *extra_headers) {
  struct mg_str null_str = MG_NULL_STR;
  struct mg_str host = MG_NULL_STR, path = MG_NULL_STR, user_info = MG_NULL_STR;
  struct mg_connection *nc =
      mg_connect_http_base(mgr, MG_CB(ev_handler, user_data), opts, "http",
                           "ws", "https", "wss", url, &path, &user_info, &host);
  if (nc != NULL) {
    mg_send_websocket_handshake3v(nc, path, host, mg_mk_str(protocol),
                                  mg_mk_str(extra_headers), user_info,
                                  null_str);
  }
  return nc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
subq $0xe8, %rsp
leaq 0x10(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
leaq -0x40(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x3260
leaq -0x50(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x3260
leaq -0x60(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x3260
leaq -0x70(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x3260
movq -0xa0(%rbp), %rdx
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rcx
movq 0x20(%rdx), %r8
movq %rsp, %rax
movq %r8, 0x20(%rax)
movups (%rdx), %xmm0
movups 0x10(%rdx), %xmm1
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
leaq -0x50(%rbp), %rdx
movq %rdx, 0x40(%rax)
leaq -0x70(%rbp), %rdx
movq %rdx, 0x38(%rax)
leaq -0x60(%rbp), %rdx
movq %rdx, 0x30(%rax)
movq %rcx, 0x28(%rax)
leaq 0x9584(%rip), %rdx      # 0x1fdce
leaq 0x97fb(%rip), %rcx      # 0x2004c
leaq 0x957b(%rip), %r8       # 0x1fdd3
leaq 0x97f0(%rip), %r9       # 0x2004f
callq 0x141f0
movq %rax, -0x78(%rbp)
cmpq $0x0, -0x78(%rbp)
je 0x1691e
movq -0x78(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq -0x28(%rbp), %rdi
callq 0x8a60
movq %rax, -0x88(%rbp)
movq %rdx, -0x80(%rbp)
movq -0x30(%rbp), %rdi
callq 0x8a60
movq -0xa8(%rbp), %rdi
movq %rax, -0x98(%rbp)
movq %rdx, -0x90(%rbp)
movq -0x60(%rbp), %rsi
movq -0x58(%rbp), %rdx
movq -0x50(%rbp), %rcx
movq -0x48(%rbp), %r8
leaq -0x88(%rbp), %r11
leaq -0x98(%rbp), %r10
leaq -0x70(%rbp), %r9
leaq -0x40(%rbp), %rax
movq (%r11), %rbx
movq %rbx, (%rsp)
movq 0x8(%r11), %r11
movq %r11, 0x8(%rsp)
movq (%r10), %r11
movq %r11, 0x10(%rsp)
movq 0x8(%r10), %r10
movq %r10, 0x18(%rsp)
movq (%r9), %r10
movq %r10, 0x20(%rsp)
movq 0x8(%r9), %r9
movq %r9, 0x28(%rsp)
movq (%rax), %r9
movq %r9, 0x30(%rsp)
movq 0x8(%rax), %rax
movq %rax, 0x38(%rsp)
callq 0x16490
movq -0x78(%rbp), %rax
addq $0xe8, %rsp
popq %rbx
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_conn_addr_to_str
int mg_conn_addr_to_str(struct mg_connection *nc, char *buf, size_t len,
                        int flags) {
  union socket_address sa;
  memset(&sa, 0, sizeof(sa));
  mg_if_get_conn_addr(nc, flags & MG_SOCK_STRINGIFY_REMOTE, &sa);
  return mg_sock_addr_to_str(&sa, buf, len, flags);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
leaq -0x2c(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x3260
movq -0x8(%rbp), %rdi
movl -0x1c(%rbp), %esi
andl $0x4, %esi
leaq -0x2c(%rbp), %rdx
callq 0xd360
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movl -0x1c(%rbp), %ecx
leaq -0x2c(%rbp), %rdi
callq 0xeec0
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_hexdumpf
void mg_hexdumpf(FILE *fp, const void *buf, int len) {
  char tmp[80];
  int offset = 0, n;
  while (len > 0) {
    n = (len < 16 ? len : 16);
    mg_hexdump_n(((const char *) buf) + offset, n, tmp, sizeof(tmp), offset);
    fputs(tmp, fp);
    offset += n;
    len -= n;
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl $0x0, -0x74(%rbp)
cmpl $0x0, -0x14(%rbp)
jle 0x16e44
cmpl $0x10, -0x14(%rbp)
jge 0x16df1
movl -0x14(%rbp), %eax
movl %eax, -0x7c(%rbp)
jmp 0x16dfb
movl $0x10, %eax
movl %eax, -0x7c(%rbp)
jmp 0x16dfb
movl -0x7c(%rbp), %eax
movl %eax, -0x78(%rbp)
movq -0x10(%rbp), %rdi
movslq -0x74(%rbp), %rax
addq %rax, %rdi
movl -0x78(%rbp), %esi
leaq -0x70(%rbp), %rdx
movl -0x74(%rbp), %r8d
movl $0x50, %ecx
callq 0x16ae0
leaq -0x70(%rbp), %rdi
movq -0x8(%rbp), %rsi
callq 0x3240
movl -0x78(%rbp), %eax
addl -0x74(%rbp), %eax
movl %eax, -0x74(%rbp)
movl -0x78(%rbp), %ecx
movl -0x14(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x14(%rbp)
jmp 0x16ddd
addq $0x80, %rsp
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_mbuf_append_base64
void mg_mbuf_append_base64(struct mbuf *mbuf, const void *data, size_t len) {
  struct cs_base64_ctx ctx;
  cs_base64_init(&ctx, mg_mbuf_append_base64_putc, mbuf);
  cs_base64_update(&ctx, (const char *) data, len);
  cs_base64_finish(&ctx);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rdx
leaq -0x30(%rbp), %rdi
leaq -0x63(%rip), %rsi       # 0x16e70
callq 0x48b0
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
leaq -0x30(%rbp), %rdi
callq 0x48f0
leaq -0x30(%rbp), %rdi
callq 0x4a20
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_url_encode
struct mg_str mg_url_encode(const struct mg_str src) {
  static const char *dont_escape = "._-$,;~()/";
  static const char *hex = "0123456789abcdef";
  size_t i = 0;
  struct mbuf mb;
  mbuf_init(&mb, src.len);

  for (i = 0; i < src.len; i++) {
    const unsigned char c = *((const unsigned char *) src.p + i);
    if (isalnum(c) || strchr(dont_escape, c) != NULL) {
      mbuf_append(&mb, &c, 1);
    } else {
      mbuf_append(&mb, "%", 1);
      mbuf_append(&mb, &hex[c >> 4], 1);
      mbuf_append(&mb, &hex[c & 15], 1);
    }
  }
  mbuf_append(&mb, "", 1);
  mbuf_trim(&mb);
  return mg_mk_str_n(mb.buf, mb.len - 1);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x20(%rbp)
movq %rsi, -0x18(%rbp)
movq $0x0, -0x28(%rbp)
movq -0x18(%rbp), %rsi
leaq -0x40(%rbp), %rdi
callq 0x8610
movq $0x0, -0x28(%rbp)
movq -0x28(%rbp), %rax
cmpq -0x18(%rbp), %rax
jae 0x16ff8
movq -0x20(%rbp), %rax
movq -0x28(%rbp), %rcx
movb (%rax,%rcx), %al
movb %al, -0x41(%rbp)
callq 0x36a0
movq (%rax), %rax
movzbl -0x41(%rbp), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x8, %eax
cmpl $0x0, %eax
jne 0x16f7a
movq 0x1045d(%rip), %rdi     # 0x273c8
movzbl -0x41(%rbp), %esi
callq 0x31e0
cmpq $0x0, %rax
je 0x16f8e
leaq -0x40(%rbp), %rdi
leaq -0x41(%rbp), %rsi
movl $0x1, %edx
callq 0x89b0
jmp 0x16fe5
leaq -0x40(%rbp), %rdi
leaq 0x9101(%rip), %rsi      # 0x2009a
movl $0x1, %edx
callq 0x89b0
movq 0x10426(%rip), %rsi     # 0x273d0
movzbl -0x41(%rbp), %eax
sarl $0x4, %eax
cltq
addq %rax, %rsi
leaq -0x40(%rbp), %rdi
movl $0x1, %edx
callq 0x89b0
movq 0x10405(%rip), %rsi     # 0x273d0
movzbl -0x41(%rbp), %eax
andl $0xf, %eax
cltq
addq %rax, %rsi
leaq -0x40(%rbp), %rdi
movl $0x1, %edx
callq 0x89b0
jmp 0x16fe7
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
jmp 0x16f2d
leaq 0x97ac(%rip), %rsi      # 0x207ab
leaq -0x40(%rbp), %rdi
movq %rdi, -0x50(%rbp)
movl $0x1, %edx
callq 0x89b0
movq -0x50(%rbp), %rdi
callq 0x8720
movq -0x40(%rbp), %rdi
movq -0x38(%rbp), %rsi
decq %rsi
callq 0x8aa0
movq %rax, -0x10(%rbp)
movq %rdx, -0x8(%rbp)
movq -0x10(%rbp), %rax
movq -0x8(%rbp), %rdx
addq $0x50, %rsp
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O0/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_mqtt_match_topic_expression
int mg_mqtt_match_topic_expression(struct mg_str exp, struct mg_str topic) {
  /* TODO(mkm): implement real matching */
  if (memchr(exp.p, '#', exp.len)) {
    /* exp `foo/#` will become `foo/` */
    exp.len -= 1;
    /*
     * topic should be longer than the expression: e.g. topic `foo/bar` does
     * match `foo/#`, but neither `foo` nor `foo/` do.
     */
    if (topic.len <= exp.len) {
      return 0;
    }

    /* Truncate topic so that it'll pass the next length check */
    topic.len = exp.len;
  }
  if (topic.len != exp.len) {
    return 0;
  }
  return strncmp(topic.p, exp.p, exp.len) == 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x18(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x28(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rdx
movl $0x23, %esi
callq 0x32e0
cmpq $0x0, %rax
je 0x17097
movq -0x10(%rbp), %rax
subq $0x1, %rax
movq %rax, -0x10(%rbp)
movq -0x20(%rbp), %rax
cmpq -0x10(%rbp), %rax
ja 0x1708f
movl $0x0, -0x4(%rbp)
jmp 0x170c9
movq -0x10(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
cmpq -0x10(%rbp), %rax
je 0x170aa
movl $0x0, -0x4(%rbp)
jmp 0x170c9
movq -0x28(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x10(%rbp), %rdx
callq 0x30b0
cmpl $0x0, %eax
sete %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_mqtt_prepend_header
static void mg_mqtt_prepend_header(struct mg_connection *nc, uint8_t cmd,
                                   uint8_t flags, size_t len) {
  struct mg_mqtt_proto_data *pd = (struct mg_mqtt_proto_data *) nc->proto_data;
  size_t off = nc->send_mbuf.len - len;
  uint8_t header = cmd << 4 | (uint8_t) flags;

  uint8_t buf[1 + sizeof(size_t)];
  uint8_t *vlen = &buf[1];

  assert(nc->send_mbuf.len >= len);

  buf[0] = header;

  /* mqtt variable length encoding */
  do {
    *vlen = len % 0x80;
    len /= 0x80;
    if (len > 0) *vlen |= 0x80;
    vlen++;
  } while (len > 0);

  mbuf_insert(&nc->send_mbuf, off, buf, vlen - buf);
  pd->last_control_time = mg_time();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movb %dl, %al
movb %sil, %dl
movq %rdi, -0x8(%rbp)
movb %dl, -0x9(%rbp)
movb %al, -0xa(%rbp)
movq %rcx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq 0x88(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq 0x60(%rax), %rax
subq -0x18(%rbp), %rax
movq %rax, -0x28(%rbp)
movzbl -0x9(%rbp), %eax
shll $0x4, %eax
movzbl -0xa(%rbp), %ecx
orl %ecx, %eax
movb %al, -0x29(%rbp)
leaq -0x32(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rax
movq 0x60(%rax), %rax
cmpq -0x18(%rbp), %rax
jb 0x17766
jmp 0x17785
leaq 0x9f19(%rip), %rdi      # 0x21686
leaq 0x7dd6(%rip), %rsi      # 0x1f54a
movl $0x28de, %edx           # imm = 0x28DE
leaq 0x9f1f(%rip), %rcx      # 0x2169f
callq 0x3230
movb -0x29(%rbp), %al
movb %al, -0x32(%rbp)
movq -0x18(%rbp), %rax
andq $0x7f, %rax
movb %al, %cl
movq -0x40(%rbp), %rax
movb %cl, (%rax)
movq -0x18(%rbp), %rax
shrq $0x7, %rax
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jbe 0x177bd
movq -0x40(%rbp), %rax
movzbl (%rax), %ecx
orl $0x80, %ecx
movb %cl, (%rax)
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x18(%rbp)
ja 0x1778b
movq -0x8(%rbp), %rdi
addq $0x58, %rdi
movq -0x28(%rbp), %rsi
leaq -0x32(%rbp), %rdx
movq -0x40(%rbp), %rcx
leaq -0x32(%rbp), %rax
subq %rax, %rcx
callq 0x8750
callq 0xb6e0
movq -0x20(%rbp), %rax
movsd %xmm0, 0x8(%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_mqtt_publish
void mg_mqtt_publish(struct mg_connection *nc, const char *topic,
                     uint16_t message_id, int flags, const void *data,
                     size_t len) {
  size_t old_len = nc->send_mbuf.len;

  uint16_t topic_len = htons((uint16_t) strlen(topic));
  uint16_t message_id_net = htons(message_id);

  mg_send(nc, &topic_len, 2);
  mg_send(nc, topic, strlen(topic));
  if (MG_MQTT_GET_QOS(flags) > 0) {
    mg_send(nc, &message_id_net, 2);
  }
  mg_send(nc, data, len);

  mg_mqtt_prepend_header(nc, MG_MQTT_CMD_PUBLISH, flags,
                         nc->send_mbuf.len - old_len);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movw %dx, %ax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movw %ax, -0x12(%rbp)
movl %ecx, -0x18(%rbp)
movq %r8, -0x20(%rbp)
movq %r9, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq 0x60(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rdi
callq 0x3180
movzwl %ax, %edi
callq 0x31a0
movw %ax, -0x32(%rbp)
movzwl -0x12(%rbp), %edi
callq 0x31a0
movw %ax, -0x34(%rbp)
movq -0x8(%rbp), %rdi
leaq -0x32(%rbp), %rsi
movl $0x2, %edx
callq 0xb260
movq -0x8(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rdi
callq 0x3180
movq -0x48(%rbp), %rdi
movq -0x40(%rbp), %rsi
movl %eax, %edx
callq 0xb260
movl -0x18(%rbp), %eax
andl $0x6, %eax
sarl %eax
cmpl $0x0, %eax
jle 0x178b9
movq -0x8(%rbp), %rdi
leaq -0x34(%rbp), %rsi
movl $0x2, %edx
callq 0xb260
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x28(%rbp), %rax
movl %eax, %edx
callq 0xb260
movq -0x8(%rbp), %rdi
movl -0x18(%rbp), %eax
movq -0x8(%rbp), %rcx
movq 0x60(%rcx), %rcx
subq -0x30(%rbp), %rcx
movl $0x3, %esi
movzbl %al, %edx
callq 0x17700
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_mqtt_subscribe
void mg_mqtt_subscribe(struct mg_connection *nc,
                       const struct mg_mqtt_topic_expression *topics,
                       size_t topics_len, uint16_t message_id) {
  size_t old_len = nc->send_mbuf.len;

  uint16_t message_id_n = htons(message_id);
  size_t i;

  mg_send(nc, (char *) &message_id_n, 2);
  for (i = 0; i < topics_len; i++) {
    uint16_t topic_len_n = htons((uint16_t) strlen(topics[i].topic));
    mg_send(nc, &topic_len_n, 2);
    mg_send(nc, topics[i].topic, strlen(topics[i].topic));
    mg_send(nc, &topics[i].qos, 1);
  }

  mg_mqtt_prepend_header(nc, MG_MQTT_CMD_SUBSCRIBE, MG_MQTT_QOS(1),
                         nc->send_mbuf.len - old_len);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movw %cx, %ax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movw %ax, -0x1a(%rbp)
movq -0x8(%rbp), %rax
movq 0x60(%rax), %rax
movq %rax, -0x28(%rbp)
movzwl -0x1a(%rbp), %edi
callq 0x31a0
movw %ax, -0x2a(%rbp)
movq -0x8(%rbp), %rdi
leaq -0x2a(%rbp), %rsi
movl $0x2, %edx
callq 0xb260
movq $0x0, -0x38(%rbp)
movq -0x38(%rbp), %rax
cmpq -0x18(%rbp), %rax
jae 0x17a07
movq -0x10(%rbp), %rax
movq -0x38(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rdi
callq 0x3180
movzwl %ax, %edi
callq 0x31a0
movw %ax, -0x3a(%rbp)
movq -0x8(%rbp), %rdi
leaq -0x3a(%rbp), %rsi
movl $0x2, %edx
callq 0xb260
movq -0x8(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x10(%rbp), %rax
movq -0x38(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rax
movq -0x38(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rdi
callq 0x3180
movq -0x50(%rbp), %rdi
movq -0x48(%rbp), %rsi
movl %eax, %edx
callq 0xb260
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x38(%rbp), %rax
shlq $0x4, %rax
addq %rax, %rsi
addq $0x8, %rsi
movl $0x1, %edx
callq 0xb260
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x1794e
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x60(%rax), %rcx
subq -0x28(%rbp), %rcx
movl $0x8, %esi
movl $0x2, %edx
callq 0x17700
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_mqtt_next_subscribe_topic
int mg_mqtt_next_subscribe_topic(struct mg_mqtt_message *msg,
                                 struct mg_str *topic, uint8_t *qos, int pos) {
  unsigned char *buf = (unsigned char *) msg->payload.p + pos;
  int new_pos;

  if ((size_t) pos >= msg->payload.len) return -1;

  topic->len = buf[0] << 8 | buf[1];
  topic->p = (char *) buf + 2;
  new_pos = pos + 2 + topic->len + 1;
  if ((size_t) new_pos > msg->payload.len) return -1;
  *qos = buf[2 + topic->len];
  return new_pos;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x24(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movslq -0x24(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x28(%rcx), %rax
jb 0x17a6d
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x17ae8
movq -0x30(%rbp), %rax
movzbl (%rax), %eax
shll $0x8, %eax
movq -0x30(%rbp), %rcx
movzbl 0x1(%rcx), %ecx
orl %ecx, %eax
movslq %eax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x30(%rbp), %rcx
addq $0x2, %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movl -0x24(%rbp), %eax
addl $0x2, %eax
cltq
movq -0x18(%rbp), %rcx
addq 0x8(%rcx), %rax
addq $0x1, %rax
movl %eax, -0x34(%rbp)
movslq -0x34(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x28(%rcx), %rax
jbe 0x17ac9
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x17ae8
movq -0x30(%rbp), %rax
movq -0x18(%rbp), %rcx
movq 0x8(%rcx), %rcx
addq $0x2, %rcx
movb (%rax,%rcx), %cl
movq -0x20(%rbp), %rax
movb %cl, (%rax)
movl -0x34(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_mqtt_unsubscribe
void mg_mqtt_unsubscribe(struct mg_connection *nc, char **topics,
                         size_t topics_len, uint16_t message_id) {
  size_t old_len = nc->send_mbuf.len;

  uint16_t message_id_n = htons(message_id);
  size_t i;

  mg_send(nc, (char *) &message_id_n, 2);
  for (i = 0; i < topics_len; i++) {
    uint16_t topic_len_n = htons((uint16_t) strlen(topics[i]));
    mg_send(nc, &topic_len_n, 2);
    mg_send(nc, topics[i], strlen(topics[i]));
  }

  mg_mqtt_prepend_header(nc, MG_MQTT_CMD_UNSUBSCRIBE, MG_MQTT_QOS(1),
                         nc->send_mbuf.len - old_len);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movw %cx, %ax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movw %ax, -0x1a(%rbp)
movq -0x8(%rbp), %rax
movq 0x60(%rax), %rax
movq %rax, -0x28(%rbp)
movzwl -0x1a(%rbp), %edi
callq 0x31a0
movw %ax, -0x2a(%rbp)
movq -0x8(%rbp), %rdi
leaq -0x2a(%rbp), %rsi
movl $0x2, %edx
callq 0xb260
movq $0x0, -0x38(%rbp)
movq -0x38(%rbp), %rax
cmpq -0x18(%rbp), %rax
jae 0x17bbd
movq -0x10(%rbp), %rax
movq -0x38(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x3180
movzwl %ax, %edi
callq 0x31a0
movw %ax, -0x3a(%rbp)
movq -0x8(%rbp), %rdi
leaq -0x3a(%rbp), %rsi
movl $0x2, %edx
callq 0xb260
movq -0x8(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x10(%rbp), %rax
movq -0x38(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rax
movq -0x38(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x3180
movq -0x50(%rbp), %rdi
movq -0x48(%rbp), %rsi
movl %eax, %edx
callq 0xb260
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x17b3e
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x60(%rax), %rcx
subq -0x28(%rbp), %rcx
movl $0xa, %esi
movl $0x2, %edx
callq 0x17700
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_mqtt_connack
void mg_mqtt_connack(struct mg_connection *nc, uint8_t return_code) {
  uint8_t unused = 0;
  mg_send(nc, &unused, 1);
  mg_send(nc, &return_code, 1);
  mg_mqtt_prepend_header(nc, MG_MQTT_CMD_CONNACK, 0, 2);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movb %sil, %al
movq %rdi, -0x8(%rbp)
movb %al, -0x9(%rbp)
movb $0x0, -0xa(%rbp)
movq -0x8(%rbp), %rdi
leaq -0xa(%rbp), %rsi
movl $0x1, %edx
callq 0xb260
movq -0x8(%rbp), %rdi
leaq -0x9(%rbp), %rsi
movl $0x1, %edx
callq 0xb260
movq -0x8(%rbp), %rdi
movl $0x2, %esi
xorl %edx, %edx
movl $0x2, %ecx
callq 0x17700
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_send_mqtt_short_command
static void mg_send_mqtt_short_command(struct mg_connection *nc, uint8_t cmd,
                                       uint16_t message_id) {
  uint16_t message_id_net = htons(message_id);
  uint8_t flags = (cmd == MG_MQTT_CMD_PUBREL ? 2 : 0);
  mg_send(nc, &message_id_net, 2);
  mg_mqtt_prepend_header(nc, cmd, flags, 2 /* len */);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movw %dx, %ax
movb %sil, %cl
movq %rdi, -0x8(%rbp)
movb %cl, -0x9(%rbp)
movw %ax, -0xc(%rbp)
movzwl -0xc(%rbp), %edi
callq 0x31a0
movw %ax, -0xe(%rbp)
movzbl -0x9(%rbp), %edx
xorl %eax, %eax
movl $0x2, %ecx
cmpl $0x6, %edx
cmovel %ecx, %eax
movb %al, -0xf(%rbp)
movq -0x8(%rbp), %rdi
leaq -0xe(%rbp), %rsi
movl $0x2, %edx
callq 0xb260
movq -0x8(%rbp), %rdi
movb -0x9(%rbp), %al
movl $0x2, %ecx
movzbl %al, %esi
movzbl -0xf(%rbp), %edx
callq 0x17700
addq $0x10, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_mqtt_suback
void mg_mqtt_suback(struct mg_connection *nc, uint8_t *qoss, size_t qoss_len,
                    uint16_t message_id) {
  size_t i;
  uint16_t message_id_net = htons(message_id);
  mg_send(nc, &message_id_net, 2);
  for (i = 0; i < qoss_len; i++) {
    mg_send(nc, &qoss[i], 1);
  }
  mg_mqtt_prepend_header(nc, MG_MQTT_CMD_SUBACK, MG_MQTT_QOS(1), 2 + qoss_len);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movw %cx, %ax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movw %ax, -0x1a(%rbp)
movzwl -0x1a(%rbp), %edi
callq 0x31a0
movw %ax, -0x2a(%rbp)
movq -0x8(%rbp), %rdi
leaq -0x2a(%rbp), %rsi
movl $0x2, %edx
callq 0xb260
movq $0x0, -0x28(%rbp)
movq -0x28(%rbp), %rax
cmpq -0x18(%rbp), %rax
jae 0x17df0
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
addq -0x28(%rbp), %rsi
movl $0x1, %edx
callq 0xb260
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
jmp 0x17dc2
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rcx
addq $0x2, %rcx
movl $0x9, %esi
movl $0x2, %edx
callq 0x17700
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)