// File: /workspace/github_c_makefile_star2_O2/zenkj[P]luajit-arm64/src/./../dynasm/dasm_x86.h
// Function: dasm_encode
int dasm_encode(Dst_DECL, void *buffer)
{
  dasm_State *D = Dst_REF;
  unsigned char *base = (unsigned char *)buffer;
  unsigned char *cp = base;
  int secnum;

  /* Encode all code sections. No support for data sections (yet). */
  for (secnum = 0; secnum < D->maxsection; secnum++) {
    dasm_Section *sec = D->sections + secnum;
    int *b = sec->buf;
    int *endb = sec->rbuf + sec->pos;

    while (b != endb) {
      dasm_ActList p = D->actionlist + *b++;
      unsigned char *mark = NULL;
      while (1) {
	int action = *p++;
	int n = (action >= DASM_DISP && action <= DASM_ALIGN) ? *b++ : 0;
	switch (action) {
	case DASM_DISP: if (!mark) mark = cp; {
	  unsigned char *mm = mark;
	  if (*p != DASM_IMM_DB && *p != DASM_IMM_WB) mark = NULL;
	  if (n == 0) { int mrm = mm[-1]&7; if (mrm == 4) mrm = mm[0]&7;
	    if (mrm != 5) { mm[-1] -= 0x80; break; } }
	  if (((n+128) & -256) != 0) goto wd; else mm[-1] -= 0x40;
	}
	case DASM_IMM_S: case DASM_IMM_B: wb: dasmb(n); break;
	case DASM_IMM_DB: if (((n+128)&-256) == 0) {
	    db: if (!mark) mark = cp; mark[-2] += 2; mark = NULL; goto wb;
	  } else mark = NULL;
	case DASM_IMM_D: wd: dasmd(n); break;
	case DASM_IMM_WB: if (((n+128)&-256) == 0) goto db; else mark = NULL;
	case DASM_IMM_W: dasmw(n); break;
	case DASM_VREG: { int t = *p++; if (t >= 2) n<<=3; cp[-1] |= n; break; }
	case DASM_REL_LG: p++; if (n >= 0) goto rel_pc;
	  b++; n = (int)(ptrdiff_t)D->globals[-n];
	case DASM_REL_A: rel_a: n -= (int)(ptrdiff_t)(cp+4); goto wd; /* !x64 */
	case DASM_REL_PC: rel_pc: {
	  int shrink = *b++;
	  int *pb = DASM_POS2PTR(D, n); if (*pb < 0) { n = pb[1]; goto rel_a; }
	  n = *pb - ((int)(cp-base) + 4-shrink);
	  if (shrink == 0) goto wd;
	  if (shrink == 4) { cp--; cp[-1] = *cp-0x10; } else cp[-1] = 0xeb;
	  goto wb;
	}
	case DASM_IMM_LG:
	  p++; if (n < 0) { n = (int)(ptrdiff_t)D->globals[-n]; goto wd; }
	case DASM_IMM_PC: {
	  int *pb = DASM_POS2PTR(D, n);
	  n = *pb < 0 ? pb[1] : (*pb + (int)(ptrdiff_t)base);
	  goto wd;
	}
	case DASM_LABEL_LG: {
	  int idx = *p++;
	  if (idx >= 10)
	    D->globals[idx] = (void *)(base + (*p == DASM_SETLABEL ? *b : n));
	  break;
	}
	case DASM_LABEL_PC: case DASM_SETLABEL: break;
	case DASM_SPACE: { int fill = *p++; while (n--) *cp++ = fill; break; }
	case DASM_ALIGN:
	  n = *p++;
	  while (((cp-base) & n)) *cp++ = 0x90; /* nop */
	  break;
	case DASM_EXTERN: n = DASM_EXTERN(Dst, cp, p[1], *p); p += 2; goto wd;
	case DASM_MARK: mark = cp; break;
	case DASM_ESC: action = *p++;
	default: *cp++ = action; break;
	case DASM_SECTION: case DASM_STOP: goto stop;
	}
      }
      stop: (void)0;
    }
  }

  if (base + D->codesize != cp)  /* Check for phase errors. */
    return DASM_S_PHASE;
  return DASM_S_OK;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rsi, %r8
movq (%rdi), %r9
leaq 0x50(%r9), %r11
leaq 0x90(%rdi), %rax
movq %rax, 0x38(%rsp)
movq %rsi, %rax
negq %rax
movq %rax, 0x40(%rsp)
xorl %ecx, %ecx
leaq 0x5405(%rip), %r15      # 0xb0c8
movq %rsi, %rbx
movq %rsi, 0x30(%rsp)
movq %r9, 0x28(%rsp)
movq %rdi, 0x20(%rsp)
movq %r11, 0x18(%rsp)
movslq 0x48(%r9), %rax
cmpq %rax, %rcx
jge 0x6057
movq %rcx, 0x8(%rsp)
imulq $0x28, %rcx, %rax
movq 0x8(%r11,%rax), %r12
movslq 0x18(%r11,%rax), %rcx
shlq $0x2, %rcx
addq (%r11,%rax), %rcx
movq %rcx, 0x10(%rsp)
cmpq 0x10(%rsp), %r12
je 0x604a
movslq (%r12), %rcx
addq $0x4, %r12
addq 0x8(%r9), %rcx
xorl %edx, %edx
movq %rcx, %r13
movq %rdx, %rbp
movb (%rcx), %dl
leal 0x17(%rdx), %ecx
xorl %eax, %eax
cmpb $0x11, %cl
ja 0x5d3a
movl (%r12), %eax
addq $0x4, %r12
leaq 0x1(%r13), %rcx
movzbl %dl, %esi
addl $0xffffff17, %esi       # imm = 0xFFFFFF17
cmpl $0x16, %esi
ja 0x5fba
movslq (%r15,%rsi,4), %rsi
addq %r15, %rsi
movslq %eax, %r10
movq %rbx, %rdx
jmpq *%rsi
movq %rbp, %rdx
jmp 0x602e
movzbl 0x1(%r13), %esi
addq $0x2, %r13
movq %rbp, %rdx
movq %r13, %rcx
cmpq $0xa, %rsi
jb 0x5d20
cmpb $-0xe, (%r13)
jne 0x5d87
movl (%r12), %eax
cltq
addq %r8, %rax
movq 0x30(%r9), %rcx
movq %rax, (%rcx,%rsi,8)
jmp 0x5f8e
movq %rcx, %r13
jmp 0x5db7
addq $0x2, %r13
testl %eax, %eax
jns 0x5e78
addq $0x4, %r12
movq 0x30(%r9), %rcx
negl %eax
movl (%rcx,%rax,8), %eax
movq %r12, %rsi
jmp 0x5fcd
leaq 0x2(%r13), %rcx
leal (,%rax,8), %edx
cmpb $0x2, 0x1(%r13)
cmovbl %eax, %edx
orb %dl, -0x1(%rbx)
jmp 0x5ff0
addq $0x2, %r13
testl %eax, %eax
js 0x5fde
movq %r13, %rcx
sarl $0x18, %eax
cltq
imulq $0x28, %rax, %rax
movq (%r11,%rax), %rdx
movl (%rdx,%r10,4), %eax
testl %eax, %eax
js 0x5fc1
addl %r8d, %eax
jmp 0x5fea
movsbl %al, %edx
cmpl %eax, %edx
je 0x5fa0
xorl %ebp, %ebp
movw %ax, (%rbx)
addq $0x2, %rbx
jmp 0x5ff0
testq %rbp, %rbp
cmoveq %rbx, %rbp
movb (%rcx), %dl
andb $-0x2, %dl
cmpb $-0x12, %dl
movl $0x0, %edx
cmoveq %rbp, %rdx
testl %eax, %eax
je 0x5ff8
movsbl %al, %esi
cmpl %eax, %esi
jne 0x6038
movb -0x1(%rbp), %sil
jmp 0x6017
movzbl (%rcx), %eax
movq 0x40(%rsp), %rcx
addq %rbx, %rcx
testl %eax, %ecx
je 0x5f8a
movb $-0x70, (%rbx)
incq %rbx
incq %rcx
jmp 0x5e62
movq %rcx, %r13
leaq 0x4(%r12), %rsi
sarl $0x18, %eax
cltq
imulq $0x28, %rax, %rax
movq (%r11,%rax), %rcx
movl (%rcx,%r10,4), %eax
testl %eax, %eax
js 0x5fc8
movl (%r12), %ecx
movl %r8d, %edx
subl %ebx, %edx
addl %eax, %edx
leal (%rcx,%rdx), %eax
addl $-0x4, %eax
testl %ecx, %ecx
je 0x5fd2
cmpl $0x4, %ecx
jne 0x6021
movb -0x1(%rbx), %cl
addb $-0x10, %cl
movb %cl, -0x2(%rbx)
decq %rbx
jmp 0x6025
movl 0x44(%rdi), %eax
cmpl $0xc8, %eax
jge 0x6075
movzbl (%rcx), %ecx
movl %ecx, 0x4(%rsp)
movzbl 0x2(%r13), %r14d
leaq 0x10236(%rip), %rcx     # 0x16120
movl (%rcx,%r14,4), %ecx
testl %ecx, %ecx
jns 0x5f4b
movl 0x48(%rdi), %eax
leaq 0x10224(%rip), %rcx     # 0x16120
movl %eax, (%rcx,%r14,4)
leaq 0xf5c9(%rip), %rax      # 0x154d0
movq (%rax,%r14,8), %rdx
leaq 0xab1d(%rip), %rsi      # 0x10a2f
callq 0x6bdf
movq 0x18(%rsp), %r11
movq 0x20(%rsp), %rdi
movq 0x28(%rsp), %r9
movq 0x30(%rsp), %r8
movq 0x60(%rdi), %rcx
movslq 0x48(%rdi), %rdx
movq %rax, (%rcx,%rdx,8)
leal 0x1(%rdx), %eax
movl %eax, 0x48(%rdi)
movl 0x44(%rdi), %eax
leaq 0x101d9(%rip), %rcx     # 0x16120
movl (%rcx,%r14,4), %ecx
movl 0x28(%rdi), %edx
movl %ebx, %esi
subl %edx, %esi
cltq
imulq $0xc, %rax, %rdx
movq 0x38(%rsp), %r10
movl %esi, (%r10,%rdx)
movl %ecx, 0x4(%r10,%rdx)
movl 0x4(%rsp), %ecx
movl %ecx, 0x8(%r10,%rdx)
incl %eax
movl %eax, 0x44(%rdi)
addq $0x3, %r13
xorl %eax, %eax
jmp 0x5fe7
movb (%rcx), %cl
subl $0x1, %eax
jb 0x5f8a
movb %cl, (%rbx)
incq %rbx
jmp 0x5f7e
addq $0x2, %r13
movq %rbp, %rdx
movq %r13, %rcx
jmp 0x5d20
movsbl %al, %edx
cmpl %eax, %edx
jne 0x5fda
testq %rbp, %rbp
cmoveq %rbx, %rbp
addb $0x2, -0x2(%rbp)
xorl %edx, %edx
jmp 0x602e
movb 0x1(%r13), %dl
addq $0x2, %r13
movq %r13, %rcx
movb %dl, (%rbx)
incq %rbx
jmp 0x5ff0
movl 0x4(%rdx,%r10,4), %eax
jmp 0x5fea
movl 0x4(%rcx,%r10,4), %eax
subl %ebx, %eax
addl $-0x4, %eax
movq %r13, %rcx
movq %rsi, %r12
jmp 0x5fea
xorl %ebp, %ebp
jmp 0x5fea
movq 0x30(%r9), %rcx
negl %eax
movl (%rcx,%rax,8), %eax
movq %r13, %rcx
movl %eax, (%rbx)
addq $0x4, %rbx
movq %rbp, %rdx
jmp 0x5d20
movb -0x1(%rbp), %sil
movl %esi, %r10d
andb $0x7, %r10b
cmpb $0x4, %r10b
jne 0x6011
movb (%rbp), %r10b
andb $0x7, %r10b
cmpb $0x5, %r10b
jne 0x603d
addb $-0x40, %sil
movb %sil, -0x1(%rbp)
jmp 0x602e
movb $-0x15, -0x1(%rbx)
movq %rbp, %rdx
movq %r13, %rcx
movq %rsi, %r12
movb %al, (%rbx)
incq %rbx
jmp 0x5d20
movq %rdx, %rbp
jmp 0x5fea
addb $-0x80, %sil
movb %sil, -0x1(%rbp)
jmp 0x5d20
movq 0x8(%rsp), %rcx
incq %rcx
jmp 0x5cda
addq 0x40(%r9), %r8
xorl %eax, %eax
cmpq %rbx, %r8
setne %al
shll $0x19, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xff7c(%rip), %rax      # 0x15ff8
movq (%rax), %rcx
leaq 0x9272(%rip), %rdi      # 0xf2f8
pushq $0x37
popq %rsi
pushq $0x1
popq %rdx
callq 0x51d0
pushq $0x1
popq %rdi
callq 0x51c0