// File: /workspace/github_c_makefile_star2_O1/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, -0x40(%rbp)
movq %rdi, %rbx
leaq 0x8(%rdi), %r13
leaq 0xa061(%rip), %rsi      # 0x7b67d
movq %r13, %rdi
callq 0x69863
movq 0x2a8(%rbx), %rcx
movq 0x78(%rcx), %r15
movl $0xcf, 0x284(%rbx)
testl %r14d, %r14d
je 0x7176c
movq %rax, -0x38(%rbp)
movl $0xf000, %r14d          # imm = 0xF000
movl 0x18(%r12), %eax
andl %r14d, %eax
cmpl $0x4000, %eax           # imm = 0x4000
jne 0x71690
callq 0xc4a0
movq (%rax), %rax
xorl %ecx, %ecx
leaq 0x4eff(%rip), %rdx      # 0x7656b
movzbl (%r15,%rcx), %r8d
movl (%rax,%r8,4), %esi
movzbl (%rcx,%rdx), %edi
movl (%rax,%rdi,4), %edi
testl %r8d, %r8d
je 0x71688
incq %rcx
cmpl %edi, %esi
je 0x7166c
cmpl %edi, %esi
jne 0x71786
movq (%rbx), %rdi
leaq 0x8ad6(%rip), %rsi      # 0x7a170
movl $0x9c, %edx
callq 0x681c0
movq 0x10(%rbx), %rsi
movq %rbx, %rdi
movq %r12, %rdx
callq 0x71b96
andl 0x18(%r12), %r14d
cmpl $0x4000, %r14d          # imm = 0x4000
movq -0x38(%rbp), %rdi
jne 0x71756
testq %rdi, %rdi
je 0x716de
leaq 0x9a0d(%rip), %rsi      # 0x7b0e2
callq 0xc950
testl %eax, %eax
je 0x71756
leaq -0x30(%rbp), %rdx
movq $0x0, (%rdx)
movq %rbx, %rdi
movq -0x40(%rbp), %rsi
callq 0x6e368
testl %eax, %eax
jle 0x7174d
movq -0x30(%rbp), %r14
movl %eax, %r13d
addq $0x10, %r14
leaq -0x6040(%rbp), %r15
movq -0x8(%r14), %r12
movq %r12, %rdi
callq 0xc460
movl $0x6000, %ecx           # imm = 0x6000
movq %r12, %rdi
movq %rax, %rsi
movq %r15, %rdx
callq 0x6a4c1
movq %rbx, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x71b96
movq -0x8(%r14), %rdi
callq 0xc250
addq $0xa0, %r14
decq %r13
jne 0x7170b
movq -0x30(%rbp), %rdi
callq 0xc250
movq (%rbx), %rdi
leaq 0x8ab0(%rip), %rsi      # 0x7a210
movl $0x10, %edx
callq 0x681c0
jmp 0x717a8
movl $0x194, 0x284(%rbx)     # imm = 0x194
leaq 0x6bc7(%rip), %rsi      # 0x78344
leaq 0x9eff(%rip), %rdx      # 0x7b683
jmp 0x7179e
movl $0x193, 0x284(%rbx)     # imm = 0x193
leaq 0x6bad(%rip), %rsi      # 0x78344
leaq 0x9f00(%rip), %rdx      # 0x7b69e
movq %r13, %rdi
xorl %eax, %eax
callq 0x69675
movq %rbx, %rdi
callq 0x6a615
addq $0x6018, %rsp           # imm = 0x6018
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq