// File: /workspace/github_c_makefile_star2_O3/markdryan[P]subtilis/frontend/int32_type.c
// Function: prv_to_string_common
static subtilis_exp_t *prv_to_string_common(subtilis_parser_t *p,
					    subtilis_exp_t *e, int32_t buf_size,
					    subtilis_backend_caps_t cap,
					    subtilis_op_instr_type_t op_code,
					    subtilis_int32_type_format_t fn,
					    subtilis_error_t *err)
{
	size_t size_reg;
	subtilis_exp_t *sizee;
	const subtilis_symbol_t *s;
	subtilis_ir_operand_t op0;
	subtilis_ir_operand_t op1;

	op1.integer = buf_size;
	size_reg = subtilis_ir_section_add_instr2(
	    p->current, SUBTILIS_OP_INSTR_MOVI_I32, op1, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto on_error;

	s = subtilis_symbol_table_insert_tmp(p->local_st, &subtilis_type_string,
					     NULL, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto on_error;

	/*
	 * Here we allocate more memory then we probably need but it saves
	 * us a memcpy.
	 */

	op0.reg = subtilis_reference_type_alloc(p, &subtilis_type_string,
						s->loc, SUBTILIS_IR_REG_LOCAL,
						size_reg, true, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto on_error;

	if (p->backend.caps & cap) {
		size_reg = subtilis_ir_section_add_instr(
		    p->current, op_code, e->exp.ir_op, op0, err);
		if (err->type != SUBTILIS_ERROR_OK)
			goto on_error;
	} else {
		sizee = fn(p, e->exp.ir_op.integer, op0.reg, err);
		if (err->type != SUBTILIS_ERROR_OK)
			goto on_error;
		size_reg = sizee->exp.ir_op.reg;
		subtilis_exp_delete(sizee);
	}

	subtilis_exp_delete(e);
	e = NULL;

	subtilis_reference_type_set_size(p, SUBTILIS_IR_REG_LOCAL, s->loc,
					 size_reg, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return NULL;

	op0.reg = subtilis_reference_get_pointer(p, SUBTILIS_IR_REG_LOCAL,
						 s->loc, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return NULL;

	return subtilis_exp_new_var(&subtilis_type_string, op0.reg, err);

on_error:

	subtilis_exp_delete(e);
	return NULL;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r9, %rbx
movq %r8, 0x10(%rsp)
movl %ecx, %ebp
movl %edx, %r12d
movq %rsi, %r15
movq %rdi, %r14
movq 0x48(%rdi), %rdi
movl $0x10, %edx
movl $0x1b, %esi
movq %r9, %rcx
callq 0x2be09
cmpl $0x0, (%rbx)
jne 0x3bae2
movq %rax, %r13
movq 0x68(%r14), %rdi
leaq 0x39103(%rip), %rsi     # 0x74ba8
xorl %edx, %edx
movq %rbx, %rcx
callq 0x2e6f1
cmpl $0x0, (%rbx)
jne 0x3bae2
movq (%rax), %rdx
movq %rbx, (%rsp)
leaq 0x390e6(%rip), %rsi     # 0x74ba8
movq %rax, 0x8(%rsp)
movl $0x2, %ecx
movq %r14, %rdi
movq %r13, %r8
movl $0x1, %r9d
callq 0x4ddaa
cmpl $0x0, (%rbx)
je 0x3bafb
movq %r15, %rdi
callq 0x2b166
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testl %r12d, 0x8(%r14)
je 0x3bb23
movq 0x48(%r14), %rdi
movq 0x148(%r15), %rdx
movl %ebp, %esi
movq %rax, %rcx
movq %rbx, %r8
callq 0x2bc8f
cmpl $0x0, (%rbx)
jne 0x3bae2
movq %rax, %r12
jmp 0x3bb4b
movslq 0x148(%r15), %rsi
movq %r14, %rdi
movq %rax, %rdx
movq %rbx, %rcx
callq *0x10(%rsp)
cmpl $0x0, (%rbx)
jne 0x3bae2
movq 0x148(%rax), %r12
movq %rax, %rdi
callq 0x2b166
movq %r15, %rdi
callq 0x2b166
movq 0x8(%rsp), %r15
movq (%r15), %rdx
movl $0x2, %esi
movq %r14, %rdi
movq %r12, %rcx
movq %rbx, %r8
callq 0x4d8dd
cmpl $0x0, (%rbx)
jne 0x3baea
movq (%r15), %rdx
movl $0x2, %esi
movq %r14, %rdi
movq %rbx, %rcx
callq 0x4d71f
cmpl $0x0, (%rbx)
jne 0x3baea
leaq 0x3900e(%rip), %rdi     # 0x74ba8
movl %eax, %esi
movq %rbx, %rdx
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2b5fb