// File: /workspace/github_c_makefile_star2_O1/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 0x2c189
cmpl $0x0, (%rbx)
jne 0x3bc29
movq %rax, %r13
movq 0x68(%r14), %rdi
leaq 0x38f9c(%rip), %rsi     # 0x74b88
xorl %edx, %edx
movq %rbx, %rcx
callq 0x2ea12
cmpl $0x0, (%rbx)
jne 0x3bc29
movq (%rax), %rdx
movq %rbx, (%rsp)
leaq 0x38f7f(%rip), %rsi     # 0x74b88
movq %rax, 0x8(%rsp)
movl $0x2, %ecx
movq %r14, %rdi
movq %r13, %r8
movl $0x1, %r9d
callq 0x4ddee
cmpl $0x0, (%rbx)
je 0x3bc42
movq %r15, %rdi
callq 0x2b4c3
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testl %r12d, 0x8(%r14)
je 0x3bc6a
movq 0x48(%r14), %rdi
movq 0x148(%r15), %rdx
movl %ebp, %esi
movq %rax, %rcx
movq %rbx, %r8
callq 0x2c00f
cmpl $0x0, (%rbx)
jne 0x3bc29
movq %rax, %r12
jmp 0x3bc92
movslq 0x148(%r15), %rsi
movq %r14, %rdi
movq %rax, %rdx
movq %rbx, %rcx
callq *0x10(%rsp)
cmpl $0x0, (%rbx)
jne 0x3bc29
movq 0x148(%rax), %r12
movq %rax, %rdi
callq 0x2b4c3
movq %r15, %rdi
callq 0x2b4c3
movq 0x8(%rsp), %r15
movq (%r15), %rdx
movl $0x2, %esi
movq %r14, %rdi
movq %r12, %rcx
movq %rbx, %r8
callq 0x4d921
cmpl $0x0, (%rbx)
jne 0x3bc31
movq (%r15), %rdx
movl $0x2, %esi
movq %r14, %rdi
movq %rbx, %rcx
callq 0x4d763
cmpl $0x0, (%rbx)
jne 0x3bc31
leaq 0x38ea7(%rip), %rdi     # 0x74b88
movl %eax, %esi
movq %rbx, %rdx
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2b971