// File: /workspace/github_c_makefile_star2_O0/cogbee[P]vmir-latest/src/vmir.c
// Function: vmir_run
int
vmir_run(ir_unit_t *iu, int *retptr, int argc, char **argv)
{
  ir_function_t *f;
  f = vmir_find_function(iu, "main");
  if(f == NULL) {
    return VM_STOP_BAD_FUNCTION;
  }

  int vm_argv = vmir_argv_copy(iu, argc, argv);

  union {
    uint32_t u32;
    uint64_t u64;
  } ret;

  int r = vmir_vm_function_call(iu, f, &ret, argc, vm_argv);


  if(r == VM_STOP_EXIT)
    ret.u32 = iu->iu_exit_code;

  if(retptr != NULL)
    *retptr = ret.u32;

  switch(r) {
  case 0:
    vmir_log(iu, VMIR_LOG_DEBUG, "Program returned normally: 0x%x", ret.u32);
    break;
  case VM_STOP_EXIT:
    vmir_log(iu, VMIR_LOG_DEBUG, "Program exit(): 0x%x", iu->iu_exit_code);
    break;
  case VM_STOP_ABORT:
    vmir_log(iu, VMIR_LOG_ERROR, "Program abort");
    break;
  case VM_STOP_UNREACHABLE:
    vmir_log(iu, VMIR_LOG_ERROR, "Unreachable instruction");
    break;
  case VM_STOP_BAD_INSTRUCTION:
    vmir_log(iu, VMIR_LOG_ERROR, "Bad instruction");
    break;
  case VM_STOP_BAD_FUNCTION:
    vmir_log(iu, VMIR_LOG_ERROR, "Bad function %d", iu->iu_exit_code);
    break;
  case VM_STOP_UNCAUGHT_EXCEPTION:
    vmir_log(iu, VMIR_LOG_ERROR, "Uncaught exception");
    break;
  }
  return r;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq %rcx, -0x28(%rbp)
movq -0x10(%rbp), %rdi
leaq 0x25bb5(%rip), %rsi     # 0x3e1e7
callq 0x3c60
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x1864e
movl $0x5, -0x4(%rbp)
jmp 0x1878d
movq -0x10(%rbp), %rdi
movl -0x1c(%rbp), %esi
movq -0x28(%rbp), %rdx
callq 0x187a0
movl %eax, -0x34(%rbp)
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rsi
movl -0x1c(%rbp), %ecx
movl -0x34(%rbp), %r8d
leaq -0x40(%rbp), %rdx
movb $0x0, %al
callq 0x3f20
movl %eax, -0x44(%rbp)
cmpl $0x1, -0x44(%rbp)
jne 0x1868e
movq -0x10(%rbp), %rax
movl 0x40(%rax), %eax
movl %eax, -0x40(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x1869e
movl -0x40(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
movl -0x44(%rbp), %eax
movq %rax, -0x50(%rbp)
subq $0x6, %rax
ja 0x18787
movq -0x50(%rbp), %rax
leaq 0x2451a(%rip), %rcx     # 0x3cbd4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x10(%rbp), %rdi
movl -0x40(%rbp), %ecx
movl $0x3, %esi
leaq 0x25b16(%rip), %rdx     # 0x3e1ec
movb $0x0, %al
callq 0x4650
jmp 0x18787
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x40(%rax), %ecx
movl $0x3, %esi
leaq 0x25b13(%rip), %rdx     # 0x3e20c
movb $0x0, %al
callq 0x4650
jmp 0x18787
movq -0x10(%rbp), %rdi
movl $0x1, %esi
leaq 0x25b0c(%rip), %rdx     # 0x3e221
movb $0x0, %al
callq 0x4650
jmp 0x18787
movq -0x10(%rbp), %rdi
movl $0x1, %esi
leaq 0x25a1a(%rip), %rdx     # 0x3e148
movb $0x0, %al
callq 0x4650
jmp 0x18787
movq -0x10(%rbp), %rdi
movl $0x1, %esi
leaq 0x25ae8(%rip), %rdx     # 0x3e22f
movb $0x0, %al
callq 0x4650
jmp 0x18787
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x40(%rax), %ecx
movl $0x1, %esi
leaq 0x25ad8(%rip), %rdx     # 0x3e23f
movb $0x0, %al
callq 0x4650
jmp 0x18787
movq -0x10(%rbp), %rdi
movl $0x1, %esi
leaq 0x25a04(%rip), %rdx     # 0x3e184
movb $0x0, %al
callq 0x4650
movl -0x44(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)