// File: /workspace/github_c_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %r9, %rbx
movq %r8, %r13
movq %rcx, %rbp
movq %rdx, 0x18(%rsp)
movq %rsi, 0x10(%rsp)
movq %rdi, %r14
leaq 0x41568(%rip), %r8      # 0x748f8
leaq 0x20(%rsp), %rcx
movq %r8, (%rcx)
movq %r8, 0x8(%rcx)
movq %r8, 0x10(%rcx)
movq %r8, 0x18(%rcx)
subq $0x8, %rsp
leaq 0x41eb1(%rip), %rsi     # 0x75260
movl $0x4, %edx
xorl %r9d, %r9d
pushq %rbx
callq 0x34307
addq $0x10, %rsp
movq %rax, %r12
movl (%rbx), %eax
testl %eax, %eax
je 0x333e0
cmpl $0x20, %eax
jne 0x33531
movq %rbx, %rdi
callq 0x14404
jmp 0x33467
movq %rbp, 0x8(%rsp)
movq 0x48(%r14), %rbp
movq %r12, 0x48(%r14)
movq 0x98(%r12), %rax
movq %rax, (%rsp)
movq 0xa8(%r12), %r15
movl $0x4, %edx
movl $0x5, %ecx
movl $0x6, %r8d
movl $0x7, %r9d
movq %r14, %rdi
xorl %esi, %esi
pushq %rbx
pushq %r15
callq 0x4e3eb
addq $0x10, %rsp
cmpl $0x0, (%rbx)
jne 0x33455
movq %r12, %rdi
movq (%rsp), %rsi
movq %rbx, %rdx
callq 0x2d017
cmpl $0x0, (%rbx)
jne 0x33455
movq 0x48(%r14), %rdi
movl $0x47, %esi
movq %r15, %rdx
movq %rbx, %rcx
callq 0x2c19f
movq %rbp, 0x48(%r14)
cmpl $0x0, (%rbx)
movq 0x8(%rsp), %rbp
jne 0x33531
movl $0x60, %edi
callq 0x121d0
testq %rax, %rax
je 0x334f5
movq %rax, %r15
movl $0xa, %edi
callq 0x121d0
testq %rax, %rax
je 0x33510
movabsq $0x6f72675f6665725f, %rcx # imm = 0x6F72675F6665725F
movq %rcx, (%rax)
movw $0x77, 0x8(%rax)
xorl %ecx, %ecx
movl %ecx, (%r15)
movq 0x10(%rsp), %rdx
movq %rdx, 0x8(%r15)
movl %ecx, 0x18(%r15)
movq 0x18(%rsp), %rdx
movq %rdx, 0x20(%r15)
movl %ecx, 0x30(%r15)
movq %rbp, 0x38(%r15)
movl %ecx, 0x48(%r15)
movq %r13, 0x50(%r15)
subq $0x8, %rsp
leaq 0x41423(%rip), %r9      # 0x748f8
movq %r14, %rdi
movq %rax, %rsi
movl $0x9, %edx
xorl %ecx, %ecx
movq %r15, %r8
pushq %rbx
pushq $0x1
pushq $0x4
callq 0x2b507
addq $0x68, %rsp
jmp 0x33537
leaq 0x41d4d(%rip), %rdx     # 0x75249
movq %rbx, %rdi
movl $0x1, %esi
movl $0xa29, %ecx            # imm = 0xA29
callq 0x145f4
jmp 0x33531
leaq 0x41d32(%rip), %rdx     # 0x75249
movq %rbx, %rdi
movl $0x1, %esi
movl $0xa2f, %ecx            # imm = 0xA2F
callq 0x145f4
movq %r15, %rdi
callq 0x122c0
xorl %eax, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq