// File: /workspace/github_c_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %r8, %rbx
movq %rcx, %r15
movl %edx, %ebp
movq %rdi, %r14
xorl %esi, %esi
movq %r8, %rdx
callq 0x59d65
cmpl $0x0, (%rbx)
je 0x5959f
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq 0x10(%r15), %rax
cmpq $0xf, %rax
ja 0x595b3
movq 0x8(%r15), %r12
cmpq $0x10, %r12
jb 0x595d4
leaq 0x1c886(%rip), %rdx     # 0x75e40
movq %rbx, %rdi
movl $0xf, %esi
movl $0x859, %ecx            # imm = 0x859
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x145f4
movl (%r15), %ecx
movl 0x4(%r15), %edx
shll $0x1c, %edx
movzbl 0x28(%r15), %esi
shll $0x18, %esi
orl %edx, %esi
movzbl 0x29(%r15), %edx
shll $0x15, %edx
orl %esi, %edx
movzbl 0x2a(%r15), %esi
xorl $0x1, %esi
shll $0x17, %esi
orl %edx, %esi
shll $0x10, %eax
shll $0xc, %r12d
orl %eax, %r12d
orl %esi, %r12d
orl $0x90, %r12d
cmpq $0x3, %rcx
ja 0x5967d
leaq 0x1c700(%rip), %rax     # 0x75d20
movslq (%rax,%rcx,4), %rcx
addq %rax, %rcx
jmpq *%rcx
xorl %eax, %eax
cmpl $0x83, %ebp
sete %al
shll $0x14, %eax
jmp 0x5965e
movl %r12d, %eax
orl $0x100000, %eax         # imm = 0x100000
cmpl $0x83, %ebp
cmovnel %r12d, %eax
orl $0x20, %eax
jmp 0x5967a
xorl %eax, %eax
cmpl $0x84, %ebp
sete %al
shll $0x5, %eax
orl %r12d, %eax
orl $0x40, %eax
jmp 0x5967a
xorl %eax, %eax
cmpl $0x83, %ebp
sete %al
shll $0x14, %eax
orl %r12d, %eax
orl $0x60, %eax
movl %eax, %r12d
cmpb $0x1, 0x18(%r15)
jne 0x5968a
orl 0x20(%r15), %r12d
jmp 0x596a9
movsbl 0x20(%r15), %eax
movl %eax, %ecx
andl $0xf, %ecx
shll $0x8, %eax
andl $0xf000, %eax           # imm = 0xF000
orl %ecx, %eax
orl %r12d, %eax
orl $0x400000, %eax         # imm = 0x400000
movl %eax, %r12d
movl $0x4, %esi
movq %r14, %rdi
movq %rbx, %rdx
callq 0x57496
cmpl $0x0, (%rbx)
jne 0x59596
movq 0x30(%r14), %rax
testb $0x3, %al
je 0x596e3
leaq 0x1c76f(%rip), %rdx     # 0x75e40
movq %rbx, %rdi
movl $0x5d, %esi
movl $0xfb, %ecx
jmp 0x595c7
movq 0x28(%r14), %rcx
movl %r12d, (%rcx,%rax)
addq $0x4, %rax
movq %rax, 0x30(%r14)
jmp 0x59596