// File: /workspace/github_c_makefile_star2_O2/mmcco[P]sljit/sljit_src/sljitNativeX86_common.c
// Function: sljit_generate_code
void* sljit_generate_code(struct sljit_compiler *compiler)
{
	struct sljit_memory_fragment *buf;
	u_char *code;
	u_char *code_ptr;
	u_char *buf_ptr;
	u_char *buf_end;
	u_char len;

	struct sljit_label *label;
	struct sljit_jump *jump;
	struct sljit_const *const_;

	CHECK_ERROR_PTR();
	CHECK_PTR(check_sljit_generate_code(compiler));
	reverse_buf(compiler);

	/* Second code generation pass. */
	code = (u_char*)SLJIT_MALLOC_EXEC(compiler->size);
	PTR_FAIL_WITH_EXEC_IF(code);
	buf = compiler->buf;

	code_ptr = code;
	label = compiler->labels;
	jump = compiler->jumps;
	const_ = compiler->consts;
	do {
		buf_ptr = buf->memory;
		buf_end = buf_ptr + buf->used_size;
		do {
			len = *buf_ptr++;
			if (len > 0) {
				/* The code is already generated. */
				memmove(code_ptr, buf_ptr, len);
				code_ptr += len;
				buf_ptr += len;
			}
			else {
				if (*buf_ptr >= 4) {
					jump->addr = (unsigned long)code_ptr;
					if (!(jump->flags & SLJIT_REWRITABLE_JUMP))
						code_ptr = generate_near_jump_code(jump, code_ptr, code, *buf_ptr - 4);
					else
						code_ptr = generate_far_jump_code(jump, code_ptr, *buf_ptr - 4);
					jump = jump->next;
				}
				else if (*buf_ptr == 0) {
					label->addr = (unsigned long)code_ptr;
					label->size = code_ptr - code;
					label = label->next;
				}
				else if (*buf_ptr == 1) {
					const_->addr = ((unsigned long)code_ptr) - sizeof(long);
					const_ = const_->next;
				}
				else {
#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
					*code_ptr++ = (*buf_ptr == 2) ? CALL_i32 : JMP_i32;
					buf_ptr++;
					*(long*)code_ptr = *(long*)buf_ptr - ((long)code_ptr + sizeof(long));
					code_ptr += sizeof(long);
					buf_ptr += sizeof(long) - 1;
#else
					code_ptr = generate_fixed_jump(code_ptr, *(long*)(buf_ptr + 1), *buf_ptr);
					buf_ptr += sizeof(long);
#endif
				}
				buf_ptr++;
			}
		} while (buf_ptr < buf_end);
		SLJIT_ASSERT(buf_ptr == buf_end);
		buf = buf->next;
	} while (buf);

	SLJIT_ASSERT(!label);
	SLJIT_ASSERT(!jump);
	SLJIT_ASSERT(!const_);

	jump = compiler->jumps;
	while (jump) {
		if (jump->flags & PATCH_MB) {
			SLJIT_ASSERT((long)(jump->u.label->addr - (jump->addr + sizeof(s_char))) >= -128 && (long)(jump->u.label->addr - (jump->addr + sizeof(s_char))) <= 127);
			*(u_char*)jump->addr = (u_char)(jump->u.label->addr - (jump->addr + sizeof(s_char)));
		} else if (jump->flags & PATCH_MW) {
			if (jump->flags & JUMP_LABEL) {
#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
				*(long*)jump->addr = (long)(jump->u.label->addr - (jump->addr + sizeof(long)));
#else
				SLJIT_ASSERT((long)(jump->u.label->addr - (jump->addr + sizeof(int))) >= HALFWORD_MIN && (long)(jump->u.label->addr - (jump->addr + sizeof(int))) <= HALFWORD_MAX);
				*(int*)jump->addr = (int)(jump->u.label->addr - (jump->addr + sizeof(int)));
#endif
			}
			else {
#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
				*(long*)jump->addr = (long)(jump->u.target - (jump->addr + sizeof(long)));
#else
				SLJIT_ASSERT((long)(jump->u.target - (jump->addr + sizeof(int))) >= HALFWORD_MIN && (long)(jump->u.target - (jump->addr + sizeof(int))) <= HALFWORD_MAX);
				*(int*)jump->addr = (int)(jump->u.target - (jump->addr + sizeof(int)));
#endif
			}
		}
#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
		else if (jump->flags & PATCH_MD)
			*(long*)jump->addr = jump->u.label->addr;
#endif

		jump = jump->next;
	}

	/* Maybe we waste some space because of short jumps. */
	SLJIT_ASSERT(code_ptr <= code + compiler->size);
	compiler->error = SLJIT_ERR_COMPILED;
	compiler->executable_size = code_ptr - code;
	return code;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
cmpl $0x0, (%rdi)
je 0x12d49
xorl %eax, %eax
jmp 0x130b5
movq %rdi, %rbx
movq 0x60(%rdi), %rdi
testq %rdi, %rdi
je 0x13107
leaq 0x10(%rbx), %r14
movq %r14, %rax
movq (%rax), %rax
testq %rax, %rax
je 0x12d7f
testb $0x3, 0x10(%rax)
jne 0x12d60
leaq 0xe58a(%rip), %rdi      # 0x212ff
movl $0x380, %esi            # imm = 0x380
jmp 0x1314b
movq 0x38(%rbx), %rax
xorl %ecx, %ecx
movq %rax, %rdx
movq (%rax), %rax
movq %rcx, (%rdx)
movq %rdx, %rcx
testq %rax, %rax
jne 0x12d85
movq %rdx, 0x38(%rbx)
callq 0x1283f
testq %rax, %rax
je 0x130c4
movq %r14, 0x20(%rsp)
movq 0x38(%rbx), %rdx
movq 0x8(%rbx), %rcx
movq %rcx, 0x10(%rsp)
movq %rax, %r15
movq 0x10(%rbx), %r12
movq %rbx, 0x28(%rsp)
movq 0x18(%rbx), %rax
movq %rax, 0x18(%rsp)
movq %r15, 0x8(%rsp)
leaq 0x10(%rdx), %rbx
movq %rdx, 0x30(%rsp)
movq 0x8(%rdx), %r14
addq %rbx, %r14
leaq 0x1(%rbx), %r13
movzbl (%rbx), %ebp
testq %rbp, %rbp
je 0x12e0c
movq %r15, %rdi
movq %r13, %rsi
movq %rbp, %rdx
callq 0x2110
addq %rbp, %r15
addq %rbp, %r13
movq %r13, %rbx
jmp 0x12eef
movzbl (%r13), %eax
cmpl $0x4, %eax
jb 0x12e40
movq %r15, 0x8(%r12)
movq 0x10(%r12), %rax
movzbl (%r13), %ecx
leal -0x4(%rcx), %edx
btl $0xc, %eax
jb 0x12ed4
testb $0x1, %al
jne 0x12eb3
movq 0x18(%r12), %rax
jmp 0x12ec1
cmpl $0x1, %eax
je 0x12e68
testl %eax, %eax
jne 0x12e7f
movq 0x10(%rsp), %rcx
movq %r15, 0x8(%rcx)
movq %r15, %rax
subq 0x8(%rsp), %rax
movq %rax, 0x10(%rcx)
movq (%rcx), %rcx
movq %rcx, 0x10(%rsp)
jmp 0x12ee6
leaq -0x8(%r15), %rax
movq 0x18(%rsp), %rcx
movq %rax, 0x8(%rcx)
movq (%rcx), %rcx
movq %rcx, 0x18(%rsp)
jmp 0x12ee6
movq 0x2(%rbx), %rdx
movq %rdx, %rcx
subq %r15, %rcx
leaq 0x7ffffffb(%rcx), %rsi
shrq $0x20, %rsi
jne 0x12f2c
addq $-0x5, %rcx
cmpl $0x2, %eax
sete %al
xorb $-0x17, %al
leaq 0x1(%r15), %rdx
movq %rcx, 0x1(%r15)
jmp 0x12f51
movq 0x18(%r12), %rax
movq 0x10(%rax), %rax
addq 0x8(%rsp), %rax
movq %r15, %rsi
subq %rax, %rsi
subq $-0x80000000, %rsi      # imm = 0x80000000
shrq $0x20, %rsi
je 0x12efd
movq %r12, %rdi
movq %r15, %rsi
callq 0x13157
movq %rax, %r15
movq (%r12), %r12
pushq $0x1
popq %rax
addq %rax, %rbx
incq %rbx
cmpq %r14, %rbx
jb 0x12de4
jmp 0x12fb9
subq %r15, %rax
addq $0x7e, %rax
cmpl $0x16, %edx
jne 0x12f5b
cmpq $0x100, %rax            # imm = 0x100
setb %cl
addb %cl, %cl
orb $-0x17, %cl
movb %cl, (%r15)
incq 0x8(%r12)
pushq $0x1
popq %rcx
cmpq $0xff, %rax
jbe 0x12f81
jmp 0x12fa7
movb $-0x47, 0x1(%r15)
movq %rdx, 0x2(%r15)
movw $0xff41, 0xa(%r15)      # imm = 0xFF41
cmpl $0x2, %eax
setne %al
shlb $0x4, %al
addb $-0x2f, %al
leaq 0xd(%r15), %rdx
movb %al, 0xc(%r15)
movb $0x49, %al
movb %al, (%r15)
movq %rdx, %r15
pushq $0x9
jmp 0x12ee8
cmpb $0x1b, %cl
jb 0x12f68
movb $-0x18, (%r15)
pushq $0x1
jmp 0x12fa1
cmpq $0xff, %rax
ja 0x12f90
movl %edx, %edi
callq 0x1b935
addb $-0x10, %al
movb %al, (%r15)
incq 0x8(%r12)
orb $0x4, 0x10(%r12)
addq $0x2, %r15
jmp 0x12ee2
movb $0xf, (%r15)
movl %edx, %edi
callq 0x1b935
movb %al, 0x1(%r15)
pushq $0x2
popq %rcx
addq %rcx, 0x8(%r12)
orb $0x8, 0x10(%r12)
addq %rcx, %r15
addq $0x4, %r15
jmp 0x12ee2
jne 0x130cf
movq 0x30(%rsp), %rdx
movq (%rdx), %rdx
testq %rdx, %rdx
jne 0x12dd4
cmpq $0x0, 0x10(%rsp)
jne 0x13115
testq %r12, %r12
movq 0x28(%rsp), %rsi
jne 0x13123
cmpq $0x0, 0x18(%rsp)
movq 0x20(%rsp), %rdi
movq 0x8(%rsp), %rax
jne 0x13131
movq (%rdi), %rdi
testq %rdi, %rdi
je 0x13098
movq 0x10(%rdi), %rcx
testb $0x4, %cl
jne 0x13030
testb $0x8, %cl
jne 0x13054
testb $0x10, %cl
je 0x13000
movq 0x8(%rdi), %rdx
movq 0x18(%rdi), %rcx
movq 0x8(%rcx), %rcx
movq %rcx, (%rdx)
jmp 0x13000
movq 0x8(%rdi), %r8
movq 0x18(%rdi), %rdx
movq %r8, %rcx
notq %rcx
addq 0x8(%rdx), %rcx
movsbq %cl, %rdx
cmpq %rcx, %rdx
jne 0x130dd
movb %cl, (%r8)
jmp 0x13000
testb $0x1, %cl
jne 0x13075
movq 0x8(%rdi), %r8
movq 0x18(%rdi), %rcx
subq %r8, %rcx
addq $-0x4, %rcx
movslq %ecx, %rdx
cmpq %rcx, %rdx
je 0x13090
jmp 0x130f9
movq 0x8(%rdi), %r8
movq 0x18(%rdi), %rcx
movq 0x8(%rcx), %rcx
subq %r8, %rcx
addq $-0x4, %rcx
movslq %ecx, %rdx
cmpq %rcx, %rdx
jne 0x130eb
movl %ecx, (%r8)
jmp 0x13000
movq 0x60(%rsi), %rcx
addq %rax, %rcx
cmpq %rcx, %r15
ja 0x1313f
movl $0x1, (%rsi)
subq %rax, %r15
movq %r15, 0x68(%rsi)
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x3, (%rbx)
jmp 0x12d42
leaq 0xe1b9(%rip), %rdi      # 0x2128f
movl $0x204, %esi            # imm = 0x204
jmp 0x1314b
leaq 0xe1ab(%rip), %rdi      # 0x2128f
movl $0x20f, %esi            # imm = 0x20F
jmp 0x1314b
leaq 0xe19d(%rip), %rdi      # 0x2128f
movl $0x216, %esi            # imm = 0x216
jmp 0x1314b
leaq 0xe18f(%rip), %rdi      # 0x2128f
movl $0x21e, %esi            # imm = 0x21E
jmp 0x1314b
leaq 0xe1f1(%rip), %rdi      # 0x212ff
movl $0x37c, %esi            # imm = 0x37C
jmp 0x1314b
leaq 0xe173(%rip), %rdi      # 0x2128f
movl $0x208, %esi            # imm = 0x208
jmp 0x1314b
leaq 0xe165(%rip), %rdi      # 0x2128f
movl $0x209, %esi            # imm = 0x209
jmp 0x1314b
leaq 0xe157(%rip), %rdi      # 0x2128f
movl $0x20a, %esi            # imm = 0x20A
jmp 0x1314b
leaq 0xe149(%rip), %rdi      # 0x2128f
movl $0x22c, %esi            # imm = 0x22C
xorl %eax, %eax
callq 0x2080
callq 0x2040