// File: /workspace/github_c_makefile_star2_O2/markdryan[P]subtilis/frontend/string_type.c
// Function: subtilis_string_new_str_from_zt
subtilis_exp_t *subtilis_string_new_str_from_zt(subtilis_parser_t *p,
						size_t reg,
						subtilis_error_t *err)
{
	subtilis_ir_operand_t zero;
	subtilis_ir_operand_t one;
	subtilis_ir_operand_t reg_copy;
	subtilis_ir_operand_t reg_orig;
	subtilis_ir_operand_t byte;
	subtilis_ir_operand_t size;
	subtilis_ir_operand_t start;
	subtilis_ir_operand_t next;
	subtilis_ir_operand_t end;
	subtilis_ir_operand_t empty;
	subtilis_ir_operand_t full;
	subtilis_ir_operand_t real_end;
	const subtilis_symbol_t *s;
	subtilis_exp_t *e;
	char *tmp_name = NULL;

	/*
	 * Compute length of string.
	 */

	start.label = subtilis_ir_section_new_label(p->current);
	next.label = subtilis_ir_section_new_label(p->current);
	end.label = subtilis_ir_section_new_label(p->current);
	empty.label = subtilis_ir_section_new_label(p->current);
	real_end.label = subtilis_ir_section_new_label(p->current);
	full.label = subtilis_ir_section_new_label(p->current);

	zero.integer = 0;

	reg_orig.reg = reg;
	reg_copy.reg = subtilis_ir_section_add_instr2(
	    p->current, SUBTILIS_OP_INSTR_MOV, reg_orig, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return NULL;

	subtilis_ir_section_add_label(p->current, start.label, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return NULL;

	byte.reg = subtilis_ir_section_add_instr(
	    p->current, SUBTILIS_OP_INSTR_LOADO_I8, reg_copy, zero, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return NULL;

	subtilis_ir_section_add_instr_reg(p->current, SUBTILIS_OP_INSTR_JMPC,
					  byte, next, end, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return NULL;

	subtilis_ir_section_add_label(p->current, next.label, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return NULL;

	one.integer = 1;
	subtilis_ir_section_add_instr_reg(p->current,
					  SUBTILIS_OP_INSTR_ADDI_I32, reg_copy,
					  reg_copy, one, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return NULL;

	subtilis_ir_section_add_instr_no_reg(p->current, SUBTILIS_OP_INSTR_JMP,
					     start, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return NULL;

	subtilis_ir_section_add_label(p->current, end.label, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return NULL;

	size.reg = subtilis_ir_section_add_instr(
	    p->current, SUBTILIS_OP_INSTR_SUB_I32, reg_copy, reg_orig, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return NULL;

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

	subtilis_ir_section_add_instr_reg(p->current, SUBTILIS_OP_INSTR_JMPC,
					  size, full, empty, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	subtilis_ir_section_add_label(p->current, full.label, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	subtilis_string_init_from_lca(p, SUBTILIS_IR_REG_LOCAL, s->loc, reg,
				      size.reg, false, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	subtilis_ir_section_add_instr_no_reg(p->current, SUBTILIS_OP_INSTR_JMP,
					     real_end, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	subtilis_ir_section_add_label(p->current, empty.label, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	subtilis_string_type_zero_ref(p, &subtilis_type_string,
				      SUBTILIS_IR_REG_LOCAL, s->loc, false,
				      err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	subtilis_ir_section_add_label(p->current, real_end.label, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	subtilis_reference_type_push_reference(
	    p, &subtilis_type_string, SUBTILIS_IR_REG_LOCAL, s->loc, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	reg = subtilis_reference_get_pointer(p, SUBTILIS_IR_REG_LOCAL, s->loc,
					     err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	e = subtilis_exp_new_var(&subtilis_type_string, reg, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	e->temporary = tmp_name;

	return e;

cleanup:

	free(tmp_name);

	return NULL;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdx, %r12
movq %rsi, %rbp
movq %rdi, %r14
andq $0x0, 0x20(%rsp)
movq 0x48(%rdi), %rdi
callq 0x2b774
movq %rax, 0x50(%rsp)
movq 0x48(%r14), %rdi
callq 0x2b774
movq %rax, 0x40(%rsp)
movq 0x48(%r14), %rdi
callq 0x2b774
movq %rax, 0x48(%rsp)
movq 0x48(%r14), %rdi
callq 0x2b774
movq %rax, %r15
movq 0x48(%r14), %rdi
callq 0x2b774
movq %rax, %rbx
movq 0x48(%r14), %rdi
callq 0x2b774
movq %rax, %r13
movq 0x48(%r14), %rdi
pushq $0x1d
popq %rsi
movq %rbp, %rdx
movq %r12, %rcx
callq 0x2a981
movq %r12, 0x10(%rsp)
cmpl $0x0, (%r12)
jne 0x45e9c
movq %rbx, %r12
movq %rax, 0x18(%rsp)
movq 0x48(%rsp), %rbx
movq %r13, 0x38(%rsp)
movq %r15, 0x30(%rsp)
movq 0x48(%r14), %rdi
movq 0x50(%rsp), %r15
movq %r15, %rsi
movq 0x10(%rsp), %r13
movq %r13, %rdx
callq 0x2b781
cmpl $0x0, (%r13)
je 0x45eb1
xorl %r12d, %r12d
movq %r12, %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r12, 0x28(%rsp)
movq 0x48(%r14), %rdi
xorl %r12d, %r12d
pushq $0x11
popq %rsi
movq 0x18(%rsp), %rdx
xorl %ecx, %ecx
movq %r13, %r8
callq 0x2a819
cmpl $0x0, (%r13)
jne 0x45e9f
movq 0x48(%r14), %rdi
pushq $0x43
popq %rsi
movq %rax, %rdx
movq 0x40(%rsp), %r12
movq %r12, %rcx
movq %rbx, %r8
movq %r13, %r9
callq 0x2a8c1
cmpl $0x0, (%r13)
jne 0x45e9c
movq 0x48(%r14), %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x2b781
cmpl $0x0, (%r13)
jne 0x45e9c
movq 0x48(%r14), %rdi
pushq $0x9
popq %rsi
pushq $0x1
popq %r8
movq 0x18(%rsp), %rcx
movq %rcx, %rdx
movq %r13, %r9
callq 0x2a8c1
cmpl $0x0, (%r13)
jne 0x45e9c
movq 0x48(%r14), %rdi
pushq $0x45
popq %rsi
movq %r15, %rdx
movq %r13, %rcx
callq 0x2a997
cmpl $0x0, (%r13)
jne 0x45e9c
movq 0x48(%r14), %rdi
movq %rbx, %rsi
movq %r13, %rdx
callq 0x2b781
cmpl $0x0, (%r13)
jne 0x45e9c
movq 0x48(%r14), %rdi
pushq $0x2
popq %rsi
movq 0x18(%rsp), %rdx
movq %rbp, %rcx
movq %r13, %r8
callq 0x2a819
cmpl $0x0, (%r13)
jne 0x45e9c
movq %rax, %r12
movq 0x68(%r14), %rdi
leaq 0x28bbb(%rip), %rsi     # 0x6eb58
leaq 0x20(%rsp), %rdx
movq 0x10(%rsp), %rbx
movq %rbx, %rcx
callq 0x2cee3
cmpl $0x0, (%rbx)
jne 0x46106
movq %rax, %r15
movq 0x48(%r14), %rdi
pushq $0x43
popq %rsi
movq %r12, %rdx
movq 0x38(%rsp), %rcx
movq 0x30(%rsp), %r8
movq 0x10(%rsp), %rbx
movq %rbx, %r9
callq 0x2a8c1
cmpl $0x0, (%rbx)
jne 0x46106
movq 0x48(%r14), %rdi
movq 0x38(%rsp), %rsi
movq 0x10(%rsp), %rbx
movq %rbx, %rdx
callq 0x2b781
cmpl $0x0, (%rbx)
jne 0x46106
movq (%r15), %rdx
movq 0x10(%rsp), %rbx
movq %rbx, (%rsp)
pushq $0x2
popq %rsi
movq %r14, %rdi
movq %rbp, %rcx
movq %r12, %r8
xorl %r9d, %r9d
callq 0x45b72
cmpl $0x0, (%rbx)
jne 0x46106
movq 0x48(%r14), %rdi
pushq $0x45
popq %rsi
movq 0x28(%rsp), %rdx
movq 0x10(%rsp), %rbx
movq %rbx, %rcx
callq 0x2a997
cmpl $0x0, (%rbx)
jne 0x46106
movq 0x48(%r14), %rdi
movq 0x30(%rsp), %rsi
movq 0x10(%rsp), %rbx
movq %rbx, %rdx
callq 0x2b781
cmpl $0x0, (%rbx)
jne 0x46106
movq (%r15), %rcx
leaq 0x28ae0(%rip), %rsi     # 0x6eb58
pushq $0x2
popq %rdx
movq %r14, %rdi
xorl %r8d, %r8d
movq 0x10(%rsp), %rbx
movq %rbx, %r9
callq 0x45982
cmpl $0x0, (%rbx)
jne 0x46106
movq 0x48(%r14), %rdi
movq 0x28(%rsp), %rsi
movq 0x10(%rsp), %rbx
movq %rbx, %rdx
callq 0x2b781
cmpl $0x0, (%rbx)
jne 0x46106
movq (%r15), %rcx
leaq 0x28aa0(%rip), %rsi     # 0x6eb58
pushq $0x2
popq %rdx
movq %r14, %rdi
movq 0x10(%rsp), %rbx
movq %rbx, %r8
callq 0x4a8be
cmpl $0x0, (%rbx)
jne 0x46106
movq (%r15), %rdx
pushq $0x2
popq %rsi
movq %r14, %rdi
movq 0x10(%rsp), %rbx
movq %rbx, %rcx
callq 0x4ab28
cmpl $0x0, (%rbx)
jne 0x46106
leaq 0x28a66(%rip), %rdi     # 0x6eb58
movl %eax, %esi
movq 0x10(%rsp), %rbx
movq %rbx, %rdx
callq 0x2a226
cmpl $0x0, (%rbx)
je 0x46115
movq 0x20(%rsp), %rdi
callq 0x122c0
jmp 0x45e9c
movq %rax, %r12
movq 0x20(%rsp), %rax
movq %rax, 0x158(%r12)
jmp 0x45e9f