// File: /workspace/github_c_makefile_star2_O1/ohkimur[P]the-c-programming-language-2nd-edition-solutions/chapter_7/exercise_7_04/minscanf.c
// Function: minscanf
void minscanf(const char *format, ...)
{
  va_list arg_p;

  va_start(arg_p, format);
  for (; *format != '\0'; ++format)
  {
    if (*format != '%')
    {
      continue;
    }

    switch (*++format)
    {
    case 'd':
      scanf("%d", va_arg(arg_p, int *));
      break;

    case 'i':
      scanf("%i", va_arg(arg_p, int *));
      break;

    case 'o':
      scanf("%o", va_arg(arg_p, int *));
      break;

    case 'u':
      scanf("%u", va_arg(arg_p, unsigned int *));
      break;

    case 'x':
      scanf("%x", va_arg(arg_p, int *));
      break;

    case 'c':
      scanf("%c", va_arg(arg_p, char *));
      break;

    case 's':
      scanf("%s", va_arg(arg_p, char *));
      break;

    case 'e':
    case 'f':
    case 'g':
      scanf("%f", va_arg(arg_p, float *));
      break;

    default:
      break;
    }
  }
  va_end(arg_p);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movq %rdi, %rbx
leaq 0x20(%rsp), %rdi
movq %rsi, 0x8(%rdi)
movq %rdx, 0x10(%rdi)
movq %rcx, 0x18(%rdi)
movq %r8, 0x20(%rdi)
movq %r9, 0x28(%rdi)
testb %al, %al
je 0x1315
movaps %xmm0, 0x50(%rsp)
movaps %xmm1, 0x60(%rsp)
movaps %xmm2, 0x70(%rsp)
movaps %xmm3, 0x80(%rsp)
movaps %xmm4, 0x90(%rsp)
movaps %xmm5, 0xa0(%rsp)
movaps %xmm6, 0xb0(%rsp)
movaps %xmm7, 0xc0(%rsp)
movq %rdi, 0x10(%rsp)
leaq 0x110(%rsp), %rax
movq %rax, 0x8(%rsp)
movabsq $0x3000000008, %rax     # imm = 0x3000000008
movq %rax, (%rsp)
leaq 0xcc8(%rip), %r14       # 0x2004
leaq 0xd2e(%rip), %r13       # 0x2071
leaq 0xd24(%rip), %r12       # 0x206e
leaq 0xd14(%rip), %rbp       # 0x2065
leaq 0xd10(%rip), %r15       # 0x2068
movzbl (%rbx), %eax
cmpl $0x25, %eax
je 0x136d
testl %eax, %eax
jne 0x1535
jmp 0x153d
movzbl 0x1(%rbx), %eax
incq %rbx
addl $-0x63, %eax
cmpl $0x15, %eax
ja 0x1535
movslq (%r14,%rax,4), %rax
addq %r14, %rax
jmpq *%rax
movl (%rsp), %ecx
cmpq $0x28, %rcx
ja 0x13a2
movq %rcx, %rax
addq 0x10(%rsp), %rax
addl $0x8, %ecx
movl %ecx, (%rsp)
jmp 0x13b0
movq 0x8(%rsp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq %r13, %rdi
jmp 0x152b
movl (%rsp), %ecx
cmpq $0x28, %rcx
ja 0x1498
movq %rcx, %rax
addq 0x10(%rsp), %rax
addl $0x8, %ecx
movl %ecx, (%rsp)
jmp 0x14a6
movl (%rsp), %ecx
cmpq $0x28, %rcx
ja 0x14af
movq %rcx, %rax
addq 0x10(%rsp), %rax
addl $0x8, %ecx
movl %ecx, (%rsp)
jmp 0x14bd
movl (%rsp), %ecx
cmpq $0x28, %rcx
ja 0x14c2
movq %rcx, %rax
addq 0x10(%rsp), %rax
addl $0x8, %ecx
movl %ecx, (%rsp)
jmp 0x14d0
movl (%rsp), %ecx
cmpq $0x28, %rcx
ja 0x14d9
movq %rcx, %rax
addq 0x10(%rsp), %rax
addl $0x8, %ecx
movl %ecx, (%rsp)
jmp 0x14e7
movl (%rsp), %ecx
cmpq $0x28, %rcx
ja 0x14f0
movq %rcx, %rax
addq 0x10(%rsp), %rax
addl $0x8, %ecx
movl %ecx, (%rsp)
jmp 0x14fe
movl (%rsp), %ecx
cmpq $0x28, %rcx
ja 0x1503
movq %rcx, %rax
addq 0x10(%rsp), %rax
addl $0x8, %ecx
movl %ecx, (%rsp)
jmp 0x1511
movl (%rsp), %ecx
cmpq $0x28, %rcx
ja 0x1516
movq %rcx, %rax
addq 0x10(%rsp), %rax
addl $0x8, %ecx
movl %ecx, (%rsp)
jmp 0x1524
movq 0x8(%rsp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
leaq 0xbb5(%rip), %rdi       # 0x2062
jmp 0x152b
movq 0x8(%rsp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq %r12, %rdi
jmp 0x152b
movq 0x8(%rsp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
leaq 0xb94(%rip), %rdi       # 0x206b
jmp 0x152b
movq 0x8(%rsp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
leaq 0xb6e(%rip), %rdi       # 0x205c
jmp 0x152b
movq 0x8(%rsp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq %r15, %rdi
jmp 0x152b
movq 0x8(%rsp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq %rbp, %rdi
jmp 0x152b
movq 0x8(%rsp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
leaq 0xb34(%rip), %rdi       # 0x205f
movq (%rax), %rsi
xorl %eax, %eax
callq 0x1040
incq %rbx
jmp 0x1358
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq