// File: /workspace/github_c_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x128, %rsp            # imm = 0x128
cmpq $0x0, 0xc0(%rdx)
je 0x4e84d
movl %r8d, %ebp
movq %rdx, %r8
movq 0x48(%rdi), %rax
movq (%rax,%rsi,8), %r12
movq 0x10(%r12), %rbx
xorl %eax, %eax
movq %rbx, %r15
xorl %r13d, %r13d
xorl %r10d, %r10d
subq $0x1, %r15
jb 0x4e824
movq 0x20(%r12), %rdx
xorl %esi, %esi
xorl %r14d, %r14d
cmpl $0x1, (%rdx,%rax)
sete %sil
setne %r14b
addq %r14, %r13
addq %rsi, %r10
addq $0x18, %rax
jmp 0x4e7fc
cmpq $0x11, %r10
setae %al
cmpq $0x11, %r13
setae %dl
orb %al, %dl
cmpb $0x1, %dl
jne 0x4e875
leaq 0x2133e(%rip), %rdx     # 0x6fb7e
pushq $0xf
popq %rsi
movq %r9, %rdi
movl $0x360, %ecx            # imm = 0x360
jmp 0x4e85f
leaq 0x2132a(%rip), %rdx     # 0x6fb7e
pushq $0xf
popq %rsi
movq %r9, %rdi
movl $0x353, %ecx            # imm = 0x353
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1429e
movl %ecx, 0x3c(%rsp)
movq %rdi, 0x40(%rsp)
movl %ebp, 0x24(%rsp)
movq %r10, 0x30(%rsp)
movq %r9, 0x8(%rsp)
imulq $0x18, %rbx, %rcx
addq $-0x10, %rcx
movq $0x0, 0x10(%rsp)
movq %r13, 0x48(%rsp)
movq $0x0, 0x28(%rsp)
movq %r12, 0x18(%rsp)
addq $-0x1, %rbx
jae 0x4e97c
cmpq $0x5, %r13
jb 0x4e97c
movq 0x20(%r12), %rax
cmpl $0x1, -0x8(%rax,%rcx)
je 0x4e973
movq %r13, %r15
movq %rcx, 0x58(%rsp)
movq (%rax,%rcx), %r13
movq %r8, %rdi
pushq $0x13
popq %rsi
movq %r8, %rbp
movq 0x8(%rsp), %r14
movq %r14, %rdx
callq 0x4c92b
cmpl $0x0, (%r14)
jne 0x4eb61
movq %rax, %r12
movq 0x10(%rsp), %r14
addq $0x4, %r14
movq 0x28(%rbp), %rax
movq 0x28(%rsp), %rcx
movq %rax, 0xc0(%rsp,%rcx,8)
incq %rcx
movq %rcx, 0x28(%rsp)
movl $0xe, 0x8(%r12)
movq %r13, %rdi
callq 0x4c214
movq %rax, 0x10(%r12)
movq $0xd, 0x18(%r12)
movl $0x1, 0x20(%r12)
movq %r14, 0x10(%rsp)
movl %r14d, 0x28(%r12)
movl $0x10001, 0x48(%r12)    # imm = 0x10001
movq %r15, %r13
decq %r13
movq %rbp, %r8
movq 0x18(%rsp), %r12
movq 0x58(%rsp), %rcx
addq $-0x18, %rcx
jmp 0x4e8b0
movq 0x10(%r12), %rbx
imulq $0x18, %rbx, %r15
addq $-0x10, %r15
xorl %ebp, %ebp
movq 0x30(%rsp), %rsi
movq %r13, 0x50(%rsp)
addq $-0x1, %rbx
jae 0x4ea32
cmpq $0x4, %rsi
jbe 0x4ea32
movq 0x20(%r12), %rax
cmpl $0x1, -0x8(%rax,%r15)
jne 0x4ea29
movq %rsi, %r14
movq 0x10(%rsp), %r13
addq $0x8, %r13
movq (%rax,%r15), %rsi
movq 0xc0(%r8), %rax
movq %r8, %r12
movq 0x48(%rax), %rax
movq %rax, 0x28(%rsp)
movq %r8, %rdi
callq 0x4c24a
movq %r12, %rdi
movq %rax, %rsi
pushq $0xd
popq %rdx
movq %r13, 0x10(%rsp)
movq %r13, %rcx
movq 0x8(%rsp), %r13
movq %r13, %r8
callq *0x28(%rsp)
cmpl $0x0, (%r13)
jne 0x4eb61
movq 0x28(%r12), %rax
movq %rax, 0x60(%rsp,%rbp,8)
incq %rbp
movq %r14, %rsi
decq %rsi
movq %r12, %r8
movq 0x18(%rsp), %r12
movq 0x50(%rsp), %r13
addq $-0x18, %r15
jmp 0x4e995
movq %r8, 0x10(%rsp)
pushq $0x8
popq %rbx
xorl %r14d, %r14d
xorl %r12d, %r12d
movq 0x8(%rsp), %r15
movq 0x18(%rsp), %rax
movq 0x10(%rax), %rax
cmpq %rax, %r14
jae 0x4eaad
cmpq %r13, %r12
jae 0x4eaad
movq 0x18(%rsp), %rax
movq 0x20(%rax), %rax
cmpl $0x0, -0x8(%rax,%rbx)
jne 0x4eaa4
movq %rsi, %rbp
movq (%rax,%rbx), %rdi
callq 0x4c214
subq $0x8, %rsp
movq 0x18(%rsp), %rdi
pushq $0xd
popq %rsi
pushq $0xe
popq %rdx
xorl %ecx, %ecx
movq %r12, %r8
movq %rax, %r9
pushq %r15
callq 0x4d518
popq %rax
popq %rcx
cmpl $0x0, (%r15)
jne 0x4eb61
incq %r12
movq %rbp, %rsi
incq %r14
addq $0x18, %rbx
jmp 0x4ea45
pushq $0x8
popq %rbx
xorl %r14d, %r14d
xorl %r13d, %r13d
movq 0x8(%rsp), %r15
movq 0x18(%rsp), %rdx
movq 0x10(%rsp), %r12
cmpq %rax, %r14
jae 0x4eb24
cmpq %rsi, %r13
jae 0x4eb24
movq 0x20(%rdx), %rcx
cmpl $0x1, -0x8(%rcx,%rbx)
jne 0x4eb1b
movq %rsi, %rbp
movq (%rcx,%rbx), %rsi
movq %r12, %rdi
callq 0x4c24a
movq 0xc0(%r12), %r8
movq %r12, %rdi
movq %r13, %rsi
movq %rax, %rdx
movq %r15, %rcx
callq *0x50(%r8)
cmpl $0x0, (%r15)
jne 0x4eb61
incq %r13
movq 0x18(%rsp), %rdx
movq 0x10(%rdx), %rax
movq 0x8(%rsp), %r15
movq %rbp, %rsi
incq %r14
addq $0x18, %rbx
jmp 0x4eac5
cmpl $0x0, (%r15)
movq 0x10(%rsp), %r14
jne 0x4eb61
subq $0x8, %rsp
pushq $0x15
popq %rsi
pushq $0xe
popq %rdx
pushq $0xd
popq %rcx
pushq $0x5
popq %r9
movl $0x4800, %r8d           # imm = 0x4800
movq %r14, %rdi
movq 0x10(%rsp), %rbx
pushq %rbx
pushq $0x0
pushq $0x1
callq 0x4d95f
addq $0x20, %rsp
cmpl $0x0, (%rbx)
je 0x4eb73
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x28(%r14), %r13
movq 0x40(%rsp), %rax
cmpq $0x0, 0x20(%rax)
je 0x4ebb6
movq 0x30(%rsp), %rax
cmpq $0x4, %rax
pushq $0x4
popq %r15
cmovbq %rax, %r15
movq 0xc0(%r14), %rax
movq %r14, %rdi
movl %r15d, %esi
movq 0x8(%rsp), %rbx
movq %rbx, %rdx
callq *0x28(%rax)
cmpl $0x0, (%rbx)
jne 0x4eb61
movq %rax, %rbp
jmp 0x4ebc1
movl $0x7fffffff, %r15d      # imm = 0x7FFFFFFF
movl $0x7fffffff, %ebp       # imm = 0x7FFFFFFF
cmpb $0x0, 0x24(%rsp)
movq 0x10(%rsp), %r14
je 0x4ebfa
subq $0x8, %rsp
pushq $0xd
popq %rsi
pushq $0xe
popq %rdx
pushq $0xe
popq %r8
pushq $0xf
popq %r9
movq %r14, %rdi
xorl %ecx, %ecx
movq 0x10(%rsp), %rbx
pushq %rbx
callq 0x4d518
popq %rax
popq %rcx
cmpl $0x0, (%rbx)
jne 0x4eb61
pushq $0x16
popq %rsi
movq %r14, %rdi
movq 0x8(%rsp), %rbx
movq %rbx, %rdx
callq 0x4c92b
cmpl $0x0, (%rbx)
jne 0x4eb61
movq %rax, %r12
movl $0xe, 0x8(%rax)
movb $0x1, 0xc(%rax)
movl 0x3c(%rsp), %eax
movl %eax, 0x10(%r12)
movq 0x18(%rsp), %rax
movq 0x8(%rax), %rax
cmpb $0x0, 0x24(%rsp)
je 0x4ec45
movq %rax, %rdi
callq 0x4c214
movq 0x10(%rsp), %rdi
movq %rax, 0x18(%r12)
movl 0x24(%rsp), %eax
movb %al, 0xe(%r12)
movq 0x28(%rdi), %rbx
movq 0x40(%rsp), %rax
cmpq $0x0, 0x20(%rax)
je 0x4ec92
movq 0xc0(%rdi), %rax
movl %r15d, %esi
movq %rdi, %r15
movq 0x8(%rsp), %r14
movq %r14, %rdx
callq *0x30(%rax)
cmpl $0x0, (%r14)
jne 0x4eb61
movq %rax, %r12
movq %r15, %rdi
jmp 0x4ec98
movl $0x7fffffff, %r12d      # imm = 0x7FFFFFFF
subq $0x8, %rsp
pushq $0x14
popq %rsi
pushq $0xe
popq %rdx
pushq $0xd
popq %rcx
pushq $0x5
popq %r9
movl $0x4800, %r8d           # imm = 0x4800
movq %rdi, %r15
movq 0x10(%rsp), %r14
pushq %r14
pushq $0x0
pushq $0x1
callq 0x4d95f
addq $0x20, %rsp
cmpl $0x0, (%r14)
jne 0x4eb61
movq 0x28(%r15), %rdx
subq $0x8, %rsp
leaq 0x68(%rsp), %rax
leaq 0xc8(%rsp), %r10
movq %r15, %rdi
movq %r13, %rsi
movq %rbp, %rcx
movq %r12, %r8
movq 0x50(%rsp), %r9
pushq 0x10(%rsp)
pushq %rax
pushq %r10
pushq %rbx
pushq 0x58(%rsp)
callq 0x4c395
addq $0x30, %rsp
jmp 0x4eb61