// File: /workspace/github_c_makefile_star2_O1/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, %r14
movq %rcx, %rbx
xorps %xmm0, %xmm0
leaq 0x30(%rsp), %rax
movaps %xmm0, (%rax)
leaq 0x60(%rsp), %rcx
movaps %xmm0, (%rcx)
leaq 0x10(%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 0x5eec(%rip), %rdx      # 0x15e2e
leaq 0x5eea(%rip), %r8       # 0x15e33
xorl %ebp, %ebp
xorl %ecx, %ecx
xorl %r9d, %r9d
callq 0xe65a
addq $0x50, %rsp
testq %rax, %rax
je 0x10052
movq %rax, %rbp
leaq 0x48(%rsp), %rdi
xorl %esi, %esi
callq 0x69aa
movq 0x38(%rsp), %rsi
testq %rsi, %rsi
je 0xff8e
movq 0x30(%rsp), %rdi
leaq 0x48(%rsp), %r8
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x10064
testq %r14, %r14
leaq 0x6837(%rip), %r15      # 0x167cf
cmoveq %r15, %r14
testq %rbx, %rbx
cmoveq %r15, %rbx
movq %rbx, 0x28(%rsp)
cmpq $0x0, 0x18(%rsp)
jne 0xffc6
leaq 0x6141(%rip), %rdi      # 0x160f8
callq 0x6be8
movq %rax, 0x10(%rsp)
movq %rdx, 0x18(%rsp)
cmpb $0x0, (%r14)
leaq 0x6024(%rip), %rax      # 0x15ff5
leaq 0x5a1d(%rip), %r13      # 0x159f5
cmoveq %rax, %r13
movl 0x18(%rsp), %eax
movl %eax, 0xc(%rsp)
movq 0x10(%rsp), %r12
movq 0x60(%rsp), %rax
movq %rax, 0x20(%rsp)
movl %r12d, %ebx
subl %eax, %ebx
movq %r14, %rdi
callq 0x3180
movq %rax, %r10
leaq 0x48(%rsp), %rax
movl 0x8(%rax), %r11d
movq (%rax), %rax
testq %rax, %rax
cmovneq %rax, %r15
leaq 0x5f9a(%rip), %rsi      # 0x15fb7
movq %rbp, %rdi
movq %r13, %rdx
movl 0xc(%rsp), %ecx
movq %r12, %r8
movl %ebx, %r9d
xorl %eax, %eax
pushq %r14
pushq 0x30(%rsp)
pushq %r15
pushq %r11
pushq %r10
pushq 0x48(%rsp)
callq 0x80d3
addq $0x30, %rsp
leaq 0x48(%rsp), %rdi
callq 0x6a01
movq %rbp, %rax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq