// File: /workspace/github_c_makefile_star2_O0/markdryan[P]subtilis/arch/arm32/arm_core.c
// Function: subtilis_arm_add_rsub_imm
void subtilis_arm_add_rsub_imm(subtilis_arm_section_t *s,
			       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;
	bool can_encode;
	uint32_t encoded;
	subtilis_arm_reg_t neg_dest;
	subtilis_arm_instr_type_t itype = SUBTILIS_ARM_INSTR_RSB;

	can_encode = subtilis_arm_encode_imm(op2, &encoded);
	if ((!can_encode) && (op2 < 0) &&
	    !(status && (ccode != SUBTILIS_ARM_CCODE_AL))) {
		can_encode = subtilis_arm_encode_imm(-op2, &encoded);
		if (can_encode) {
			neg_dest = subtilis_arm_acquire_new_reg(s);
			subtilis_arm_add_rsub_imm(s, ccode, false, neg_dest,
						  op1, 0, err);
			if (err->type != SUBTILIS_ERROR_OK)
				return;
			op1 = neg_dest;
			op2 = -op2;
			itype = SUBTILIS_ARM_INSTR_SUB;
		}
	}

	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 = dest;
	datai->op1 = op1;
	datai->op2.op.integer = encoded;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movb %dl, %al
movq 0x10(%rbp), %rdx
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
andb $0x1, %al
movb %al, -0xd(%rbp)
movq %rcx, -0x18(%rbp)
movq %r8, -0x20(%rbp)
movl %r9d, -0x24(%rbp)
movl $0x3, -0x4c(%rbp)
movl -0x24(%rbp), %edi
leaq -0x40(%rbp), %rsi
callq 0x70e60
andb $0x1, %al
movb %al, -0x39(%rbp)
testb $0x1, -0x39(%rbp)
jne 0x71949
cmpl $0x0, -0x24(%rbp)
jge 0x71949
testb $0x1, -0xd(%rbp)
je 0x718da
cmpl $0xe, -0xc(%rbp)
jne 0x71949
xorl %edi, %edi
subl -0x24(%rbp), %edi
leaq -0x40(%rbp), %rsi
callq 0x70e60
andb $0x1, %al
movb %al, -0x39(%rbp)
testb $0x1, -0x39(%rbp)
je 0x71947
movq -0x8(%rbp), %rdi
callq 0x6fe60
movq %rax, -0x48(%rbp)
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
movq -0x48(%rbp), %rcx
movq -0x20(%rbp), %r8
movq 0x10(%rbp), %rax
xorl %r9d, %r9d
movl %r9d, %edx
movq %rax, (%rsp)
callq 0x71880
movq 0x10(%rbp), %rax
cmpl $0x0, (%rax)
je 0x71930
jmp 0x719f0
movq -0x48(%rbp), %rax
movq %rax, -0x20(%rbp)
xorl %eax, %eax
subl -0x24(%rbp), %eax
movl %eax, -0x24(%rbp)
movl $0x2, -0x4c(%rbp)
jmp 0x71949
testb $0x1, -0x39(%rbp)
jne 0x71982
movq -0x8(%rbp), %rdi
movl -0x4c(%rbp), %esi
movl -0xc(%rbp), %edx
movb -0xd(%rbp), %cl
movq -0x18(%rbp), %r8
movq -0x20(%rbp), %r9
movl -0x24(%rbp), %r10d
movq 0x10(%rbp), %rax
andb $0x1, %cl
movzbl %cl, %ecx
movl %r10d, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x71410
jmp 0x719f0
movq -0x8(%rbp), %rdi
movl -0x4c(%rbp), %esi
movq 0x10(%rbp), %rdx
callq 0x70b50
movq %rax, -0x30(%rbp)
movq 0x10(%rbp), %rax
cmpl $0x0, (%rax)
je 0x719a1
jmp 0x719f0
movq -0x30(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x38(%rbp)
movb -0xd(%rbp), %cl
movq -0x38(%rbp), %rax
andb $0x1, %cl
movb %cl, 0x4(%rax)
movq -0x38(%rbp), %rax
movl $0x1, 0x18(%rax)
movl -0xc(%rbp), %ecx
movq -0x38(%rbp), %rax
movl %ecx, (%rax)
movq -0x18(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x20(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x10(%rax)
movl -0x40(%rbp), %ecx
movq -0x38(%rbp), %rax
movl %ecx, 0x20(%rax)
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)