// File: /workspace/github_c_makefile_star2_O0/markdryan[P]subtilis/arch/arm32/arm_reg_alloc.c
// Function: prv_new_regs
static subtilis_arm_reg_class_t *prv_new_regs(
	size_t reg_count, size_t max_regs, size_t reg_start, size_t reg_size,
	size_t args, int32_t max_offset, subtilis_arm_reg_spill_imm_t spill_imm,
	subtilis_arm_reg_stran_imm_t stran_imm,
	subtilis_arm_instr_type_t store_type,
	subtilis_arm_instr_type_t load_type,
	subtilis_arm_fp_is_fixed_t is_fixed, subtilis_error_t *err)

/* clang-format on */
{
	size_t i;
	size_t index;
	subtilis_arm_reg_class_t *regs;
	size_t reg_args = 4;

	regs = calloc(sizeof(*regs), 1);
	if (!regs) {
		subtilis_error_set_oom(err);
		goto on_error;
	}

	regs->phys_to_virt = malloc(sizeof(*regs->phys_to_virt) * max_regs);
	if (!regs->phys_to_virt) {
		subtilis_error_set_oom(err);
		goto on_error;
	}

	regs->next = malloc(sizeof(*regs->next) * max_regs);
	if (!regs->next) {
		subtilis_error_set_oom(err);
		goto on_error;
	}

	if (args <= reg_args) {
		reg_args = args;
		regs->spill_top = 0;
	} else {
		regs->spill_top = args - reg_args;
	}

	regs->spilt_regs = malloc(reg_count * sizeof(int32_t));
	if (!regs->spilt_regs) {
		subtilis_error_set_oom(err);
		goto on_error;
	}
	regs->spill_stack = malloc(reg_count * sizeof(size_t));
	if (!regs->spill_stack) {
		subtilis_error_set_oom(err);
		goto on_error;
	}
	regs->max_regs = max_regs;
	regs->spill_max = regs->spill_top;
	regs->reg_size = reg_size;
	regs->spill_imm = spill_imm;
	regs->stran_imm = stran_imm;
	regs->store_type = store_type;
	regs->load_type = load_type;
	regs->max_offset = max_offset;
	regs->is_fixed = is_fixed;

	for (i = 0; i < reg_count; i++) {
		regs->spilt_regs[i] = -1;
		regs->spill_stack[i] = i * reg_size;
	}
	regs->vr_reg_count = reg_count;

	for (i = 0; i < reg_args; i++) {
		regs->next[i] = -1;
		regs->phys_to_virt[i] = i + reg_start;
	}

	for (; i < max_regs; i++) {
		regs->next[i] = -1;
		regs->phys_to_virt[i] = INT_MAX;
	}

	for (i = reg_args; i < args; i++) {
		index = i - reg_args;
		regs->spilt_regs[i + reg_start] = index * reg_size;
	}

	if (i > reg_args) {
		regs->spilt_args = i - reg_args;
		regs->spill_top = regs->spilt_args;
		regs->spill_max = regs->spill_top;
		for (i = 0; i < regs->spilt_args; i++)
			regs->spill_stack[i] = INT_MAX;
	} else {
		regs->spilt_args = 0;
	}

	regs->spill_points = NULL;
	regs->spill_points_count = 0;
	regs->spill_points_max = 0;

	return regs;

on_error:

	free(regs->spilt_regs);
	free(regs->next);
	free(regs->phys_to_virt);
	free(regs);

	return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq 0x38(%rbp), %rax
movq 0x30(%rbp), %rax
movl 0x28(%rbp), %eax
movl 0x20(%rbp), %eax
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movl %r9d, -0x34(%rbp)
movq $0x4, -0x58(%rbp)
movl $0x2e0, %edi            # imm = 0x2E0
movl $0x1, %esi
callq 0x12130
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
jne 0x7a647
movq 0x38(%rbp), %rdi
movl $0x1, %esi
leaq 0x3255b(%rip), %rdx     # 0xacb93
movl $0x153, %ecx            # imm = 0x153
callq 0x158e0
jmp 0x7a9ca
movq -0x18(%rbp), %rdi
shlq $0x3, %rdi
callq 0x121b0
movq %rax, %rcx
movq -0x50(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x50(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jne 0x7a689
movq 0x38(%rbp), %rdi
movl $0x1, %esi
leaq 0x32519(%rip), %rdx     # 0xacb93
movl $0x159, %ecx            # imm = 0x159
callq 0x158e0
jmp 0x7a9ca
movq -0x18(%rbp), %rdi
shlq $0x2, %rdi
callq 0x121b0
movq %rax, %rcx
movq -0x50(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x50(%rbp), %rax
cmpq $0x0, 0x10(%rax)
jne 0x7a6cb
movq 0x38(%rbp), %rdi
movl $0x1, %esi
leaq 0x324d7(%rip), %rdx     # 0xacb93
movl $0x15f, %ecx            # imm = 0x15F
callq 0x158e0
jmp 0x7a9ca
movq -0x30(%rbp), %rax
cmpq -0x58(%rbp), %rax
ja 0x7a6eb
movq -0x30(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x50(%rbp), %rax
movq $0x0, 0x30(%rax)
jmp 0x7a6fb
movq -0x30(%rbp), %rcx
subq -0x58(%rbp), %rcx
movq -0x50(%rbp), %rax
movq %rcx, 0x30(%rax)
movq -0x10(%rbp), %rdi
shlq $0x2, %rdi
callq 0x121b0
movq %rax, %rcx
movq -0x50(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x50(%rbp), %rax
cmpq $0x0, 0x20(%rax)
jne 0x7a73d
movq 0x38(%rbp), %rdi
movl $0x1, %esi
leaq 0x32465(%rip), %rdx     # 0xacb93
movl $0x16c, %ecx            # imm = 0x16C
callq 0x158e0
jmp 0x7a9ca
movq -0x10(%rbp), %rdi
shlq $0x3, %rdi
callq 0x121b0
movq %rax, %rcx
movq -0x50(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x50(%rbp), %rax
cmpq $0x0, 0x28(%rax)
jne 0x7a77f
movq 0x38(%rbp), %rdi
movl $0x1, %esi
leaq 0x32423(%rip), %rdx     # 0xacb93
movl $0x171, %ecx            # imm = 0x171
callq 0x158e0
jmp 0x7a9ca
movq -0x18(%rbp), %rcx
movq -0x50(%rbp), %rax
movq %rcx, (%rax)
movq -0x50(%rbp), %rax
movq 0x30(%rax), %rcx
movq -0x50(%rbp), %rax
movq %rcx, 0x38(%rax)
movq -0x28(%rbp), %rcx
movq -0x50(%rbp), %rax
movq %rcx, 0x40(%rax)
movq 0x10(%rbp), %rcx
movq -0x50(%rbp), %rax
movq %rcx, 0x58(%rax)
movq 0x18(%rbp), %rcx
movq -0x50(%rbp), %rax
movq %rcx, 0x60(%rax)
movl 0x20(%rbp), %ecx
movq -0x50(%rbp), %rax
movl %ecx, 0x68(%rax)
movl 0x28(%rbp), %ecx
movq -0x50(%rbp), %rax
movl %ecx, 0x6c(%rax)
movl -0x34(%rbp), %ecx
movq -0x50(%rbp), %rax
movl %ecx, 0x48(%rax)
movq 0x30(%rbp), %rcx
movq -0x50(%rbp), %rax
movq %rcx, 0x70(%rax)
movq $0x0, -0x40(%rbp)
movq -0x40(%rbp), %rax
cmpq -0x10(%rbp), %rax
jae 0x7a834
movq -0x50(%rbp), %rax
movq 0x20(%rax), %rax
movq -0x40(%rbp), %rcx
movl $0xffffffff, (%rax,%rcx,4) # imm = 0xFFFFFFFF
movq -0x40(%rbp), %rdx
imulq -0x28(%rbp), %rdx
movq -0x50(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x40(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
jmp 0x7a7f0
movq -0x10(%rbp), %rcx
movq -0x50(%rbp), %rax
movq %rcx, 0x18(%rax)
movq $0x0, -0x40(%rbp)
movq -0x40(%rbp), %rax
cmpq -0x58(%rbp), %rax
jae 0x7a88b
movq -0x50(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x40(%rbp), %rcx
movl $0xffffffff, (%rax,%rcx,4) # imm = 0xFFFFFFFF
movq -0x40(%rbp), %rdx
addq -0x20(%rbp), %rdx
movq -0x50(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x40(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
jmp 0x7a848
jmp 0x7a88d
movq -0x40(%rbp), %rax
cmpq -0x18(%rbp), %rax
jae 0x7a8cc
movq -0x50(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x40(%rbp), %rcx
movl $0xffffffff, (%rax,%rcx,4) # imm = 0xFFFFFFFF
movq -0x50(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x40(%rbp), %rcx
movq $0x7fffffff, (%rax,%rcx,8) # imm = 0x7FFFFFFF
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
jmp 0x7a88d
movq -0x58(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
cmpq -0x30(%rbp), %rax
jae 0x7a916
movq -0x40(%rbp), %rax
subq -0x58(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
imulq -0x28(%rbp), %rax
movl %eax, %edx
movq -0x50(%rbp), %rax
movq 0x20(%rax), %rax
movq -0x40(%rbp), %rcx
addq -0x20(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
jmp 0x7a8d4
movq -0x40(%rbp), %rax
cmpq -0x58(%rbp), %rax
jbe 0x7a98a
movq -0x40(%rbp), %rcx
subq -0x58(%rbp), %rcx
movq -0x50(%rbp), %rax
movq %rcx, 0x50(%rax)
movq -0x50(%rbp), %rax
movq 0x50(%rax), %rcx
movq -0x50(%rbp), %rax
movq %rcx, 0x30(%rax)
movq -0x50(%rbp), %rax
movq 0x30(%rax), %rcx
movq -0x50(%rbp), %rax
movq %rcx, 0x38(%rax)
movq $0x0, -0x40(%rbp)
movq -0x40(%rbp), %rax
movq -0x50(%rbp), %rcx
cmpq 0x50(%rcx), %rax
jae 0x7a988
movq -0x50(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x40(%rbp), %rcx
movq $0x7fffffff, (%rax,%rcx,8) # imm = 0x7FFFFFFF
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
jmp 0x7a958
jmp 0x7a996
movq -0x50(%rbp), %rax
movq $0x0, 0x50(%rax)
movq -0x50(%rbp), %rax
movq $0x0, 0x78(%rax)
movq -0x50(%rbp), %rax
movq $0x0, 0x80(%rax)
movq -0x50(%rbp), %rax
movq $0x0, 0x88(%rax)
movq -0x50(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x7aa02
movq -0x50(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x12290
movq -0x50(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x12290
movq -0x50(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x12290
movq -0x50(%rbp), %rdi
callq 0x12290
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax)