// File: /workspace/github_c_makefile_star2_O3/markdryan[P]subtilis/arch/arm32/arm_encode.c
// Function: prv_encode_simd_instr
static void prv_encode_simd_instr(void *user_data, subtilis_arm_op_t *op,
				  subtilis_arm_instr_type_t type,
				  subtilis_arm_reg_only_instr_t *instr,
				  subtilis_error_t *err)
{
	uint32_t word;
	subtilis_arm_encode_ud_t *ud = user_data;
	const uint32_t opcodes[] = {
	    0x06200010, // SUBTILIS_ARM_SIMD_QADD16
	    0x06200090, // SUBTILIS_ARM_SIMD_QADD8
	    0x06200030, // SUBTILIS_ARM_SIMD_QADDSUBX
	    0x06200070, // SUBTILIS_ARM_SIMD_QSUB16
	    0x062000f0, // SUBTILIS_ARM_SIMD_QSUB8
	    0x06200050, // SUBTILIS_ARM_SIMD_QSUBADDX,
	    0x06100010, // SUBTILIS_ARM_SIMD_SADD16
	    0x06100090, // SUBTILIS_ARM_SIMD_SADD8
	    0x06100030, // SUBTILIS_ARM_SIMD_SADDSUBX,
	    0x06100070, // SUBTILIS_ARM_SIMD_SSUB16
	    0x061000f0, // SUBTILIS_ARM_SIMD_SSUB8,
	    0x06100050, // SUBTILIS_ARM_SIMD_SSUBADDX
	    0x06300010, // SUBTILIS_ARM_SIMD_SHADD16
	    0x06300090, // SUBTILIS_ARM_SIMD_SHADD8
	    0x06300030, // SUBTILIS_ARM_SIMD_SHADDSUBX,
	    0x06300070, // SUBTILIS_ARM_SIMD_SHSUB16,
	    0x063000f0, // SUBTILIS_ARM_SIMD_SHSUB8,
	    0x06300050, // SUBTILIS_ARM_SIMD_SHSUBADDX,
	    0x06500010, // SUBTILIS_ARM_SIMD_UADD16,
	    0x06500090, // SUBTILIS_ARM_SIMD_UADD8,
	    0x06500030, // SUBTILIS_ARM_SIMD_UADDSUBX,
	    0x06500070, // SUBTILIS_ARM_SIMD_USUB16,
	    0x065000f0, // SUBTILIS_ARM_SIMD_USUB8,
	    0x06500050, // SUBTILIS_ARM_SIMD_USUBADDX,
	    0x06700010, // SUBTILIS_ARM_SIMD_UHADD16,
	    0x06700090, // SUBTILIS_ARM_SIMD_UHADD8,
	    0x06700030, // SUBTILIS_ARM_SIMD_UHADDSUBX,
	    0x06700070, // SUBTILIS_ARM_SIMD_UHSUB16,
	    0x067000f0, // SUBTILIS_ARM_SIMD_UHSUB8,
	    0x06700050, // SUBTILIS_ARM_SIMD_UHSUBADDX,
	    0x06600010, // SUBTILIS_ARM_SIMD_UQADD16,
	    0x06600090, // SUBTILIS_ARM_SIMD_UQADD8,
	    0x06600030, // SUBTILIS_ARM_SIMD_UQADDSUBX,
	    0x06600070, // SUBTILIS_ARM_SIMD_UQSUB16,
	    0x066000f0, // SUBTILIS_ARM_SIMD_UQSUB8,
	    0x06600050, // SUBTILIS_ARM_SIMD_UQSUBADDX,
	};
	size_t index = type - SUBTILIS_ARM_SIMD_QADD16;

	if (type > SUBTILIS_ARM_SIMD_UQSUBADDX) {
		subtilis_error_set_assertion_failed(err);
		return;
	}

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

	word = opcodes[index];
	word |= instr->ccode << 28;
	word |= (instr->dest & 0xf) << 12;
	word |= (instr->op1 & 0xf) << 16;
	word |= (instr->op2 & 0xf);

	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 %r13
pushq %r12
pushq %rbx
pushq %rax
movq %r8, %r14
cmpl $0xa9, %edx
jb 0x59803
leaq 0x1c69d(%rip), %rdx     # 0x75e80
movq %r14, %rdi
movl $0xf, %esi
movl $0x8be, %ecx            # imm = 0x8BE
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x145a4
movq %rcx, %r15
movl %edx, %r12d
movq %rdi, %rbx
xorl %esi, %esi
movq %r14, %rdx
callq 0x59e32
cmpl $0x0, (%r14)
jne 0x59857
addl $0xffffff7b, %r12d      # imm = 0xFFFFFF7B
leaq 0x1c546(%rip), %rax     # 0x75d70
movl (%rax,%r12,4), %eax
movl %eax, 0x4(%rsp)
movl (%r15), %r13d
movq 0x8(%r15), %r12
movq 0x10(%r15), %rbp
movq 0x18(%r15), %r15
movl $0x4, %esi
movq %rbx, %rdi
movq %r14, %rdx
callq 0x5758f
cmpl $0x0, (%r14)
je 0x59866
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl 0x4(%rsp), %edx
movq 0x30(%rbx), %rax
testb $0x3, %al
je 0x5988b
leaq 0x1c607(%rip), %rdx     # 0x75e80
movq %r14, %rdi
movl $0x5d, %esi
movl $0xfb, %ecx
jmp 0x597f0
andl $0xf, %r15d
andl $0xf, %ebp
shll $0x10, %ebp
orl %r15d, %ebp
shll $0xc, %r12d
movzwl %r12w, %ecx
shll $0x1c, %r13d
orl %edx, %r13d
orl %ecx, %r13d
orl %ebp, %r13d
movq 0x28(%rbx), %rcx
movl %r13d, (%rcx,%rax)
addq $0x4, %rax
movq %rax, 0x30(%rbx)
jmp 0x59857