// File: /workspace/github_c_makefile_star2_O0/fanf2[P]luajit-2/src/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);

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

  for (i = rel = 0; i < ctx->nsym; i++) {
    int32_t ofs = ctx->sym[i].ofs;
    int32_t next = ctx->sym[i+1].ofs;
    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
  }

  fprintf(ctx->fp, "\n");
  switch (ctx->mode) {
  case BUILD_elfasm:
    fprintf(ctx->fp, "\t.section .note.GNU-stack,\"\",@progbits\n");
#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
    /* 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 0x8d8b(%rip), %rsi      # 0x14790
movb $0x0, %al
callq 0x4110
movq 0x30(%rsp), %rax
movq 0x10(%rax), %rdi
leaq 0x8d8e(%rip), %rsi      # 0x147aa
movb $0x0, %al
callq 0x4110
movq 0x30(%rsp), %rdi
movl $0x4, %esi
callq 0xbd10
movq 0x30(%rsp), %rdi
movq 0x30(%rsp), %rax
movq 0x70(%rax), %rsi
xorl %ecx, %ecx
movl %ecx, %edx
callq 0xbd80
movq 0x30(%rsp), %rax
cmpl $0x2, 0x8(%rax)
je 0xba6b
movq 0x30(%rsp), %rax
movq 0x10(%rax), %rdi
leaq 0x8d4e(%rip), %rsi      # 0x147b2
movb $0x0, %al
callq 0x4110
movl $0x0, 0x28(%rsp)
movl $0x0, 0x2c(%rsp)
movl 0x2c(%rsp), %eax
movq 0x30(%rsp), %rcx
cmpl 0x40(%rcx), %eax
jge 0xbc4f
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 0xbd80
movl 0x28(%rsp), %ecx
movq 0x30(%rsp), %rdx
xorl %eax, %eax
cmpl 0x44(%rdx), %ecx
movb %al, 0x13(%rsp)
jge 0xbb31
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
setl %al
movb %al, 0x13(%rsp)
movb 0x13(%rsp), %al
testb $0x1, %al
jne 0xbb3e
jmp 0xbc1c
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 0xbbb6
movq 0x18(%rsp), %rax
cmpl $0x0, 0x8(%rax)
je 0xbbb6
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 0xbeb0
jmp 0xbbfd
movq 0x30(%rsp), %rdi
movq 0x30(%rsp), %rax
movq 0x28(%rax), %rsi
movslq 0x24(%rsp), %rax
addq %rax, %rsi
movl 0x14(%rsp), %edx
callq 0xc010
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 0xc0e0
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 0xbaf9
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 0xc010
movl 0x2c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x2c(%rsp)
jmp 0xba7b
movq 0x30(%rsp), %rax
movq 0x10(%rax), %rdi
leaq 0x8783(%rip), %rsi      # 0x143e2
xorl %eax, %eax
callq 0x4110
movq 0x30(%rsp), %rax
movl 0x8(%rax), %eax
movl %eax, 0xc(%rsp)
testl %eax, %eax
je 0xbc8e
jmp 0xbc78
movl 0xc(%rsp), %eax
subl $0x1, %eax
je 0xbca5
jmp 0xbc83
movl 0xc(%rsp), %eax
subl $0x2, %eax
je 0xbcca
jmp 0xbcef
movq 0x30(%rsp), %rax
movq 0x10(%rax), %rdi
leaq 0x8b1e(%rip), %rsi      # 0x147bc
movb $0x0, %al
callq 0x4110
movq 0x30(%rsp), %rax
movq 0x10(%rax), %rdi
movq 0x30(%rsp), %rax
movq 0x80(%rax), %rdx
leaq 0x8b23(%rip), %rsi      # 0x147e4
movb $0x0, %al
callq 0x4110
jmp 0xbcf1
movq 0x30(%rsp), %rax
movq 0x10(%rax), %rdi
movq 0x30(%rsp), %rax
movq 0x80(%rax), %rdx
leaq 0x8b0c(%rip), %rsi      # 0x147f2
movb $0x0, %al
callq 0x4110
jmp 0xbcf1
jmp 0xbcf1
movq 0x30(%rsp), %rax
movq 0x10(%rax), %rdi
leaq 0x86e1(%rip), %rsi      # 0x143e2
movb $0x0, %al
callq 0x4110
addq $0x38, %rsp
retq
nopl (%rax)