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

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

	word |= instr->ccode << 28;
	word |= 0x4 << 25;

	m_type = instr->type;
	if (type == SUBTILIS_ARM_INSTR_STM) {
		switch (m_type) {
		case SUBTILIS_ARM_MTRAN_FA:
			m_type = SUBTILIS_ARM_MTRAN_IB;
			break;
		case SUBTILIS_ARM_MTRAN_FD:
			m_type = SUBTILIS_ARM_MTRAN_DB;
			break;
		case SUBTILIS_ARM_MTRAN_EA:
			m_type = SUBTILIS_ARM_MTRAN_IA;
			break;
		case SUBTILIS_ARM_MTRAN_ED:
			m_type = SUBTILIS_ARM_MTRAN_DA;
			break;
		default:
			break;
		}
	} else {
		switch (m_type) {
		case SUBTILIS_ARM_MTRAN_FA:
			m_type = SUBTILIS_ARM_MTRAN_DA;
			break;
		case SUBTILIS_ARM_MTRAN_FD:
			m_type = SUBTILIS_ARM_MTRAN_IA;
			break;
		case SUBTILIS_ARM_MTRAN_EA:
			m_type = SUBTILIS_ARM_MTRAN_DB;
			break;
		case SUBTILIS_ARM_MTRAN_ED:
			m_type = SUBTILIS_ARM_MTRAN_IB;
			break;
		default:
			break;
		}
	}

	switch (m_type) {
	case SUBTILIS_ARM_MTRAN_IA:
		word |= 1 << 23;
		break;
	case SUBTILIS_ARM_MTRAN_IB:
		word |= 1 << 23;
		word |= 1 << 24;
		break;
	case SUBTILIS_ARM_MTRAN_DA:
		break;
	case SUBTILIS_ARM_MTRAN_DB:
		word |= 1 << 24;
		break;
	default:
		break;
	}

	if (instr->write_back)
		word |= 1 << 21;

	if (instr->status)
		word |= 1 << 22;

	if (type == SUBTILIS_ARM_INSTR_LDM)
		word |= 1 << 20;

	word |= instr->op0 << 16;
	word |= instr->reg_list & 0xffff;

	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)
movl $0x0, -0x34(%rbp)
movq -0x30(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x819a0
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x7ed35
jmp 0x7eee0
movq -0x20(%rbp), %rax
movl (%rax), %eax
shll $0x1c, %eax
orl -0x34(%rbp), %eax
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %eax
orl $0x8000000, %eax        # imm = 0x8000000
movl %eax, -0x34(%rbp)
movq -0x20(%rbp), %rax
movl 0x18(%rax), %eax
movl %eax, -0x38(%rbp)
cmpl $0x15, -0x14(%rbp)
jne 0x7edac
movl -0x38(%rbp), %eax
addl $-0x4, %eax
movl %eax, %ecx
movq %rcx, -0x40(%rbp)
subl $0x3, %eax
ja 0x7eda8
movq -0x40(%rbp), %rax
leaq 0x2de85(%rip), %rcx     # 0xacc00
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x1, -0x38(%rbp)
jmp 0x7edaa
movl $0x3, -0x38(%rbp)
jmp 0x7edaa
movl $0x0, -0x38(%rbp)
jmp 0x7edaa
movl $0x2, -0x38(%rbp)
jmp 0x7edaa
jmp 0x7edaa
jmp 0x7edf9
movl -0x38(%rbp), %eax
addl $-0x4, %eax
movl %eax, %ecx
movq %rcx, -0x48(%rbp)
subl $0x3, %eax
ja 0x7edf5
movq -0x48(%rbp), %rax
leaq 0x2de28(%rip), %rcx     # 0xacbf0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x2, -0x38(%rbp)
jmp 0x7edf7
movl $0x0, -0x38(%rbp)
jmp 0x7edf7
movl $0x3, -0x38(%rbp)
jmp 0x7edf7
movl $0x1, -0x38(%rbp)
jmp 0x7edf7
jmp 0x7edf7
jmp 0x7edf9
movl -0x38(%rbp), %eax
movq %rax, -0x50(%rbp)
subq $0x3, %rax
ja 0x7ee4e
movq -0x50(%rbp), %rax
leaq 0x2ddff(%rip), %rcx     # 0xacc10
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl -0x34(%rbp), %eax
orl $0x800000, %eax         # imm = 0x800000
movl %eax, -0x34(%rbp)
jmp 0x7ee50
movl -0x34(%rbp), %eax
orl $0x800000, %eax         # imm = 0x800000
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %eax
orl $0x1000000, %eax        # imm = 0x1000000
movl %eax, -0x34(%rbp)
jmp 0x7ee50
jmp 0x7ee50
movl -0x34(%rbp), %eax
orl $0x1000000, %eax        # imm = 0x1000000
movl %eax, -0x34(%rbp)
jmp 0x7ee50
jmp 0x7ee50
movq -0x20(%rbp), %rax
testb $0x1, 0x1c(%rax)
je 0x7ee65
movl -0x34(%rbp), %eax
orl $0x200000, %eax         # imm = 0x200000
movl %eax, -0x34(%rbp)
movq -0x20(%rbp), %rax
testb $0x1, 0x1d(%rax)
je 0x7ee7a
movl -0x34(%rbp), %eax
orl $0x400000, %eax         # imm = 0x400000
movl %eax, -0x34(%rbp)
cmpl $0x14, -0x14(%rbp)
jne 0x7ee8b
movl -0x34(%rbp), %eax
orl $0x100000, %eax         # imm = 0x100000
movl %eax, -0x34(%rbp)
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rcx
shlq $0x10, %rcx
movl -0x34(%rbp), %eax
orq %rcx, %rax
movl %eax, -0x34(%rbp)
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rcx
andq $0xffff, %rcx           # imm = 0xFFFF
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 0x7eed0
jmp 0x7eee0
movq -0x30(%rbp), %rdi
movl -0x34(%rbp), %esi
movq -0x28(%rbp), %rdx
callq 0x81bc0
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)