// File: /workspace/github_c_makefile_star2_O3/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 0x59e32
cmpl $0x0, (%rbx)
je 0x5966d
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq 0x10(%r15), %rax
cmpq $0xf, %rax
ja 0x59681
movq 0x8(%r15), %r12
cmpq $0x10, %r12
jb 0x596a2
leaq 0x1c7f8(%rip), %rdx     # 0x75e80
movq %rbx, %rdi
movl $0xf, %esi
movl $0x859, %ecx            # imm = 0x859
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x145a4
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 0x5974b
leaq 0x1c672(%rip), %rax     # 0x75d60
movslq (%rax,%rcx,4), %rcx
addq %rax, %rcx
jmpq *%rcx
xorl %eax, %eax
cmpl $0x83, %ebp
sete %al
shll $0x14, %eax
jmp 0x5972c
movl %r12d, %eax
orl $0x100000, %eax         # imm = 0x100000
cmpl $0x83, %ebp
cmovnel %r12d, %eax
orl $0x20, %eax
jmp 0x59748
xorl %eax, %eax
cmpl $0x84, %ebp
sete %al
shll $0x5, %eax
orl %r12d, %eax
orl $0x40, %eax
jmp 0x59748
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 0x59758
orl 0x20(%r15), %r12d
jmp 0x59777
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 0x5758f
cmpl $0x0, (%rbx)
jne 0x59664
movq 0x30(%r14), %rax
testb $0x3, %al
je 0x597b1
leaq 0x1c6e1(%rip), %rdx     # 0x75e80
movq %rbx, %rdi
movl $0x5d, %esi
movl $0xfb, %ecx
jmp 0x59695
movq 0x28(%r14), %rcx
movl %r12d, (%rcx,%rax)
addq $0x4, %rax
movq %rax, 0x30(%r14)
jmp 0x59664