// File: /workspace/github_c_makefile_star2_O0/cogbee[P]vmir-latest/src/vmir_vm.c
// Function: emit_vaarg
static void
emit_vaarg(ir_unit_t *iu, ir_instr_unary_t *ii)
{
  const ir_value_t *val = value_get(iu, ii->value.value);
  int valreg;
  switch(val->iv_class) {
  case IR_VC_REGFRAME:
    valreg = value_reg(val);
    break;

  case IR_VC_CONSTANT:
  case IR_VC_GLOBALVAR:
    emit_op1(iu, VM_MOV32_C, 0);
    emit_i32(iu, value_get_const32(iu, val));
    valreg = 0;
    break;
  default:
    parser_error(iu, "bad vaarg class");
  }

  const ir_value_t *ret = value_get(iu, ii->super.ii_ret.value);
  const ir_type_t *ty = type_get(iu, ii->super.ii_ret.type);
  switch(legalize_type(ty)) {
  case IR_TYPE_INT32:
  case IR_TYPE_POINTER:
  case IR_TYPE_INT1:
    emit_op(iu, VM_VAARG32);
    break;
  case IR_TYPE_DOUBLE:
  case IR_TYPE_INT64:
    emit_op(iu, VM_VAARG64);
    break;
  default:
    parser_error(iu, "Unable to emit vaarg() for type %s",
                 type_str(iu, ty));
  }

  emit_i16(iu, value_reg(ret));
  emit_i16(iu, valreg);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x58(%rax), %esi
callq 0x20ee0
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x34(%rbp)
addl $-0x2, %eax
subl $0x2, %eax
jb 0x308af
jmp 0x30897
movl -0x34(%rbp), %eax
subl $0x5, %eax
jne 0x308e8
jmp 0x308a1
movq -0x18(%rbp), %rdi
callq 0x321a0
movl %eax, -0x1c(%rbp)
jmp 0x30906
movq -0x8(%rbp), %rdi
movl $0x17f, %esi            # imm = 0x17F
xorl %edx, %edx
callq 0x32150
movq -0x8(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x261a0
movq -0x40(%rbp), %rdi
movl %eax, %esi
callq 0x2b450
movl $0x0, -0x1c(%rbp)
jmp 0x30906
movq -0x8(%rbp), %rdi
leaq 0xf62c(%rip), %rsi      # 0x3ff1f
movl $0x1170, %edx           # imm = 0x1170
leaq 0xfc88(%rip), %rcx      # 0x40587
movb $0x0, %al
callq 0x18220
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x2c(%rax), %esi
callq 0x20ee0
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x30(%rax), %esi
callq 0x1ee20
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
callq 0x45d0
movl %eax, %ecx
movl %ecx, -0x44(%rbp)
subl $0x2, %eax
je 0x3096b
jmp 0x30943
movl -0x44(%rbp), %eax
subl $0x5, %eax
je 0x3096b
jmp 0x3094d
movl -0x44(%rbp), %eax
subl $0x6, %eax
je 0x3097b
jmp 0x30957
movl -0x44(%rbp), %eax
subl $0x9, %eax
je 0x3097b
jmp 0x30961
movl -0x44(%rbp), %eax
subl $0xb, %eax
jne 0x3098b
jmp 0x3096b
movq -0x8(%rbp), %rdi
movl $0x1df, %esi            # imm = 0x1DF
callq 0x2b410
jmp 0x309c1
movq -0x8(%rbp), %rdi
movl $0x1e0, %esi            # imm = 0x1E0
callq 0x2b410
jmp 0x309c1
movq -0x8(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x4760
movq -0x50(%rbp), %rdi
movq %rax, %r8
leaq 0xf571(%rip), %rsi      # 0x3ff1f
movl $0x1181, %edx           # imm = 0x1181
leaq 0xfbdd(%rip), %rcx      # 0x40597
movb $0x0, %al
callq 0x18220
movq -0x8(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x28(%rbp), %rdi
callq 0x321a0
movq -0x58(%rbp), %rdi
movzwl %ax, %esi
callq 0x2bae0
movq -0x8(%rbp), %rdi
movl -0x1c(%rbp), %eax
movzwl %ax, %esi
callq 0x2bae0
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)