// File: /workspace/github_c_makefile_star2_O2/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
pushq $0x1b
popq %rsi
pushq $0x10
popq %rdx
movq %r9, %rcx
callq 0x2a981
cmpl $0x0, (%rbx)
jne 0x39909
movq %rax, %r13
movq 0x68(%r14), %rdi
leaq 0x35288(%rip), %rsi     # 0x6eb58
xorl %edx, %edx
movq %rbx, %rcx
callq 0x2cee3
cmpl $0x0, (%rbx)
jne 0x39909
movq (%rax), %rdx
movq %rbx, (%rsp)
leaq 0x3526b(%rip), %rsi     # 0x6eb58
movq %rax, 0x8(%rsp)
pushq $0x2
popq %rcx
pushq $0x1
popq %r9
movq %r14, %rdi
movq %r13, %r8
callq 0x4b101
cmpl $0x0, (%rbx)
je 0x39922
movq %r15, %rdi
callq 0x29d88
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testl %r12d, 0x8(%r14)
je 0x3994a
movq 0x48(%r14), %rdi
movq 0x148(%r15), %rdx
movl %ebp, %esi
movq %rax, %rcx
movq %rbx, %r8
callq 0x2a819
cmpl $0x0, (%rbx)
jne 0x39909
movq %rax, %r12
jmp 0x39972
movslq 0x148(%r15), %rsi
movq %r14, %rdi
movq %rax, %rdx
movq %rbx, %rcx
callq *0x10(%rsp)
cmpl $0x0, (%rbx)
jne 0x39909
movq 0x148(%rax), %r12
movq %rax, %rdi
callq 0x29d88
movq %r15, %rdi
callq 0x29d88
movq 0x8(%rsp), %r15
movq (%r15), %rdx
pushq $0x2
popq %rsi
movq %r14, %rdi
movq %r12, %rcx
movq %rbx, %r8
callq 0x4acc2
cmpl $0x0, (%rbx)
jne 0x39911
movq (%r15), %rdx
pushq $0x2
popq %rsi
movq %r14, %rdi
movq %rbx, %rcx
callq 0x4ab28
cmpl $0x0, (%rbx)
jne 0x39911
leaq 0x3519b(%rip), %rdi     # 0x6eb58
movl %eax, %esi
movq %rbx, %rdx
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2a226