// File: /workspace/github_c_makefile_star2_O2/cogbee[P]vmir-latest/src/vmir_libc.c
// Function: dofmt2
static void
dofmt2(void (*output)(void *opaque, const char *str, int len),
       void *opaque,
       const char *start, const char *end, int num_field_args,
       int type, const void **va, ir_unit_t *iu)
{
  const void *vacopy = *va;
  size_t len = end - start;
  char fmt[len + 1];
  char tmpbuf[100];
  void *alloc = NULL;
  char *dst;
  size_t dz = sizeof(tmpbuf);
  memcpy(fmt, start, len);
  fmt[len] = 0;
  dst = tmpbuf;

  while(1) {
    int n = -1;
    int l1, l2;
    *va = vacopy;
    switch(type) {
    case FMT_TYPE_INT:
      switch(num_field_args) {
      case 0:
        n = snprintf(dst, dz, fmt, vmir_vm_vaarg32(va, iu));
        break;
      case 1:
        l1 = vmir_vm_vaarg32(va, iu);
        n = snprintf(dst, dz, fmt, l1, vmir_vm_vaarg32(va, iu));
        break;
      case 2:
        l1 = vmir_vm_vaarg32(va, iu);
        l2 = vmir_vm_vaarg32(va, iu);
        n = snprintf(dst, dz, fmt, l1, l2, vmir_vm_vaarg32(va, iu));
        break;
      default:
        goto done;
      }
      break;

    case FMT_TYPE_INT64:
      switch(num_field_args) {
      case 0:
        n = snprintf(dst, dz, fmt, vmir_vm_vaarg64(va, iu));
        break;
      case 1:
        l1 = vmir_vm_vaarg32(va, iu);
        n = snprintf(dst, dz, fmt, l1, vmir_vm_vaarg64(va, iu));
        break;
      case 2:
        l1 = vmir_vm_vaarg32(va, iu);
        l2 = vmir_vm_vaarg32(va, iu);
        n = snprintf(dst, dz, fmt, l1, l2, vmir_vm_vaarg64(va, iu));
        break;
      default:
        goto done;
      }
      break;

    case FMT_TYPE_PTR:
      switch(num_field_args) {
      case 0:
        n = snprintf(dst, dz, fmt, (void *)(intptr_t)vmir_vm_vaarg32(va, iu));
        break;
      case 1:
        l1 = vmir_vm_vaarg32(va, iu);
        n = snprintf(dst, dz, fmt, l1,
                     (void *)(intptr_t)vmir_vm_vaarg32(va, iu));
        break;
      case 2:
        l1 = vmir_vm_vaarg32(va, iu);
        l2 = vmir_vm_vaarg32(va, iu);
        n = snprintf(dst, dz, fmt, l1, l2,
                     (void *)(intptr_t)vmir_vm_vaarg32(va, iu));
        break;
      default:
        goto done;
      }
      break;

    case FMT_TYPE_STR:
      switch(num_field_args) {
      case 0:
        n = snprintf(dst, dz, fmt, vmir_vm_vaptr(va, iu));
        break;
      case 1:
        l1 = vmir_vm_vaarg32(va, iu);
        n = snprintf(dst, dz, fmt, l1, vmir_vm_vaptr(va, iu));
        break;
      case 2:
        l1 = vmir_vm_vaarg32(va, iu);
        l2 = vmir_vm_vaarg32(va, iu);
        n = snprintf(dst, dz, fmt, l1, l2, vmir_vm_vaptr(va, iu));
        break;
      default:
        goto done;
      }
      break;

    case FMT_TYPE_DOUBLE:
      switch(num_field_args) {
      case 0:
        n = snprintf(dst, dz, fmt, vmir_vm_vaarg_dbl(va, iu));
        break;
      case 1:
        l1 = vmir_vm_vaarg32(va, iu);
        n = snprintf(dst, dz, fmt, vmir_vm_vaarg32(va, iu),
                     vmir_vm_vaarg_dbl(va, iu));
        break;
      case 2:
        l1 = vmir_vm_vaarg32(va, iu);
        l2 = vmir_vm_vaarg32(va, iu);
        n = snprintf(dst, dz, fmt, l1, l2, vmir_vm_vaarg_dbl(va, iu));
        break;
      default:
        goto done;
      }
      break;
    }

    if(n < 0)
      break;

    if(n < dz) {
      output(opaque, dst, n);
      break;
    }

    assert(alloc == NULL);
    dz = n + 1;
    alloc = malloc(dz);
    dst = alloc;
  }

 done:
  free(alloc);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movl %r9d, %r14d
movl %r8d, -0x3c(%rbp)
movq %rcx, %rbx
movq %rsi, -0x60(%rbp)
movq %rdi, -0x68(%rbp)
movq 0x10(%rbp), %rax
movq (%rax), %r13
subq %rdx, %rbx
leaq 0x10(%rbx), %rax
andq $-0x10, %rax
movq %rsp, %r15
subq %rax, %r15
movq %r15, %rsp
movq %r15, %rdi
movq %rdx, %rsi
movq %rbx, %rdx
callq 0x3360
movq %r15, -0x30(%rbp)
movb $0x0, (%rbx,%r15)
leaq -0x4(%r13), %rax
movq %rax, -0x38(%rbp)
leaq 0x4(%r13), %r15
leaq -0x8(%r13), %rax
movq %rax, -0x58(%rbp)
leaq 0x8(%r13), %rax
movq %rax, -0x50(%rbp)
pushq $0x64
popq %r12
leaq -0xe0(%rbp), %rbx
movq $0x0, -0x48(%rbp)
movq 0x10(%rbp), %rax
movq %r13, (%rax)
decl %r14d
leaq 0x113fe(%rip), %rcx     # 0x1ede0
movq %r14, -0x70(%rbp)
movslq (%rcx,%r14,4), %rax
addq %rcx, %rax
jmpq *%rax
movl -0x3c(%rbp), %eax
cmpl $0x2, %eax
je 0xda94
cmpl $0x1, %eax
je 0xda3f
testl %eax, %eax
jne 0xdf3e
xorl %eax, %eax
movq 0x18(%rbp), %rcx
cmpl $0x1, 0x64(%rcx)
sete %al
movq -0x38(%rbp), %rcx
cmoveq %r15, %rcx
movq 0x10(%rbp), %rdx
movq %rcx, (%rdx)
movl -0x4(%r13,%rax,4), %ecx
movq %rbx, %rdi
movq %r12, %rsi
movq -0x30(%rbp), %rdx
xorl %eax, %eax
callq 0x31a0
jmp 0xdeeb
movq 0x18(%rbp), %rax
movl 0x64(%rax), %eax
cmpl $0x1, %eax
movq -0x38(%rbp), %rdx
cmoveq %r15, %rdx
leaq -0x4(%rdx), %rsi
cmpl $0x1, %eax
movq %rsi, %rdi
cmoveq %r15, %rdi
addq $0x4, %rdx
xorl %ecx, %ecx
cmpl $0x1, %eax
sete %cl
movl -0x4(%r13,%rcx,4), %ecx
cmovneq %rsi, %rdx
movq 0x10(%rbp), %rax
movq %rdx, (%rax)
movl (%rdi), %r8d
movq %rbx, %rdi
movq %r12, %rsi
movq -0x30(%rbp), %rdx
xorl %eax, %eax
callq 0x31a0
jmp 0xdeeb
movq 0x18(%rbp), %rax
movl 0x64(%rax), %eax
cmpl $0x1, %eax
movq -0x38(%rbp), %rdx
cmoveq %r15, %rdx
leaq -0x4(%rdx), %rsi
addq $0x4, %rdx
cmpl $0x1, %eax
movq %rsi, %rdi
cmoveq %rdx, %rdi
leaq -0x4(%rdi), %r9
cmpl $0x1, %eax
cmovneq %r9, %rdx
addq $0x4, %rdi
xorl %ecx, %ecx
cmpl $0x1, %eax
sete %cl
movl -0x4(%r13,%rcx,4), %ecx
cmoveq %r15, %rsi
movl (%rsi), %r8d
cmovneq %r9, %rdi
movq 0x10(%rbp), %rax
movq %rdi, (%rax)
movl (%rdx), %r9d
movq %rbx, %rdi
movq %r12, %rsi
movq -0x30(%rbp), %rdx
xorl %eax, %eax
callq 0x31a0
jmp 0xdeeb
movl -0x3c(%rbp), %eax
cmpl $0x2, %eax
je 0xdb7c
cmpl $0x1, %eax
je 0xdb3b
testl %eax, %eax
jne 0xdf3e
xorl %eax, %eax
movq 0x18(%rbp), %rcx
cmpl $0x1, 0x64(%rcx)
sete %al
movq -0x58(%rbp), %rcx
cmoveq -0x50(%rbp), %rcx
movq 0x10(%rbp), %rdx
movq %rcx, (%rdx)
movq -0x8(%r13,%rax,8), %rcx
jmp 0xdcd8
movq 0x18(%rbp), %rax
movl 0x64(%rax), %eax
cmpl $0x1, %eax
movq -0x38(%rbp), %rdx
cmoveq %r15, %rdx
leaq -0x8(%rdx), %rsi
cmpl $0x1, %eax
movq %rsi, %rdi
cmoveq %r15, %rdi
addq $0x8, %rdx
xorl %ecx, %ecx
cmpl $0x1, %eax
sete %cl
movl -0x4(%r13,%rcx,4), %ecx
cmovneq %rsi, %rdx
movq 0x10(%rbp), %rax
movq %rdx, (%rax)
movq (%rdi), %r8
jmp 0xdbd3
movq 0x18(%rbp), %rax
movl 0x64(%rax), %eax
cmpl $0x1, %eax
movq -0x38(%rbp), %rdx
cmoveq %r15, %rdx
leaq -0x4(%rdx), %rsi
addq $0x4, %rdx
cmpl $0x1, %eax
movq %rsi, %rdi
cmoveq %rdx, %rdi
leaq -0x8(%rdi), %r9
cmpl $0x1, %eax
cmovneq %r9, %rdx
addq $0x8, %rdi
xorl %ecx, %ecx
cmpl $0x1, %eax
sete %cl
movl -0x4(%r13,%rcx,4), %ecx
cmoveq %r15, %rsi
movl (%rsi), %r8d
cmovneq %r9, %rdi
movq 0x10(%rbp), %rax
movq %rdi, (%rax)
movq (%rdx), %r9
jmp 0xdbe9
movq %rbx, %rdi
movq %r12, %rsi
movq -0x30(%rbp), %rdx
xorl %eax, %eax
callq 0x31a0
jmp 0xdeeb
movq %rbx, %rdi
movq %r12, %rsi
movq -0x30(%rbp), %rdx
xorl %eax, %eax
callq 0x31a0
jmp 0xdeeb
movl -0x3c(%rbp), %eax
cmpl $0x2, %eax
je 0xdc7e
cmpl $0x1, %eax
je 0xdc3a
testl %eax, %eax
jne 0xdf3e
xorl %eax, %eax
movq 0x18(%rbp), %rcx
cmpl $0x1, 0x64(%rcx)
sete %al
movq -0x38(%rbp), %rcx
cmoveq %r15, %rcx
movq 0x10(%rbp), %rdx
movq %rcx, (%rdx)
movl -0x4(%r13,%rax,4), %ecx
jmp 0xdcd8
movq 0x18(%rbp), %rax
movl 0x64(%rax), %eax
cmpl $0x1, %eax
movq -0x38(%rbp), %rdx
cmoveq %r15, %rdx
leaq -0x4(%rdx), %rsi
cmpl $0x1, %eax
movq %rsi, %rdi
cmoveq %r15, %rdi
addq $0x4, %rdx
xorl %ecx, %ecx
cmpl $0x1, %eax
sete %cl
movl -0x4(%r13,%rcx,4), %ecx
cmovneq %rsi, %rdx
movq 0x10(%rbp), %rax
movq %rdx, (%rax)
movl (%rdi), %r8d
jmp 0xdbd3
movq 0x18(%rbp), %rax
movl 0x64(%rax), %eax
cmpl $0x1, %eax
movq -0x38(%rbp), %rdx
cmoveq %r15, %rdx
leaq -0x4(%rdx), %rsi
addq $0x4, %rdx
cmpl $0x1, %eax
movq %rsi, %rdi
cmoveq %rdx, %rdi
leaq -0x4(%rdi), %r9
cmpl $0x1, %eax
cmovneq %r9, %rdx
addq $0x4, %rdi
xorl %ecx, %ecx
cmpl $0x1, %eax
sete %cl
movl -0x4(%r13,%rcx,4), %ecx
cmoveq %r15, %rsi
movl (%rsi), %r8d
cmovneq %r9, %rdi
movq 0x10(%rbp), %rax
movq %rdi, (%rax)
movl (%rdx), %r9d
jmp 0xdbe9
movq %rbx, %rdi
movq %r12, %rsi
movq -0x30(%rbp), %rdx
xorl %eax, %eax
callq 0x31a0
jmp 0xdeeb
movl -0x3c(%rbp), %eax
cmpl $0x2, %eax
je 0xdd73
cmpl $0x1, %eax
je 0xdd2a
testl %eax, %eax
jne 0xdf3e
xorl %eax, %eax
movq 0x18(%rbp), %rdx
cmpl $0x1, 0x64(%rdx)
sete %al
movq -0x38(%rbp), %rcx
cmoveq %r15, %rcx
movq 0x10(%rbp), %rsi
movq %rcx, (%rsi)
movl -0x4(%r13,%rax,4), %ecx
addq 0x20(%rdx), %rcx
jmp 0xdcd8
movq 0x18(%rbp), %r9
movl 0x64(%r9), %eax
cmpl $0x1, %eax
movq -0x38(%rbp), %rdx
cmoveq %r15, %rdx
leaq -0x4(%rdx), %rsi
cmpl $0x1, %eax
movq %rsi, %rdi
cmoveq %r15, %rdi
addq $0x4, %rdx
xorl %ecx, %ecx
cmpl $0x1, %eax
sete %cl
movl -0x4(%r13,%rcx,4), %ecx
cmovneq %rsi, %rdx
movq 0x10(%rbp), %rax
movq %rdx, (%rax)
movl (%rdi), %r8d
addq 0x20(%r9), %r8
jmp 0xdbd3
movq 0x18(%rbp), %r10
movl 0x64(%r10), %eax
cmpl $0x1, %eax
movq -0x38(%rbp), %rdx
cmoveq %r15, %rdx
leaq -0x4(%rdx), %rsi
addq $0x4, %rdx
cmpl $0x1, %eax
movq %rsi, %rdi
cmoveq %rdx, %rdi
leaq -0x4(%rdi), %r9
cmpl $0x1, %eax
cmovneq %r9, %rdx
addq $0x4, %rdi
xorl %ecx, %ecx
cmpl $0x1, %eax
sete %cl
cmoveq %r15, %rsi
movl -0x4(%r13,%rcx,4), %ecx
movl (%rsi), %r8d
cmovneq %r9, %rdi
movq 0x10(%rbp), %rax
movq %rdi, (%rax)
movl (%rdx), %r9d
addq 0x20(%r10), %r9
jmp 0xdbe9
movl -0x3c(%rbp), %eax
cmpl $0x2, %eax
je 0xde84
cmpl $0x1, %eax
je 0xde25
testl %eax, %eax
jne 0xdf3e
xorl %eax, %eax
movq 0x18(%rbp), %rcx
cmpl $0x1, 0x64(%rcx)
sete %al
movq -0x58(%rbp), %rcx
cmoveq -0x50(%rbp), %rcx
movq 0x10(%rbp), %rdx
movq %rcx, (%rdx)
movsd -0x8(%r13,%rax,8), %xmm0
movq %rbx, %rdi
movq %r12, %rsi
movq -0x30(%rbp), %rdx
movb $0x1, %al
callq 0x31a0
jmp 0xdeeb
movq 0x18(%rbp), %rax
movl 0x64(%rax), %eax
xorl %ecx, %ecx
cmpl $0x1, %eax
sete %cl
leaq (%r13,%rcx,8), %rdx
leaq -0x8(%r13,%rcx,8), %rsi
movq %rsi, %rdi
cmoveq %rdx, %rdi
leaq -0x8(%rdi), %r8
cmpl $0x1, %eax
cmovneq %r8, %rdx
addq $0x8, %rdi
cmpl $0x1, %eax
leaq -0x4(%r13,%rcx,8), %rax
cmovneq %rsi, %rax
movl (%rax), %ecx
cmovneq %r8, %rdi
movq 0x10(%rbp), %rax
movq %rdi, (%rax)
movsd (%rdx), %xmm0
movq %rbx, %rdi
movq %r12, %rsi
movq -0x30(%rbp), %rdx
movb $0x1, %al
callq 0x31a0
jmp 0xdeeb
movq 0x18(%rbp), %rax
movl 0x64(%rax), %eax
cmpl $0x1, %eax
movq -0x38(%rbp), %rdx
cmoveq %r15, %rdx
leaq -0x4(%rdx), %rsi
addq $0x4, %rdx
cmpl $0x1, %eax
movq %rsi, %rdi
cmoveq %rdx, %rdi
leaq -0x8(%rdi), %r9
cmpl $0x1, %eax
cmovneq %r9, %rdx
addq $0x8, %rdi
xorl %ecx, %ecx
cmpl $0x1, %eax
sete %cl
movl -0x4(%r13,%rcx,4), %ecx
cmoveq %r15, %rsi
movl (%rsi), %r8d
cmovneq %r9, %rdi
movq 0x10(%rbp), %rax
movq %rdi, (%rax)
movsd (%rdx), %xmm0
movq %rbx, %rdi
movq %r12, %rsi
movq -0x30(%rbp), %rdx
movb $0x1, %al
callq 0x31a0
movl %eax, %r14d
testl %eax, %eax
js 0xdf3e
movl %r14d, %eax
cmpq %rax, %r12
ja 0xdf31
cmpq $0x0, -0x48(%rbp)
jne 0xdf56
incl %r14d
movq %r14, %rdi
callq 0x3380
movq %rax, %rbx
movq 0x10(%rbp), %rax
movq %r13, (%rax)
movq -0x70(%rbp), %rax
leaq 0x10ebf(%rip), %rcx     # 0x1ede0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
movq %r14, %r12
movq %rbx, -0x48(%rbp)
jmpq *%rax
movq -0x60(%rbp), %rdi
movq %rbx, %rsi
movl %r14d, %edx
callq *-0x68(%rbp)
movq -0x48(%rbp), %rdi
callq 0x3030
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x12581(%rip), %rdi     # 0x204de
leaq 0x12548(%rip), %rsi     # 0x204ac
leaq 0x12581(%rip), %rcx     # 0x204ec
movl $0x457, %edx            # imm = 0x457
callq 0x31e0