// File: /workspace/github_c_makefile_star2_O0/cogbee[P]vmir-latest/src/vmir_vm.c
// Function: emit_ret
static void
emit_ret(ir_unit_t *iu, ir_instr_unary_t *ii)
{
  if(ii->value.value == -1) {
    emit_op(iu, VM_RET_VOID);
    return;
  }
  ir_value_t *iv = value_get(iu, ii->value.value);
  ir_type_t *it = type_get(iu, ii->value.type);
  int code = legalize_type(it);

  switch(iv->iv_class) {
  case IR_VC_REGFRAME:

    switch(code) {
    case IR_TYPE_INT1:
    case IR_TYPE_INT8:
    case IR_TYPE_INT16:
    case IR_TYPE_INT32:
    case IR_TYPE_POINTER:
    case IR_TYPE_FLOAT:
      emit_op1(iu, VM_RET_R32, value_reg(iv));
      return;

    case IR_TYPE_INT64:
    case IR_TYPE_DOUBLE:
      emit_op1(iu, VM_RET_R64, value_reg(iv));
      return;

    default:
      parser_error(iu, "Can't return type %s", type_str(iu, it));
    }

  case IR_VC_GLOBALVAR:
    switch(code) {
    case IR_TYPE_POINTER:
      emit_op(iu, VM_RET_R32C);
      emit_i32(iu, value_get_const32(iu, iv));
      return;

    default:
      parser_error(iu, "Can't return global type %s", type_str(iu, it));
    }

  case IR_VC_CONSTANT:
    switch(code) {
    case IR_TYPE_INT1:
    case IR_TYPE_INT8:
    case IR_TYPE_INT16:
    case IR_TYPE_INT32:
    case IR_TYPE_POINTER:
    case IR_TYPE_FLOAT:
      emit_op(iu, VM_RET_R32C);
      emit_i32(iu, value_get_const32(iu, iv));
      return;
    case IR_TYPE_INT64:
    case IR_TYPE_DOUBLE:
      vm_align32(iu, 1);
      emit_op(iu, VM_RET_R64C);
      emit_i64(iu, value_get_const64(iu, iv));
      return;

    default:
      parser_error(iu, "Can't return const type %s", type_str(iu, it));
    }

  case IR_VC_FUNCTION:
    emit_op(iu, VM_RET_R32C);
    emit_i32(iu, value_function_addr(iv));
    return;

  default:
    parser_error(iu, "Can't return value class %d", iv->iv_class);
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rax
cmpl $-0x1, 0x58(%rax)
jne 0x2bba0
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x2b410
jmp 0x2be68
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x58(%rax), %esi
callq 0x20ee0
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x5c(%rax), %esi
callq 0x1ee20
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
callq 0x45d0
movl %eax, -0x24(%rbp)
movq -0x18(%rbp), %rax
movl (%rax), %eax
decl %eax
movl %eax, %ecx
movq %rcx, -0x30(%rbp)
subl $0x4, %eax
ja 0x2be43
movq -0x30(%rbp), %rax
leaq 0x11e76(%rip), %rcx     # 0x3da6c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl -0x24(%rbp), %eax
movl %eax, -0x34(%rbp)
addl $-0x2, %eax
subl $0x4, %eax
jb 0x2bc37
jmp 0x2bc0f
movl -0x34(%rbp), %eax
subl $0x6, %eax
je 0x2bc5e
jmp 0x2bc19
movl -0x34(%rbp), %eax
subl $0x8, %eax
je 0x2bc37
jmp 0x2bc23
movl -0x34(%rbp), %eax
subl $0x9, %eax
je 0x2bc5e
jmp 0x2bc2d
movl -0x34(%rbp), %eax
subl $0xb, %eax
jne 0x2bc85
jmp 0x2bc37
movq -0x8(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x18(%rbp), %rdi
callq 0x321a0
movq -0x40(%rbp), %rdi
movl $0x2, %esi
movzwl %ax, %edx
callq 0x32150
jmp 0x2be68
movq -0x8(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x18(%rbp), %rdi
callq 0x321a0
movq -0x48(%rbp), %rdi
movl $0x3, %esi
movzwl %ax, %edx
callq 0x32150
jmp 0x2be68
movq -0x8(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x4760
movq -0x50(%rbp), %rdi
movq %rax, %r8
leaq 0x14277(%rip), %rsi     # 0x3ff1f
movl $0x9d4, %edx            # imm = 0x9D4
leaq 0x14325(%rip), %rcx     # 0x3ffd9
movb $0x0, %al
callq 0x18220
movl -0x24(%rbp), %eax
subl $0xb, %eax
jne 0x2bcf8
jmp 0x2bcc5
movq -0x8(%rbp), %rdi
movl $0x4, %esi
callq 0x2b410
movq -0x8(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x261a0
movq -0x58(%rbp), %rdi
movl %eax, %esi
callq 0x2b450
jmp 0x2be68
movq -0x8(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x4760
movq -0x60(%rbp), %rdi
movq %rax, %r8
leaq 0x14204(%rip), %rsi     # 0x3ff1f
movl $0x9df, %edx            # imm = 0x9DF
leaq 0x142c7(%rip), %rcx     # 0x3ffee
movb $0x0, %al
callq 0x18220
movl -0x24(%rbp), %eax
movl %eax, -0x64(%rbp)
addl $-0x2, %eax
subl $0x4, %eax
jb 0x2bd66
jmp 0x2bd3e
movl -0x64(%rbp), %eax
subl $0x6, %eax
je 0x2bd99
jmp 0x2bd48
movl -0x64(%rbp), %eax
subl $0x8, %eax
je 0x2bd66
jmp 0x2bd52
movl -0x64(%rbp), %eax
subl $0x9, %eax
je 0x2bd99
jmp 0x2bd5c
movl -0x64(%rbp), %eax
subl $0xb, %eax
jne 0x2bddb
jmp 0x2bd66
movq -0x8(%rbp), %rdi
movl $0x4, %esi
callq 0x2b410
movq -0x8(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x261a0
movq -0x70(%rbp), %rdi
movl %eax, %esi
callq 0x2b450
jmp 0x2be68
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x321f0
movq -0x8(%rbp), %rdi
movl $0x5, %esi
callq 0x2b410
movq -0x8(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x322d0
movq -0x78(%rbp), %rdi
movq %rax, %rsi
callq 0x32240
jmp 0x2be68
movq -0x8(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x4760
movq -0x80(%rbp), %rdi
movq %rax, %r8
leaq 0x14121(%rip), %rsi     # 0x3ff1f
movl $0x9f5, %edx            # imm = 0x9F5
leaq 0x14200(%rip), %rcx     # 0x4000a
movb $0x0, %al
callq 0x18220
movq -0x8(%rbp), %rdi
movl $0x4, %esi
callq 0x2b410
movq -0x8(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x18(%rbp), %rdi
callq 0x323e0
movq -0x88(%rbp), %rdi
movl %eax, %esi
callq 0x2b450
jmp 0x2be68
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movl (%rax), %r8d
leaq 0x140ca(%rip), %rsi     # 0x3ff1f
movl $0x9fe, %edx            # imm = 0x9FE
leaq 0x141c4(%rip), %rcx     # 0x40025
movb $0x0, %al
callq 0x18220
addq $0x90, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)