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

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

	if ((instr->base > 15) || (instr->dest > 15)) {
		subtilis_error_set_assertion_failed(err);
		return;
	}

	word |= instr->ccode << 28;
	if (instr->pre_indexed)
		word |= 1 << 24;

	if (instr->write_back)
		word |= 1 << 21;
	if (!instr->subtract)
		word |= 1 << 23;
	word |= instr->base << 16;
	word |= instr->dest << 12;

	switch (instr->type) {
	case SUBTILIS_ARM_STRAN_MISC_SB:
		word |= 1 << 6;
		if (type == SUBTILIS_ARM_STRAN_MISC_LDR)
			word |= 1 << 20;
		break;
	case SUBTILIS_ARM_STRAN_MISC_SH:
		word |= 1 << 6;
		word |= 1 << 5;
		if (type == SUBTILIS_ARM_STRAN_MISC_LDR)
			word |= 1 << 20;
		break;
	case SUBTILIS_ARM_STRAN_MISC_H:
		if (type == SUBTILIS_ARM_STRAN_MISC_LDR)
			word |= 1 << 20;
		word |= 1 << 5;
		break;
	case SUBTILIS_ARM_STRAN_MISC_D:
		word |= 1 << 6;
		if (type == SUBTILIS_ARM_STRAN_MISC_STR)
			word |= 1 << 5;
		break;
	}

	if (instr->reg_offset) {
		word |= instr->offset.reg;
	} else {
		word |= 1 << 22;
		word |= instr->offset.imm & 0xf;
		word |= (instr->offset.imm & 0xf0) << 8;
	}

	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 $0x40, %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)
movl $0x90, -0x34(%rbp)
movq -0x30(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x819a0
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x80f85
jmp 0x8114f
movq -0x20(%rbp), %rax
cmpq $0xf, 0x10(%rax)
ja 0x80f9b
movq -0x20(%rbp), %rax
cmpq $0xf, 0x8(%rax)
jbe 0x80fba
movq -0x28(%rbp), %rdi
movl $0xf, %esi
leaq 0x2be85(%rip), %rdx     # 0xace30
movl $0x859, %ecx            # imm = 0x859
callq 0x158e0
jmp 0x8114f
movq -0x20(%rbp), %rax
movl 0x4(%rax), %eax
shll $0x1c, %eax
orl -0x34(%rbp), %eax
movl %eax, -0x34(%rbp)
movq -0x20(%rbp), %rax
testb $0x1, 0x28(%rax)
je 0x80fdf
movl -0x34(%rbp), %eax
orl $0x1000000, %eax        # imm = 0x1000000
movl %eax, -0x34(%rbp)
movq -0x20(%rbp), %rax
testb $0x1, 0x29(%rax)
je 0x80ff4
movl -0x34(%rbp), %eax
orl $0x200000, %eax         # imm = 0x200000
movl %eax, -0x34(%rbp)
movq -0x20(%rbp), %rax
testb $0x1, 0x2a(%rax)
jne 0x81009
movl -0x34(%rbp), %eax
orl $0x800000, %eax         # imm = 0x800000
movl %eax, -0x34(%rbp)
movq -0x20(%rbp), %rax
movl 0x10(%rax), %ecx
shll $0x10, %ecx
movl -0x34(%rbp), %eax
orl %ecx, %eax
movl %eax, -0x34(%rbp)
movq -0x20(%rbp), %rax
movl 0x8(%rax), %ecx
shll $0xc, %ecx
movl -0x34(%rbp), %eax
orl %ecx, %eax
movl %eax, -0x34(%rbp)
movq -0x20(%rbp), %rax
movl (%rax), %eax
movq %rax, -0x40(%rbp)
subq $0x3, %rax
ja 0x810d8
movq -0x40(%rbp), %rax
leaq 0x2bca4(%rip), %rcx     # 0xaccf0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl -0x34(%rbp), %eax
orl $0x40, %eax
movl %eax, -0x34(%rbp)
cmpl $0x83, -0x14(%rbp)
jne 0x81072
movl -0x34(%rbp), %eax
orl $0x100000, %eax         # imm = 0x100000
movl %eax, -0x34(%rbp)
jmp 0x810d8
movl -0x34(%rbp), %eax
orl $0x40, %eax
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %eax
orl $0x20, %eax
movl %eax, -0x34(%rbp)
cmpl $0x83, -0x14(%rbp)
jne 0x8109a
movl -0x34(%rbp), %eax
orl $0x100000, %eax         # imm = 0x100000
movl %eax, -0x34(%rbp)
jmp 0x810d8
cmpl $0x83, -0x14(%rbp)
jne 0x810b0
movl -0x34(%rbp), %eax
orl $0x100000, %eax         # imm = 0x100000
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %eax
orl $0x20, %eax
movl %eax, -0x34(%rbp)
jmp 0x810d8
movl -0x34(%rbp), %eax
orl $0x40, %eax
movl %eax, -0x34(%rbp)
cmpl $0x84, -0x14(%rbp)
jne 0x810d6
movl -0x34(%rbp), %eax
orl $0x20, %eax
movl %eax, -0x34(%rbp)
jmp 0x810d8
movq -0x20(%rbp), %rax
testb $0x1, 0x18(%rax)
je 0x810f5
movq -0x20(%rbp), %rax
movq 0x20(%rax), %rcx
movl -0x34(%rbp), %eax
orq %rcx, %rax
movl %eax, -0x34(%rbp)
jmp 0x81127
movl -0x34(%rbp), %eax
orl $0x400000, %eax         # imm = 0x400000
movl %eax, -0x34(%rbp)
movq -0x20(%rbp), %rax
movsbl 0x20(%rax), %eax
andl $0xf, %eax
orl -0x34(%rbp), %eax
movl %eax, -0x34(%rbp)
movq -0x20(%rbp), %rax
movsbl 0x20(%rax), %eax
andl $0xf0, %eax
shll $0x8, %eax
orl -0x34(%rbp), %eax
movl %eax, -0x34(%rbp)
movq -0x30(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x81b90
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x8113f
jmp 0x8114f
movq -0x30(%rbp), %rdi
movl -0x34(%rbp), %esi
movq -0x28(%rbp), %rdx
callq 0x81bc0
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)