// File: /workspace/github_c_makefile_star2_O0/zenkj[P]luajit-arm64/src/host/buildvm_asm.c
// Function: emit_asm
void emit_asm(BuildCtx *ctx)
{
  int i, rel;

  fprintf(ctx->fp, "\t.file \"buildvm_%s.dasc\"\n", ctx->dasm_arch);
  fprintf(ctx->fp, "\t.text\n");
  emit_asm_align(ctx, 4);

#if LJ_TARGET_PS3
  emit_asm_label(ctx, ctx->beginsym, ctx->codesz, 0);
#else
  emit_asm_label(ctx, ctx->beginsym, 0, 0);
#endif
  if (ctx->mode != BUILD_machasm)
    fprintf(ctx->fp, ".Lbegin:\n");

#if LJ_TARGET_ARM && defined(__GNUC__) && !LJ_NO_UNWIND
  /* This should really be moved into buildvm_arm.dasc. */
  fprintf(ctx->fp,
	  ".fnstart\n"
	  ".save {r4, r5, r6, r7, r8, r9, r10, r11, lr}\n"
	  ".pad #28\n");
#endif
#if LJ_TARGET_MIPS
  fprintf(ctx->fp, ".set nomips16\n.abicalls\n.set noreorder\n.set nomacro\n");
#endif

  for (i = rel = 0; i < ctx->nsym; i++) {
    int32_t ofs = ctx->sym[i].ofs;
    int32_t next = ctx->sym[i+1].ofs;
#if LJ_TARGET_ARM && defined(__GNUC__) && !LJ_NO_UNWIND && LJ_HASFFI
    if (!strcmp(ctx->sym[i].name, "lj_vm_ffi_call"))
      fprintf(ctx->fp,
	      ".globl lj_err_unwind_arm\n"
	      ".personality lj_err_unwind_arm\n"
	      ".fnend\n"
	      ".fnstart\n"
	      ".save {r4, r5, r11, lr}\n"
	      ".setfp r11, sp\n");
#endif
    emit_asm_label(ctx, ctx->sym[i].name, next - ofs, 1);
    while (rel < ctx->nreloc && ctx->reloc[rel].ofs <= next) {
      BuildReloc *r = &ctx->reloc[rel];
      int n = r->ofs - ofs;
#if LJ_TARGET_X86ORX64
      if (ctx->mode == BUILD_machasm && r->type != 0) {
	emit_asm_reloc_mach(ctx, ctx->code+ofs, n, ctx->relocsym[r->sym]);
      } else {
	emit_asm_bytes(ctx, ctx->code+ofs, n);
	emit_asm_reloc(ctx, r->type, ctx->relocsym[r->sym]);
      }
      ofs += n+4;
#else
      emit_asm_wordreloc(ctx, ctx->code+ofs, n, ctx->relocsym[r->sym]);
      ofs += n;
#endif
      rel++;
    }
#if LJ_TARGET_X86ORX64
    emit_asm_bytes(ctx, ctx->code+ofs, next-ofs);
#else
    emit_asm_words(ctx, ctx->code+ofs, next-ofs);
#endif
  }

#if LJ_TARGET_ARM && defined(__GNUC__) && !LJ_NO_UNWIND
  fprintf(ctx->fp,
#if !LJ_HASFFI
	  ".globl lj_err_unwind_arm\n"
	  ".personality lj_err_unwind_arm\n"
#endif
	  ".fnend\n");
#endif

  fprintf(ctx->fp, "\n");
  switch (ctx->mode) {
  case BUILD_elfasm:
#if !LJ_TARGET_PS3
    fprintf(ctx->fp, "\t.section .note.GNU-stack,\"\"," ELFASM_PX "progbits\n");
#endif
#if LJ_TARGET_PPCSPE
    /* Soft-float ABI + SPE. */
    fprintf(ctx->fp, "\t.gnu_attribute 4, 2\n\t.gnu_attribute 8, 3\n");
#elif LJ_TARGET_PPC && !LJ_TARGET_PS3
    /* Hard-float ABI. */
    fprintf(ctx->fp, "\t.gnu_attribute 4, 1\n");
#endif
    /* fallthrough */
  case BUILD_coffasm:
    fprintf(ctx->fp, "\t.ident \"%s\"\n", ctx->dasm_ident);
    break;
  case BUILD_machasm:
    fprintf(ctx->fp,
      "\t.cstring\n"
      "\t.ascii \"%s\\0\"\n", ctx->dasm_ident);
    break;
  default:
    break;
  }
  fprintf(ctx->fp, "\n");
}

