// File: /workspace/github_c_makefile_star2_O0/zenkj[P]luajit-arm64/src/host/buildvm.c
// Function: main
int main(int argc, char **argv)
{
  BuildCtx ctx_;
  BuildCtx *ctx = &ctx_;
  int status, binmode;

  if (sizeof(void *) != 4*LJ_32+8*LJ_64) {
    fprintf(stderr,"Error: pointer size mismatch in cross-build.\n");
    fprintf(stderr,"Try: make HOST_CC=\"gcc -m32\" CROSS=...\n\n");
    return 1;
  }

  UNUSED(argc);
  parseargs(ctx, argv);

  if ((status = build_code(ctx))) {
    fprintf(stderr,"Error: DASM error %08x\n", status);
    return 1;
  }

  switch (ctx->mode) {
  case BUILD_peobj:
  case BUILD_raw:
    binmode = 1;
    break;
  default:
    binmode = 0;
    break;
  }

  if (ctx->outname[0] == '-' && ctx->outname[1] == '\0') {
    ctx->fp = stdout;
#if defined(_WIN32)
    if (binmode)
      _setmode(_fileno(stdout), _O_BINARY);  /* Yuck. */
#endif
  } else if (!(ctx->fp = fopen(ctx->outname, binmode ? "wb" : "w"))) {
    fprintf(stderr, "Error: cannot open output file '%s': %s\n",
	    ctx->outname, strerror(errno));
    exit(1);
  }

  switch (ctx->mode) {
  case BUILD_elfasm:
  case BUILD_coffasm:
  case BUILD_machasm:
    emit_asm(ctx);
    emit_asm_debug(ctx);
    break;
  case BUILD_peobj:
    emit_peobj(ctx);
    break;
  case BUILD_raw:
    emit_raw(ctx);
    break;
  case BUILD_bcdef:
    emit_bcdef(ctx);
    emit_lib(ctx);
    break;
  case BUILD_vmdef:
    emit_vmdef(ctx);
    emit_lib(ctx);
    break;
  case BUILD_ffdef:
  case BUILD_libdef:
  case BUILD_recdef:
    emit_lib(ctx);
    break;
  case BUILD_folddef:
    emit_fold(ctx);
    break;
  default:
    break;
  }

  fflush(ctx->fp);
  if (ferror(ctx->fp)) {
    fprintf(stderr, "Error: cannot write to output file: %s\n",
	    strerror(errno));
    exit(1);
  }
  fclose(ctx->fp);

  return 0;
}

// Assembly:
subq $0xa38, %rsp            # imm = 0xA38
movl $0x0, 0xa34(%rsp)
movl %edi, 0xa30(%rsp)
movq %rsi, 0xa28(%rsp)
leaq 0x38(%rsp), %rax
movq %rax, 0x30(%rsp)
movq 0x30(%rsp), %rdi
movq 0xa28(%rsp), %rsi
callq 0x7810
movq 0x30(%rsp), %rdi
callq 0x79b0
movl %eax, 0x2c(%rsp)
cmpl $0x0, %eax
je 0x75fc
movq 0x12a21(%rip), %rax     # 0x19ff8
movq (%rax), %rdi
movl 0x2c(%rsp), %edx
leaq 0xccdf(%rip), %rsi      # 0x142c4
movb $0x0, %al
callq 0x5110
movl $0x1, 0xa34(%rsp)
jmp 0x77f6
movq 0x30(%rsp), %rax
movl 0x8(%rax), %eax
addl $-0x3, %eax
subl $0x1, %eax
ja 0x7618
jmp 0x760e
movl $0x1, 0x28(%rsp)
jmp 0x7620
movl $0x0, 0x28(%rsp)
movq 0x30(%rsp), %rax
movq 0x18(%rax), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
jne 0x765b
movq 0x30(%rsp), %rax
movq 0x18(%rax), %rax
movsbl 0x1(%rax), %eax
cmpl $0x0, %eax
jne 0x765b
movq 0x12986(%rip), %rax     # 0x19fd0
movq (%rax), %rcx
movq 0x30(%rsp), %rax
movq %rcx, 0x10(%rax)
jmp 0x76e1
movq 0x30(%rsp), %rax
movq 0x18(%rax), %rdi
movl 0x28(%rsp), %ecx
leaq 0xd777(%rip), %rsi      # 0x14de6
leaq 0xcc66(%rip), %rax      # 0x142dc
cmpl $0x0, %ecx
cmovneq %rax, %rsi
callq 0x5160
movq 0x30(%rsp), %rcx
movq %rax, 0x10(%rcx)
cmpq $0x0, %rax
jne 0x76df
movq 0x12960(%rip), %rax     # 0x19ff8
movq (%rax), %rax
movq %rax, 0x18(%rsp)
movq 0x30(%rsp), %rax
movq 0x18(%rax), %rax
movq %rax, 0x20(%rsp)
callq 0x5040
movl (%rax), %edi
callq 0x51b0
movq 0x18(%rsp), %rdi
movq 0x20(%rsp), %rdx
movq %rax, %rcx
leaq 0xcc11(%rip), %rsi      # 0x142df
movb $0x0, %al
callq 0x5110
movl $0x1, %edi
callq 0x5190
jmp 0x76e1
movq 0x30(%rsp), %rax
movl 0x8(%rax), %eax
movq %rax, 0x10(%rsp)
subq $0xa, %rax
ja 0x777f
movq 0x10(%rsp), %rax
leaq 0x8a20(%rip), %rcx      # 0x10124
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x30(%rsp), %rdi
callq 0xbc60
movq 0x30(%rsp), %rdi
callq 0x7db0
jmp 0x7781
movq 0x30(%rsp), %rdi
callq 0xc460
jmp 0x7781
movq 0x30(%rsp), %rdi
callq 0x80c0
jmp 0x7781
movq 0x30(%rsp), %rdi
callq 0x80e0
movq 0x30(%rsp), %rdi
callq 0xcef0
jmp 0x7781
movq 0x30(%rsp), %rdi
callq 0x8190
movq 0x30(%rsp), %rdi
callq 0xcef0
jmp 0x7781
movq 0x30(%rsp), %rdi
callq 0xcef0
jmp 0x7781
movq 0x30(%rsp), %rdi
callq 0xe380
jmp 0x7781
jmp 0x7781
movq 0x30(%rsp), %rax
movq 0x10(%rax), %rdi
callq 0x5140
movq 0x30(%rsp), %rax
movq 0x10(%rax), %rdi
callq 0x5070
cmpl $0x0, %eax
je 0x77dd
movq 0x1284f(%rip), %rax     # 0x19ff8
movq (%rax), %rax
movq %rax, 0x8(%rsp)
callq 0x5040
movl (%rax), %edi
callq 0x51b0
movq 0x8(%rsp), %rdi
movq %rax, %rdx
leaq 0xc32d(%rip), %rsi      # 0x13af9
movb $0x0, %al
callq 0x5110
movl $0x1, %edi
callq 0x5190
movq 0x30(%rsp), %rax
movq 0x10(%rax), %rdi
callq 0x5090
movl $0x0, 0xa34(%rsp)
movl 0xa34(%rsp), %eax
addq $0xa38, %rsp            # imm = 0xA38
retq
nopw %cs:(%rax,%rax)