// File: /workspace/github_c_makefile_star2_O0/markdryan[P]subtilis/frontend/builtins_ir.c
// Function: subtilis_builtin_ir_call_ref_grow
subtilis_exp_t *
subtilis_builtin_ir_call_ref_grow(subtilis_parser_t *p, size_t a1_mem_reg,
				  size_t a1_size_reg, size_t gran_reg,
				  size_t a2_size_reg, subtilis_error_t *err)
{
	subtilis_ir_section_t *fn;
	subtilis_ir_arg_t *args = NULL;
	char *name_dup = NULL;
	const subtilis_type_t *ptype[4];
	const char *const name = "_ref_grow";

	ptype[0] = &subtilis_type_integer;
	ptype[1] = &subtilis_type_integer;
	ptype[2] = &subtilis_type_integer;
	ptype[3] = &subtilis_type_integer;

	fn = prv_add_args(p, name, 4, ptype, &subtilis_type_integer, err);
	if (err->type != SUBTILIS_ERROR_OK) {
		if (err->type != SUBTILIS_ERROR_ALREADY_DEFINED)
			return NULL;
		subtilis_error_init(err);
	} else {
		prv_builtins_ir_gen_ref_grow(p, fn, err);
		if (err->type != SUBTILIS_ERROR_OK)
			return NULL;
	}

	args = malloc(sizeof(*args) * 4);
	if (!args) {
		subtilis_error_set_oom(err);
		return NULL;
	}

	name_dup = malloc(strlen(name) + 1);
	if (!name_dup) {
		subtilis_error_set_oom(err);
		goto cleanup;
	}
	strcpy(name_dup, name);

	args[0].type = SUBTILIS_IR_REG_TYPE_INTEGER;
	args[0].reg = a1_mem_reg;
	args[1].type = SUBTILIS_IR_REG_TYPE_INTEGER;
	args[1].reg = a1_size_reg;
	args[2].type = SUBTILIS_IR_REG_TYPE_INTEGER;
	args[2].reg = gran_reg;
	args[3].type = SUBTILIS_IR_REG_TYPE_INTEGER;
	args[3].reg = a2_size_reg;

	return subtilis_exp_add_call(p, name_dup, SUBTILIS_BUILTINS_MAX, NULL,
				     args, &subtilis_type_integer, 4, true,
				     err);

cleanup:
	free(args);

	return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
movq $0x0, -0x48(%rbp)
movq $0x0, -0x50(%rbp)
leaq 0x6958f(%rip), %rax     # 0xac269
movq %rax, -0x78(%rbp)
leaq 0x68beb(%rip), %rax     # 0xab8d0
movq %rax, -0x70(%rbp)
leaq 0x68be0(%rip), %rax     # 0xab8d0
movq %rax, -0x68(%rbp)
leaq 0x68bd5(%rip), %rax     # 0xab8d0
movq %rax, -0x60(%rbp)
leaq 0x68bca(%rip), %rax     # 0xab8d0
movq %rax, -0x58(%rbp)
movq -0x10(%rbp), %rdi
leaq -0x70(%rbp), %rcx
movq -0x38(%rbp), %r9
leaq 0x6954c(%rip), %rsi     # 0xac269
movl $0x4, %edx
leaq 0x68ba7(%rip), %r8      # 0xab8d0
callq 0x42960
movq %rax, -0x40(%rbp)
movq -0x38(%rbp), %rax
cmpl $0x0, (%rax)
je 0x42d5c
movq -0x38(%rbp), %rax
cmpl $0x20, (%rax)
je 0x42d51
movq $0x0, -0x8(%rbp)
jmp 0x42eaf
movq -0x38(%rbp), %rdi
callq 0x15670
jmp 0x42d85
movq -0x10(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq -0x38(%rbp), %rdx
callq 0x42ec0
movq -0x38(%rbp), %rax
cmpl $0x0, (%rax)
je 0x42d83
movq $0x0, -0x8(%rbp)
jmp 0x42eaf
jmp 0x42d85
movl $0x60, %edi
callq 0x121b0
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
jne 0x42dc1
movq -0x38(%rbp), %rdi
movl $0x1, %esi
leaq 0x694a8(%rip), %rdx     # 0xac252
movl $0xa29, %ecx            # imm = 0xA29
callq 0x158e0
movq $0x0, -0x8(%rbp)
jmp 0x42eaf
movl $0xa, %edi
callq 0x121b0
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
jne 0x42df5
movq -0x38(%rbp), %rdi
movl $0x1, %esi
leaq 0x6946c(%rip), %rdx     # 0xac252
movl $0xa2f, %ecx            # imm = 0xA2F
callq 0x158e0
jmp 0x42e9e
movq -0x50(%rbp), %rdi
leaq 0x69469(%rip), %rsi     # 0xac269
callq 0x12060
movq -0x48(%rbp), %rax
movl $0x0, (%rax)
movq -0x18(%rbp), %rcx
movq -0x48(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x48(%rbp), %rax
movl $0x0, 0x18(%rax)
movq -0x20(%rbp), %rcx
movq -0x48(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x48(%rbp), %rax
movl $0x0, 0x30(%rax)
movq -0x28(%rbp), %rcx
movq -0x48(%rbp), %rax
movq %rcx, 0x38(%rax)
movq -0x48(%rbp), %rax
movl $0x0, 0x48(%rax)
movq -0x30(%rbp), %rcx
movq -0x48(%rbp), %rax
movq %rcx, 0x50(%rax)
movq -0x10(%rbp), %rdi
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %r8
movq -0x38(%rbp), %rax
movl $0x9, %edx
xorl %ecx, %ecx
leaq 0x68a52(%rip), %r9      # 0xab8d0
movq $0x4, (%rsp)
movl $0x1, 0x8(%rsp)
movq %rax, 0x10(%rsp)
callq 0x36f50
movq %rax, -0x8(%rbp)
jmp 0x42eaf
movq -0x48(%rbp), %rdi
callq 0x12290
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x90, %rsp
popq %rbp
retq
nopl (%rax)