// File: /workspace/github_c_makefile_star2_O0/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_serve_http
void mg_serve_http(struct mg_connection *nc, struct http_message *hm,
                   struct mg_serve_http_opts opts) {
  char *path = NULL;
  struct mg_str *hdr, path_info;
  uint32_t remote_ip = ntohl(*(uint32_t *) &nc->sa.sin.sin_addr);

  if (mg_check_ip_acl(opts.ip_acl, remote_ip) != 1) {
    /* Not allowed to connect */
    mg_http_send_error(nc, 403, NULL);
    nc->flags |= MG_F_SEND_AND_CLOSE;
    return;
  }

#if MG_ENABLE_HTTP_URL_REWRITES
  if (mg_http_handle_forwarding(nc, hm, &opts)) {
    return;
  }

  if (mg_http_send_port_based_redirect(nc, hm, &opts)) {
    return;
  }
#endif

  if (opts.document_root == NULL) {
    opts.document_root = ".";
  }
  if (opts.per_directory_auth_file == NULL) {
    opts.per_directory_auth_file = ".htpasswd";
  }
  if (opts.enable_directory_listing == NULL) {
    opts.enable_directory_listing = "yes";
  }
  if (opts.cgi_file_pattern == NULL) {
    opts.cgi_file_pattern = "**.cgi$|**.php$";
  }
  if (opts.ssi_pattern == NULL) {
    opts.ssi_pattern = "**.shtml$|**.shtm$";
  }
  if (opts.index_files == NULL) {
    opts.index_files = "index.html,index.htm,index.shtml,index.cgi,index.php";
  }
  /* Normalize path - resolve "." and ".." (in-place). */
  if (!mg_normalize_uri_path(&hm->uri, &hm->uri)) {
    mg_http_send_error(nc, 400, NULL);
    return;
  }
  if (mg_uri_to_local_path(hm, &opts, &path, &path_info) == 0) {
    mg_http_send_error(nc, 404, NULL);
    return;
  }
  mg_send_http_file(nc, path, &path_info, hm, &opts);

  MG_FREE(path);
  path = NULL;

  /* Close connection for non-keep-alive requests */
  if (mg_vcmp(&hm->proto, "HTTP/1.1") != 0 ||
      ((hdr = mg_get_http_header(hm, "Connection")) != NULL &&
       mg_vcmp(hdr, "keep-alive") != 0)) {
#if 0
    nc->flags |= MG_F_SEND_AND_CLOSE;
#endif
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
leaq 0x10(%rbp), %rax
movq %rax, -0x40(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq $0x0, -0x18(%rbp)
movq -0x8(%rbp), %rax
movl 0x2c(%rax), %edi
callq 0x3630
movl %eax, %ecx
movq -0x40(%rbp), %rax
movl %ecx, -0x34(%rbp)
movq 0x38(%rax), %rdi
movl -0x34(%rbp), %esi
callq 0xcfb0
cmpl $0x1, %eax
je 0x14646
movq -0x8(%rbp), %rdi
movl $0x193, %esi            # imm = 0x193
xorl %eax, %eax
movl %eax, %edx
callq 0x11e30
movq -0x8(%rbp), %rax
movq 0xc8(%rax), %rcx
orq $0x400, %rcx            # imm = 0x400
movq %rcx, 0xc8(%rax)
jmp 0x147e9
movq -0x40(%rbp), %rdx
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x147f0
cmpl $0x0, %eax
je 0x14661
jmp 0x147e9
movq -0x40(%rbp), %rdx
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x14900
cmpl $0x0, %eax
je 0x1467c
jmp 0x147e9
movq -0x40(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x14694
movq -0x40(%rbp), %rax
leaq 0xb2fa(%rip), %rcx      # 0x1f98b
movq %rcx, (%rax)
movq -0x40(%rbp), %rax
cmpq $0x0, 0x10(%rax)
jne 0x146ae
movq -0x40(%rbp), %rax
leaq 0xb7f1(%rip), %rcx      # 0x1fe9b
movq %rcx, 0x10(%rax)
movq -0x40(%rbp), %rax
cmpq $0x0, 0x28(%rax)
jne 0x146c8
movq -0x40(%rbp), %rax
leaq 0xb7e1(%rip), %rcx      # 0x1fea5
movq %rcx, 0x28(%rax)
movq -0x40(%rbp), %rax
cmpq $0x0, 0x60(%rax)
jne 0x146e2
movq -0x40(%rbp), %rax
leaq 0xb7cb(%rip), %rcx      # 0x1fea9
movq %rcx, 0x60(%rax)
movq -0x40(%rbp), %rax
cmpq $0x0, 0x30(%rax)
jne 0x146fc
movq -0x40(%rbp), %rax
leaq 0xb7c1(%rip), %rcx      # 0x1feb9
movq %rcx, 0x30(%rax)
movq -0x40(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jne 0x14716
movq -0x40(%rbp), %rax
leaq 0xb7ba(%rip), %rcx      # 0x1fecc
movq %rcx, 0x8(%rax)
movq -0x10(%rbp), %rdi
addq $0x30, %rdi
movq -0x10(%rbp), %rsi
addq $0x30, %rsi
callq 0xfcd0
cmpl $0x0, %eax
jne 0x14747
movq -0x8(%rbp), %rdi
movl $0x190, %esi            # imm = 0x190
xorl %eax, %eax
movl %eax, %edx
callq 0x11e30
jmp 0x147e9
movq -0x40(%rbp), %rsi
movq -0x10(%rbp), %rdi
leaq -0x18(%rbp), %rdx
leaq -0x30(%rbp), %rcx
callq 0x14a00
cmpl $0x0, %eax
jne 0x14775
movq -0x8(%rbp), %rdi
movl $0x194, %esi            # imm = 0x194
xorl %eax, %eax
movl %eax, %edx
callq 0x11e30
jmp 0x147e9
movq -0x40(%rbp), %r8
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x10(%rbp), %rcx
leaq -0x30(%rbp), %rdx
callq 0x15080
movq -0x18(%rbp), %rdi
callq 0x3050
movq $0x0, -0x18(%rbp)
movq -0x10(%rbp), %rdi
addq $0x40, %rdi
leaq 0xc0a4(%rip), %rsi      # 0x20852
callq 0x8ad0
cmpl $0x0, %eax
jne 0x147e7
movq -0x10(%rbp), %rdi
leaq 0xb47f(%rip), %rsi      # 0x1fc42
callq 0x10830
movq %rax, -0x20(%rbp)
cmpq $0x0, %rax
je 0x147e9
movq -0x20(%rbp), %rdi
leaq 0xb470(%rip), %rsi      # 0x1fc4d
callq 0x8ad0
cmpl $0x0, %eax
je 0x147e9
jmp 0x147e9
addq $0x40, %rsp
popq %rbp
retq
nop