// File: /workspace/github_c_makefile_star2_O1/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, %ebx
movq %rcx, %r15
movq %rsi, -0x68(%rbp)
movq %rdi, -0x60(%rbp)
movq 0x10(%rbp), %rax
movq (%rax), %r12
subq %rdx, %r15
leaq 0x10(%r15), %rax
andq $-0x10, %rax
movq %rsp, %r13
subq %rax, %r13
movq %r13, %rsp
movq %r13, %rdi
movq %rdx, %rsi
movq %r15, %rdx
callq 0x3360
movq %r13, -0x30(%rbp)
movb $0x0, (%r15,%r13)
leaq -0x4(%r12), %rax
movq %rax, -0x40(%rbp)
leaq 0x4(%r12), %rax
movq %rax, -0x38(%rbp)
leaq -0x8(%r12), %rax
movq %rax, -0x58(%rbp)
leaq 0x8(%r12), %rax
movq %rax, -0x50(%rbp)
movl $0x64, %r15d
leaq -0xe0(%rbp), %r13
decl %r14d
leaq 0x1543a(%rip), %rax     # 0x23d10
movslq (%rax,%r14,4), %rcx
movq 0x10(%rbp), %r14
addq %rax, %rcx
movq %rcx, -0x70(%rbp)
movq $0x0, -0x48(%rbp)
movq %r12, (%r14)
jmpq *-0x70(%rbp)
cmpl $0x2, %ebx
je 0xed42
cmpl $0x1, %ebx
je 0xec23
testl %ebx, %ebx
jne 0xea4f
xorl %eax, %eax
movq 0x18(%rbp), %rcx
cmpl $0x1, 0x64(%rcx)
sete %al
movq -0x40(%rbp), %rcx
cmoveq -0x38(%rbp), %rcx
movq %rcx, (%r14)
movl -0x4(%r12,%rax,4), %ecx
movq %r13, %rdi
movq %r15, %rsi
movq -0x30(%rbp), %rdx
xorl %eax, %eax
callq 0x31a0
jmp 0xee20
cmpl $0x2, %ebx
je 0xeab6
cmpl $0x1, %ebx
je 0xea56
testl %ebx, %ebx
jne 0xea4f
xorl %eax, %eax
movq 0x18(%rbp), %rcx
cmpl $0x1, 0x64(%rcx)
sete %al
movq -0x58(%rbp), %rcx
cmoveq -0x50(%rbp), %rcx
movq %rcx, (%r14)
movsd -0x8(%r12,%rax,8), %xmm0
movq %r13, %rdi
movq %r15, %rsi
movq -0x30(%rbp), %rdx
movb $0x1, %al
callq 0x31a0
jmp 0xee20
cmpl $0x2, %ebx
je 0xeb73
cmpl $0x1, %ebx
je 0xeb2a
testl %ebx, %ebx
jne 0xea4f
xorl %eax, %eax
movq 0x18(%rbp), %rcx
cmpl $0x1, 0x64(%rcx)
sete %al
movq -0x40(%rbp), %rcx
cmoveq -0x38(%rbp), %rcx
movq %rcx, (%r14)
movl -0x4(%r12,%rax,4), %ecx
jmp 0xea39
cmpl $0x2, %ebx
je 0xecd7
cmpl $0x1, %ebx
je 0xebd5
testl %ebx, %ebx
jne 0xea4f
xorl %eax, %eax
movq 0x18(%rbp), %rdx
cmpl $0x1, 0x64(%rdx)
sete %al
movq -0x40(%rbp), %rcx
cmoveq -0x38(%rbp), %rcx
movq %rcx, (%r14)
movl -0x4(%r12,%rax,4), %ecx
addq 0x20(%rdx), %rcx
jmp 0xea39
cmpl $0x2, %ebx
je 0xedb2
cmpl $0x1, %ebx
je 0xec7d
testl %ebx, %ebx
jne 0xea4f
xorl %eax, %eax
movq 0x18(%rbp), %rcx
cmpl $0x1, 0x64(%rcx)
sete %al
movq -0x58(%rbp), %rcx
cmoveq -0x50(%rbp), %rcx
movq %rcx, (%r14)
movq -0x8(%r12,%rax,8), %rcx
movq %r13, %rdi
movq %r15, %rsi
movq -0x30(%rbp), %rdx
xorl %eax, %eax
callq 0x31a0
jmp 0xee20
xorl %eax, %eax
jmp 0xee62
movq 0x18(%rbp), %rax
movl 0x64(%rax), %eax
xorl %ecx, %ecx
cmpl $0x1, %eax
sete %cl
leaq (%r12,%rcx,8), %rdx
leaq -0x8(%r12,%rcx,8), %rsi
movq %rsi, %rdi
cmoveq %rdx, %rdi
leaq -0x8(%rdi), %r8
cmpl $0x1, %eax
cmovneq %r8, %rdx
leaq 0x8(%rdi), %r9
cmpl $0x1, %eax
leaq -0x4(%r12,%rcx,8), %rax
cmovneq %rsi, %rax
movq %rdi, (%r14)
movl (%rax), %ecx
cmovneq %r8, %r9
movq %r9, (%r14)
movsd (%rdx), %xmm0
movq %r13, %rdi
movq %r15, %rsi
movq -0x30(%rbp), %rdx
movb $0x1, %al
callq 0x31a0
jmp 0xee20
movq 0x18(%rbp), %rax
movl 0x64(%rax), %eax
cmpl $0x1, %eax
movq -0x40(%rbp), %rcx
movq -0x38(%rbp), %r11
cmoveq %r11, %rcx
leaq -0x4(%rcx), %rdx
leaq 0x4(%rcx), %rsi
cmpl $0x1, %eax
movq %rdx, %rdi
cmoveq %rsi, %rdi
leaq -0x8(%rdi), %r9
cmpl $0x1, %eax
cmovneq %r9, %rsi
leaq 0x8(%rdi), %r10
xorl %r8d, %r8d
cmpl $0x1, %eax
sete %r8b
movq %rcx, (%r14)
movl -0x4(%r12,%r8,4), %ecx
cmoveq %r11, %rdx
movq %rdi, (%r14)
movl (%rdx), %r8d
cmovneq %r9, %r10
movq %r10, (%r14)
movsd (%rsi), %xmm0
movq %r13, %rdi
movq %r15, %rsi
movq -0x30(%rbp), %rdx
movb $0x1, %al
callq 0x31a0
jmp 0xee20
movq 0x18(%rbp), %rax
movl 0x64(%rax), %eax
cmpl $0x1, %eax
movq -0x40(%rbp), %rcx
movq -0x38(%rbp), %rdi
cmoveq %rdi, %rcx
leaq -0x4(%rcx), %rdx
cmpl $0x1, %eax
movq %rdx, %rsi
cmoveq %rdi, %rsi
leaq 0x4(%rcx), %rdi
xorl %r8d, %r8d
cmpl $0x1, %eax
sete %r8b
movq %rcx, (%r14)
movl -0x4(%r12,%r8,4), %ecx
cmovneq %rdx, %rdi
movq %rdi, (%r14)
movl (%rsi), %r8d
jmp 0xecc1
movq 0x18(%rbp), %rax
movl 0x64(%rax), %eax
cmpl $0x1, %eax
movq -0x40(%rbp), %rcx
movq -0x38(%rbp), %r11
cmoveq %r11, %rcx
leaq -0x4(%rcx), %rdx
leaq 0x4(%rcx), %rsi
cmpl $0x1, %eax
movq %rdx, %rdi
cmoveq %rsi, %rdi
leaq -0x4(%rdi), %r9
cmpl $0x1, %eax
cmovneq %r9, %rsi
leaq 0x4(%rdi), %r10
xorl %r8d, %r8d
cmpl $0x1, %eax
sete %r8b
movq %rcx, (%r14)
movl -0x4(%r12,%r8,4), %ecx
cmoveq %r11, %rdx
movq %rdi, (%r14)
movl (%rdx), %r8d
cmovneq %r9, %r10
movq %r10, (%r14)
movl (%rsi), %r9d
jmp 0xee0f
movq 0x18(%rbp), %r9
movl 0x64(%r9), %eax
cmpl $0x1, %eax
movq -0x40(%rbp), %rcx
movq -0x38(%rbp), %rdi
cmoveq %rdi, %rcx
leaq -0x4(%rcx), %rdx
cmpl $0x1, %eax
movq %rdx, %rsi
cmoveq %rdi, %rsi
leaq 0x4(%rcx), %rdi
xorl %r8d, %r8d
cmpl $0x1, %eax
sete %r8b
movq %rcx, (%r14)
movl -0x4(%r12,%r8,4), %ecx
cmovneq %rdx, %rdi
movq %rdi, (%r14)
movl (%rsi), %r8d
addq 0x20(%r9), %r8
jmp 0xecc1
movq 0x18(%rbp), %rax
movl 0x64(%rax), %eax
cmpl $0x1, %eax
movq -0x40(%rbp), %rcx
movq -0x38(%rbp), %rdi
cmoveq %rdi, %rcx
leaq -0x4(%rcx), %rdx
cmpl $0x1, %eax
movq %rdx, %rsi
cmoveq %rdi, %rsi
leaq 0x4(%rcx), %rdi
xorl %r8d, %r8d
cmpl $0x1, %eax
sete %r8b
movq %rcx, (%r14)
movl -0x4(%r12,%r8,4), %ecx
cmovneq %rdx, %rdi
movq %rdi, (%r14)
movl (%rsi), %r8d
movq %r13, %rdi
movq %r15, %rsi
movq -0x30(%rbp), %rdx
xorl %eax, %eax
callq 0x31a0
jmp 0xee20
movq 0x18(%rbp), %rax
movl 0x64(%rax), %eax
cmpl $0x1, %eax
movq -0x40(%rbp), %rcx
movq -0x38(%rbp), %rdi
cmoveq %rdi, %rcx
leaq -0x8(%rcx), %rdx
cmpl $0x1, %eax
movq %rdx, %rsi
cmoveq %rdi, %rsi
leaq 0x8(%rcx), %rdi
xorl %r8d, %r8d
cmpl $0x1, %eax
sete %r8b
movq %rcx, (%r14)
movl -0x4(%r12,%r8,4), %ecx
cmovneq %rdx, %rdi
movq %rdi, (%r14)
movq (%rsi), %r8
movq %r13, %rdi
movq %r15, %rsi
movq -0x30(%rbp), %rdx
xorl %eax, %eax
callq 0x31a0
jmp 0xee20
movq 0x18(%rbp), %r11
movl 0x64(%r11), %eax
cmpl $0x1, %eax
movq -0x40(%rbp), %rcx
movq -0x38(%rbp), %r11
cmoveq %r11, %rcx
leaq -0x4(%rcx), %rdx
leaq 0x4(%rcx), %rsi
cmpl $0x1, %eax
movq %rdx, %rdi
cmoveq %rsi, %rdi
leaq -0x4(%rdi), %r9
cmpl $0x1, %eax
cmovneq %r9, %rsi
leaq 0x4(%rdi), %r10
xorl %r8d, %r8d
cmpl $0x1, %eax
sete %r8b
movq %rcx, (%r14)
movl -0x4(%r12,%r8,4), %ecx
cmoveq %r11, %rdx
movq %rdi, (%r14)
movl (%rdx), %r8d
cmovneq %r9, %r10
movq %r10, (%r14)
movl (%rsi), %r9d
movq 0x18(%rbp), %rax
addq 0x20(%rax), %r9
jmp 0xee0f
movq 0x18(%rbp), %rax
movl 0x64(%rax), %eax
cmpl $0x1, %eax
movq -0x40(%rbp), %rcx
movq -0x38(%rbp), %r11
cmoveq %r11, %rcx
leaq -0x4(%rcx), %rdx
leaq 0x4(%rcx), %rsi
cmpl $0x1, %eax
movq %rdx, %rdi
cmoveq %rsi, %rdi
leaq -0x4(%rdi), %r9
cmpl $0x1, %eax
cmovneq %r9, %rsi
leaq 0x4(%rdi), %r10
xorl %r8d, %r8d
cmpl $0x1, %eax
sete %r8b
movq %rcx, (%r14)
movl -0x4(%r12,%r8,4), %ecx
cmoveq %r11, %rdx
movq %rdi, (%r14)
movl (%rdx), %r8d
cmovneq %r9, %r10
movq %r10, (%r14)
movl (%rsi), %r9d
movq %r13, %rdi
movq %r15, %rsi
movq -0x30(%rbp), %rdx
xorl %eax, %eax
callq 0x31a0
jmp 0xee20
movq 0x18(%rbp), %rax
movl 0x64(%rax), %eax
cmpl $0x1, %eax
movq -0x40(%rbp), %rcx
movq -0x38(%rbp), %r11
cmoveq %r11, %rcx
leaq -0x4(%rcx), %rdx
leaq 0x4(%rcx), %rsi
cmpl $0x1, %eax
movq %rdx, %rdi
cmoveq %rsi, %rdi
leaq -0x8(%rdi), %r9
cmpl $0x1, %eax
cmovneq %r9, %rsi
leaq 0x8(%rdi), %r10
xorl %r8d, %r8d
cmpl $0x1, %eax
sete %r8b
movq %rcx, (%r14)
movl -0x4(%r12,%r8,4), %ecx
cmoveq %r11, %rdx
movq %rdi, (%r14)
movl (%rdx), %r8d
cmovneq %r9, %r10
movq %r10, (%r14)
movq (%rsi), %r9
movq %r13, %rdi
movq %r15, %rsi
movq -0x30(%rbp), %rdx
xorl %eax, %eax
callq 0x31a0
movl %eax, %r14d
testl %eax, %eax
js 0xee3c
movl %r14d, %eax
cmpq %rax, %r15
jbe 0xee40
movq -0x68(%rbp), %rdi
movq %r13, %rsi
movl %r14d, %edx
callq *-0x60(%rbp)
xorl %eax, %eax
jmp 0xee5e
cmpq $0x0, -0x48(%rbp)
jne 0xee82
incl %r14d
movq %r14, %rdi
callq 0x3380
movq %rax, %r13
movb $0x1, %al
movq %r13, -0x48(%rbp)
movq %r14, %r15
movq 0x10(%rbp), %r14
testb %al, %al
jne 0xe8ed
movq -0x48(%rbp), %rdi
callq 0x3030
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1646f(%rip), %rdi     # 0x252f8
leaq 0x16436(%rip), %rsi     # 0x252c6
leaq 0x1646f(%rip), %rcx     # 0x25306
movl $0x457, %edx            # imm = 0x457
callq 0x31e0