// File: /workspace/github_c_makefile_star2_O0/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_send_http_file
MG_INTERNAL void mg_send_http_file(struct mg_connection *nc, char *path,
                                   const struct mg_str *path_info,
                                   struct http_message *hm,
                                   struct mg_serve_http_opts *opts) {
  int exists, is_directory, is_cgi;
#if MG_ENABLE_HTTP_WEBDAV
  int is_dav = mg_is_dav_request(&hm->method);
#else
  int is_dav = 0;
#endif
  char *index_file = NULL;
  cs_stat_t st;

  exists = (mg_stat(path, &st) == 0);
  is_directory = exists && S_ISDIR(st.st_mode);

  if (is_directory)
    mg_find_index_file(path, opts->index_files, &index_file, &st);

  is_cgi =
      (mg_match_prefix(opts->cgi_file_pattern, strlen(opts->cgi_file_pattern),
                       index_file ? index_file : path) > 0);

  LOG(LL_DEBUG,
      ("%p %.*s [%s] exists=%d is_dir=%d is_dav=%d is_cgi=%d index=%s", nc,
       (int) hm->method.len, hm->method.p, path, exists, is_directory, is_dav,
       is_cgi, index_file ? index_file : ""));

  if (is_directory && hm->uri.p[hm->uri.len - 1] != '/' && !is_dav) {
    mg_printf(nc,
              "HTTP/1.1 301 Moved\r\nLocation: %.*s/\r\n"
              "Content-Length: 0\r\n\r\n",
              (int) hm->uri.len, hm->uri.p);
    MG_FREE(index_file);
    return;
  }

  /* If we have path_info, the only way to handle it is CGI. */
  if (path_info->len > 0 && !is_cgi) {
    mg_http_send_error(nc, 501, NULL);
    MG_FREE(index_file);
    return;
  }

  if (is_dav && opts->dav_document_root == NULL) {
    mg_http_send_error(nc, 501, NULL);
  } else if (!mg_http_is_authorized(hm, mg_mk_str(path), is_directory,
                                    opts->auth_domain, opts->global_auth_file,
                                    1) ||
             !mg_http_is_authorized(hm, mg_mk_str(path), is_directory,
                                    opts->auth_domain,
                                    opts->per_directory_auth_file, 0)) {
    mg_http_send_digest_auth_request(nc, opts->auth_domain);
  } else if (is_cgi) {
#if MG_ENABLE_HTTP_CGI
    mg_handle_cgi(nc, index_file ? index_file : path, path_info, hm, opts);
#else
    mg_http_send_error(nc, 501, NULL);
#endif /* MG_ENABLE_HTTP_CGI */
  } else if ((!exists ||
              mg_is_file_hidden(path, opts, 0 /* specials are ok */)) &&
             !mg_is_creation_request(hm)) {
    mg_http_send_error(nc, 404, NULL);
#if MG_ENABLE_HTTP_WEBDAV
  } else if (!mg_vcmp(&hm->method, "PROPFIND")) {
    mg_handle_propfind(nc, path, &st, hm, opts);
#if !MG_DISABLE_DAV_AUTH
  } else if (is_dav && (opts->dav_auth_file == NULL ||
                        (strcmp(opts->dav_auth_file, "-") != 0 &&
                         !mg_http_is_authorized(hm, mg_mk_str(path),
                                                is_directory, opts->auth_domain,
                                                opts->dav_auth_file, 1)))) {
    mg_http_send_digest_auth_request(nc, opts->auth_domain);
#endif
  } else if (!mg_vcmp(&hm->method, "MKCOL")) {
    mg_handle_mkcol(nc, path, hm);
  } else if (!mg_vcmp(&hm->method, "DELETE")) {
    mg_handle_delete(nc, opts, path);
  } else if (!mg_vcmp(&hm->method, "PUT")) {
    mg_handle_put(nc, path, hm);
  } else if (!mg_vcmp(&hm->method, "MOVE")) {
    mg_handle_move(nc, opts, path, hm);
#if MG_ENABLE_FAKE_DAVLOCK
  } else if (!mg_vcmp(&hm->method, "LOCK")) {
    mg_handle_lock(nc, path);
#endif
#endif /* MG_ENABLE_HTTP_WEBDAV */
  } else if (!mg_vcmp(&hm->method, "OPTIONS")) {
    mg_http_send_options(nc);
  } else if (is_directory && index_file == NULL) {
#if MG_ENABLE_DIRECTORY_LISTING
    if (strcmp(opts->enable_directory_listing, "yes") == 0) {
      mg_send_directory_listing(nc, path, hm, opts);
    } else {
      mg_http_send_error(nc, 403, NULL);
    }
#else
    mg_http_send_error(nc, 501, NULL);
#endif
  } else if (mg_is_not_modified(hm, &st)) {
    mg_http_send_error(nc, 304, "Not Modified");
  } else {
    mg_http_serve_file2(nc, index_file ? index_file : path, hm, opts);
  }
  MG_FREE(index_file);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
subq $0x198, %rsp            # imm = 0x198
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movl $0x0, -0x40(%rbp)
movq $0x0, -0x48(%rbp)
movq -0x18(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
callq 0x12330
cmpl $0x0, %eax
sete %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x34(%rbp)
xorl %eax, %eax
cmpl $0x0, -0x34(%rbp)
movb %al, -0xf9(%rbp)
je 0x150f4
movl -0xc0(%rbp), %eax
andl $0xf000, %eax           # imm = 0xF000
cmpl $0x4000, %eax           # imm = 0x4000
sete %al
movb %al, -0xf9(%rbp)
movb -0xf9(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x38(%rbp)
cmpl $0x0, -0x38(%rbp)
je 0x15124
movq -0x18(%rbp), %rdi
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rsi
leaq -0x48(%rbp), %rdx
leaq -0xd8(%rbp), %rcx
callq 0x19e30
movq -0x30(%rbp), %rax
movq 0x60(%rax), %rax
movq %rax, -0x108(%rbp)
movq -0x30(%rbp), %rax
movq 0x60(%rax), %rdi
callq 0x3180
movl %eax, -0x100(%rbp)
cmpq $0x0, -0x48(%rbp)
je 0x1515a
movq -0x48(%rbp), %rax
movq %rax, -0x110(%rbp)
jmp 0x15165
movq -0x18(%rbp), %rax
movq %rax, -0x110(%rbp)
movl -0x100(%rbp), %esi
movq -0x108(%rbp), %rdi
movq -0x110(%rbp), %rdx
callq 0x4730
cmpl $0x0, %eax
setg %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x3c(%rbp)
movl $0x3, %edi
leaq 0xb4b2(%rip), %rsi      # 0x2064a
leaq 0xa3ab(%rip), %rdx      # 0x1f54a
callq 0x4650
cmpl $0x0, %eax
je 0x15285
movq -0x10(%rbp), %rax
movq %rax, -0x140(%rbp)
movq -0x28(%rbp), %rax
movq 0x28(%rax), %rax
movl %eax, -0x134(%rbp)
movq -0x28(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x130(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x128(%rbp)
movl -0x34(%rbp), %eax
movl %eax, -0x120(%rbp)
movl -0x38(%rbp), %eax
movl %eax, -0x11c(%rbp)
movl -0x40(%rbp), %eax
movl %eax, -0x118(%rbp)
movl -0x3c(%rbp), %eax
movl %eax, -0x114(%rbp)
cmpq $0x0, -0x48(%rbp)
je 0x15218
movq -0x48(%rbp), %rax
movq %rax, -0x148(%rbp)
jmp 0x15228
leaq 0xb58c(%rip), %rax      # 0x207ab
movq %rax, -0x148(%rbp)
jmp 0x15228
movl -0x114(%rbp), %r10d
movl -0x118(%rbp), %r11d
movl -0x11c(%rbp), %ebx
movl -0x120(%rbp), %r9d
movq -0x128(%rbp), %r8
movq -0x130(%rbp), %rcx
movl -0x134(%rbp), %edx
movq -0x140(%rbp), %rsi
movq -0x148(%rbp), %rax
leaq 0xb3f0(%rip), %rdi      # 0x2065c
movl %ebx, (%rsp)
movl %r11d, 0x8(%rsp)
movl %r10d, 0x10(%rsp)
movq %rax, 0x18(%rsp)
movb $0x0, %al
callq 0x47a0
jmp 0x15287
cmpl $0x0, -0x38(%rbp)
je 0x152e2
movq -0x28(%rbp), %rax
movq 0x30(%rax), %rax
movq -0x28(%rbp), %rcx
movq 0x38(%rcx), %rcx
subq $0x1, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x2f, %eax
je 0x152e2
cmpl $0x0, -0x40(%rbp)
jne 0x152e2
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rax
movq 0x38(%rax), %rax
movl %eax, %edx
movq -0x28(%rbp), %rax
movq 0x30(%rax), %rcx
leaq 0xb3cd(%rip), %rsi      # 0x2069a
movb $0x0, %al
callq 0xb2f0
movq -0x48(%rbp), %rdi
callq 0x3050
jmp 0x1559a
movq -0x20(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jbe 0x15313
cmpl $0x0, -0x3c(%rbp)
jne 0x15313
movq -0x10(%rbp), %rdi
movl $0x1f5, %esi            # imm = 0x1F5
xorl %eax, %eax
movl %eax, %edx
callq 0x11e30
movq -0x48(%rbp), %rdi
callq 0x3050
jmp 0x1559a
cmpl $0x0, -0x40(%rbp)
je 0x1533b
movq -0x30(%rbp), %rax
cmpq $0x0, 0x48(%rax)
jne 0x1533b
movq -0x10(%rbp), %rdi
movl $0x1f5, %esi            # imm = 0x1F5
xorl %eax, %eax
movl %eax, %edx
callq 0x11e30
jmp 0x15591
movq -0x28(%rbp), %rax
movq %rax, -0x150(%rbp)
movq -0x18(%rbp), %rdi
callq 0x8a60
movq -0x150(%rbp), %rdi
movq %rax, -0xe8(%rbp)
movq %rdx, -0xe0(%rbp)
movl -0x38(%rbp), %ecx
movq -0x30(%rbp), %rax
movq 0x18(%rax), %r8
movq -0x30(%rbp), %rax
movq 0x20(%rax), %r9
movq -0xe8(%rbp), %rsi
movq -0xe0(%rbp), %rdx
movl $0x1, (%rsp)
callq 0x19ff0
cmpl $0x0, %eax
je 0x153f3
movq -0x28(%rbp), %rax
movq %rax, -0x158(%rbp)
movq -0x18(%rbp), %rdi
callq 0x8a60
movq -0x158(%rbp), %rdi
movq %rax, -0xf8(%rbp)
movq %rdx, -0xf0(%rbp)
movl -0x38(%rbp), %ecx
movq -0x30(%rbp), %rax
movq 0x18(%rax), %r8
movq -0x30(%rbp), %rax
movq 0x10(%rax), %r9
movq -0xf8(%rbp), %rsi
movq -0xf0(%rbp), %rdx
xorl %eax, %eax
movl $0x0, (%rsp)
callq 0x19ff0
cmpl $0x0, %eax
jne 0x15409
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rsi
callq 0x1a200
jmp 0x1558f
cmpl $0x0, -0x3c(%rbp)
je 0x1545d
movq -0x10(%rbp), %rax
movq %rax, -0x160(%rbp)
cmpq $0x0, -0x48(%rbp)
je 0x1542e
movq -0x48(%rbp), %rax
movq %rax, -0x168(%rbp)
jmp 0x15439
movq -0x18(%rbp), %rax
movq %rax, -0x168(%rbp)
movq -0x160(%rbp), %rdi
movq -0x168(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
movq -0x30(%rbp), %r8
callq 0x1a270
jmp 0x1558d
cmpl $0x0, -0x34(%rbp)
je 0x15477
movq -0x18(%rbp), %rdi
movq -0x30(%rbp), %rsi
xorl %edx, %edx
callq 0x1a530
cmpl $0x0, %eax
je 0x1549c
movq -0x28(%rbp), %rdi
callq 0x1a650
cmpl $0x0, %eax
jne 0x1549c
movq -0x10(%rbp), %rdi
movl $0x194, %esi            # imm = 0x194
xorl %eax, %eax
movl %eax, %edx
callq 0x11e30
jmp 0x1558b
movq -0x28(%rbp), %rdi
addq $0x20, %rdi
leaq 0xb22a(%rip), %rsi      # 0x206d5
callq 0x8ad0
cmpl $0x0, %eax
jne 0x154c3
movq -0x10(%rbp), %rdi
callq 0x1a6b0
jmp 0x15589
cmpl $0x0, -0x38(%rbp)
je 0x15514
cmpq $0x0, -0x48(%rbp)
jne 0x15514
movq -0x30(%rbp), %rax
movq 0x28(%rax), %rdi
leaq 0xa9c6(%rip), %rsi      # 0x1fea5
callq 0x3340
cmpl $0x0, %eax
jne 0x15500
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x28(%rbp), %rdx
movq -0x30(%rbp), %rcx
callq 0x1a700
jmp 0x15512
movq -0x10(%rbp), %rdi
movl $0x193, %esi            # imm = 0x193
xorl %eax, %eax
movl %eax, %edx
callq 0x11e30
jmp 0x15587
movq -0x28(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
callq 0x1a810
cmpl $0x0, %eax
je 0x15540
movq -0x10(%rbp), %rdi
movl $0x130, %esi            # imm = 0x130
leaq 0xb1a4(%rip), %rdx      # 0x206dd
callq 0x11e30
jmp 0x15585
movq -0x10(%rbp), %rax
movq %rax, -0x170(%rbp)
cmpq $0x0, -0x48(%rbp)
je 0x1555f
movq -0x48(%rbp), %rax
movq %rax, -0x178(%rbp)
jmp 0x1556a
movq -0x18(%rbp), %rax
movq %rax, -0x178(%rbp)
movq -0x170(%rbp), %rdi
movq -0x178(%rbp), %rsi
movq -0x28(%rbp), %rdx
movq -0x30(%rbp), %rcx
callq 0x1a8d0
jmp 0x15587
jmp 0x15589
jmp 0x1558b
jmp 0x1558d
jmp 0x1558f
jmp 0x15591
movq -0x48(%rbp), %rdi
callq 0x3050
addq $0x198, %rsp            # imm = 0x198
popq %rbx
popq %rbp
retq
nopw %cs:(%rax,%rax)