// File: /workspace/github_c_makefile_star2_O0/cogbee[P]vmir-latest/src/vmir_libc.c
// Function: dofmt
static void
dofmt(void (*output)(void *opaque, const char *str, int len),
      void *opaque, const char *fmt, const void *valist,
      ir_unit_t *iu)
{
  while(*fmt) {
    char c = *fmt;
    if(c != '%') {
      output(opaque, fmt, 1); // xxx: lame, should do long runs of unfmted str
      fmt++;
      continue;
    }
    int num_field_args = 0;
    const char *start = fmt;
    int flags = 0;
    fmt++;
  again:
    c = *fmt++;
  reswitch:
    switch(c) {
    case ' ':
    case '#':
    case '+':
    case '-':
    case '0':
      goto again;
    case '*':
      num_field_args++;
      goto again;

    case '.':
      if((c = *fmt++) == '*') {
        goto reswitch;
      }

      while(c >= '0' && c <= '9')
        c = *fmt++;
      goto reswitch;

    case '1':
    case '2':
    case '3':
    case '4':
    case '5':
    case '6':
    case '7':
    case '8':
    case '9':
      do {
        c = *fmt++;
      } while(c >= '0' && c <= '9');
      goto reswitch;
    case 'z':
      flags = 0;
      goto again;
    case 'l':
      if(flags & FMT_FLAGS_LONG)
        flags |= FMT_FLAGS_INT64;
      else
        flags |= FMT_FLAGS_LONG;
      goto again;

    case 'q':
      flags |= FMT_FLAGS_INT64;
      goto again;

    case 'c':
      dofmt2(output, opaque, start, fmt, num_field_args, FMT_TYPE_INT,
             &valist, iu);
      break;

    case 'O':
    case 'o':
    case 'D':
    case 'd':
    case 'i':
    case 'U':
    case 'u':
    case 'X':
    case 'x':
      if(flags & FMT_FLAGS_INT64) {
        dofmt2(output, opaque, start, fmt, num_field_args, FMT_TYPE_INT64,
               &valist, iu);
      } else {
        dofmt2(output, opaque, start, fmt, num_field_args, FMT_TYPE_INT,
               &valist, iu);
      }
      break;

    case 'e':
    case 'E':
    case 'f':
    case 'g':
    case 'G':
      dofmt2(output, opaque, start, fmt, num_field_args, FMT_TYPE_DOUBLE,
             &valist, iu);
      break;

    case 'p':
      dofmt2(output, opaque, start, fmt, num_field_args, FMT_TYPE_PTR,
             &valist, iu);
      break;

    case 's':
      dofmt2(output, opaque, start, fmt, num_field_args, FMT_TYPE_STR,
             &valist, iu);
      break;

    case 0:
      return;

    default:
      output(opaque, &c, 1);
      break;
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq -0x18(%rbp), %rax
cmpb $0x0, (%rax)
je 0x1b8e7
movq -0x18(%rbp), %rax
movb (%rax), %al
movb %al, -0x29(%rbp)
movsbl -0x29(%rbp), %eax
cmpl $0x25, %eax
je 0x1b64c
movq -0x8(%rbp), %rax
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl $0x1, %edx
callq *%rax
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0x1b60c
movl $0x0, -0x30(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x38(%rbp)
movl $0x0, -0x3c(%rbp)
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x18(%rbp)
movb (%rax), %al
movb %al, -0x29(%rbp)
movsbl -0x29(%rbp), %eax
movl %eax, %ecx
movq %rcx, -0x48(%rbp)
subl $0x7a, %eax
ja 0x1b8cf
movq -0x48(%rbp), %rax
leaq 0x21590(%rip), %rcx     # 0x3cc30
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
jmp 0x1b66e
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x1b66e
movq -0x18(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x18(%rbp)
movb (%rax), %al
movb %al, -0x29(%rbp)
movsbl %al, %eax
cmpl $0x2a, %eax
jne 0x1b6d4
jmp 0x1b682
jmp 0x1b6d6
movsbl -0x29(%rbp), %ecx
xorl %eax, %eax
cmpl $0x30, %ecx
movb %al, -0x49(%rbp)
jl 0x1b6f1
movsbl -0x29(%rbp), %eax
cmpl $0x39, %eax
setle %al
movb %al, -0x49(%rbp)
movb -0x49(%rbp), %al
testb $0x1, %al
jne 0x1b6fa
jmp 0x1b710
movq -0x18(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x18(%rbp)
movb (%rax), %al
movb %al, -0x29(%rbp)
jmp 0x1b6d6
jmp 0x1b682
jmp 0x1b717
movq -0x18(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x18(%rbp)
movb (%rax), %al
movb %al, -0x29(%rbp)
movsbl -0x29(%rbp), %ecx
xorl %eax, %eax
cmpl $0x30, %ecx
movb %al, -0x4a(%rbp)
jl 0x1b746
movsbl -0x29(%rbp), %eax
cmpl $0x39, %eax
setle %al
movb %al, -0x4a(%rbp)
movb -0x4a(%rbp), %al
testb $0x1, %al
jne 0x1b717
jmp 0x1b682
movl $0x0, -0x3c(%rbp)
jmp 0x1b66e
movl -0x3c(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x1b774
movl -0x3c(%rbp), %eax
orl $0x2, %eax
movl %eax, -0x3c(%rbp)
jmp 0x1b77d
movl -0x3c(%rbp), %eax
orl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x1b66e
movl -0x3c(%rbp), %eax
orl $0x2, %eax
movl %eax, -0x3c(%rbp)
jmp 0x1b66e
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x38(%rbp), %rdx
movq -0x18(%rbp), %rcx
movl -0x30(%rbp), %r8d
movq -0x28(%rbp), %rax
movl $0x1, %r9d
leaq -0x20(%rbp), %r10
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x1b990
jmp 0x1b8e2
movl -0x3c(%rbp), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x1b802
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x38(%rbp), %rdx
movq -0x18(%rbp), %rcx
movl -0x30(%rbp), %r8d
movq -0x28(%rbp), %rax
movl $0x2, %r9d
leaq -0x20(%rbp), %r10
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x1b990
jmp 0x1b832
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x38(%rbp), %rdx
movq -0x18(%rbp), %rcx
movl -0x30(%rbp), %r8d
movq -0x28(%rbp), %rax
movl $0x1, %r9d
leaq -0x20(%rbp), %r10
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x1b990
jmp 0x1b8e2
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x38(%rbp), %rdx
movq -0x18(%rbp), %rcx
movl -0x30(%rbp), %r8d
movq -0x28(%rbp), %rax
movl $0x5, %r9d
leaq -0x20(%rbp), %r10
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x1b990
jmp 0x1b8e2
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x38(%rbp), %rdx
movq -0x18(%rbp), %rcx
movl -0x30(%rbp), %r8d
movq -0x28(%rbp), %rax
movl $0x3, %r9d
leaq -0x20(%rbp), %r10
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x1b990
jmp 0x1b8e2
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x38(%rbp), %rdx
movq -0x18(%rbp), %rcx
movl -0x30(%rbp), %r8d
movq -0x28(%rbp), %rax
movl $0x4, %r9d
leaq -0x20(%rbp), %r10
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x1b990
jmp 0x1b8e2
jmp 0x1b8e7
movq -0x8(%rbp), %rax
movq -0x10(%rbp), %rdi
leaq -0x29(%rbp), %rsi
movl $0x1, %edx
callq *%rax
jmp 0x1b60c
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax)