// File: /workspace/github_c_makefile_star2_O3/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 0x6022(%rip), %rdx      # 0x15e4f
leaq 0x6020(%rip), %r8       # 0x15e54
xorl %ecx, %ecx
xorl %r9d, %r9d
callq 0xe587
addq $0x50, %rsp
testq %rax, %rax
je 0xff41
movq %rax, %r14
leaq 0x48(%rsp), %rdi
xorl %esi, %esi
callq 0x68dd
movq 0x38(%rsp), %rsi
testq %rsi, %rsi
je 0xfe77
movq 0x30(%rsp), %rdi
leaq 0x48(%rsp), %r8
xorl %edx, %edx
xorl %ecx, %ecx
callq 0xff50
testq %r13, %r13
leaq 0x696c(%rip), %r15      # 0x167ed
cmoveq %r15, %r13
testq %rbx, %rbx
cmoveq %r15, %rbx
movq 0x8(%rsp), %r12
testq %r12, %r12
movq %rbx, 0x28(%rsp)
je 0xfea1
movq (%rsp), %rax
jmp 0xfeb9
leaq 0x626e(%rip), %rdi      # 0x16116
callq 0x6b26
movq %rdx, %r12
movq %rax, (%rsp)
movq %rdx, 0x8(%rsp)
movq %rax, 0x18(%rsp)
cmpb $0x0, (%r13)
leaq 0x614c(%rip), %rcx      # 0x16016
leaq 0x5b45(%rip), %rbp      # 0x15a16
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 0x60d0(%rip), %rsi      # 0x15fd8
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 0x7ff5
addq $0x30, %rsp
leaq 0x48(%rsp), %rdi
callq 0x6934
movq %r14, %rax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq