// File: /workspace/github_c_makefile_star2_O0/markdryan[P]subtilis/arch/arm32/arm_gen.c
// Function: prv_stack_args
static void prv_stack_args(subtilis_arm_section_t *arm_s,
			   subtilis_ir_call_t *call, size_t int_args_left,
			   size_t real_args_left, size_t *int_arg_ops,
			   size_t *real_arg_ops, subtilis_error_t *err)
{
	size_t offset;
	subtilis_arm_reg_t op0;
	subtilis_arm_reg_t arg_dest;
	subtilis_arm_reg_t arg_src;
	size_t i;
	size_t reg_num;
	size_t arg;
	subtilis_arm_instr_t *instr;
	subtilis_arm_stran_instr_t *stran;
	size_t stack_ops;

	op0 = 13;

	/* TODO: There should be an argument limit here. */

	/*
	 * We shove the remaining arguments on the stack.  Then we just need
	 * to prime the register allocator to think it has previously spilled
	 * these values to the stack.
	 */

	offset = 0;
	stack_ops = 0;
	for (i = call->arg_count; i > 0 && int_args_left > 4; i--) {
		if (call->args[i - 1].type == SUBTILIS_IR_REG_TYPE_REAL)
			continue;
		offset += 4;
		reg_num = call->args[i - 1].reg;
		instr = subtilis_arm_section_add_instr(
		    arm_s, SUBTILIS_ARM_INSTR_STR, err);
		if (err->type != SUBTILIS_ERROR_OK)
			return;
		int_arg_ops[stack_ops++] = arm_s->last_op;
		stran = &instr->operands.stran;
		stran->ccode = SUBTILIS_ARM_CCODE_AL;
		stran->dest = subtilis_arm_ir_to_arm_reg(reg_num);
		stran->base = op0;
		stran->offset.type = SUBTILIS_ARM_OP2_I32;
		stran->offset.op.integer = offset;
		stran->pre_indexed = true;
		stran->write_back = false;
		stran->subtract = true;
		stran->byte = false;
		int_args_left--;
	}

	stack_ops = 0;
	for (i = call->arg_count; i > 0 && real_args_left > 4; i--) {
		if (call->args[i - 1].type != SUBTILIS_IR_REG_TYPE_REAL)
			continue;
		offset += 8;
		reg_num = call->args[i - 1].reg;
		arm_s->fp_if->store_dbl_fn(
		    arm_s, subtilis_arm_ir_to_real_reg(arm_s, reg_num), op0,
		    offset, err);
		if (err->type != SUBTILIS_ERROR_OK)
			return;
		real_arg_ops[stack_ops++] = arm_s->last_op;
		real_args_left--;
	}

	for (i = 0, arg = 0; i < call->arg_count && arg < int_args_left; i++) {
		if (call->args[i].type != SUBTILIS_IR_REG_TYPE_INTEGER)
			continue;
		arg_dest = arg;
		arg_src = subtilis_arm_ir_to_arm_reg(call->args[i].reg);
		subtilis_arm_add_mov_reg(arm_s, SUBTILIS_ARM_CCODE_AL, false,
					 arg_dest, arg_src, err);
		if (err->type != SUBTILIS_ERROR_OK)
			return;
		arg++;
	}

	for (i = 0, arg = 0; i < call->arg_count && arg < real_args_left; i++) {
		if (call->args[i].type != SUBTILIS_IR_REG_TYPE_REAL)
			continue;
		arg_dest = arg;
		arg_src = subtilis_arm_ir_to_real_reg(arm_s, call->args[i].reg);
		arm_s->fp_if->mov_reg_fn(arm_s, arg_dest, arg_src, err);
		if (err->type != SUBTILIS_ERROR_OK)
			return;
		arg++;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movq $0xd, -0x40(%rbp)
movq $0x0, -0x38(%rbp)
movq $0x0, -0x80(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x58(%rbp)
xorl %eax, %eax
cmpq $0x0, -0x58(%rbp)
movb %al, -0x81(%rbp)
jbe 0x74d88
cmpq $0x4, -0x18(%rbp)
seta %al
movb %al, -0x81(%rbp)
movb -0x81(%rbp), %al
testb $0x1, %al
jne 0x74d97
jmp 0x74eb1
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x58(%rbp), %rcx
subq $0x1, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
cmpl $0x1, (%rax)
jne 0x74db8
jmp 0x74ea0
movq -0x38(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x58(%rbp), %rcx
subq $0x1, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movq %rax, -0x60(%rbp)
movq -0x8(%rbp), %rdi
movq 0x10(%rbp), %rdx
movl $0x13, %esi
callq 0x70b50
movq %rax, -0x70(%rbp)
movq 0x10(%rbp), %rax
cmpl $0x0, (%rax)
je 0x74e07
jmp 0x75175
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rdx
movq -0x28(%rbp), %rax
movq -0x80(%rbp), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, -0x80(%rbp)
movq %rdx, (%rax,%rcx,8)
movq -0x70(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rax
movl $0xe, (%rax)
movq -0x60(%rbp), %rdi
callq 0x6fe90
movq %rax, %rcx
movq -0x78(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x40(%rbp), %rcx
movq -0x78(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x78(%rbp), %rax
movl $0x1, 0x18(%rax)
movq -0x38(%rbp), %rax
movl %eax, %ecx
movq -0x78(%rbp), %rax
movl %ecx, 0x20(%rax)
movq -0x78(%rbp), %rax
movb $0x1, 0x40(%rax)
movq -0x78(%rbp), %rax
movb $0x0, 0x41(%rax)
movq -0x78(%rbp), %rax
movb $0x1, 0x42(%rax)
movq -0x78(%rbp), %rax
movb $0x0, 0x43(%rax)
movq -0x18(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x18(%rbp)
movq -0x58(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x58(%rbp)
jmp 0x74d6b
movq $0x0, -0x80(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x58(%rbp)
xorl %eax, %eax
cmpq $0x0, -0x58(%rbp)
movb %al, -0x82(%rbp)
jbe 0x74ee2
cmpq $0x4, -0x20(%rbp)
seta %al
movb %al, -0x82(%rbp)
movb -0x82(%rbp), %al
testb $0x1, %al
jne 0x74ef1
jmp 0x74fd4
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x58(%rbp), %rcx
subq $0x1, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
cmpl $0x1, (%rax)
je 0x74f12
jmp 0x74fc3
movq -0x38(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x58(%rbp), %rcx
subq $0x1, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movq %rax, -0x60(%rbp)
movq -0x8(%rbp), %rax
movq 0xc0(%rax), %rax
movq 0x48(%rax), %rax
movq %rax, -0x90(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0x8(%rbp), %rdi
movq -0x60(%rbp), %rsi
callq 0x6ff30
movq -0x98(%rbp), %rdi
movq %rax, %rsi
movq -0x90(%rbp), %rax
movq -0x40(%rbp), %rdx
movq -0x38(%rbp), %rcx
movq 0x10(%rbp), %r8
callq *%rax
movq 0x10(%rbp), %rax
cmpl $0x0, (%rax)
je 0x74f98
jmp 0x75175
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rdx
movq -0x30(%rbp), %rax
movq -0x80(%rbp), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, -0x80(%rbp)
movq %rdx, (%rax,%rcx,8)
movq -0x20(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x20(%rbp)
movq -0x58(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x58(%rbp)
jmp 0x74ec5
movq $0x0, -0x58(%rbp)
movq $0x0, -0x68(%rbp)
movq -0x58(%rbp), %rcx
movq -0x10(%rbp), %rdx
xorl %eax, %eax
cmpq 0x8(%rdx), %rcx
movb %al, -0x99(%rbp)
jae 0x7500b
movq -0x68(%rbp), %rax
cmpq -0x18(%rbp), %rax
setb %al
movb %al, -0x99(%rbp)
movb -0x99(%rbp), %al
testb $0x1, %al
jne 0x7501a
jmp 0x750a6
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
imulq $0x18, -0x58(%rbp), %rcx
addq %rcx, %rax
cmpl $0x0, (%rax)
je 0x75031
jmp 0x75095
movq -0x68(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
imulq $0x18, -0x58(%rbp), %rcx
addq %rcx, %rax
movq 0x8(%rax), %rdi
callq 0x6fe90
movq %rax, -0x50(%rbp)
movq -0x8(%rbp), %rdi
movq -0x48(%rbp), %r8
movq -0x50(%rbp), %r9
movq 0x10(%rbp), %rax
movl $0xd, %esi
movl $0xe, %edx
xorl %ecx, %ecx
movq %rax, (%rsp)
callq 0x71fa0
movq 0x10(%rbp), %rax
cmpl $0x0, (%rax)
je 0x75089
jmp 0x75175
movq -0x68(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x68(%rbp)
movq -0x58(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x58(%rbp)
jmp 0x74fe4
movq $0x0, -0x58(%rbp)
movq $0x0, -0x68(%rbp)
movq -0x58(%rbp), %rcx
movq -0x10(%rbp), %rdx
xorl %eax, %eax
cmpq 0x8(%rdx), %rcx
movb %al, -0x9a(%rbp)
jae 0x750dd
movq -0x68(%rbp), %rax
cmpq -0x20(%rbp), %rax
setb %al
movb %al, -0x9a(%rbp)
movb -0x9a(%rbp), %al
testb $0x1, %al
jne 0x750ec
jmp 0x75175
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
imulq $0x18, -0x58(%rbp), %rcx
addq %rcx, %rax
cmpl $0x1, (%rax)
je 0x75103
jmp 0x75164
movq -0x68(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
imulq $0x18, -0x58(%rbp), %rcx
addq %rcx, %rax
movq 0x8(%rax), %rsi
callq 0x6ff30
movq %rax, -0x50(%rbp)
movq -0x8(%rbp), %rax
movq 0xc0(%rax), %rax
movq 0x50(%rax), %rax
movq -0x8(%rbp), %rdi
movq -0x48(%rbp), %rsi
movq -0x50(%rbp), %rdx
movq 0x10(%rbp), %rcx
callq *%rax
movq 0x10(%rbp), %rax
cmpl $0x0, (%rax)
je 0x75158
jmp 0x75175
movq -0x68(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x68(%rbp)
movq -0x58(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x58(%rbp)
jmp 0x750b6
addq $0xb0, %rsp
popq %rbp
retq
nop