// File: /workspace/github_c_makefile_star2_O0/markdryan[P]subtilis/arch/arm32/arm_core.c
// Function: subtilis_arm_add_addsub_imm
void subtilis_arm_add_addsub_imm(subtilis_arm_section_t *s,
				 subtilis_arm_instr_type_t itype,
				 subtilis_arm_instr_type_t alt_type,
				 subtilis_arm_ccode_type_t ccode, bool status,
				 subtilis_arm_reg_t dest,
				 subtilis_arm_reg_t op1, int32_t op2,
				 subtilis_error_t *err)
{
	subtilis_arm_instr_t *instr;
	subtilis_arm_data_instr_t *datai;
	subtilis_arm_data_instr_t *datai2;
	bool can_encode;
	uint32_t encoded;
	uint32_t encoded2 = 0;

	can_encode = subtilis_arm_encode_imm(op2, &encoded);
	/* TODO why does it matter if the op2 is less than 0? */
	if ((!can_encode) && (op2 < 0)) {
		can_encode = subtilis_arm_encode_imm(-op2, &encoded);
		if (can_encode) {
			op2 = -op2;
			itype = alt_type;
		}
	}

	if (!can_encode) {
		if (status && (ccode != SUBTILIS_ARM_CCODE_AL)) {
			(void)subtilis_add_data_imm_ldr_datai(
			    s, itype, ccode, status, dest, op1, op2, err);
			return;
		}

		can_encode =
		    subtilis_arm_encode_lvl2_imm(op2, &encoded, &encoded2);

		if ((!can_encode) && (op2 < 0)) {
			can_encode = subtilis_arm_encode_lvl2_imm(
			    -op2, &encoded, &encoded2);
			if (can_encode) {
				op2 = -op2;
				itype = alt_type;
			}
		}
	}

	if (!can_encode) {
		(void)subtilis_add_data_imm_ldr_datai(s, itype, ccode, status,
						      dest, op1, op2, err);
		return;
	}

	instr = subtilis_arm_section_add_instr(s, itype, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	datai = &instr->operands.data;
	datai->status = status;
	datai->op2.type = SUBTILIS_ARM_OP2_I32;
	datai->ccode = ccode;
	datai->dest = encoded2 == 0 ? dest : subtilis_arm_acquire_new_reg(s);
	datai->op1 = op1;
	datai->op2.op.integer = encoded;

	if (encoded2 == 0)
		return;

	instr = subtilis_arm_section_dup_instr(s, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;
	datai2 = &instr->operands.data;
	datai2->op1 = datai->dest;
	datai2->op2.op.integer = encoded2;
	datai2->dest = dest;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movb %r8b, %al
movq 0x20(%rbp), %r8
movl 0x18(%rbp), %r8d
movq 0x10(%rbp), %r8
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movl %ecx, -0x14(%rbp)
andb $0x1, %al
movb %al, -0x15(%rbp)
movq %r9, -0x20(%rbp)
movl $0x0, -0x44(%rbp)
movl 0x18(%rbp), %edi
leaq -0x40(%rbp), %rsi
callq 0x70e60
andb $0x1, %al
movb %al, -0x39(%rbp)
testb $0x1, -0x39(%rbp)
jne 0x716ba
cmpl $0x0, 0x18(%rbp)
jge 0x716ba
xorl %edi, %edi
subl 0x18(%rbp), %edi
leaq -0x40(%rbp), %rsi
callq 0x70e60
andb $0x1, %al
movb %al, -0x39(%rbp)
testb $0x1, -0x39(%rbp)
je 0x716b8
xorl %eax, %eax
subl 0x18(%rbp), %eax
movl %eax, 0x18(%rbp)
movl -0x10(%rbp), %eax
movl %eax, -0xc(%rbp)
jmp 0x716ba
testb $0x1, -0x39(%rbp)
jne 0x71756
testb $0x1, -0x15(%rbp)
je 0x71706
cmpl $0xe, -0x14(%rbp)
je 0x71706
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
movl -0x14(%rbp), %edx
movb -0x15(%rbp), %cl
movq -0x20(%rbp), %r8
movq 0x10(%rbp), %r9
movl 0x18(%rbp), %r10d
movq 0x20(%rbp), %rax
andb $0x1, %cl
movzbl %cl, %ecx
movl %r10d, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x71410
jmp 0x71876
movl 0x18(%rbp), %edi
leaq -0x40(%rbp), %rsi
leaq -0x44(%rbp), %rdx
callq 0x70fc0
andb $0x1, %al
movb %al, -0x39(%rbp)
testb $0x1, -0x39(%rbp)
jne 0x71754
cmpl $0x0, 0x18(%rbp)
jge 0x71754
xorl %edi, %edi
subl 0x18(%rbp), %edi
leaq -0x40(%rbp), %rsi
leaq -0x44(%rbp), %rdx
callq 0x70fc0
andb $0x1, %al
movb %al, -0x39(%rbp)
testb $0x1, -0x39(%rbp)
je 0x71752
xorl %eax, %eax
subl 0x18(%rbp), %eax
movl %eax, 0x18(%rbp)
movl -0x10(%rbp), %eax
movl %eax, -0xc(%rbp)
jmp 0x71754
jmp 0x71756
testb $0x1, -0x39(%rbp)
jne 0x71792
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
movl -0x14(%rbp), %edx
movb -0x15(%rbp), %cl
movq -0x20(%rbp), %r8
movq 0x10(%rbp), %r9
movl 0x18(%rbp), %r10d
movq 0x20(%rbp), %rax
andb $0x1, %cl
movzbl %cl, %ecx
movl %r10d, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x71410
jmp 0x71876
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
movq 0x20(%rbp), %rdx
callq 0x70b50
movq %rax, -0x28(%rbp)
movq 0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x717b4
jmp 0x71876
movq -0x28(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x30(%rbp)
movb -0x15(%rbp), %cl
movq -0x30(%rbp), %rax
andb $0x1, %cl
movb %cl, 0x4(%rax)
movq -0x30(%rbp), %rax
movl $0x1, 0x18(%rax)
movl -0x14(%rbp), %ecx
movq -0x30(%rbp), %rax
movl %ecx, (%rax)
cmpl $0x0, -0x44(%rbp)
jne 0x717f1
movq -0x20(%rbp), %rax
movq %rax, -0x50(%rbp)
jmp 0x717fe
movq -0x8(%rbp), %rdi
callq 0x6fe60
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x8(%rax)
movq 0x10(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x10(%rax)
movl -0x40(%rbp), %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0x20(%rax)
cmpl $0x0, -0x44(%rbp)
jne 0x71828
jmp 0x71876
movq -0x8(%rbp), %rdi
movq 0x20(%rbp), %rsi
callq 0x70c30
movq %rax, -0x28(%rbp)
movq 0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x71844
jmp 0x71876
movq -0x28(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x38(%rbp)
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x10(%rax)
movl -0x44(%rbp), %ecx
movq -0x38(%rbp), %rax
movl %ecx, 0x20(%rax)
movq -0x20(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x8(%rax)
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax)