// File: /workspace/github_c_makefile_star2_O3/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 (%rdi), %rax
movq %rax, (%rsp)
movl 0x48(%rax), %eax
movq %rsi, %r15
testl %eax, %eax
jle 0x65b7
movq (%rsp), %rcx
leaq 0x50(%rcx), %r9
leaq 0x90(%rdi), %rcx
movq %rcx, 0x40(%rsp)
movl $0x1, %ecx
subq %rsi, %rcx
movq %rcx, 0x38(%rsp)
xorl %edx, %edx
leaq 0x5f1e(%rip), %r13      # 0xc0c8
movq %rsi, %r15
movq %rsi, 0x20(%rsp)
movq %rdi, 0x18(%rsp)
movq %r9, 0x10(%rsp)
movq %rdx, 0x28(%rsp)
leaq (%rdx,%rdx,4), %rcx
movq 0x8(%r9,%rcx,8), %r12
movslq 0x18(%r9,%rcx,8), %rdx
shlq $0x2, %rdx
addq (%r9,%rcx,8), %rdx
movq %rdx, 0x30(%rsp)
cmpq %rdx, %r12
je 0x65a3
movslq (%r12), %rdx
addq $0x4, %r12
movq (%rsp), %rax
addq 0x8(%rax), %rdx
xorl %ecx, %ecx
movq %rdx, %r14
movq %rcx, %rbp
movb (%rdx), %cl
leal 0x17(%rcx), %eax
xorl %ebx, %ebx
cmpb $0x11, %al
ja 0x6210
movl (%r12), %ebx
addq $0x4, %r12
leaq 0x1(%r14), %rax
movzbl %cl, %edx
addl $0xffffff17, %edx       # imm = 0xFFFFFF17
cmpl $0x16, %edx
ja 0x64f5
movslq (%r13,%rdx,4), %r8
addq %r13, %r8
movq %r15, %rcx
movq %rax, %rdx
jmpq *%r8
movq %rbp, %rcx
jmp 0x6570
movzbl 0x1(%r14), %eax
addq $0x2, %r14
movq %rbp, %rcx
movq %r14, %rdx
cmpq $0xa, %rax
jb 0x61f7
cmpb $-0xe, (%r14)
jne 0x625e
movl (%r12), %ebx
movslq %ebx, %rcx
addq %rsi, %rcx
movq (%rsp), %rdx
movq 0x30(%rdx), %rdx
movq %rcx, (%rdx,%rax,8)
jmp 0x64c6
movq %rax, %r14
jmp 0x6297
addq $0x2, %r14
testl %ebx, %ebx
jns 0x637f
addq $0x4, %r12
movq (%rsp), %rax
movq 0x30(%rax), %rax
negl %ebx
movl (%rax,%rbx,8), %ebx
movq %r12, %rdx
jmp 0x6508
leaq 0x2(%r14), %rdx
leal (,%rbx,8), %eax
cmpb $0x2, 0x1(%r14)
cmovbl %ebx, %eax
orb %al, -0x1(%r15)
movq %rbp, %rcx
jmp 0x61f7
addq $0x2, %r14
testl %ebx, %ebx
js 0x651a
movq %r14, %rax
movslq %ebx, %rcx
sarl $0x18, %ebx
movslq %ebx, %rdx
leaq (%rdx,%rdx,4), %rdx
movq (%r9,%rdx,8), %rdx
movl (%rdx,%rcx,4), %ebx
testl %ebx, %ebx
js 0x64fd
addl %esi, %ebx
jmp 0x652a
movsbl %bl, %ecx
cmpl %ebx, %ecx
je 0x64d8
xorl %ebp, %ebp
movw %bx, (%r15)
addq $0x2, %r15
jmp 0x6531
testq %rbp, %rbp
cmoveq %r15, %rbp
movb (%rax), %cl
andb $-0x2, %cl
cmpb $-0x12, %cl
movl $0x0, %ecx
cmoveq %rbp, %rcx
testl %ebx, %ebx
je 0x653c
movsbl %bl, %edx
cmpl %ebx, %edx
jne 0x657e
movb -0x1(%rbp), %dl
jmp 0x655a
movzbl 0x1(%r14), %eax
addq $0x2, %r14
movl %r15d, %r8d
subl %esi, %r8d
movq %rbp, %rcx
movq %r14, %rdx
testl %eax, %r8d
je 0x61f7
movq 0x38(%rsp), %rcx
addq %r15, %rcx
movq %rcx, %rdx
movb $-0x70, (%r15)
incq %r15
incq %rdx
testl %eax, %ecx
movq %rdx, %rcx
jne 0x6366
jmp 0x64c6
movq %rax, %r14
leaq 0x4(%r12), %rdx
movslq %ebx, %rax
sarl $0x18, %ebx
movslq %ebx, %rcx
leaq (%rcx,%rcx,4), %rcx
movq (%r9,%rcx,8), %r8
movl (%r8,%rax,4), %ecx
testl %ecx, %ecx
js 0x6503
movl (%r12), %eax
movl %esi, %r8d
subl %r15d, %r8d
addl %ecx, %r8d
leal (%rax,%r8), %ebx
addl $-0x4, %ebx
testl %eax, %eax
je 0x650e
cmpl $0x4, %eax
jne 0x6562
movb -0x1(%r15), %al
addb $-0x10, %al
movb %al, -0x2(%r15)
decq %r15
jmp 0x6567
movl 0x44(%rdi), %ecx
cmpl $0xc8, %ecx
jge 0x65d9
movzbl (%rax), %r11d
movzbl 0x2(%r14), %ebx
leaq 0xfd29(%rip), %rax      # 0x16120
movl (%rax,%rbx,4), %eax
testl %eax, %eax
jns 0x645d
movl 0x48(%rdi), %eax
leaq 0xfd18(%rip), %rcx      # 0x16120
movl %eax, (%rcx,%rbx,4)
leaq 0xf0be(%rip), %rax      # 0x154d0
movq (%rax,%rbx,8), %rdx
movl 0x8(%rdi), %edi
leaq 0xb60f(%rip), %rsi      # 0x11a2f
movl %r11d, 0xc(%rsp)
callq 0x71ba
movl 0xc(%rsp), %r11d
movq 0x10(%rsp), %r9
movq 0x18(%rsp), %rdi
movq 0x20(%rsp), %rsi
movq 0x60(%rdi), %rcx
movslq 0x48(%rdi), %rdx
movq %rax, (%rcx,%rdx,8)
leal 0x1(%rdx), %eax
movl %eax, 0x48(%rdi)
movl 0x44(%rdi), %ecx
leaq 0xfcc6(%rip), %rax      # 0x16120
movl (%rax,%rbx,4), %eax
movl 0x28(%rdi), %edx
movl %r15d, %r8d
subl %edx, %r8d
movslq %ecx, %rcx
leaq (%rcx,%rcx,2), %rdx
movq 0x40(%rsp), %r10
movl %r8d, (%r10,%rdx,4)
movl %eax, 0x4(%r10,%rdx,4)
movl %r11d, 0x8(%r10,%rdx,4)
incl %ecx
movl %ecx, 0x44(%rdi)
addq $0x3, %r14
xorl %ebx, %ebx
jmp 0x6527
addq $0x2, %r14
movq %rbp, %rcx
movq %r14, %rdx
testl %ebx, %ebx
je 0x61f7
movl %ebx, %edx
movzbl (%rax), %esi
movq %r15, %rdi
callq 0x50c0
movq 0x10(%rsp), %r9
movq 0x18(%rsp), %rdi
movq 0x20(%rsp), %rsi
decl %ebx
addq %rbx, %r15
incq %r15
movq %rbp, %rcx
movq %r14, %rdx
jmp 0x61f7
movsbl %bl, %ecx
cmpl %ebx, %ecx
jne 0x6516
testq %rbp, %rbp
cmoveq %r15, %rbp
addb $0x2, -0x2(%rbp)
xorl %ecx, %ecx
jmp 0x6570
movb 0x1(%r14), %cl
addq $0x2, %r14
movq %r14, %rax
movb %cl, (%r15)
incq %r15
jmp 0x6531
movl 0x4(%rdx,%rcx,4), %ebx
jmp 0x652a
movl 0x4(%r8,%rax,4), %ebx
subl %r15d, %ebx
addl $-0x4, %ebx
movq %r14, %rax
movq %rdx, %r12
jmp 0x652a
xorl %ebp, %ebp
jmp 0x652a
movq (%rsp), %rax
movq 0x30(%rax), %rax
negl %ebx
movl (%rax,%rbx,8), %ebx
movq %r14, %rax
movl %ebx, (%r15)
addq $0x4, %r15
movq %rbp, %rcx
movq %rax, %rdx
jmp 0x61f7
movb -0x1(%rbp), %dl
movl %edx, %r8d
andb $0x7, %r8b
cmpb $0x4, %r8b
jne 0x6554
movb (%rbp), %r8b
andb $0x7, %r8b
cmpb $0x5, %r8b
jne 0x6583
addb $-0x40, %dl
movb %dl, -0x1(%rbp)
jmp 0x6570
movb $-0x15, -0x1(%r15)
movq %rbp, %rcx
movq %r14, %rax
movq %rdx, %r12
movb %bl, (%r15)
incq %r15
movq %rax, %rdx
jmp 0x61f7
movq %rcx, %rbp
jmp 0x652a
addb $-0x80, %dl
movb %dl, -0x1(%rbp)
movq %rax, %rdx
jmp 0x61f7
cmpq 0x30(%rsp), %r12
jne 0x61e5
movq (%rsp), %rax
movl 0x48(%rax), %eax
movq 0x28(%rsp), %rdx
incq %rdx
movslq %eax, %rcx
cmpq %rcx, %rdx
jl 0x61bc
movq (%rsp), %rax
addq 0x40(%rax), %rsi
xorl %eax, %eax
cmpq %r15, %rsi
setne %al
shll $0x19, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x5200