// File: /workspace/github_c_makefile_star2_O0/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
subq $0x6050, %rsp           # imm = 0x6050
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq -0x8(%rbp), %rdi
addq $0x8, %rdi
leaq 0xb024(%rip), %rsi      # 0xc7f7d
callq 0xb0fe0
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq 0x2a8(%rax), %rax
movq 0x78(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rax
movl $0xcf, 0x284(%rax)
cmpl $0x0, -0x1c(%rbp)
jne 0xbcfb9
movq -0x8(%rbp), %rax
movl $0x194, 0x284(%rax)     # imm = 0x194
movq -0x8(%rbp), %rdi
addq $0x8, %rdi
leaq 0x788a(%rip), %rsi      # 0xc4830
leaq 0xafd6(%rip), %rdx      # 0xc7f83
movb $0x0, %al
callq 0xb0cb0
jmp 0xbd156
movq -0x18(%rbp), %rax
movl 0x18(%rax), %eax
andl $0xf000, %eax           # imm = 0xF000
cmpl $0x4000, %eax           # imm = 0x4000
jne 0xbd011
movq -0x30(%rbp), %rdi
leaq 0x5a6d(%rip), %rsi      # 0xc2a44
callq 0xb1070
cmpl $0x0, %eax
je 0xbd011
movq -0x8(%rbp), %rax
movl $0x193, 0x284(%rax)     # imm = 0x193
movq -0x8(%rbp), %rdi
addq $0x8, %rdi
leaq 0x7832(%rip), %rsi      # 0xc4830
leaq 0xaf99(%rip), %rdx      # 0xc7f9e
movb $0x0, %al
callq 0xb0cb0
jmp 0xbd154
movq -0x8(%rbp), %rax
movq (%rax), %rdi
leaq 0x9a61(%rip), %rsi      # 0xc6a80
movl $0x9c, %edx
callq 0xafce0
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rsi
movq -0x18(%rbp), %rdx
callq 0xbd6f0
movq -0x18(%rbp), %rax
movl 0x18(%rax), %eax
andl $0xf000, %eax           # imm = 0xF000
cmpl $0x4000, %eax           # imm = 0x4000
jne 0xbd13c
cmpq $0x0, -0x28(%rbp)
je 0xbd075
movq -0x28(%rbp), %rdi
leaq 0xa97b(%rip), %rsi      # 0xc79e2
callq 0xdab0
cmpl $0x0, %eax
je 0xbd13c
movq $0x0, -0x38(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
leaq -0x38(%rbp), %rdx
callq 0xb7370
movl %eax, -0x40(%rbp)
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x40(%rbp), %eax
jge 0xbd133
movq -0x38(%rbp), %rax
movslq -0x3c(%rbp), %rcx
imulq $0xa0, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x6048(%rbp)
movq -0x6048(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x6050(%rbp)
movq -0x6048(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0xd550
movq -0x6050(%rbp), %rdi
movq %rax, %rsi
leaq -0x6040(%rbp), %rdx
movl $0x6000, %ecx           # imm = 0x6000
callq 0xb21e0
movq -0x8(%rbp), %rdi
leaq -0x6040(%rbp), %rsi
movq -0x6048(%rbp), %rdx
addq $0x10, %rdx
callq 0xbd6f0
movq -0x6048(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0xd2c0
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0xbd098
movq -0x38(%rbp), %rdi
callq 0xd2c0
movq -0x8(%rbp), %rax
movq (%rax), %rdi
leaq 0x99d6(%rip), %rsi      # 0xc6b20
movl $0x10, %edx
callq 0xafce0
jmp 0xbd156
movq -0x8(%rbp), %rdi
callq 0xb23e0
addq $0x6050, %rsp           # imm = 0x6050
popq %rbp
retq
nopl (%rax,%rax)