// File: /workspace/github_c_makefile_star2_O0/coyove[P]chann/./lib/mongoose/mongoose.c
// Function: compare_dir_entries
static int __cdecl compare_dir_entries(const void *p1, const void *p2) {
  const struct dir_entry *a = (const struct dir_entry *) p1,
        *b = (const struct dir_entry *) p2;
  const char *qs = a->conn->mg_conn.query_string ?
    a->conn->mg_conn.query_string : "na";
  int cmp_result = 0;

  if (S_ISDIR(a->st.st_mode) && !S_ISDIR(b->st.st_mode)) {
    return -1;  // Always put directories on top
  } else if (!S_ISDIR(a->st.st_mode) && S_ISDIR(b->st.st_mode)) {
    return 1;   // Always put directories on top
  } else if (*qs == 'n') {
    cmp_result = strcmp(a->file_name, b->file_name);
  } else if (*qs == 's') {
    cmp_result = a->st.st_size == b->st.st_size ? 0 :
      a->st.st_size > b->st.st_size ? 1 : -1;
  } else if (*qs == 'd') {
    cmp_result = a->st.st_mtime == b->st.st_mtime ? 0 :
      a->st.st_mtime > b->st.st_mtime ? 1 : -1;
  }

  return qs[1] == 'd' ? -cmp_result : cmp_result;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rax
movq (%rax), %rax
cmpq $0x0, 0x20(%rax)
je 0xb75ff
movq -0x20(%rbp), %rax
movq (%rax), %rax
movq 0x20(%rax), %rax
movq %rax, -0x40(%rbp)
jmp 0xb760c
leaq 0x100bd(%rip), %rax     # 0xc76c3
movq %rax, -0x40(%rbp)
jmp 0xb760c
movq -0x40(%rbp), %rax
movq %rax, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
movq -0x20(%rbp), %rax
movl 0x28(%rax), %eax
andl $0xf000, %eax           # imm = 0xF000
cmpl $0x4000, %eax           # imm = 0x4000
jne 0xb764d
movq -0x28(%rbp), %rax
movl 0x28(%rax), %eax
andl $0xf000, %eax           # imm = 0xF000
cmpl $0x4000, %eax           # imm = 0x4000
je 0xb764d
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xb7771
movq -0x20(%rbp), %rax
movl 0x28(%rax), %eax
andl $0xf000, %eax           # imm = 0xF000
cmpl $0x4000, %eax           # imm = 0x4000
je 0xb767f
movq -0x28(%rbp), %rax
movl 0x28(%rax), %eax
andl $0xf000, %eax           # imm = 0xF000
cmpl $0x4000, %eax           # imm = 0x4000
jne 0xb767f
movl $0x1, -0x4(%rbp)
jmp 0xb7771
movq -0x30(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x6e, %eax
jne 0xb76a8
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rsi
callq 0xdab0
movl %eax, -0x34(%rbp)
jmp 0xb774a
movq -0x30(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x73, %eax
jne 0xb76f8
movq -0x20(%rbp), %rax
movq 0x40(%rax), %rax
movq -0x28(%rbp), %rcx
cmpq 0x40(%rcx), %rax
jne 0xb76cd
xorl %eax, %eax
movl %eax, -0x44(%rbp)
jmp 0xb76f0
movq -0x20(%rbp), %rax
movq 0x40(%rax), %rdx
movq -0x28(%rbp), %rax
movq 0x40(%rax), %rsi
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl $0x1, %ecx
cmpq %rsi, %rdx
cmovgl %ecx, %eax
movl %eax, -0x44(%rbp)
movl -0x44(%rbp), %eax
movl %eax, -0x34(%rbp)
jmp 0xb7748
movq -0x30(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x64, %eax
jne 0xb7746
movq -0x20(%rbp), %rax
movq 0x68(%rax), %rax
movq -0x28(%rbp), %rcx
cmpq 0x68(%rcx), %rax
jne 0xb771d
xorl %eax, %eax
movl %eax, -0x48(%rbp)
jmp 0xb7740
movq -0x20(%rbp), %rax
movq 0x68(%rax), %rdx
movq -0x28(%rbp), %rax
movq 0x68(%rax), %rsi
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl $0x1, %ecx
cmpq %rsi, %rdx
cmovgl %ecx, %eax
movl %eax, -0x48(%rbp)
movl -0x48(%rbp), %eax
movl %eax, -0x34(%rbp)
jmp 0xb7748
jmp 0xb774a
jmp 0xb774c
jmp 0xb774e
movq -0x30(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x64, %eax
jne 0xb7765
xorl %eax, %eax
subl -0x34(%rbp), %eax
movl %eax, -0x4c(%rbp)
jmp 0xb776b
movl -0x34(%rbp), %eax
movl %eax, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopw (%rax,%rax)