// File: /workspace/github_c_makefile_star2_O1/coyove[P]chann/./lib/mongoose/mongoose.c
// Function: send_directory_listing
static void send_directory_listing(struct connection *conn, const char *dir) {
  struct dir_entry *arr = NULL;
  int i, num_entries, sort_direction = conn->mg_conn.query_string != NULL &&
    conn->mg_conn.query_string[1] == 'd' ? 'a' : 'd';

  mg_send_header(&conn->mg_conn, "Transfer-Encoding", "chunked");
  mg_send_header(&conn->mg_conn, "Content-Type", "text/html; charset=utf-8");

  mg_printf_data(&conn->mg_conn,
              "<html><head><title>Index of %s</title>"
              "<style>th {text-align: left;}</style></head>"
              "<body><h1>Index of %s</h1><pre><table cellpadding=\"0\">"
              "<tr><th><a href=\"?n%c\">Name</a></th>"
              "<th><a href=\"?d%c\">Modified</a></th>"
              "<th><a href=\"?s%c\">Size</a></th></tr>"
              "<tr><td colspan=\"3\"><hr></td></tr>",
              conn->mg_conn.uri, conn->mg_conn.uri,
              sort_direction, sort_direction, sort_direction);

  num_entries = scan_directory(conn, dir, &arr);
  if (arr) {
      qsort(arr, num_entries, sizeof(arr[0]), compare_dir_entries);
      for (i = 0; i < num_entries; i++) {
        print_dir_entry(&arr[i]);
        NS_FREE(arr[i].file_name);
      }
      NS_FREE(arr);
  }

  write_terminating_chunk(conn);
  close_local_endpoint(conn);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x60a8, %rsp           # imm = 0x60A8
movq %rsi, %rbx
movq $0x0, -0x40(%rbp)
leaq 0x8(%rdi), %r14
movq %rdi, -0x30(%rbp)
movq 0x20(%rdi), %rax
testq %rax, %rax
je 0x6c9ed
xorl %ecx, %ecx
cmpb $0x64, 0x1(%rax)
setne %cl
leal (%rcx,%rcx,2), %r15d
addl $0x61, %r15d
jmp 0x6c9f3
movl $0x64, %r15d
leaq 0xdeab(%rip), %rsi      # 0x7a8a5
leaq 0xdeb6(%rip), %rdx      # 0x7a8b7
movq %r14, %rdi
callq 0x69fbf
leaq 0x6f48(%rip), %rsi      # 0x73958
leaq 0xe28d(%rip), %rdx      # 0x7aca4
movq %r14, %rdi
callq 0x69fbf
movq -0x30(%rbp), %r12
movq 0x10(%r12), %rcx
subq $0x8, %rsp
leaq 0xe28a(%rip), %rsi      # 0x7acbd
movq %r14, %rdi
movq %rcx, %rdx
movl %r15d, %r8d
movl %r15d, %r9d
xorl %eax, %eax
pushq %r15
callq 0x6a0f7
addq $0x10, %rsp
leaq -0x40(%rbp), %r14
movq %r12, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x6e368
movq (%r14), %r14
testq %r14, %r14
je 0x6cc22
movl %eax, %ebx
movslq %eax, %r15
leaq 0x1ac0(%rip), %rcx      # 0x6e536
movl $0xa0, %edx
movq %r14, %rdi
movq %r15, %rsi
callq 0xc7f0
testl %r15d, %r15d
jle 0x6cc1a
movl %ebx, %eax
shlq $0x5, %rax
leaq (%rax,%rax,4), %rax
movq %rax, -0x38(%rbp)
leaq -0xd0(%rbp), %rdi
xorl %ebx, %ebx
movl 0x28(%r14,%rbx), %eax
movl $0xf000, %ecx           # imm = 0xF000
andl %ecx, %eax
cmpl $0x4000, %eax           # imm = 0x4000
jne 0x6cadf
movl $0x40, %esi
leaq 0xb87f(%rip), %rdx      # 0x78344
leaq 0xe313(%rip), %rcx      # 0x7addf
xorl %eax, %eax
callq 0x6c630
leaq 0xead2(%rip), %r12      # 0x7b5ac
jmp 0x6cb6a
movq 0x40(%r14,%rbx), %rcx
cmpq $0x3ff, %rcx            # imm = 0x3FF
jg 0x6cb02
movl $0x40, %esi
leaq 0x750c(%rip), %rdx      # 0x74005
xorl %eax, %eax
callq 0x6c630
jmp 0x6cb63
xorps %xmm0, %xmm0
cvtsi2sd %rcx, %xmm0
cmpq $0xfffff, %rcx          # imm = 0xFFFFF
jg 0x6cb29
mulsd 0xd735(%rip), %xmm0     # 0x7a250
movl $0x40, %esi
leaq 0xe2c4(%rip), %rdx      # 0x7adeb
jmp 0x6cb5c
cmpq $0x3fffffff, %rcx       # imm = 0x3FFFFFFF
jg 0x6cb48
mulsd 0xd70e(%rip), %xmm0     # 0x7a248
movl $0x40, %esi
leaq 0xe2ab(%rip), %rdx      # 0x7adf1
jmp 0x6cb5c
mulsd 0xd6f0(%rip), %xmm0     # 0x7a240
movl $0x40, %esi
leaq 0xe29b(%rip), %rdx      # 0x7adf7
movb $0x1, %al
callq 0x6c630
leaq 0xcafd(%rip), %r12      # 0x79667
movq 0x68(%r14,%rbx), %rax
movq %rax, -0x48(%rbp)
leaq -0x48(%rbp), %rdi
callq 0xc770
movl $0x40, %esi
movq %r14, %r15
leaq -0x90(%rbp), %rdi
leaq 0xe26b(%rip), %rdx      # 0x7adfd
movq %rax, %rcx
callq 0xc9d0
movq 0x8(%r14,%rbx), %r13
movq %r13, %rdi
callq 0xc460
movl $0x6000, %ecx           # imm = 0x6000
movq %r13, %rdi
movq %rax, %rsi
leaq -0x60d0(%rbp), %r14
movq %r14, %rdx
callq 0x6a4c1
movq (%r15,%rbx), %rdi
addq $0x8, %rdi
leaq 0xe23c(%rip), %rsi      # 0x7ae0c
movq %r14, %rdx
movq %r12, %rcx
movq %r13, %r8
movq %r12, %r9
xorl %eax, %eax
leaq -0xd0(%rbp), %r12
pushq %r12
leaq -0x90(%rbp), %r10
pushq %r10
movq %r15, %r14
callq 0x6a0f7
addq $0x10, %rsp
movq 0x8(%r15,%rbx), %rdi
callq 0xc250
addq $0xa0, %rbx
cmpq %rbx, -0x38(%rbp)
movq %r12, %rdi
jne 0x6caa6
movq %r14, %rdi
callq 0xc250
movq -0x30(%rbp), %rbx
movq (%rbx), %rdi
leaq 0xebe9(%rip), %rsi      # 0x7b819
movl $0x5, %edx
callq 0x681c0
movq %rbx, %rdi
callq 0x6a615
addq $0x60a8, %rsp           # imm = 0x60A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq