// File: /workspace/github_c_makefile_star2_O0/LuaJIT[P]LuaJIT/src/host/buildvm_asm.c
// Function: emit_asm_reloc_text
static void emit_asm_reloc_text(BuildCtx *ctx, uint8_t *cp, int n,
				const char *sym)
{
  const char *opname = NULL;
  if (--n < 0) goto err;
  if (cp[n] == 0xe8) {
    opname = "call";
  } else if (cp[n] == 0xe9) {
    opname = "jmp";
  } else if (cp[n] >= 0x80 && cp[n] <= 0x8f && n > 0 && cp[n-1] == 0x0f) {
    opname = jccnames[cp[n]-0x80];
    n--;
  } else {
err:
    fprintf(stderr, "Error: unsupported opcode for %s symbol relocation.\n",
	    sym);
    exit(1);
  }
  emit_asm_bytes(ctx, cp, n);
  if (strncmp(sym+(*sym == '_'), LABEL_PREFIX, sizeof(LABEL_PREFIX)-1)) {
    /* Various fixups for external symbols outside of our binary. */
    if (ctx->mode == BUILD_elfasm) {
      if (LJ_32)
	fprintf(ctx->fp, "#if __PIC__\n\t%s lj_wrap_%s\n#else\n", opname, sym);
      fprintf(ctx->fp, "\t%s %s@PLT\n", opname, sym);
      if (LJ_32)
	fprintf(ctx->fp, "#endif\n");
      return;
    } else if (LJ_32 && ctx->mode == BUILD_machasm) {
      fprintf(ctx->fp, "\t%s L%s$stub\n", opname, sym);
      return;
    }
  }
  fprintf(ctx->fp, "\t%s %s\n", opname, sym);
}

// Assembly:
subq $0x28, %rsp
movq %rdi, 0x20(%rsp)
movq %rsi, 0x18(%rsp)
movl %edx, 0x14(%rsp)
movq %rcx, 0x8(%rsp)
movq $0x0, (%rsp)
movl 0x14(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x14(%rsp)
cmpl $0x0, %eax
jge 0xc474
jmp 0xc53b
movq 0x18(%rsp), %rax
movslq 0x14(%rsp), %rcx
movzbl (%rax,%rcx), %eax
cmpl $0xe8, %eax
jne 0xc499
leaq 0x79af(%rip), %rax      # 0x13e3f
movq %rax, (%rsp)
jmp 0xc566
movq 0x18(%rsp), %rax
movslq 0x14(%rsp), %rcx
movzbl (%rax,%rcx), %eax
cmpl $0xe9, %eax
jne 0xc4be
leaq 0x950d(%rip), %rax      # 0x159c2
movq %rax, (%rsp)
jmp 0xc564
movq 0x18(%rsp), %rax
movslq 0x14(%rsp), %rcx
movzbl (%rax,%rcx), %eax
cmpl $0x80, %eax
jl 0xc539
movq 0x18(%rsp), %rax
movslq 0x14(%rsp), %rcx
movzbl (%rax,%rcx), %eax
cmpl $0x8f, %eax
jg 0xc539
cmpl $0x0, 0x14(%rsp)
jle 0xc539
movq 0x18(%rsp), %rax
movl 0x14(%rsp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movzbl (%rax,%rcx), %eax
cmpl $0xf, %eax
jne 0xc539
movq 0x18(%rsp), %rax
movslq 0x14(%rsp), %rcx
movzbl (%rax,%rcx), %eax
subl $0x80, %eax
movslq %eax, %rcx
leaq 0xd64c(%rip), %rax      # 0x19b70
movq (%rax,%rcx,8), %rax
movq %rax, (%rsp)
movl 0x14(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x14(%rsp)
jmp 0xc562
jmp 0xc53b
movq 0xdab6(%rip), %rax      # 0x19ff8
movq (%rax), %rdi
movq 0x8(%rsp), %rdx
leaq 0x9475(%rip), %rsi      # 0x159c6
movb $0x0, %al
callq 0x5110
movl $0x1, %edi
callq 0x5190
jmp 0xc564
jmp 0xc566
movq 0x20(%rsp), %rdi
movq 0x18(%rsp), %rsi
movl 0x14(%rsp), %edx
callq 0xc610
movq 0x8(%rsp), %rdi
movq 0x8(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x5f, %eax
sete %al
andb $0x1, %al
movzbl %al, %eax
cltq
addq %rax, %rdi
leaq 0x7b2b(%rip), %rsi      # 0x140c8
movl $0x3, %edx
callq 0x5050
cmpl $0x0, %eax
je 0xc5dd
movq 0x20(%rsp), %rax
cmpl $0x0, 0x8(%rax)
jne 0xc5d9
movq 0x20(%rsp), %rax
movq 0x10(%rax), %rdi
movq (%rsp), %rdx
movq 0x8(%rsp), %rcx
leaq 0x942b(%rip), %rsi      # 0x159fb
movb $0x0, %al
callq 0x5110
jmp 0xc5fd
jmp 0xc5db
jmp 0xc5dd
movq 0x20(%rsp), %rax
movq 0x10(%rax), %rdi
movq (%rsp), %rdx
movq 0x8(%rsp), %rcx
leaq 0x9411(%rip), %rsi      # 0x15a07
movb $0x0, %al
callq 0x5110
addq $0x28, %rsp
retq
nopw %cs:(%rax,%rax)