// File: /workspace/github_c_makefile_star2_O3/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, %r15
movq %rsi, 0x18(%rsp)
movq %rdi, %r14
leaq 0x4174f(%rip), %r8      # 0x74918
leaq 0x20(%rsp), %rcx
movq %r8, (%rcx)
movq %r8, 0x8(%rcx)
movq %r8, 0x10(%rcx)
movq %r8, 0x18(%rcx)
subq $0x8, %rsp
leaq 0x42098(%rip), %rsi     # 0x75280
movl $0x4, %edx
xorl %r9d, %r9d
pushq %rbx
callq 0x34176
addq $0x10, %rsp
movq %rax, %r12
movl (%rbx), %eax
testl %eax, %eax
je 0x332ab
cmpl $0x20, %eax
jne 0x33383
movq %rbx, %rdi
callq 0x143b4
movq %r15, %r12
movl $0x60, %edi
callq 0x121d0
testq %rax, %rax
je 0x33316
movq %rax, %r15
movl $0xa, %edi
callq 0x121d0
testq %rax, %rax
je 0x33331
movabsq $0x6f72675f6665725f, %rcx # imm = 0x6F72675F6665725F
movq %rcx, (%rax)
movw $0x77, 0x8(%rax)
xorl %ecx, %ecx
movl %ecx, (%r15)
movq 0x18(%rsp), %rdx
movq %rdx, 0x8(%r15)
movl %ecx, 0x18(%r15)
movq %r12, 0x20(%r15)
movl %ecx, 0x30(%r15)
movq %rbp, 0x38(%r15)
movl %ecx, 0x48(%r15)
movq %r13, 0x50(%r15)
subq $0x8, %rsp
leaq 0x41690(%rip), %r9      # 0x74918
movq %r14, %rdi
movq %rax, %rsi
movl $0x9, %edx
xorl %ecx, %ecx
movq %r15, %r8
pushq %rbx
pushq $0x1
pushq $0x4
callq 0x2b1aa
addq $0x68, %rsp
jmp 0x33389
movq %r15, (%rsp)
movq %rbp, 0x8(%rsp)
movq %r13, 0x10(%rsp)
movq 0x48(%r14), %rbp
movq %r12, 0x48(%r14)
movq 0x98(%r12), %r13
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 0x4e3a7
addq $0x10, %rsp
cmpl $0x0, (%rbx)
jne 0x33310
movq %r12, %rdi
movq %r13, %rsi
movq %rbx, %rdx
callq 0x2cca6
cmpl $0x0, (%rbx)
je 0x33354
movq %rbp, 0x48(%r14)
jmp 0x33383
leaq 0x41f4c(%rip), %rdx     # 0x75269
movq %rbx, %rdi
movl $0x1, %esi
movl $0xa29, %ecx            # imm = 0xA29
callq 0x145a4
jmp 0x33383
leaq 0x41f31(%rip), %rdx     # 0x75269
movq %rbx, %rdi
movl $0x1, %esi
movl $0xa2f, %ecx            # imm = 0xA2F
callq 0x145a4
movq %r15, %rdi
callq 0x122c0
jmp 0x33383
movq 0x48(%r14), %rdi
movl $0x47, %esi
movq %r15, %rdx
movq %rbx, %rcx
callq 0x2be1f
cmpl $0x0, (%rbx)
movq %rbp, 0x48(%r14)
movq 0x10(%rsp), %r13
movq 0x8(%rsp), %rbp
movq (%rsp), %r15
je 0x33218
xorl %eax, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq