// File: /workspace/github_c_makefile_star2_O0/markdryan[P]subtilis/backends/riscos_common/riscos_arm.c
// Function: prv_add_section
static void prv_add_section(subtilis_ir_section_t *s,
			    subtilis_arm_section_t *arm_s,
			    subtilis_ir_rule_t *parsed, size_t rule_count,
			    subtilis_error_t *err)
{
	size_t spill_regs;
	size_t stack_space;
	subtilis_arm_instr_t *stack_sub;
	subtilis_arm_data_instr_t *datai;
	uint32_t encoded;
	subtilis_arm_reg_t dest;
	subtilis_arm_reg_t op2;
	size_t move_instr;

	stack_sub =
	    subtilis_arm_section_add_instr(arm_s, SUBTILIS_ARM_INSTR_SUB, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	move_instr = arm_s->last_op;

	datai = &stack_sub->operands.data;
	datai->status = false;
	datai->ccode = SUBTILIS_ARM_CCODE_AL;
	datai->dest = 13;
	datai->op1 = datai->dest;
	datai->op2.type = SUBTILIS_ARM_OP2_I32;
	datai->op2.op.integer = 0;

	dest = 11;
	op2 = 13;

	subtilis_arm_add_mov_reg(arm_s, SUBTILIS_ARM_CCODE_AL, false, dest, op2,
				 err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	subtilis_ir_match(s, parsed, rule_count, arm_s, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	prv_compute_sss(arm_s, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	spill_regs = subtilis_arm_reg_alloc(arm_s, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	stack_space = spill_regs + arm_s->locals;

	encoded = subtilis_arm_encode_nearest(stack_space, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	/*
	 * The original datai pointer may have become invalidated by a realloc
	 * on the ops pool.
	 */

	stack_sub = &arm_s->op_pool->ops[move_instr].op.instr;
	datai = &stack_sub->operands.data;
	datai->op2.op.integer = encoded;

	subtilis_arm_save_regs(arm_s, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;
	subtilis_arm_restore_stack(arm_s, encoded, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;
	subtilis_arm_peephole(arm_s, err);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rdx
movl $0x2, %esi
callq 0x70b50
movq %rax, -0x40(%rbp)
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0xa3f90
jmp 0xa4130
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x68(%rbp)
movq -0x40(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movb $0x0, 0x4(%rax)
movq -0x48(%rbp), %rax
movl $0xe, (%rax)
movq -0x48(%rbp), %rax
movq $0xd, 0x8(%rax)
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0x48(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x48(%rbp), %rax
movl $0x1, 0x18(%rax)
movq -0x48(%rbp), %rax
movl $0x0, 0x20(%rax)
movq $0xb, -0x58(%rbp)
movq $0xd, -0x60(%rbp)
movq -0x10(%rbp), %rdi
movq -0x58(%rbp), %r8
movq -0x60(%rbp), %r9
movq -0x28(%rbp), %rax
movl $0xd, %esi
movl $0xe, %edx
xorl %ecx, %ecx
movq %rax, (%rsp)
callq 0x71fa0
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0xa402f
jmp 0xa4130
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x10(%rbp), %rcx
movq -0x28(%rbp), %r8
callq 0x3a4f0
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0xa4056
jmp 0xa4130
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0xa8710
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0xa4071
jmp 0xa4130
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x77a00
movq %rax, -0x30(%rbp)
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0xa4090
jmp 0xa4130
movq -0x30(%rbp), %rax
movq -0x10(%rbp), %rcx
addq 0x30(%rcx), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movl %eax, %edi
movq -0x28(%rbp), %rsi
callq 0x70cf0
movl %eax, -0x4c(%rbp)
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0xa40bd
jmp 0xa4130
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rax
movq (%rax), %rax
imulq $0x68, -0x68(%rbp), %rcx
addq %rcx, %rax
addq $0x8, %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x48(%rbp)
movl -0x4c(%rbp), %ecx
movq -0x48(%rbp), %rax
movl %ecx, 0x20(%rax)
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x79e10
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0xa4106
jmp 0xa4130
movq -0x10(%rbp), %rdi
movl -0x4c(%rbp), %eax
movl %eax, %esi
movq -0x28(%rbp), %rdx
callq 0x72b40
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0xa4123
jmp 0xa4130
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x8a610
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)