// File: /workspace/github_c_makefile_star2_O0/markdryan[P]subtilis/arch/arm32/arm_gen.c
// Function: subtilis_arm_gen_call_gen
void subtilis_arm_gen_call_gen(subtilis_ir_section_t *s, size_t start,
			       void *user_data,
			       subtilis_arm_br_link_type_t link_type,
			       bool indirect, subtilis_error_t *err)
{
	subtilis_arm_reg_t op0;
	subtilis_arm_instr_t *instr;
	subtilis_arm_br_instr_t *br;
	size_t stm_site;
	size_t ldm_site;
	size_t call_site;
	int i;
	subtilis_ir_call_t *call = &s->ops[start]->op.call;
	subtilis_arm_section_t *arm_s = user_data;
	size_t stf_site = INT_MAX;
	size_t ldf_site = INT_MAX;
	size_t int_args = 0;
	size_t real_args = 0;
	int save_real_start = INT_MAX;
	size_t int_arg_ops[SUBTILIS_IR_MAX_ARGS_PER_TYPE - 4];
	size_t real_arg_ops[SUBTILIS_IR_MAX_ARGS_PER_TYPE - 4];

	if (!arm_s->fp_if) {
		subtilis_error_set_assertion_failed(err);
		return;
	}

	for (i = 0; i < call->arg_count; i++) {
		if (call->args[i].type == SUBTILIS_IR_REG_TYPE_REAL)
			real_args++;
		else
			int_args++;
	}

	if (real_args > SUBTILIS_IR_MAX_ARGS_PER_TYPE ||
	    int_args > SUBTILIS_IR_MAX_ARGS_PER_TYPE) {
		subtilis_error_set_assertion_failed(err);
		return;
	}

	prv_stack_args(arm_s, call, int_args, real_args, int_arg_ops,
		       real_arg_ops, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	op0 = 13;

	subtilis_arm_add_mtran(arm_s, SUBTILIS_ARM_INSTR_STM,
			       SUBTILIS_ARM_CCODE_AL, op0, 1 << 14 | 1 << 11,
			       SUBTILIS_ARM_MTRAN_FD, true, false, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	stm_site = arm_s->last_op;

	if (s->freg_counter > 0) {
		save_real_start = real_args > 4 ? 4 : real_args;
		stf_site =
		    arm_s->fp_if->preserve_regs_fn(arm_s, save_real_start, err);
		if (err->type != SUBTILIS_ERROR_OK)
			return;
	}

	if (indirect) {
		subtilis_arm_add_mov_reg(arm_s, SUBTILIS_ARM_CCODE_AL, false,
					 14, 15, err);
		if (err->type != SUBTILIS_ERROR_OK)
			return;
	}

	instr =
	    subtilis_arm_section_add_instr(arm_s, SUBTILIS_ARM_INSTR_B, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	br = &instr->operands.br;
	br->ccode = SUBTILIS_ARM_CCODE_AL;
	br->link = true;
	br->link_type = link_type;
	if (indirect)
		br->target.reg = subtilis_arm_ir_to_arm_reg(call->proc_id);
	else
		br->target.label = call->proc_id;
	br->indirect = indirect;

	call_site = arm_s->last_op;

	if (s->freg_counter > 0) {
		ldf_site =
		    arm_s->fp_if->restore_regs_fn(arm_s, save_real_start, err);
		if (err->type != SUBTILIS_ERROR_OK)
			return;
	}

	subtilis_arm_add_mtran(arm_s, SUBTILIS_ARM_INSTR_LDM,
			       SUBTILIS_ARM_CCODE_AL, op0, 1 << 14 | 1 << 11,
			       SUBTILIS_ARM_MTRAN_FD, true, false, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	ldm_site = arm_s->last_op;
	subtilis_arm_section_add_call_site(
	    arm_s, stm_site, ldm_site, stf_site, ldf_site, int_args, real_args,
	    call_site, int_arg_ops, real_arg_ops, err);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x190, %rsp            # imm = 0x190
movb %r8b, %al
movq %rdi, -0x18(%rbp)
movq %rsi, -0x20(%rbp)
movq %rdx, -0x28(%rbp)
movl %ecx, -0x2c(%rbp)
andb $0x1, %al
movb %al, -0x2d(%rbp)
movq %r9, -0x38(%rbp)
movq -0x18(%rbp), %rax
movq 0x48(%rax), %rax
movq -0x20(%rbp), %rcx
movq (%rax,%rcx,8), %rax
addq $0x8, %rax
movq %rax, -0x78(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x80(%rbp)
movq $0x7fffffff, -0x88(%rbp) # imm = 0x7FFFFFFF
movq $0x7fffffff, -0x90(%rbp) # imm = 0x7FFFFFFF
movq $0x0, -0x98(%rbp)
movq $0x0, -0xa0(%rbp)
movl $0x7fffffff, -0xa4(%rbp) # imm = 0x7FFFFFFF
movq -0x80(%rbp), %rax
cmpq $0x0, 0xc0(%rax)
jne 0x7499c
movq -0x38(%rbp), %rdi
movl $0xf, %esi
leaq 0x381d9(%rip), %rdx     # 0xacb66
movl $0x353, %ecx            # imm = 0x353
callq 0x158e0
jmp 0x74d05
movl $0x0, -0x6c(%rbp)
movslq -0x6c(%rbp), %rax
movq -0x78(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jae 0x749fc
movq -0x78(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x6c(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
cmpl $0x1, (%rax)
jne 0x749dd
movq -0xa0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xa0(%rbp)
jmp 0x749ef
movq -0x98(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x98(%rbp)
jmp 0x749f1
movl -0x6c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6c(%rbp)
jmp 0x749a3
cmpq $0x10, -0xa0(%rbp)
ja 0x74a10
cmpq $0x10, -0x98(%rbp)
jbe 0x74a2f
movq -0x38(%rbp), %rdi
movl $0xf, %esi
leaq 0x38146(%rip), %rdx     # 0xacb66
movl $0x360, %ecx            # imm = 0x360
callq 0x158e0
jmp 0x74d05
movq -0x80(%rbp), %rdi
movq -0x78(%rbp), %rsi
movq -0x98(%rbp), %rdx
movq -0xa0(%rbp), %rcx
leaq -0x110(%rbp), %r8
leaq -0x170(%rbp), %r9
movq -0x38(%rbp), %rax
movq %rax, (%rsp)
callq 0x74d20
movq -0x38(%rbp), %rax
cmpl $0x0, (%rax)
je 0x74a6e
jmp 0x74d05
movq $0xd, -0x40(%rbp)
movq -0x80(%rbp), %rdi
movq -0x40(%rbp), %rcx
movq -0x38(%rbp), %rax
movl $0x15, %esi
movl $0xe, %edx
movl $0x4800, %r8d           # imm = 0x4800
movl $0x5, %r9d
xorl %r10d, %r10d
movl $0x1, (%rsp)
movl $0x0, 0x8(%rsp)
movq %rax, 0x10(%rsp)
callq 0x727a0
movq -0x38(%rbp), %rax
cmpl $0x0, (%rax)
je 0x74ac2
jmp 0x74d05
movq -0x80(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x58(%rbp)
movq -0x18(%rbp), %rax
cmpq $0x0, 0x20(%rax)
jbe 0x74b42
cmpq $0x4, -0xa0(%rbp)
jbe 0x74af1
movl $0x4, %eax
movq %rax, -0x178(%rbp)
jmp 0x74aff
movq -0xa0(%rbp), %rax
movq %rax, -0x178(%rbp)
movq -0x178(%rbp), %rax
movl %eax, -0xa4(%rbp)
movq -0x80(%rbp), %rax
movq 0xc0(%rax), %rax
movq 0x28(%rax), %rax
movq -0x80(%rbp), %rdi
movl -0xa4(%rbp), %esi
movq -0x38(%rbp), %rdx
callq *%rax
movq %rax, -0x88(%rbp)
movq -0x38(%rbp), %rax
cmpl $0x0, (%rax)
je 0x74b40
jmp 0x74d05
jmp 0x74b42
testb $0x1, -0x2d(%rbp)
je 0x74b81
movq -0x80(%rbp), %rdi
movq -0x38(%rbp), %rax
movl $0xd, %esi
movl $0xe, %edx
xorl %ecx, %ecx
movl $0xe, %r8d
movl $0xf, %r9d
movq %rax, (%rsp)
callq 0x71fa0
movq -0x38(%rbp), %rax
cmpl $0x0, (%rax)
je 0x74b7f
jmp 0x74d05
jmp 0x74b81
movq -0x80(%rbp), %rdi
movq -0x38(%rbp), %rdx
movl $0x16, %esi
callq 0x70b50
movq %rax, -0x48(%rbp)
movq -0x38(%rbp), %rax
cmpl $0x0, (%rax)
je 0x74ba5
jmp 0x74d05
movq -0x48(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movl $0xe, (%rax)
movq -0x50(%rbp), %rax
movb $0x1, 0x4(%rax)
movl -0x2c(%rbp), %ecx
movq -0x50(%rbp), %rax
movl %ecx, 0x8(%rax)
testb $0x1, -0x2d(%rbp)
je 0x74bec
movq -0x78(%rbp), %rax
movq (%rax), %rdi
callq 0x6fe90
movq %rax, %rcx
movq -0x50(%rbp), %rax
movq %rcx, 0x10(%rax)
jmp 0x74bfb
movq -0x78(%rbp), %rax
movq (%rax), %rcx
movq -0x50(%rbp), %rax
movq %rcx, 0x10(%rax)
movb -0x2d(%rbp), %cl
movq -0x50(%rbp), %rax
andb $0x1, %cl
movb %cl, 0x6(%rax)
movq -0x80(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x68(%rbp)
movq -0x18(%rbp), %rax
cmpq $0x0, 0x20(%rax)
jbe 0x74c55
movq -0x80(%rbp), %rax
movq 0xc0(%rax), %rax
movq 0x30(%rax), %rax
movq -0x80(%rbp), %rdi
movl -0xa4(%rbp), %esi
movq -0x38(%rbp), %rdx
callq *%rax
movq %rax, -0x90(%rbp)
movq -0x38(%rbp), %rax
cmpl $0x0, (%rax)
je 0x74c53
jmp 0x74d05
jmp 0x74c55
movq -0x80(%rbp), %rdi
movq -0x40(%rbp), %rcx
movq -0x38(%rbp), %rax
movl $0x14, %esi
movl $0xe, %edx
movl $0x4800, %r8d           # imm = 0x4800
movl $0x5, %r9d
xorl %r10d, %r10d
movl $0x1, (%rsp)
movl $0x0, 0x8(%rsp)
movq %rax, 0x10(%rsp)
callq 0x727a0
movq -0x38(%rbp), %rax
cmpl $0x0, (%rax)
je 0x74c9e
jmp 0x74d05
movq -0x80(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x60(%rbp)
movq -0x80(%rbp), %rdi
movq -0x58(%rbp), %rsi
movq -0x60(%rbp), %rdx
movq -0x88(%rbp), %rcx
movq -0x90(%rbp), %r8
movq -0x98(%rbp), %r9
movq -0xa0(%rbp), %r14
movq -0x68(%rbp), %rbx
leaq -0x110(%rbp), %r11
leaq -0x170(%rbp), %r10
movq -0x38(%rbp), %rax
movq %r14, (%rsp)
movq %rbx, 0x8(%rsp)
movq %r11, 0x10(%rsp)
movq %r10, 0x18(%rsp)
movq %rax, 0x20(%rsp)
callq 0x70190
addq $0x190, %rsp            # imm = 0x190
popq %rbx
popq %r14
popq %rbp
retq
nopw %cs:(%rax,%rax)