// File: /workspace/github_c_makefile_star2_O0/markdryan[P]subtilis/arch/arm32/arm_encode.c
// Function: prv_encode_signx_instr
static void prv_encode_signx_instr(void *user_data, subtilis_arm_op_t *op,
				   subtilis_arm_instr_type_t type,
				   subtilis_arm_signx_instr_t *instr,
				   subtilis_error_t *err)
{
	subtilis_arm_encode_ud_t *ud = user_data;
	uint32_t word;
	uint32_t ror;

	prv_check_pool(ud, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	switch (type) {
	case SUBTILIS_ARM_INSTR_SXTB:
		word = 0x6af0070;
		break;
	case SUBTILIS_ARM_INSTR_SXTB16:
		word = 0x68f0070;
		break;
	case SUBTILIS_ARM_INSTR_SXTH:
		word = 0x6bf0070;
		break;
	default:
		subtilis_error_set_assertion_failed(err);
		return;
	}

	switch (instr->rotate) {
	case SUBTILIS_ARM_SIGNX_ROR_NONE:
		ror = 0;
		break;
	case SUBTILIS_ARM_SIGNX_ROR_8:
		ror = 1;
		break;
	case SUBTILIS_ARM_SIGNX_ROR_16:
		ror = 2;
		break;
	case SUBTILIS_ARM_SIGNX_ROR_24:
		ror = 3;
		break;
	default:
		subtilis_error_set_assertion_failed(err);
		return;
	}

	word |= (ror << 10);
	word |= instr->ccode << 28;
	word |= (instr->dest & 0xf) << 12;
	word |= (instr->op1 & 0xf);

	prv_ensure_code(ud, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;
	prv_add_word(ud, word, err);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x819a0
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x812ce
jmp 0x81405
movl -0x14(%rbp), %eax
movl %eax, -0x3c(%rbp)
subl $0xa9, %eax
je 0x812f5
jmp 0x812dd
movl -0x3c(%rbp), %eax
subl $0xaa, %eax
je 0x812fe
jmp 0x812e9
movl -0x3c(%rbp), %eax
subl $0xab, %eax
je 0x81307
jmp 0x81310
movl $0x6af0070, -0x34(%rbp) # imm = 0x6AF0070
jmp 0x8132f
movl $0x68f0070, -0x34(%rbp) # imm = 0x68F0070
jmp 0x8132f
movl $0x6bf0070, -0x34(%rbp) # imm = 0x6BF0070
jmp 0x8132f
movq -0x28(%rbp), %rdi
movl $0xf, %esi
leaq 0x2bb10(%rip), %rdx     # 0xace30
movl $0x8ea, %ecx            # imm = 0x8EA
callq 0x158e0
jmp 0x81405
movq -0x20(%rbp), %rax
movl 0x4(%rax), %eax
movq %rax, -0x48(%rbp)
subq $0x3, %rax
ja 0x81378
movq -0x48(%rbp), %rax
leaq 0x2b9b5(%rip), %rcx     # 0xacd00
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x0, -0x38(%rbp)
jmp 0x81394
movl $0x1, -0x38(%rbp)
jmp 0x81394
movl $0x2, -0x38(%rbp)
jmp 0x81394
movl $0x3, -0x38(%rbp)
jmp 0x81394
movq -0x28(%rbp), %rdi
movl $0xf, %esi
leaq 0x2baa8(%rip), %rdx     # 0xace30
movl $0x8fc, %ecx            # imm = 0x8FC
callq 0x158e0
jmp 0x81405
movl -0x38(%rbp), %eax
shll $0xa, %eax
orl -0x34(%rbp), %eax
movl %eax, -0x34(%rbp)
movq -0x20(%rbp), %rax
movl (%rax), %eax
shll $0x1c, %eax
orl -0x34(%rbp), %eax
movl %eax, -0x34(%rbp)
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rcx
andq $0xf, %rcx
shlq $0xc, %rcx
movl -0x34(%rbp), %eax
orq %rcx, %rax
movl %eax, -0x34(%rbp)
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rcx
andq $0xf, %rcx
movl -0x34(%rbp), %eax
orq %rcx, %rax
movl %eax, -0x34(%rbp)
movq -0x30(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x81b90
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x813f5
jmp 0x81405
movq -0x30(%rbp), %rdi
movl -0x34(%rbp), %esi
movq -0x28(%rbp), %rdx
callq 0x81bc0
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax,%rax)