// File: /workspace/github_c_makefile_star2_O3/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)
movl $0x64, %r12d
leaq -0xe0(%rbp), %rbx
movq $0x0, -0x48(%rbp)
movq 0x10(%rbp), %rax
movq %r13, (%rax)
decl %r14d
leaq 0x15476(%rip), %rcx     # 0x23d34
movq %r14, -0x70(%rbp)
movslq (%rcx,%r14,4), %rax
addq %rcx, %rax
jmpq *%rax
movl -0x3c(%rbp), %eax
cmpl $0x2, %eax
je 0xe970
cmpl $0x1, %eax
je 0xe91b
testl %eax, %eax
jne 0xee1a
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 0xedc7
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 0xedc7
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 0xedc7
movl -0x3c(%rbp), %eax
cmpl $0x2, %eax
je 0xea58
cmpl $0x1, %eax
je 0xea17
testl %eax, %eax
jne 0xee1a
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 0xebb4
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 0xeaaf
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 0xeac5
movq %rbx, %rdi
movq %r12, %rsi
movq -0x30(%rbp), %rdx
xorl %eax, %eax
callq 0x31a0
jmp 0xedc7
movq %rbx, %rdi
movq %r12, %rsi
movq -0x30(%rbp), %rdx
xorl %eax, %eax
callq 0x31a0
jmp 0xedc7
movl -0x3c(%rbp), %eax
cmpl $0x2, %eax
je 0xeb5a
cmpl $0x1, %eax
je 0xeb16
testl %eax, %eax
jne 0xee1a
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 0xebb4
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 0xeaaf
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 0xeac5
movq %rbx, %rdi
movq %r12, %rsi
movq -0x30(%rbp), %rdx
xorl %eax, %eax
callq 0x31a0
jmp 0xedc7
movl -0x3c(%rbp), %eax
cmpl $0x2, %eax
je 0xec4f
cmpl $0x1, %eax
je 0xec06
testl %eax, %eax
jne 0xee1a
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 0xebb4
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 0xeaaf
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 0xeac5
movl -0x3c(%rbp), %eax
cmpl $0x2, %eax
je 0xed60
cmpl $0x1, %eax
je 0xed01
testl %eax, %eax
jne 0xee1a
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 0xedc7
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 0xedc7
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 0xee1a
movl %r14d, %eax
cmpq %rax, %r12
ja 0xee0d
cmpq $0x0, -0x48(%rbp)
jne 0xee32
incl %r14d
movq %r14, %rdi
callq 0x3380
movq %rax, %rbx
movq 0x10(%rbp), %rax
movq %r13, (%rax)
movq -0x70(%rbp), %rax
leaq 0x14f37(%rip), %rcx     # 0x23d34
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 0x1656f(%rip), %rdi     # 0x253a8
leaq 0x16536(%rip), %rsi     # 0x25376
leaq 0x1656f(%rip), %rcx     # 0x253b6
movl $0x457, %edx            # imm = 0x457
callq 0x31e0