// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x60, %rsp
movq 0x10(%rbp), %rax
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movl %ecx, -0x20(%rbp)
movl %r8d, -0x24(%rbp)
movq %r9, -0x30(%rbp)
movl -0x1c(%rbp), %eax
movl %eax, -0x58(%rbp)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
movq 0x10(%rbp), %rcx
movq -0x58(%rbp), %rdx
movl $0x1b, %esi
callq 0x38490
movq %rax, -0x38(%rbp)
movq 0x10(%rbp), %rax
cmpl $0x0, (%rax)
je 0x51214
jmp 0x5139c
movq -0x10(%rbp), %rax
movq 0x68(%rax), %rdi
movq 0x10(%rbp), %rcx
leaq 0x5a939(%rip), %rsi     # 0xabb60
xorl %eax, %eax
movl %eax, %edx
callq 0x3c920
movq %rax, -0x48(%rbp)
movq 0x10(%rbp), %rax
cmpl $0x0, (%rax)
je 0x51242
jmp 0x5139c
movq -0x10(%rbp), %rdi
movq -0x48(%rbp), %rax
movq (%rax), %rdx
movq -0x38(%rbp), %r8
movq 0x10(%rbp), %rax
leaq 0x5a904(%rip), %rsi     # 0xabb60
movl $0x2, %ecx
movl $0x1, %r9d
movq %rax, (%rsp)
callq 0x6e3e0
movq %rax, -0x50(%rbp)
movq 0x10(%rbp), %rax
cmpl $0x0, (%rax)
je 0x51282
jmp 0x5139c
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
andl -0x20(%rbp), %eax
cmpl $0x0, %eax
je 0x512c8
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
movl -0x24(%rbp), %esi
movq -0x18(%rbp), %rax
movq 0x10(%rbp), %r8
movq 0x148(%rax), %rdx
movq -0x50(%rbp), %rcx
callq 0x38230
movq %rax, -0x38(%rbp)
movq 0x10(%rbp), %rax
cmpl $0x0, (%rax)
je 0x512c6
jmp 0x5139c
jmp 0x5130f
movq -0x30(%rbp), %rax
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rcx
movslq 0x148(%rcx), %rsi
movq -0x50(%rbp), %rdx
movq 0x10(%rbp), %rcx
callq *%rax
movq %rax, -0x40(%rbp)
movq 0x10(%rbp), %rax
cmpl $0x0, (%rax)
je 0x512f7
jmp 0x5139c
movq -0x40(%rbp), %rax
movq 0x148(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x40(%rbp), %rdi
callq 0x36ee0
movq -0x18(%rbp), %rdi
callq 0x36ee0
movq $0x0, -0x18(%rbp)
movq -0x10(%rbp), %rdi
movq -0x48(%rbp), %rax
movq (%rax), %rdx
movq -0x38(%rbp), %rcx
movq 0x10(%rbp), %r8
movl $0x2, %esi
callq 0x6dc50
movq 0x10(%rbp), %rax
cmpl $0x0, (%rax)
je 0x51350
movq $0x0, -0x8(%rbp)
jmp 0x513ad
movq -0x10(%rbp), %rdi
movq -0x48(%rbp), %rax
movq (%rax), %rdx
movq 0x10(%rbp), %rcx
movl $0x2, %esi
callq 0x6d920
movq %rax, -0x50(%rbp)
movq 0x10(%rbp), %rax
cmpl $0x0, (%rax)
je 0x51380
movq $0x0, -0x8(%rbp)
jmp 0x513ad
movq -0x50(%rbp), %rax
movl %eax, %esi
movq 0x10(%rbp), %rdx
leaq 0x5a7cf(%rip), %rdi     # 0xabb60
callq 0x37590
movq %rax, -0x8(%rbp)
jmp 0x513ad
movq -0x18(%rbp), %rdi
callq 0x36ee0
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x60, %rsp
popq %rbp
retq
nopw (%rax,%rax)