// File: /workspace/github_c_makefile_star2_O0/ohkimur[P]the-c-programming-language-2nd-edition-solutions/chapter_5/exercise_5_16/sort.c
// Function: estrcmp
int estrcmp(const char *s1, const char *s2)
{
  while (*s1 != '\0' && *s2 != '\0')
  {
    if (directory)
    {
      while (*s1 != '\0' && !isalnum(*s1) && !isspace(*s1))
      {
        ++s1;
      }
      while (*s2 != '\0' && !isalnum(*s2) && !isspace(*s2))
      {
        ++s2;
      }
    }

    int result = fold ? tolower(*s1) - tolower(*s2) : *s1 - *s2;
    if (result == 0)
    {
      ++s1;
      ++s2;
    }
    else
    {
      return order * result;
    }
  }

  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x1d(%rbp)
je 0x11d1
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
setne %al
movb %al, -0x1d(%rbp)
movb -0x1d(%rbp), %al
testb $0x1, %al
jne 0x11dd
jmp 0x134f
cmpl $0x0, 0x2eb0(%rip)      # 0x4094
je 0x12d2
jmp 0x11ec
movq -0x10(%rbp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x1e(%rbp)
je 0x1246
callq 0x1090
movq (%rax), %rax
movq -0x10(%rbp), %rcx
movsbl (%rcx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %ecx
andl $0x8, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x1e(%rbp)
jne 0x1246
callq 0x1090
movq (%rax), %rax
movq -0x10(%rbp), %rcx
movsbl (%rcx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x2000, %eax           # imm = 0x2000
cmpl $0x0, %eax
setne %al
xorb $-0x1, %al
movb %al, -0x1e(%rbp)
movb -0x1e(%rbp), %al
testb $0x1, %al
jne 0x124f
jmp 0x125d
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x10(%rbp)
jmp 0x11ec
jmp 0x125f
movq -0x18(%rbp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x1f(%rbp)
je 0x12b9
callq 0x1090
movq (%rax), %rax
movq -0x18(%rbp), %rcx
movsbl (%rcx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %ecx
andl $0x8, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x1f(%rbp)
jne 0x12b9
callq 0x1090
movq (%rax), %rax
movq -0x18(%rbp), %rcx
movsbl (%rcx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x2000, %eax           # imm = 0x2000
cmpl $0x0, %eax
setne %al
xorb $-0x1, %al
movb %al, -0x1f(%rbp)
movb -0x1f(%rbp), %al
testb $0x1, %al
jne 0x12c2
jmp 0x12d0
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0x125f
jmp 0x12d2
cmpl $0x0, 0x2db7(%rip)      # 0x4090
je 0x1302
movq -0x10(%rbp), %rax
movsbl (%rax), %edi
callq 0x1070
movl %eax, -0x28(%rbp)
movq -0x18(%rbp), %rax
movsbl (%rax), %edi
callq 0x1070
movl %eax, %ecx
movl -0x28(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x24(%rbp)
jmp 0x1315
movq -0x10(%rbp), %rax
movsbl (%rax), %eax
movq -0x18(%rbp), %rcx
movsbl (%rcx), %ecx
subl %ecx, %eax
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
jne 0x133b
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x10(%rbp)
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0x134a
movl 0x2d1f(%rip), %eax      # 0x4060
imull -0x1c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x1356
jmp 0x11b0
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nop