// File: /workspace/github_c_makefile_star2_O2/katlogic[P]ljx/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++;
	  unsigned char *ex = cp - (t&7);
	  if ((n & 8) && t < 0xa0) {
	    if (*ex & 0x80) ex[1] ^= 0x20 << (t>>6); else *ex ^= 1 << (t>>6);
	    n &= 7;
	  } else if (n & 0x10) {
	    if (*ex & 0x80) {
	      *ex = 0xc5; ex[1] = (ex[1] & 0x80) | ex[2]; ex += 2;
	    }
	    while (++ex < cp) ex[-1] = *ex;
	    if (mark) mark--;
	    cp--;
	    n &= 7;
	  }
	  if (t >= 0xc0) n <<= 4;
	  else if (t >= 0x40) n <<= 3;
	  else if (n == 4 && t < 0x20) { cp[-1] ^= n; *cp++ = 0x20; }
	  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, %r9
movq (%rdi), %r10
leaq 0x50(%r10), %r11
leaq 0x98(%rdi), %rax
movq %rax, 0x38(%rsp)
movq %rsi, %rax
negq %rax
movq %rax, 0x40(%rsp)
xorl %ecx, %ecx
leaq 0x53ce(%rip), %r14      # 0xb0d8
movq %rsi, %rbx
movq %r11, 0x8(%rsp)
movq %rsi, 0x30(%rsp)
movq %r10, 0x28(%rsp)
movq %rdi, 0x20(%rsp)
movslq 0x48(%r10), %rax
cmpq %rax, %rcx
jge 0x6156
movq %rcx, 0x10(%rsp)
imulq $0x28, %rcx, %rax
movq 0x8(%r11,%rax), %r12
movslq 0x18(%r11,%rax), %rcx
shlq $0x2, %rcx
addq (%r11,%rax), %rcx
movq %rcx, 0x18(%rsp)
cmpq 0x18(%rsp), %r12
je 0x6149
movslq (%r12), %rcx
addq $0x4, %r12
addq 0x8(%r10), %rcx
xorl %edx, %edx
movq %rcx, %r13
movq %rdx, %rbp
movb (%rcx), %dl
leal 0x17(%rdx), %ecx
xorl %eax, %eax
cmpb $0x11, %cl
ja 0x5d81
movl (%r12), %eax
addq $0x4, %r12
leaq 0x1(%r13), %rcx
movzbl %dl, %esi
addl $0xffffff17, %esi       # imm = 0xFFFFFF17
cmpl $0x16, %esi
ja 0x6028
movslq (%r14,%rsi,4), %rsi
addq %r14, %rsi
movslq %eax, %r8
movq %rbx, %rdx
jmpq *%rsi
movq %rbp, %rdx
jmp 0x60e5
movzbl 0x1(%r13), %esi
addq $0x2, %r13
movq %rbp, %rdx
movq %r13, %rcx
cmpq $0xa, %rsi
jb 0x5d67
cmpb $-0xe, (%r13)
jne 0x5dce
movl (%r12), %eax
cltq
addq %r9, %rax
movq 0x30(%r10), %rcx
movq %rax, (%rcx,%rsi,8)
jmp 0x6131
movq %rcx, %r13
jmp 0x5dfe
addq $0x2, %r13
testl %eax, %eax
jns 0x5ee7
addq $0x4, %r12
movq 0x30(%r10), %rcx
negl %eax
movl (%rcx,%rax,8), %eax
movq %r12, %rsi
jmp 0x603b
movzbl 0x1(%r13), %edx
movl %edx, %ecx
andl $0x7, %ecx
movq %rbx, %rsi
subq %rcx, %rsi
testb $0x8, %al
je 0x6054
cmpb $-0x61, %dl
ja 0x6054
movb (%rsi), %r11b
movl %edx, %ecx
shrb $0x6, %cl
testb %r11b, %r11b
js 0x60f7
movb $0x1, %r8b
shlb %cl, %r8b
xorb %r8b, %r11b
movb %r11b, (%rsi)
jmp 0x6101
addq $0x2, %r13
testl %eax, %eax
js 0x60a1
movq %r13, %rcx
sarl $0x18, %eax
cltq
imulq $0x28, %rax, %rax
movq (%r11,%rax), %rdx
movl (%rdx,%r8,4), %eax
testl %eax, %eax
js 0x602f
addl %r9d, %eax
jmp 0x6046
movsbl %al, %edx
cmpl %eax, %edx
je 0x600b
xorl %ebp, %ebp
movw %ax, (%rbx)
addq $0x2, %rbx
jmp 0x604c
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 0x60af
movsbl %al, %esi
cmpl %eax, %esi
jne 0x60ef
movb -0x1(%rbp), %sil
jmp 0x60ce
movzbl (%rcx), %eax
movq 0x40(%rsp), %rcx
addq %rbx, %rcx
testl %eax, %ecx
je 0x612d
movb $-0x70, (%rbx)
incq %rbx
incq %rcx
jmp 0x5ed1
movq %rcx, %r13
leaq 0x4(%r12), %rsi
sarl $0x18, %eax
cltq
imulq $0x28, %rax, %rax
movq (%r11,%rax), %rcx
movl (%rcx,%r8,4), %eax
testl %eax, %eax
js 0x6036
movl (%r12), %ecx
movl %r9d, %edx
subl %ebx, %edx
addl %eax, %edx
leal (%rcx,%rdx), %eax
addl $-0x4, %eax
testl %ecx, %ecx
je 0x6040
cmpl $0x4, %ecx
jne 0x60d8
movb -0x1(%rbx), %cl
addb $-0x10, %cl
movb %cl, -0x2(%rbx)
decq %rbx
jmp 0x60dc
movl 0x44(%rdi), %eax
cmpl $0xc8, %eax
jge 0x6174
movzbl (%rcx), %r14d
movzbl 0x2(%r13), %r15d
leaq 0x101ca(%rip), %rcx     # 0x16120
movl (%rcx,%r15,4), %ecx
testl %ecx, %ecx
jns 0x5fb7
movl 0x48(%rdi), %eax
leaq 0x101b8(%rip), %rcx     # 0x16120
movl %eax, (%rcx,%r15,4)
leaq 0xf42d(%rip), %rax      # 0x153a0
movq (%rax,%r15,8), %rdx
leaq 0xac72(%rip), %rsi      # 0x10bf0
callq 0x6d07
movq 0x8(%rsp), %r11
movq 0x20(%rsp), %rdi
movq 0x28(%rsp), %r10
movq 0x30(%rsp), %r9
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 0x1016d(%rip), %rcx     # 0x16120
movl (%rcx,%r15,4), %ecx
movl 0x28(%rdi), %edx
movl %ebx, %esi
subl %edx, %esi
cltq
imulq $0xc, %rax, %rdx
movq 0x38(%rsp), %r8
movl %esi, (%r8,%rdx)
movl %ecx, 0x4(%r8,%rdx)
movl %r14d, 0x8(%r8,%rdx)
incl %eax
movl %eax, 0x44(%rdi)
addq $0x3, %r13
xorl %eax, %eax
movq %r13, %rcx
leaq 0x50ec(%rip), %r14      # 0xb0d8
jmp 0x6046
movb (%rcx), %cl
subl $0x1, %eax
jb 0x612d
movb %cl, (%rbx)
incq %rbx
jmp 0x5ff0
movsbl %al, %edx
cmpl %eax, %edx
jne 0x609d
testq %rbp, %rbp
cmoveq %rbx, %rbp
addb $0x2, -0x2(%rbp)
xorl %edx, %edx
jmp 0x60e5
movb 0x1(%r13), %dl
addq $0x2, %r13
movq %r13, %rcx
movb %dl, (%rbx)
incq %rbx
jmp 0x604c
movl 0x4(%rdx,%r8,4), %eax
jmp 0x6046
movl 0x4(%rcx,%r8,4), %eax
subl %ebx, %eax
addl $-0x4, %eax
movq %r13, %rcx
movq %rsi, %r12
movl %eax, (%rbx)
addq $0x4, %rbx
movq %rbp, %rdx
jmp 0x5d67
testb $0x10, %al
je 0x6090
cmpb $0x0, (%rsi)
jns 0x6077
movb $-0x3b, (%rsi)
movb 0x1(%rsi), %cl
andb $-0x80, %cl
orb 0x2(%rsi), %cl
movb %cl, 0x1(%rsi)
addq $0x2, %rsi
jmp 0x6077
movb (%rsi), %cl
movb %cl, -0x1(%rsi)
incq %rsi
cmpq %rbx, %rsi
jb 0x6072
leaq -0x1(%rbp), %rcx
testq %rbp, %rbp
cmovneq %rcx, %rbp
decq %rbx
andl $0x7, %eax
cmpb $-0x40, %dl
jb 0x6109
shll $0x4, %eax
jmp 0x612a
xorl %ebp, %ebp
jmp 0x6046
movq 0x30(%r10), %rcx
negl %eax
movl (%rcx,%rax,8), %eax
movq %r13, %rcx
jmp 0x6046
movb -0x1(%rbp), %sil
movl %esi, %r8d
andb $0x7, %r8b
cmpb $0x4, %r8b
jne 0x60c8
movb (%rbp), %r8b
andb $0x7, %r8b
cmpb $0x5, %r8b
jne 0x613c
addb $-0x40, %sil
movb %sil, -0x1(%rbp)
jmp 0x60e5
movb $-0x15, -0x1(%rbx)
movq %rbp, %rdx
movq %r13, %rcx
movq %rsi, %r12
movb %al, (%rbx)
incq %rbx
jmp 0x5d67
movq %rdx, %rbp
jmp 0x6046
movb $0x20, %r8b
shlb %cl, %r8b
xorb %r8b, 0x1(%rsi)
andl $0x7, %eax
movq 0x8(%rsp), %r11
cmpb $0x40, %dl
jb 0x6113
shll $0x3, %eax
jmp 0x612a
cmpl $0x4, %eax
jne 0x612a
cmpb $0x1f, %dl
ja 0x612a
xorb $0x4, -0x1(%rbx)
movb $0x20, (%rbx)
incq %rbx
pushq $0x4
popq %rax
xorb %al, -0x1(%rbx)
addq $0x2, %r13
movq %rbp, %rdx
movq %r13, %rcx
jmp 0x5d67
addb $-0x80, %sil
movb %sil, -0x1(%rbp)
jmp 0x5d67
movq 0x10(%rsp), %rcx
incq %rcx
jmp 0x5d21
addq 0x40(%r10), %r9
xorl %eax, %eax
cmpq %rbx, %r9
setne %al
shll $0x19, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xfe7d(%rip), %rax      # 0x15ff8
movq (%rax), %rcx
leaq 0x92d5(%rip), %rdi      # 0xf45a
pushq $0x37
popq %rsi
pushq $0x1
popq %rdx
callq 0x51d0
pushq $0x1
popq %rdi
callq 0x51c0