// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x138, %rsp            # imm = 0x138
leaq 0x10(%rbp), %rax
movq %rax, -0xc0(%rbp)
movq %rdi, -0x28(%rbp)
movq %rsi, -0x30(%rbp)
movq %rdx, -0x38(%rbp)
movq %rcx, -0x40(%rbp)
movq %r8, -0x48(%rbp)
leaq -0x58(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x3260
leaq -0x68(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x3260
leaq -0x78(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x3260
leaq -0x88(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x3260
movq -0xc0(%rbp), %rdx
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x38(%rbp), %rcx
xorl %eax, %eax
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 -0x78(%rbp), %rdx
movq %rdx, 0x40(%rax)
leaq -0x58(%rbp), %rdx
movq %rdx, 0x38(%rax)
leaq -0x88(%rbp), %rdx
movq %rdx, 0x30(%rax)
movq %rcx, 0x28(%rax)
leaq 0xa758(%rip), %rdx      # 0x1fdce
leaq 0xa756(%rip), %r8       # 0x1fdd3
xorl %eax, %eax
movl %eax, %r9d
movq %r9, %rcx
callq 0x141f0
movq %rax, -0xa8(%rbp)
cmpq $0x0, -0xa8(%rbp)
jne 0x156a8
movq $0x0, -0x20(%rbp)
jmp 0x1586c
leaq -0xa0(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x8610
cmpq $0x0, -0x50(%rbp)
jbe 0x156db
movq -0x58(%rbp), %rdi
movq -0x50(%rbp), %rsi
movq -0x68(%rbp), %rdx
movq -0x60(%rbp), %rcx
leaq -0xa0(%rbp), %r8
callq 0x15880
cmpq $0x0, -0x48(%rbp)
jne 0x156ed
leaq 0xb0c2(%rip), %rax      # 0x207ab
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x156ff
leaq 0xb0b0(%rip), %rax      # 0x207ab
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x80(%rbp)
jne 0x15739
leaq 0xa98b(%rip), %rdi      # 0x20098
callq 0x8a60
movq %rax, -0xb8(%rbp)
movq %rdx, -0xb0(%rbp)
movq -0xb8(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0xb0(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0xa8(%rbp), %rax
movq %rax, -0x100(%rbp)
movq -0x48(%rbp), %rax
movsbl (%rax), %edx
leaq 0xa240(%rip), %rax      # 0x1f995
leaq 0xa839(%rip), %rcx      # 0x1ff95
cmpl $0x0, %edx
cmoveq %rcx, %rax
movq %rax, -0xf8(%rbp)
movq -0x80(%rbp), %rax
movl %eax, -0xec(%rbp)
movq -0x88(%rbp), %rax
movq %rax, -0xe8(%rbp)
movq -0x88(%rbp), %rax
movq -0x78(%rbp), %rcx
subq %rcx, %rax
movl %eax, -0xdc(%rbp)
movq -0x78(%rbp), %rax
movq %rax, -0xd8(%rbp)
movq -0x48(%rbp), %rdi
callq 0x3180
movq %rax, -0xd0(%rbp)
movq -0x98(%rbp), %rax
movl %eax, -0xc4(%rbp)
cmpq $0x0, -0xa0(%rbp)
jne 0x157d8
leaq 0xafdc(%rip), %rax      # 0x207ab
movq %rax, -0x108(%rbp)
jmp 0x157e6
movq -0xa0(%rbp), %rax
movq %rax, -0x108(%rbp)
movl -0xc4(%rbp), %ebx
movq -0xd0(%rbp), %r14
movq -0xd8(%rbp), %r15
movl -0xdc(%rbp), %r9d
movq -0xe8(%rbp), %r8
movl -0xec(%rbp), %ecx
movq -0xf8(%rbp), %rdx
movq -0x100(%rbp), %rdi
movq -0x108(%rbp), %r11
movq -0x40(%rbp), %r10
movq -0x48(%rbp), %rax
leaq 0xa725(%rip), %rsi      # 0x1ff57
movq %r15, (%rsp)
movq %r14, 0x8(%rsp)
movl %ebx, 0x10(%rsp)
movq %r11, 0x18(%rsp)
movq %r10, 0x20(%rsp)
movq %rax, 0x28(%rsp)
movb $0x0, %al
callq 0xb2f0
leaq -0xa0(%rbp), %rdi
callq 0x86e0
movq -0xa8(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
nop