// File: /workspace/github_c_makefile_star2_O0/ohkimur[P]the-c-programming-language-2nd-edition-solutions/chapter_4/exercise_4_11/getop.c
// Function: getop
int getop(char s[])
{
  int i = 0, c;
  static int buf = EOF;

  while ((s[0] = c = getchar()) == ' ' || c == '\t')
    ;

  s[1] = '\0';

  if (!isdigit(c) && c != '.' && c != '-')
  {
    return c;
  }

  if (c == '-')
  {
    int next = getchar();
    if (!isdigit(next) && next != '.')
    {
      return next;
    }

    s[i] = c;
    c = next = buf;
  }
  else
  {
    c = getchar();
  }

  if (isdigit(c))
  {
    while (isdigit(s[++i] = c = getchar()))
      ;
  }

  if (c == '.')
  {
    while (isdigit(s[++i] = c = getchar()))
      ;
  }

  if (c != EOF)
  {
    buf = c;
  }

  return NUMBER;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movl $0x0, -0x14(%rbp)
callq 0x1050
movl %eax, -0x18(%rbp)
movq -0x10(%rbp), %rcx
movb %al, (%rcx)
movsbl %al, %ecx
movb $0x1, %al
cmpl $0x20, %ecx
movb %al, -0x1d(%rbp)
je 0x1348
cmpl $0x9, -0x18(%rbp)
sete %al
movb %al, -0x1d(%rbp)
movb -0x1d(%rbp), %al
testb $0x1, %al
jne 0x1351
jmp 0x1353
jmp 0x1323
movq -0x10(%rbp), %rax
movb $0x0, 0x1(%rax)
callq 0x1060
movq (%rax), %rax
movslq -0x18(%rbp), %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x800, %eax            # imm = 0x800
cmpl $0x0, %eax
jne 0x138c
cmpl $0x2e, -0x18(%rbp)
je 0x138c
cmpl $0x2d, -0x18(%rbp)
je 0x138c
movl -0x18(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x14af
cmpl $0x2d, -0x18(%rbp)
jne 0x13e3
callq 0x1050
movl %eax, -0x1c(%rbp)
callq 0x1060
movq (%rax), %rax
movslq -0x1c(%rbp), %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x800, %eax            # imm = 0x800
cmpl $0x0, %eax
jne 0x13c5
cmpl $0x2e, -0x1c(%rbp)
je 0x13c5
movl -0x1c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x14af
movl -0x18(%rbp), %eax
movb %al, %dl
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movb %dl, (%rax,%rcx)
movl 0x2c6d(%rip), %eax      # 0x4048
movl %eax, -0x1c(%rbp)
movl %eax, -0x18(%rbp)
jmp 0x13eb
callq 0x1050
movl %eax, -0x18(%rbp)
callq 0x1060
movq (%rax), %rax
movslq -0x18(%rbp), %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x800, %eax            # imm = 0x800
cmpl $0x0, %eax
je 0x144c
jmp 0x1407
callq 0x1060
movq (%rax), %rax
movq %rax, -0x28(%rbp)
callq 0x1050
movl %eax, %ecx
movq -0x28(%rbp), %rax
movl %ecx, -0x18(%rbp)
movq -0x10(%rbp), %rdx
movl -0x14(%rbp), %esi
addl $0x1, %esi
movl %esi, -0x14(%rbp)
movslq %esi, %rsi
movb %cl, (%rdx,%rsi)
movsbl %cl, %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x800, %eax            # imm = 0x800
cmpl $0x0, %eax
je 0x144a
jmp 0x1407
jmp 0x144c
cmpl $0x2e, -0x18(%rbp)
jne 0x1499
jmp 0x1454
callq 0x1060
movq (%rax), %rax
movq %rax, -0x30(%rbp)
callq 0x1050
movl %eax, %ecx
movq -0x30(%rbp), %rax
movl %ecx, -0x18(%rbp)
movq -0x10(%rbp), %rdx
movl -0x14(%rbp), %esi
addl $0x1, %esi
movl %esi, -0x14(%rbp)
movslq %esi, %rsi
movb %cl, (%rdx,%rsi)
movsbl %cl, %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x800, %eax            # imm = 0x800
cmpl $0x0, %eax
je 0x1497
jmp 0x1454
jmp 0x1499
cmpl $-0x1, -0x18(%rbp)
je 0x14a8
movl -0x18(%rbp), %eax
movl %eax, 0x2ba0(%rip)      # 0x4048
movl $0x30, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax,%rax)