// Assembly:
subq $0x38, %rsp
movq %rdi, 0x30(%rsp)
movq 0x30(%rsp), %rax
movq 0x10(%rax), %rdi
movq 0x30(%rsp), %rax
movq 0x88(%rax), %rdx
leaq 0xa1e6(%rip), %rsi      # 0x15e6b
movb $0x0, %al
callq 0x5110
movq 0x30(%rsp), %rax
movq 0x10(%rax), %rdi
leaq 0xa1e9(%rip), %rsi      # 0x15e85
movb $0x0, %al
callq 0x5110
movq 0x30(%rsp), %rdi
movl $0x4, %esi
callq 0xbf90
movq 0x30(%rsp), %rdi
movq 0x30(%rsp), %rax
movq 0x70(%rax), %rsi
xorl %ecx, %ecx
movl %ecx, %edx
callq 0xc000
movq 0x30(%rsp), %rax
cmpl $0x2, 0x8(%rax)
je 0xbceb
movq 0x30(%rsp), %rax
movq 0x10(%rax), %rdi
leaq 0xa1a9(%rip), %rsi      # 0x15e8d
movb $0x0, %al
callq 0x5110
movl $0x0, 0x28(%rsp)
movl $0x0, 0x2c(%rsp)
movl 0x2c(%rsp), %eax
movq 0x30(%rsp), %rcx
cmpl 0x40(%rcx), %eax
jge 0xbecf
movq 0x30(%rsp), %rax
movq 0x58(%rax), %rax
movslq 0x2c(%rsp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movl %eax, 0x24(%rsp)
movq 0x30(%rsp), %rax
movq 0x58(%rax), %rax
movl 0x2c(%rsp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movl %eax, 0x20(%rsp)
movq 0x30(%rsp), %rdi
movq 0x30(%rsp), %rax
movq 0x58(%rax), %rax
movslq 0x2c(%rsp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rsi
movl 0x20(%rsp), %edx
subl 0x24(%rsp), %edx
movl $0x1, %ecx
callq 0xc000
movl 0x28(%rsp), %ecx
movq 0x30(%rsp), %rdx
xorl %eax, %eax
cmpl 0x44(%rdx), %ecx
movb %al, 0x13(%rsp)
jge 0xbdb1
movq 0x30(%rsp), %rax
addq $0x90, %rax
movslq 0x28(%rsp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %eax
cmpl 0x20(%rsp), %eax
setle %al
movb %al, 0x13(%rsp)
movb 0x13(%rsp), %al
testb $0x1, %al
jne 0xbdbe
jmp 0xbe9c
movq 0x30(%rsp), %rax
addq $0x90, %rax
movslq 0x28(%rsp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movq %rax, 0x18(%rsp)
movq 0x18(%rsp), %rax
movl (%rax), %eax
subl 0x24(%rsp), %eax
movl %eax, 0x14(%rsp)
movq 0x30(%rsp), %rax
cmpl $0x2, 0x8(%rax)
jne 0xbe36
movq 0x18(%rsp), %rax
cmpl $0x0, 0x8(%rax)
je 0xbe36
movq 0x30(%rsp), %rdi
movq 0x30(%rsp), %rax
movq 0x28(%rax), %rsi
movslq 0x24(%rsp), %rax
addq %rax, %rsi
movl 0x14(%rsp), %edx
movq 0x30(%rsp), %rax
movq 0x60(%rax), %rax
movq 0x18(%rsp), %rcx
movslq 0x4(%rcx), %rcx
movq (%rax,%rcx,8), %rcx
callq 0xc130
jmp 0xbe7d
movq 0x30(%rsp), %rdi
movq 0x30(%rsp), %rax
movq 0x28(%rax), %rsi
movslq 0x24(%rsp), %rax
addq %rax, %rsi
movl 0x14(%rsp), %edx
callq 0xc290
movq 0x30(%rsp), %rdi
movq 0x18(%rsp), %rax
movl 0x8(%rax), %esi
movq 0x30(%rsp), %rax
movq 0x60(%rax), %rax
movq 0x18(%rsp), %rcx
movslq 0x4(%rcx), %rcx
movq (%rax,%rcx,8), %rdx
callq 0xc360
movl 0x14(%rsp), %eax
addl $0x4, %eax
addl 0x24(%rsp), %eax
movl %eax, 0x24(%rsp)
movl 0x28(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x28(%rsp)
jmp 0xbd79
movq 0x30(%rsp), %rdi
movq 0x30(%rsp), %rax
movq 0x28(%rax), %rsi
movslq 0x24(%rsp), %rax
addq %rax, %rsi
movl 0x20(%rsp), %edx
subl 0x24(%rsp), %edx
callq 0xc290
movl 0x2c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x2c(%rsp)
jmp 0xbcfb
movq 0x30(%rsp), %rax
movq 0x10(%rax), %rdi
leaq 0x9b7e(%rip), %rsi      # 0x15a5d
xorl %eax, %eax
callq 0x5110
movq 0x30(%rsp), %rax
movl 0x8(%rax), %eax
movl %eax, 0xc(%rsp)
testl %eax, %eax
je 0xbf0e
jmp 0xbef8
movl 0xc(%rsp), %eax
subl $0x1, %eax
je 0xbf25
jmp 0xbf03
movl 0xc(%rsp), %eax
subl $0x2, %eax
je 0xbf4a
jmp 0xbf6f
movq 0x30(%rsp), %rax
movq 0x10(%rax), %rdi
leaq 0x9f79(%rip), %rsi      # 0x15e97
movb $0x0, %al
callq 0x5110
movq 0x30(%rsp), %rax
movq 0x10(%rax), %rdi
movq 0x30(%rsp), %rax
movq 0x80(%rax), %rdx
leaq 0x9f7e(%rip), %rsi      # 0x15ebf
movb $0x0, %al
callq 0x5110
jmp 0xbf71
movq 0x30(%rsp), %rax
movq 0x10(%rax), %rdi
movq 0x30(%rsp), %rax
movq 0x80(%rax), %rdx
leaq 0x9f67(%rip), %rsi      # 0x15ecd
movb $0x0, %al
callq 0x5110
jmp 0xbf71
jmp 0xbf71
movq 0x30(%rsp), %rax
movq 0x10(%rax), %rdi
leaq 0x9adc(%rip), %rsi      # 0x15a5d
movb $0x0, %al
callq 0x5110
addq $0x38, %rsp
retq
nopl (%rax)