// File: /workspace/github_c_makefile_star2_O2/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_connect_http_opt
struct mg_connection *mg_connect_http_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 *extra_headers,
    const char *post_data) {
  struct mg_str user = MG_NULL_STR, null_str = MG_NULL_STR;
  struct mg_str host = MG_NULL_STR, path = MG_NULL_STR;
  struct mbuf auth;
  struct mg_connection *nc =
      mg_connect_http_base(mgr, MG_CB(ev_handler, user_data), opts, "http",
                           NULL, "https", NULL, url, &path, &user, &host);

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

  mbuf_init(&auth, 0);
  if (user.len > 0) {
    mg_basic_auth_header(user, null_str, &auth);
  }

  if (post_data == NULL) post_data = "";
  if (extra_headers == NULL) extra_headers = "";
  if (path.len == 0) path = mg_mk_str("/");

  mg_printf(nc, "%s %.*s HTTP/1.1\r\nHost: %.*s\r\nContent-Length: %" SIZE_T_FMT
                "\r\n%.*s%s\r\n%s",
            (post_data[0] == '\0' ? "GET" : "POST"), (int) path.len, path.p,
            (int) (path.p - host.p), host.p, strlen(post_data), (int) auth.len,
            (auth.buf == NULL ? "" : auth.buf), extra_headers, post_data);

  mbuf_free(&auth);
  return nc;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %r8, %r13
movq %rcx, %rbx
xorps %xmm0, %xmm0
leaq 0x30(%rsp), %rax
movaps %xmm0, (%rax)
leaq 0x60(%rsp), %rcx
movaps %xmm0, (%rcx)
movq %rsp, %r8
movaps %xmm0, (%r8)
subq $0x50, %rsp
movq 0x120(%rsp), %r9
movq %r9, 0x20(%rsp)
movaps 0x100(%rsp), %xmm0
movaps 0x110(%rsp), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movq %rcx, 0x40(%rsp)
movq %rax, 0x38(%rsp)
movq %r8, 0x30(%rsp)
movq %rdx, 0x28(%rsp)
leaq 0x598b(%rip), %rdx      # 0x14e32
leaq 0x5989(%rip), %r8       # 0x14e37
xorl %ecx, %ecx
xorl %r9d, %r9d
callq 0xd7a3
addq $0x50, %rsp
testq %rax, %rax
je 0xf5bb
movq %rax, %r14
leaq 0x48(%rsp), %rdi
xorl %esi, %esi
callq 0x662f
movq 0x38(%rsp), %rsi
testq %rsi, %rsi
je 0xf4f1
movq 0x30(%rsp), %rdi
leaq 0x48(%rsp), %r8
xorl %edx, %edx
xorl %ecx, %ecx
callq 0xf5ca
testq %r13, %r13
leaq 0x62d5(%rip), %r15      # 0x157d0
cmoveq %r15, %r13
testq %rbx, %rbx
cmoveq %r15, %rbx
movq 0x8(%rsp), %r12
testq %r12, %r12
movq %rbx, 0x28(%rsp)
je 0xf51b
movq (%rsp), %rax
jmp 0xf533
leaq 0x5bd7(%rip), %rdi      # 0x150f9
callq 0x6875
movq %rdx, %r12
movq %rax, (%rsp)
movq %rdx, 0x8(%rsp)
movq %rax, 0x18(%rsp)
cmpb $0x0, (%r13)
leaq 0x5ab5(%rip), %rcx      # 0x14ff9
leaq 0x54ae(%rip), %rbp      # 0x149f9
cmoveq %rcx, %rbp
movq 0x60(%rsp), %rcx
movq %rcx, 0x20(%rsp)
movl %eax, %ebx
subl %ecx, %ebx
movq %r13, %rdi
callq 0x3180
movq %rax, %r10
leaq 0x48(%rsp), %rax
movl 0x8(%rax), %r11d
movq (%rax), %rax
testq %rax, %rax
cmovneq %rax, %r15
leaq 0x5a39(%rip), %rsi      # 0x14fbb
movq %r14, %rdi
movq %rbp, %rdx
movl %r12d, %ecx
movq 0x18(%rsp), %r8
movl %ebx, %r9d
xorl %eax, %eax
pushq %r13
pushq 0x30(%rsp)
pushq %r15
pushq %r11
pushq %r10
pushq 0x48(%rsp)
callq 0x7bce
addq $0x30, %rsp
leaq 0x48(%rsp), %rdi
callq 0x6683
movq %r14, %rax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq