// File: /workspace/github_c_makefile_star2_O0/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:
subq $0xc8, %rsp
movq %rdi, 0xb8(%rsp)
movq %rsi, 0xb0(%rsp)
movq 0xb8(%rsp), %rax
movq (%rax), %rax
movq %rax, 0xa8(%rsp)
movq 0xb0(%rsp), %rax
movq %rax, 0xa0(%rsp)
movq 0xa0(%rsp), %rax
movq %rax, 0x98(%rsp)
movl $0x0, 0x94(%rsp)
movl 0x94(%rsp), %eax
movq 0xa8(%rsp), %rcx
cmpl 0x48(%rcx), %eax
jge 0x746c
movq 0xa8(%rsp), %rax
addq $0x50, %rax
movslq 0x94(%rsp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq %rax, 0x88(%rsp)
movq 0x88(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x80(%rsp)
movq 0x88(%rsp), %rax
movq (%rax), %rax
movq 0x88(%rsp), %rcx
movslq 0x18(%rcx), %rcx
shlq $0x2, %rcx
addq %rcx, %rax
movq %rax, 0x78(%rsp)
movq 0x80(%rsp), %rax
cmpq 0x78(%rsp), %rax
je 0x7454
movq 0xa8(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x80(%rsp), %rcx
movq %rcx, %rdx
addq $0x4, %rdx
movq %rdx, 0x80(%rsp)
movslq (%rcx), %rcx
addq %rcx, %rax
movq %rax, 0x70(%rsp)
movq $0x0, 0x68(%rsp)
movq 0x70(%rsp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, 0x70(%rsp)
movzbl (%rax), %eax
movl %eax, 0x64(%rsp)
cmpl $0xe9, 0x64(%rsp)
jl 0x6c4c
cmpl $0xfa, 0x64(%rsp)
jg 0x6c4c
movq 0x80(%rsp), %rax
movq %rax, %rcx
addq $0x4, %rcx
movq %rcx, 0x80(%rsp)
movl (%rax), %eax
movl %eax, 0x24(%rsp)
jmp 0x6c54
xorl %eax, %eax
movl %eax, 0x24(%rsp)
jmp 0x6c54
movl 0x24(%rsp), %eax
movl %eax, 0x60(%rsp)
movl 0x64(%rsp), %eax
addl $0xffffff17, %eax       # imm = 0xFFFFFF17
movl %eax, %ecx
movq %rcx, 0x18(%rsp)
subl $0x16, %eax
ja 0x7427
movq 0x18(%rsp), %rax
leaq 0x9447(%rip), %rcx      # 0x100c8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
cmpq $0x0, 0x68(%rsp)
jne 0x6c9f
movq 0x98(%rsp), %rax
movq %rax, 0x68(%rsp)
movq 0x68(%rsp), %rax
movq %rax, 0x58(%rsp)
movq 0x70(%rsp), %rax
movzbl (%rax), %eax
cmpl $0xef, %eax
je 0x6cd0
movq 0x70(%rsp), %rax
movzbl (%rax), %eax
cmpl $0xee, %eax
je 0x6cd0
movq $0x0, 0x68(%rsp)
cmpl $0x0, 0x60(%rsp)
jne 0x6d1d
movq 0x58(%rsp), %rax
movzbl -0x1(%rax), %eax
andl $0x7, %eax
movl %eax, 0x54(%rsp)
cmpl $0x4, 0x54(%rsp)
jne 0x6cfd
movq 0x58(%rsp), %rax
movzbl (%rax), %eax
andl $0x7, %eax
movl %eax, 0x54(%rsp)
cmpl $0x5, 0x54(%rsp)
je 0x6d1b
movq 0x58(%rsp), %rax
movzbl -0x1(%rax), %ecx
subl $0x80, %ecx
movb %cl, -0x1(%rax)
jmp 0x744a
jmp 0x6d1d
movl 0x60(%rsp), %eax
addl $0x80, %eax
andl $0xffffff00, %eax       # imm = 0xFFFFFF00
cmpl $0x0, %eax
je 0x6d35
jmp 0x6dbd
movq 0x58(%rsp), %rax
movzbl -0x1(%rax), %ecx
subl $0x40, %ecx
movb %cl, -0x1(%rax)
jmp 0x6d46
jmp 0x6d48
movl 0x60(%rsp), %eax
movb %al, %cl
movq 0x98(%rsp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, 0x98(%rsp)
movb %cl, (%rax)
jmp 0x744a
movl 0x60(%rsp), %eax
addl $0x80, %eax
andl $0xffffff00, %eax       # imm = 0xFFFFFF00
cmpl $0x0, %eax
jne 0x6db0
jmp 0x6d81
cmpq $0x0, 0x68(%rsp)
jne 0x6d96
movq 0x98(%rsp), %rax
movq %rax, 0x68(%rsp)
movq 0x68(%rsp), %rax
movzbl -0x2(%rax), %ecx
addl $0x2, %ecx
movb %cl, -0x2(%rax)
movq $0x0, 0x68(%rsp)
jmp 0x6d48
movq $0x0, 0x68(%rsp)
jmp 0x6dbb
jmp 0x6dbd
jmp 0x6dbf
jmp 0x6dc1
movl 0x60(%rsp), %eax
movb %al, %cl
movq 0x98(%rsp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, 0x98(%rsp)
movb %cl, (%rax)
movl 0x60(%rsp), %eax
sarl $0x8, %eax
movb %al, %cl
movq 0x98(%rsp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, 0x98(%rsp)
movb %cl, (%rax)
jmp 0x6e04
movl 0x60(%rsp), %eax
sarl $0x10, %eax
movb %al, %cl
movq 0x98(%rsp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, 0x98(%rsp)
movb %cl, (%rax)
movl 0x60(%rsp), %eax
sarl $0x10, %eax
sarl $0x8, %eax
movb %al, %cl
movq 0x98(%rsp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, 0x98(%rsp)
movb %cl, (%rax)
jmp 0x6e4d
jmp 0x744a
movl 0x60(%rsp), %eax
addl $0x80, %eax
andl $0xffffff00, %eax       # imm = 0xFFFFFF00
cmpl $0x0, %eax
jne 0x6e6a
jmp 0x6d81
movq $0x0, 0x68(%rsp)
jmp 0x6e75
jmp 0x6e77
movl 0x60(%rsp), %eax
movb %al, %cl
movq 0x98(%rsp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, 0x98(%rsp)
movb %cl, (%rax)
movl 0x60(%rsp), %eax
sarl $0x8, %eax
movb %al, %cl
movq 0x98(%rsp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, 0x98(%rsp)
movb %cl, (%rax)
jmp 0x744a
movq 0x70(%rsp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, 0x70(%rsp)
movzbl (%rax), %eax
movl %eax, 0x50(%rsp)
movq 0x98(%rsp), %rax
movl 0x50(%rsp), %ecx
andl $0x7, %ecx
movslq %ecx, %rdx
xorl %ecx, %ecx
subq %rdx, %rcx
addq %rcx, %rax
movq %rax, 0x48(%rsp)
movl 0x60(%rsp), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x6f64
cmpl $0xa0, 0x50(%rsp)
jge 0x6f64
movq 0x48(%rsp), %rax
movzbl (%rax), %eax
andl $0x80, %eax
cmpl $0x0, %eax
je 0x6f3a
movl 0x50(%rsp), %ecx
sarl $0x6, %ecx
movl $0x20, %edx
shll %cl, %edx
movq 0x48(%rsp), %rax
movzbl 0x1(%rax), %ecx
xorl %edx, %ecx
movb %cl, 0x1(%rax)
jmp 0x6f54
movl 0x50(%rsp), %ecx
sarl $0x6, %ecx
movl $0x1, %edx
shll %cl, %edx
movq 0x48(%rsp), %rax
movzbl (%rax), %ecx
xorl %edx, %ecx
movb %cl, (%rax)
movl 0x60(%rsp), %eax
andl $0x7, %eax
movl %eax, 0x60(%rsp)
jmp 0x7021
movl 0x60(%rsp), %eax
andl $0x10, %eax
cmpl $0x0, %eax
je 0x701f
movq 0x48(%rsp), %rax
movzbl (%rax), %eax
andl $0x80, %eax
cmpl $0x0, %eax
je 0x6fbf
movq 0x48(%rsp), %rax
movb $-0x3b, (%rax)
movq 0x48(%rsp), %rax
movzbl 0x1(%rax), %eax
andl $0x80, %eax
movq 0x48(%rsp), %rcx
movzbl 0x2(%rcx), %ecx
orl %ecx, %eax
movb %al, %cl
movq 0x48(%rsp), %rax
movb %cl, 0x1(%rax)
movq 0x48(%rsp), %rax
addq $0x2, %rax
movq %rax, 0x48(%rsp)
jmp 0x6fc1
movq 0x48(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x48(%rsp)
cmpq 0x98(%rsp), %rax
jae 0x6fea
movq 0x48(%rsp), %rax
movb (%rax), %cl
movq 0x48(%rsp), %rax
movb %cl, -0x1(%rax)
jmp 0x6fc1
cmpq $0x0, 0x68(%rsp)
je 0x7000
movq 0x68(%rsp), %rax
addq $-0x1, %rax
movq %rax, 0x68(%rsp)
movq 0x98(%rsp), %rax
addq $-0x1, %rax
movq %rax, 0x98(%rsp)
movl 0x60(%rsp), %eax
andl $0x7, %eax
movl %eax, 0x60(%rsp)
jmp 0x7021
cmpl $0xc0, 0x50(%rsp)
jl 0x7038
movl 0x60(%rsp), %eax
shll $0x4, %eax
movl %eax, 0x60(%rsp)
jmp 0x708d
cmpl $0x40, 0x50(%rsp)
jl 0x704c
movl 0x60(%rsp), %eax
shll $0x3, %eax
movl %eax, 0x60(%rsp)
jmp 0x708b
cmpl $0x4, 0x60(%rsp)
jne 0x7089
cmpl $0x20, 0x50(%rsp)
jge 0x7089
movl 0x60(%rsp), %edx
movq 0x98(%rsp), %rax
movzbl -0x1(%rax), %ecx
xorl %edx, %ecx
movb %cl, -0x1(%rax)
movq 0x98(%rsp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, 0x98(%rsp)
movb $0x20, (%rax)
jmp 0x708b
jmp 0x708d
movl 0x60(%rsp), %edx
movq 0x98(%rsp), %rax
movzbl -0x1(%rax), %ecx
xorl %edx, %ecx
movb %cl, -0x1(%rax)
jmp 0x744a
movq 0x70(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x70(%rsp)
cmpl $0x0, 0x60(%rsp)
jl 0x70be
jmp 0x7110
movq 0x80(%rsp), %rax
addq $0x4, %rax
movq %rax, 0x80(%rsp)
movq 0xa8(%rsp), %rax
movq 0x30(%rax), %rax
xorl %ecx, %ecx
subl 0x60(%rsp), %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movl %eax, 0x60(%rsp)
jmp 0x70f1
movq 0x98(%rsp), %rax
addq $0x4, %rax
movl %eax, %ecx
movl 0x60(%rsp), %eax
subl %ecx, %eax
movl %eax, 0x60(%rsp)
jmp 0x6dbd
jmp 0x7110
movq 0x80(%rsp), %rax
movq %rax, %rcx
addq $0x4, %rcx
movq %rcx, 0x80(%rsp)
movl (%rax), %eax
movl %eax, 0x44(%rsp)
movq 0xa8(%rsp), %rax
addq $0x50, %rax
movl 0x60(%rsp), %ecx
sarl $0x18, %ecx
movslq %ecx, %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rax
movslq 0x60(%rsp), %rcx
shlq $0x2, %rcx
addq %rcx, %rax
movq %rax, 0x38(%rsp)
movq 0x38(%rsp), %rax
cmpl $0x0, (%rax)
jge 0x7179
movq 0x38(%rsp), %rax
movl 0x4(%rax), %eax
movl %eax, 0x60(%rsp)
jmp 0x70f1
movq 0x38(%rsp), %rax
movl (%rax), %eax
movq 0x98(%rsp), %rcx
movq 0xa0(%rsp), %rdx
subq %rdx, %rcx
addl $0x4, %ecx
subl 0x44(%rsp), %ecx
subl %ecx, %eax
movl %eax, 0x60(%rsp)
cmpl $0x0, 0x44(%rsp)
jne 0x71ac
jmp 0x6dbd
cmpl $0x4, 0x44(%rsp)
jne 0x71e4
movq 0x98(%rsp), %rax
addq $-0x1, %rax
movq %rax, 0x98(%rsp)
movq 0x98(%rsp), %rax
movzbl (%rax), %eax
subl $0x10, %eax
movb %al, %cl
movq 0x98(%rsp), %rax
movb %cl, -0x1(%rax)
jmp 0x71f0
movq 0x98(%rsp), %rax
movb $-0x15, -0x1(%rax)
jmp 0x6d48
movq 0x70(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x70(%rsp)
cmpl $0x0, 0x60(%rsp)
jge 0x722c
movq 0xa8(%rsp), %rax
movq 0x30(%rax), %rax
xorl %ecx, %ecx
subl 0x60(%rsp), %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movl %eax, 0x60(%rsp)
jmp 0x6dbd
jmp 0x722e
movq 0xa8(%rsp), %rax
addq $0x50, %rax
movl 0x60(%rsp), %ecx
sarl $0x18, %ecx
movslq %ecx, %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rax
movslq 0x60(%rsp), %rcx
shlq $0x2, %rcx
addq %rcx, %rax
movq %rax, 0x30(%rsp)
movq 0x30(%rsp), %rax
cmpl $0x0, (%rax)
jge 0x7277
movq 0x30(%rsp), %rax
movl 0x4(%rax), %eax
movl %eax, 0x14(%rsp)
jmp 0x728c
movq 0x30(%rsp), %rax
movl (%rax), %eax
movq 0xa0(%rsp), %rcx
addl %ecx, %eax
movl %eax, 0x14(%rsp)
movl 0x14(%rsp), %eax
movl %eax, 0x60(%rsp)
jmp 0x6dbd
movq 0x70(%rsp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, 0x70(%rsp)
movzbl (%rax), %eax
movl %eax, 0x2c(%rsp)
cmpl $0xa, 0x2c(%rsp)
jl 0x730f
movq 0xa0(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x70(%rsp), %rax
movzbl (%rax), %eax
cmpl $0xf2, %eax
jne 0x72e4
movq 0x80(%rsp), %rax
movl (%rax), %eax
movl %eax, 0x4(%rsp)
jmp 0x72ec
movl 0x60(%rsp), %eax
movl %eax, 0x4(%rsp)
movq 0x8(%rsp), %rdx
movl 0x4(%rsp), %eax
cltq
addq %rax, %rdx
movq 0xa8(%rsp), %rax
movq 0x30(%rax), %rax
movslq 0x2c(%rsp), %rcx
movq %rdx, (%rax,%rcx,8)
jmp 0x744a
jmp 0x744a
movq 0x70(%rsp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, 0x70(%rsp)
movzbl (%rax), %eax
movl %eax, 0x28(%rsp)
movl 0x60(%rsp), %eax
movl %eax, %ecx
addl $-0x1, %ecx
movl %ecx, 0x60(%rsp)
cmpl $0x0, %eax
je 0x7364
movl 0x28(%rsp), %eax
movb %al, %cl
movq 0x98(%rsp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, 0x98(%rsp)
movb %cl, (%rax)
jmp 0x7331
jmp 0x744a
movq 0x70(%rsp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, 0x70(%rsp)
movzbl (%rax), %eax
movl %eax, 0x60(%rsp)
movq 0x98(%rsp), %rax
movq 0xa0(%rsp), %rcx
subq %rcx, %rax
movslq 0x60(%rsp), %rcx
andq %rcx, %rax
cmpq $0x0, %rax
je 0x73be
movq 0x98(%rsp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, 0x98(%rsp)
movb $-0x70, (%rax)
jmp 0x7381
jmp 0x744a
movq 0xb8(%rsp), %rdi
movq 0x98(%rsp), %rsi
movq 0x70(%rsp), %rax
movzbl 0x1(%rax), %edx
movq 0x70(%rsp), %rax
movzbl (%rax), %ecx
callq 0x74c0
movl %eax, 0x60(%rsp)
movq 0x70(%rsp), %rax
addq $0x2, %rax
movq %rax, 0x70(%rsp)
jmp 0x6dbd
movq 0x98(%rsp), %rax
movq %rax, 0x68(%rsp)
jmp 0x744a
movq 0x70(%rsp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, 0x70(%rsp)
movzbl (%rax), %eax
movl %eax, 0x64(%rsp)
movl 0x64(%rsp), %eax
movb %al, %cl
movq 0x98(%rsp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, 0x98(%rsp)
movb %cl, (%rax)
jmp 0x744a
jmp 0x744f
jmp 0x6c01
jmp 0x6bb7
jmp 0x7456
movl 0x94(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x94(%rsp)
jmp 0x6b45
movq 0xa0(%rsp), %rax
movq 0xa8(%rsp), %rcx
addq 0x40(%rcx), %rax
cmpq 0x98(%rsp), %rax
je 0x7497
movl $0x2000000, 0xc4(%rsp) # imm = 0x2000000
jmp 0x74a2
movl $0x0, 0xc4(%rsp)
movl 0xc4(%rsp), %eax
addq $0xc8, %rsp
retq
nopw %cs:(%rax,%rax)