// File: /workspace/github_c_makefile_star2_O3/coyove[P]chann/./lib/mongoose/mongoose.c
// Function: handle_propfind
static void handle_propfind(struct connection *conn, const char *path,
                            file_stat_t *stp, int exists) {
  static const char header[] = "HTTP/1.1 207 Multi-Status\r\n"
    "Connection: close\r\n"
    "Content-Type: text/xml; charset=utf-8\r\n\r\n"
    "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
    "<d:multistatus xmlns:d='DAV:'>\n";
  static const char footer[] = "</d:multistatus>";
  const char *depth = mg_get_header(&conn->mg_conn, "Depth");
#ifdef MONGOOSE_NO_DIRECTORY_LISTING
  const char *list_dir = "no";
#else
  const char *list_dir = conn->server->config_options[ENABLE_DIRECTORY_LISTING];
#endif

  conn->mg_conn.status_code = 207;

  // Print properties for the requested resource itself
  if (!exists) {
    conn->mg_conn.status_code = 404;
    mg_printf(&conn->mg_conn, "%s", "HTTP/1.1 404 Not Found\r\n\r\n");
  } else if (S_ISDIR(stp->st_mode) && mg_strcasecmp(list_dir, "yes") != 0) {
    conn->mg_conn.status_code = 403;
    mg_printf(&conn->mg_conn, "%s",
              "HTTP/1.1 403 Directory Listing Denied\r\n\r\n");
  } else {
    ns_send(conn->ns_conn, header, sizeof(header) - 1);
    print_props(conn, conn->mg_conn.uri, stp);

    if (S_ISDIR(stp->st_mode) &&
             (depth == NULL || strcmp(depth, "0") != 0)) {
      struct dir_entry *arr = NULL;
      int i, num_entries = scan_directory(conn, path, &arr);

      for (i = 0; i < num_entries; i++) {
        char buf[MAX_PATH_SIZE * 3];
        struct dir_entry *de = &arr[i];
        mg_url_encode(de->file_name, strlen(de->file_name), buf, sizeof(buf));
        print_props(conn, buf, &de->st);
        NS_FREE(de->file_name);
      }
      NS_FREE(arr);
    }
    ns_send(conn->ns_conn, footer, sizeof(footer) - 1);
  }

  close_local_endpoint(conn);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x6018, %rsp           # imm = 0x6018
movl %ecx, %r14d
movq %rdx, %r12
movq %rsi, -0x30(%rbp)
movq %rdi, %rbx
leaq 0x8(%rdi), %r13
leaq 0x9d09(%rip), %rsi      # 0x7967d
movq %r13, %rdi
callq 0x67c6a
movq 0x2a8(%rbx), %rcx
movq 0x78(%rcx), %r15
movl $0xcf, 0x284(%rbx)
testl %r14d, %r14d
je 0x6facd
movq %rax, -0x38(%rbp)
movl $0xf000, %r14d          # imm = 0xF000
movl 0x18(%r12), %eax
andl %r14d, %eax
cmpl $0x4000, %eax           # imm = 0x4000
jne 0x6f9e8
callq 0xc4a0
movq (%rax), %rax
xorl %ecx, %ecx
leaq 0x4baf(%rip), %rdx      # 0x74573
movzbl (%r15,%rcx), %r8d
movl (%rax,%r8,4), %esi
movzbl (%rcx,%rdx), %edi
movl (%rax,%rdi,4), %edi
testl %r8d, %r8d
je 0x6f9e0
incq %rcx
cmpl %edi, %esi
je 0x6f9c4
cmpl %edi, %esi
jne 0x6fae7
movq (%rbx), %rdi
leaq 0x877e(%rip), %rsi      # 0x78170
movl $0x9c, %edx
callq 0x6661a
movq 0x10(%rbx), %rsi
movq %rbx, %rdi
movq %r12, %rdx
callq 0x6fee3
andl 0x18(%r12), %r14d
cmpl $0x4000, %r14d          # imm = 0x4000
movq -0x38(%rbp), %rax
jne 0x6fab7
testq %rax, %rax
je 0x6fa35
cmpb $0x30, (%rax)
jne 0x6fa35
cmpb $0x0, 0x1(%rax)
je 0x6fab7
leaq -0x40(%rbp), %r14
movq $0x0, (%r14)
movq %rbx, %rdi
movq -0x30(%rbp), %rsi
movq %r14, %rdx
callq 0x6c7d9
movq (%r14), %rcx
movq %rcx, -0x30(%rbp)
testl %eax, %eax
jle 0x6faae
movl %eax, %r14d
movq -0x30(%rbp), %rax
leaq 0x10(%rax), %r15
leaq -0x6040(%rbp), %r12
movq -0x8(%r15), %r13
movq %r13, %rdi
callq 0xc460
movl $0x6000, %ecx           # imm = 0x6000
movq %r13, %rdi
movq %rax, %rsi
movq %r12, %rdx
callq 0x68923
movq %rbx, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x6fee3
movq -0x8(%r15), %rdi
callq 0xc250
addq $0xa0, %r15
decq %r14
jne 0x6fa6c
movq -0x30(%rbp), %rdi
callq 0xc250
movq (%rbx), %rdi
leaq 0x874f(%rip), %rsi      # 0x78210
movl $0x10, %edx
callq 0x6661a
jmp 0x6fb09
movl $0x194, 0x284(%rbx)     # imm = 0x194
leaq 0x6871(%rip), %rsi      # 0x7634f
leaq 0x9b9e(%rip), %rdx      # 0x79683
jmp 0x6faff
movl $0x193, 0x284(%rbx)     # imm = 0x193
leaq 0x6857(%rip), %rsi      # 0x7634f
leaq 0x9b9f(%rip), %rdx      # 0x7969e
movq %r13, %rdi
xorl %eax, %eax
callq 0x67a83
movq %rbx, %rdi
callq 0x68a64
addq $0x6018, %rsp           # imm = 0x6018
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq