// File: /workspace/github_c_makefile_star2_O0/mmcco[P]sljit/sljit_src/sljitNativeX86_common.c
// Function: emit_clz
static int emit_clz(struct sljit_compiler *compiler, int op_flags,
	int dst, long dstw,
	int src, long srcw)
{
	u_char* inst;
	int dst_r;

	(void)op_flags;
	if (dst == SLJIT_UNUSED) {
		/* Just set the zero flag. */
		EMIT_MOV(compiler, TMP_REG1, 0, src, srcw);
		inst = emit_x86_instruction(compiler, 1, 0, 0, TMP_REG1, 0);
		FAIL_IF(!inst);
		*inst++ = GROUP_F7;
		*inst |= NOT_rm;
#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
		inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, SLJIT_IMM, 31, TMP_REG1, 0);
#else
		inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, SLJIT_IMM, !(op_flags & SLJIT_INT_OP) ? 63 : 31, TMP_REG1, 0);
#endif
		FAIL_IF(!inst);
		*inst |= SHR;
		return SLJIT_SUCCESS;
	}

	if (src & SLJIT_IMM) {
		EMIT_MOV(compiler, TMP_REG1, 0, SLJIT_IMM, srcw);
		src = TMP_REG1;
		srcw = 0;
	}

	inst = emit_x86_instruction(compiler, 2, TMP_REG1, 0, src, srcw);
	FAIL_IF(!inst);
	*inst++ = GROUP_0F;
	*inst = BSR_r_rm;

#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
	if (FAST_IS_REG(dst))
		dst_r = dst;
	else {
		/* Find an unused temporary reg. */
		if ((dst & REG_MASK) != SLJIT_R0 && (dst & OFFS_REG_MASK) != TO_OFFS_REG(SLJIT_R0))
			dst_r = SLJIT_R0;
		else if ((dst & REG_MASK) != SLJIT_R1 && (dst & OFFS_REG_MASK) != TO_OFFS_REG(SLJIT_R1))
			dst_r = SLJIT_R1;
		else
			dst_r = SLJIT_R2;
		EMIT_MOV(compiler, dst, dstw, dst_r, 0);
	}
	EMIT_MOV(compiler, dst_r, 0, SLJIT_IMM, 32 + 31);
#else
	dst_r = FAST_IS_REG(dst) ? dst : TMP_REG2;
	compiler->mode32 = 0;
	EMIT_MOV(compiler, dst_r, 0, SLJIT_IMM, !(op_flags & SLJIT_INT_OP) ? 64 + 63 : 32 + 31);
	compiler->mode32 = op_flags & SLJIT_INT_OP;
#endif

	if (cpu_has_cmov == -1)
		get_cpu_features();

	if (cpu_has_cmov) {
		inst = emit_x86_instruction(compiler, 2, dst_r, 0, TMP_REG1, 0);
		FAIL_IF(!inst);
		*inst++ = GROUP_0F;
		*inst = CMOVNE_r_rm;
	} else {
#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
		inst = ensure_buf(compiler, 1 + 4);
		FAIL_IF(!inst);
		INC_SIZE(4);

		*inst++ = JE_i8;
		*inst++ = 2;
		*inst++ = MOV_r_rm;
		*inst++ = MOD_REG | (reg_map[dst_r] << 3) | reg_map[TMP_REG1];
#else
		inst = ensure_buf(compiler, 1 + 5);
		FAIL_IF(!inst);
		INC_SIZE(5);

		*inst++ = JE_i8;
		*inst++ = 3;
		*inst++ = REX_W | (reg_map[dst_r] >= 8 ? REX_R : 0) | (reg_map[TMP_REG1] >= 8 ? REX_B : 0);
		*inst++ = MOV_r_rm;
		*inst++ = MOD_REG | (reg_lmap[dst_r] << 3) | reg_lmap[TMP_REG1];
#endif
	}

#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
	inst = emit_x86_instruction(compiler, 1 | EX86_BIN_INS, SLJIT_IMM, 31, dst_r, 0);
#else
	inst = emit_x86_instruction(compiler, 1 | EX86_BIN_INS, SLJIT_IMM, !(op_flags & SLJIT_INT_OP) ? 63 : 31, dst_r, 0);
#endif
	FAIL_IF(!inst);
	*(inst + 1) |= XOR;

#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
	if (dst & SLJIT_MEM) {
		inst = emit_x86_instruction(compiler, 1, dst_r, 0, dst, dstw);
		FAIL_IF(!inst);
		*inst = XCHG_r_rm;
	}
#else
	if (dst & SLJIT_MEM)
		EMIT_MOV(compiler, dst, dstw, TMP_REG2, 0);
#endif
	return SLJIT_SUCCESS;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movl %r8d, -0x24(%rbp)
movq %r9, -0x30(%rbp)
cmpl $0x0, -0x18(%rbp)
jne 0x1f594
jmp 0x1f49a
movq -0x10(%rbp), %rdi
movl -0x24(%rbp), %ecx
movq -0x30(%rbp), %r8
movl $0xe, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x1d0a0
cmpl $0x0, %eax
je 0x1f4c6
movq -0x10(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x4(%rbp)
jmp 0x1f8bc
jmp 0x1f4c8
movq -0x10(%rbp), %rdi
movl $0x1, %esi
xorl %edx, %edx
xorl %eax, %eax
movl %eax, %r9d
movl $0xe, %r8d
movq %r9, %rcx
callq 0x1b8f0
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0x1f4ff
movq -0x10(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x4(%rbp)
jmp 0x1f8bc
jmp 0x1f501
movq -0x38(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x38(%rbp)
movb $-0x9, (%rax)
movq -0x38(%rbp), %rax
movzbl (%rax), %ecx
orl $0x10, %ecx
movb %cl, (%rax)
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %eax
andl $0x100, %eax            # imm = 0x100
cmpl $0x0, %eax
setne %dl
xorb $-0x1, %dl
movl $0x1f, %eax
movl $0x3f, %ecx
testb $0x1, %dl
cmovnel %ecx, %eax
movslq %eax, %rcx
movl $0x21, %esi
movl $0x40, %edx
movl $0xe, %r8d
xorl %eax, %eax
movl %eax, %r9d
callq 0x1b8f0
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0x1f57a
movq -0x10(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x4(%rbp)
jmp 0x1f8bc
jmp 0x1f57c
movq -0x38(%rbp), %rax
movzbl (%rax), %ecx
orl $0x28, %ecx
movb %cl, (%rax)
movl $0x0, -0x4(%rbp)
jmp 0x1f8bc
movl -0x24(%rbp), %eax
andl $0x40, %eax
cmpl $0x0, %eax
je 0x1f5e0
jmp 0x1f5a1
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %r8
movl $0xe, %esi
xorl %eax, %eax
movl %eax, %edx
movl $0x40, %ecx
callq 0x1d0a0
cmpl $0x0, %eax
je 0x1f5cf
movq -0x10(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x4(%rbp)
jmp 0x1f8bc
jmp 0x1f5d1
movl $0xe, -0x24(%rbp)
movq $0x0, -0x30(%rbp)
movq -0x10(%rbp), %rdi
movl -0x24(%rbp), %r8d
movq -0x30(%rbp), %r9
movl $0x2, %esi
movl $0xe, %edx
xorl %eax, %eax
movl %eax, %ecx
callq 0x1b8f0
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0x1f618
movq -0x10(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x4(%rbp)
jmp 0x1f8bc
jmp 0x1f61a
movq -0x38(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x38(%rbp)
movb $0xf, (%rax)
movq -0x38(%rbp), %rax
movb $-0x43, (%rax)
cmpl $0x3f, -0x18(%rbp)
jg 0x1f641
movl -0x18(%rbp), %eax
movl %eax, -0x40(%rbp)
jmp 0x1f64b
movl $0xf, %eax
movl %eax, -0x40(%rbp)
jmp 0x1f64b
movl -0x40(%rbp), %eax
movl %eax, -0x3c(%rbp)
movq -0x10(%rbp), %rax
movl $0x0, 0x70(%rax)
movq -0x10(%rbp), %rdi
movl -0x3c(%rbp), %esi
movl -0x14(%rbp), %eax
andl $0x100, %eax            # imm = 0x100
cmpl $0x0, %eax
setne %dl
xorb $-0x1, %dl
movl $0x3f, %eax
movl $0x7f, %ecx
testb $0x1, %dl
cmovnel %ecx, %eax
movslq %eax, %r8
xorl %eax, %eax
movl %eax, %edx
movl $0x40, %ecx
callq 0x1d0a0
cmpl $0x0, %eax
je 0x1f6a8
movq -0x10(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x4(%rbp)
jmp 0x1f8bc
jmp 0x1f6aa
movl -0x14(%rbp), %ecx
andl $0x100, %ecx            # imm = 0x100
movq -0x10(%rbp), %rax
movl %ecx, 0x70(%rax)
cmpl $-0x1, 0x14acf(%rip)    # 0x34190
jne 0x1f6c8
callq 0x2c470
cmpl $0x0, 0x14ac1(%rip)     # 0x34190
je 0x1f729
movq -0x10(%rbp), %rdi
movl -0x3c(%rbp), %edx
movl $0x2, %esi
xorl %eax, %eax
movl %eax, %r9d
movl $0xe, %r8d
movq %r9, %rcx
callq 0x1b8f0
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0x1f709
movq -0x10(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x4(%rbp)
jmp 0x1f8bc
jmp 0x1f70b
movq -0x38(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x38(%rbp)
movb $0xf, (%rax)
movq -0x38(%rbp), %rax
movb $0x45, (%rax)
jmp 0x1f812
movq -0x10(%rbp), %rdi
movl $0x6, %esi
callq 0x1a330
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0x1f750
movq -0x10(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x4(%rbp)
jmp 0x1f8bc
jmp 0x1f752
movq -0x38(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x38(%rbp)
movb $0x5, (%rax)
movq -0x10(%rbp), %rax
movq 0x60(%rax), %rcx
addq $0x5, %rcx
movq %rcx, 0x60(%rax)
movq -0x38(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x38(%rbp)
movb $0x74, (%rax)
movq -0x38(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x38(%rbp)
movb $0x3, (%rax)
movslq -0x3c(%rbp), %rcx
leaq 0x10fbd(%rip), %rax     # 0x30760
movzbl (%rax,%rcx), %edx
xorl %eax, %eax
movl $0x44, %ecx
cmpl $0x8, %edx
cmovgel %ecx, %eax
orl $0x48, %eax
orl $0x0, %eax
movb %al, %cl
movq -0x38(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x38(%rbp)
movb %cl, (%rax)
movq -0x38(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x38(%rbp)
movb $-0x75, (%rax)
movslq -0x3c(%rbp), %rcx
leaq 0x10f96(%rip), %rax     # 0x30780
movzbl (%rax,%rcx), %eax
shll $0x3, %eax
orl $0xc0, %eax
movzbl 0x10f91(%rip), %ecx     # 0x3078e
orl %ecx, %eax
movb %al, %cl
movq -0x38(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x38(%rbp)
movb %cl, (%rax)
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %eax
andl $0x100, %eax            # imm = 0x100
cmpl $0x0, %eax
setne %dl
xorb $-0x1, %dl
movl $0x1f, %eax
movl $0x3f, %ecx
testb $0x1, %dl
cmovnel %ecx, %eax
movslq %eax, %rcx
movl -0x3c(%rbp), %r8d
movl $0x11, %esi
movl $0x40, %edx
xorl %eax, %eax
movl %eax, %r9d
callq 0x1b8f0
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0x1f868
movq -0x10(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x4(%rbp)
jmp 0x1f8bc
jmp 0x1f86a
movq -0x38(%rbp), %rax
movzbl 0x1(%rax), %ecx
orl $0x30, %ecx
movb %cl, 0x1(%rax)
movl -0x18(%rbp), %eax
andl $0x80, %eax
cmpl $0x0, %eax
je 0x1f8b5
jmp 0x1f887
movq -0x10(%rbp), %rdi
movl -0x18(%rbp), %esi
movq -0x20(%rbp), %rdx
movl $0xf, %ecx
xorl %eax, %eax
movl %eax, %r8d
callq 0x1d0a0
cmpl $0x0, %eax
je 0x1f8b1
movq -0x10(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x4(%rbp)
jmp 0x1f8bc
jmp 0x1f8b3
jmp 0x1f8b5
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)