// File: /workspace/github_c_makefile_star2_O0/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_connect_http_base
struct mg_connection *mg_connect_http_base(
    struct mg_mgr *mgr, MG_CB(mg_event_handler_t ev_handler, void *user_data),
    struct mg_connect_opts opts, const char *scheme1, const char *scheme2,
    const char *scheme_ssl1, const char *scheme_ssl2, const char *url,
    struct mg_str *path, struct mg_str *user_info, struct mg_str *host) {
  struct mg_connection *nc = NULL;
  unsigned int port_i = 0;
  int use_ssl = 0;
  struct mg_str scheme, query, fragment;
  char conn_addr_buf[2];
  char *conn_addr = conn_addr_buf;

  if (mg_parse_uri(mg_mk_str(url), &scheme, user_info, host, &port_i, path,
                   &query, &fragment) != 0) {
    MG_SET_PTRPTR(opts.error_string, "cannot parse url");
    goto out;
  }

  /* If query is present, do not strip it. Pass to the caller. */
  if (query.len > 0) path->len += query.len + 1;

  if (scheme.len == 0 || mg_vcmp(&scheme, scheme1) == 0 ||
      (scheme2 != NULL && mg_vcmp(&scheme, scheme2) == 0)) {
    use_ssl = 0;
    if (port_i == 0) port_i = 80;
  } else if (mg_vcmp(&scheme, scheme_ssl1) == 0 ||
             (scheme2 != NULL && mg_vcmp(&scheme, scheme_ssl2) == 0)) {
    use_ssl = 1;
    if (port_i == 0) port_i = 443;
  } else {
    goto out;
  }

  mg_asprintf(&conn_addr, sizeof(conn_addr_buf), "tcp://%.*s:%u",
              (int) host->len, host->p, port_i);
  if (conn_addr == NULL) goto out;

  LOG(LL_DEBUG, ("%s use_ssl? %d %s", url, use_ssl, conn_addr));
  if (use_ssl) {
#if MG_ENABLE_SSL
    /*
     * Schema requires SSL, but no SSL parameters were provided in opts.
     * In order to maintain backward compatibility, use a faux-SSL with no
     * verification.
     */
    if (opts.ssl_ca_cert == NULL) {
      opts.ssl_ca_cert = "*";
    }
#else
    MG_SET_PTRPTR(opts.error_string, "ssl is disabled");
    goto out;
#endif
  }

  if ((nc = mg_connect_opt(mgr, conn_addr, MG_CB(ev_handler, user_data),
                           opts)) != NULL) {
    mg_set_protocol_http_websocket(nc);
  }

out:
  if (conn_addr != NULL && conn_addr != conn_addr_buf) MG_FREE(conn_addr);
  return nc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movq 0x50(%rbp), %rax
movq 0x48(%rbp), %rax
movq 0x40(%rbp), %rax
movq 0x38(%rbp), %rax
leaq 0x10(%rbp), %rax
movq %rax, -0x98(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
movl $0x0, -0x3c(%rbp)
movl $0x0, -0x40(%rbp)
leaq -0x72(%rbp), %rax
movq %rax, -0x80(%rbp)
movq 0x38(%rbp), %rdi
callq 0x8a60
movq %rax, -0x90(%rbp)
movq %rdx, -0x88(%rbp)
movq 0x48(%rbp), %rcx
movq 0x50(%rbp), %r8
movq 0x40(%rbp), %r11
movq -0x90(%rbp), %rdi
movq -0x88(%rbp), %rsi
leaq -0x50(%rbp), %rdx
leaq -0x3c(%rbp), %r9
leaq -0x60(%rbp), %r10
leaq -0x70(%rbp), %rax
movq %r11, (%rsp)
movq %r10, 0x8(%rsp)
movq %rax, 0x10(%rsp)
callq 0xf5d0
cmpl $0x0, %eax
je 0x142d1
jmp 0x142a7
movq -0x98(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x142ca
movq -0x98(%rbp), %rax
movq 0x10(%rax), %rax
leaq 0xbc3a(%rip), %rcx      # 0x1ff01
movq %rcx, (%rax)
jmp 0x142cc
jmp 0x14463
cmpq $0x0, -0x58(%rbp)
jbe 0x142ec
movq -0x58(%rbp), %rcx
addq $0x1, %rcx
movq 0x40(%rbp), %rax
addq 0x8(%rax), %rcx
movq %rcx, 0x8(%rax)
cmpq $0x0, -0x48(%rbp)
je 0x1431e
movq -0x18(%rbp), %rsi
leaq -0x50(%rbp), %rdi
callq 0x8ad0
cmpl $0x0, %eax
je 0x1431e
cmpq $0x0, -0x20(%rbp)
je 0x14334
movq -0x20(%rbp), %rsi
leaq -0x50(%rbp), %rdi
callq 0x8ad0
cmpl $0x0, %eax
jne 0x14334
movl $0x0, -0x40(%rbp)
cmpl $0x0, -0x3c(%rbp)
jne 0x14332
movl $0x50, -0x3c(%rbp)
jmp 0x1437c
movq -0x28(%rbp), %rsi
leaq -0x50(%rbp), %rdi
callq 0x8ad0
cmpl $0x0, %eax
je 0x1435f
cmpq $0x0, -0x20(%rbp)
je 0x14375
movq -0x30(%rbp), %rsi
leaq -0x50(%rbp), %rdi
callq 0x8ad0
cmpl $0x0, %eax
jne 0x14375
movl $0x1, -0x40(%rbp)
cmpl $0x0, -0x3c(%rbp)
jne 0x14373
movl $0x1bb, -0x3c(%rbp)     # imm = 0x1BB
jmp 0x1437a
jmp 0x14463
jmp 0x1437c
movq 0x50(%rbp), %rax
movq 0x8(%rax), %rax
movl %eax, %ecx
movq 0x50(%rbp), %rax
movq (%rax), %r8
movl -0x3c(%rbp), %r9d
leaq -0x80(%rbp), %rdi
movl $0x2, %esi
leaq 0xbb71(%rip), %rdx      # 0x1ff12
movb $0x0, %al
callq 0xa0f0
cmpq $0x0, -0x80(%rbp)
jne 0x143b4
jmp 0x14463
jmp 0x143b6
movl $0x3, %edi
leaq 0xbb5e(%rip), %rsi      # 0x1ff20
leaq 0xb181(%rip), %rdx      # 0x1f54a
callq 0x4650
cmpl $0x0, %eax
je 0x143ec
movq 0x38(%rbp), %rsi
movl -0x40(%rbp), %edx
movq -0x80(%rbp), %rcx
leaq 0xbb50(%rip), %rdi      # 0x1ff35
movb $0x0, %al
callq 0x47a0
jmp 0x143ee
cmpl $0x0, -0x40(%rbp)
je 0x1441d
jmp 0x143f6
movq -0x98(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x14419
movq -0x98(%rbp), %rax
movq 0x10(%rax), %rax
leaq 0xbb31(%rip), %rcx      # 0x1ff47
movq %rcx, (%rax)
jmp 0x1441b
jmp 0x14463
movq -0x98(%rbp), %rcx
movq -0x8(%rbp), %rdi
movq -0x80(%rbp), %rsi
movq -0x10(%rbp), %rdx
movq 0x20(%rcx), %r8
movq %rsp, %rax
movq %r8, 0x20(%rax)
movups (%rcx), %xmm0
movups 0x10(%rcx), %xmm1
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
callq 0xc100
movq %rax, -0x38(%rbp)
cmpq $0x0, %rax
je 0x14461
movq -0x38(%rbp), %rdi
callq 0x119f0
jmp 0x14463
cmpq $0x0, -0x80(%rbp)
je 0x14480
movq -0x80(%rbp), %rax
leaq -0x72(%rbp), %rcx
cmpq %rcx, %rax
je 0x14480
movq -0x80(%rbp), %rdi
callq 0x3050
movq -0x38(%rbp), %rax
addq $0xc0, %rsp
popq %rbp
retq
nopl (%rax)