// File: /workspace/github_c_makefile_star2_O0/markdryan[P]subtilis/frontend/string_type.c
// Function: subtilis_string_type_add
subtilis_exp_t *subtilis_string_type_add(subtilis_parser_t *p,
					 subtilis_exp_t *a1, subtilis_exp_t *a2,
					 bool swapped, subtilis_error_t *err)
{
	subtilis_ir_operand_t a1_size;
	subtilis_ir_operand_t a2_size;
	subtilis_ir_operand_t new_size;
	subtilis_ir_operand_t op1;
	subtilis_ir_operand_t op2;
	subtilis_ir_operand_t a1_data;
	size_t a1_tmp_heap;
	subtilis_ir_operand_t a2_data;
	const subtilis_symbol_t *s;
	size_t tmp;
	bool a2_gt_0;
	char *a1_tmp = NULL;
	char *a2_tmp = NULL;
	size_t dest_reg = SIZE_MAX;
	char *tmp_name = NULL;

	a2_data.reg = SIZE_MAX;
	a2_size.reg = SIZE_MAX;

	op2.integer = SUBTIILIS_STRING_SIZE_OFF;
	a1_size.reg = subtilis_ir_section_add_instr(
	    p->current, SUBTILIS_OP_INSTR_LOADO_I32, a1->exp.ir_op, op2, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	a1_data.reg = subtilis_reference_get_data(p, a1->exp.ir_op.reg, 0, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	a2_gt_0 =
	    prv_get_string_details(p, a2, &a2_size, &a2_data, &a2_tmp, err);
	a2 = NULL;
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	if (!a2_gt_0)
		return a1;

	new_size.reg = subtilis_ir_section_add_instr(
	    p->current, SUBTILIS_OP_INSTR_ADD_I32, a1_size, a2_size, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	if (swapped) {
		tmp = a1_size.reg;
		a1_size.reg = a2_size.reg;
		a2_size.reg = tmp;
		tmp = a1_data.reg;
		a1_data.reg = a2_data.reg;
		a2_data.reg = tmp;
		a1_tmp = a2_tmp;
	} else {
		a1_tmp = a1->temporary;
	}

	if (a1_tmp) {
		s = subtilis_symbol_table_lookup(p->local_st, a1_tmp);
		if (!s) {
			subtilis_error_set_assertion_failed(err);
			goto cleanup;
		}
		a1_tmp_heap = subtilis_reference_get_heap(
		    p, SUBTILIS_IR_REG_LOCAL, s->loc, err);
		if (err->type != SUBTILIS_ERROR_OK)
			goto cleanup;
		dest_reg = subtilis_reference_type_realloc(
		    p, s->loc, SUBTILIS_IR_REG_LOCAL, a1_tmp_heap, a1_data.reg,
		    a1_size.reg, new_size.reg, a2_size.reg, SIZE_MAX, err);
	} else {
		s = subtilis_symbol_table_insert_tmp(
		    p->local_st, &subtilis_type_string, &tmp_name, err);
		if (err->type != SUBTILIS_ERROR_OK)
			goto cleanup;

		a1->temporary = tmp_name;

		dest_reg = subtilis_reference_type_alloc(
		    p, &subtilis_type_string, s->loc, SUBTILIS_IR_REG_LOCAL,
		    new_size.reg, true, err);
		if (err->type != SUBTILIS_ERROR_OK)
			goto cleanup;

		subtilis_reference_type_memcpy_dest(p, dest_reg, a1_data.reg,
						    a1_size.reg, err);
	}
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	op1.reg = dest_reg;
	dest_reg = subtilis_ir_section_add_instr(
	    p->current, SUBTILIS_OP_INSTR_ADD_I32, op1, a1_size, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	subtilis_reference_type_memcpy_dest(p, dest_reg, a2_data.reg,
					    a2_size.reg, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	a1->exp.ir_op.reg = subtilis_reference_get_pointer(
	    p, SUBTILIS_IR_REG_LOCAL, s->loc, err);

	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	return a1;

cleanup:

	subtilis_exp_delete(a1);
	subtilis_exp_delete(a2);

	return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movb %cl, %al
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
andb $0x1, %al
movb %al, -0x21(%rbp)
movq %r8, -0x30(%rbp)
movq $0x0, -0x90(%rbp)
movq $0x0, -0x98(%rbp)
movq $-0x1, -0xa0(%rbp)
movq $0x0, -0xa8(%rbp)
movq $-0x1, -0x70(%rbp)
movq $-0x1, -0x40(%rbp)
movl $0x0, -0x58(%rbp)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x18(%rbp), %rax
movq -0x30(%rbp), %r8
movq 0x148(%rax), %rdx
movq -0x58(%rbp), %rcx
movl $0x12, %esi
callq 0x38230
movq %rax, -0x38(%rbp)
movq -0x30(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6ae1c
jmp 0x6b135
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x148(%rax), %rsi
movq -0x30(%rbp), %rcx
xorl %eax, %eax
movl %eax, %edx
callq 0x6d1e0
movq %rax, -0x60(%rbp)
movq -0x30(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6ae4a
jmp 0x6b135
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x30(%rbp), %r9
leaq -0x40(%rbp), %rdx
leaq -0x70(%rbp), %rcx
leaq -0x98(%rbp), %r8
callq 0x6b160
andb $0x1, %al
movb %al, -0x81(%rbp)
movq $0x0, -0x20(%rbp)
movq -0x30(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6ae88
jmp 0x6b135
testb $0x1, -0x81(%rbp)
jne 0x6ae9e
movq -0x18(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x6b14f
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x30(%rbp), %r8
movq -0x38(%rbp), %rdx
movq -0x40(%rbp), %rcx
xorl %esi, %esi
callq 0x38230
movq %rax, -0x48(%rbp)
movq -0x30(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6aecb
jmp 0x6b135
testb $0x1, -0x21(%rbp)
je 0x6af11
movq -0x38(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x80(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x60(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x70(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x80(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x98(%rbp), %rax
movq %rax, -0x90(%rbp)
jmp 0x6af23
movq -0x18(%rbp), %rax
movq 0x158(%rax), %rax
movq %rax, -0x90(%rbp)
cmpq $0x0, -0x90(%rbp)
je 0x6afea
movq -0x10(%rbp), %rax
movq 0x68(%rax), %rdi
movq -0x90(%rbp), %rsi
callq 0x3cff0
movq %rax, -0x78(%rbp)
cmpq $0x0, -0x78(%rbp)
jne 0x6af6f
movq -0x30(%rbp), %rdi
movl $0xf, %esi
leaq 0x41af7(%rip), %rdx     # 0xaca57
movl $0xd81, %ecx            # imm = 0xD81
callq 0x158e0
jmp 0x6b135
movq -0x10(%rbp), %rdi
movq -0x78(%rbp), %rax
movq (%rax), %rdx
movq -0x30(%rbp), %rcx
movl $0x2, %esi
callq 0x6d230
movq %rax, -0x68(%rbp)
movq -0x30(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6af9a
jmp 0x6b135
movq -0x10(%rbp), %rdi
movq -0x78(%rbp), %rax
movq (%rax), %rsi
movq -0x68(%rbp), %rcx
movq -0x60(%rbp), %r8
movq -0x38(%rbp), %r9
movq -0x48(%rbp), %r11
movq -0x40(%rbp), %r10
movq -0x30(%rbp), %rax
movl $0x2, %edx
movq %r11, (%rsp)
movq %r10, 0x8(%rsp)
movq $-0x1, 0x10(%rsp)
movq %rax, 0x18(%rsp)
callq 0x6e580
movq %rax, -0xa0(%rbp)
jmp 0x6b08c
movq -0x10(%rbp), %rax
movq 0x68(%rax), %rdi
movq -0x30(%rbp), %rcx
leaq 0x40b63(%rip), %rsi     # 0xabb60
leaq -0xa8(%rbp), %rdx
callq 0x3c920
movq %rax, -0x78(%rbp)
movq -0x30(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6b01b
jmp 0x6b135
movq -0xa8(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x158(%rax)
movq -0x10(%rbp), %rdi
movq -0x78(%rbp), %rax
movq (%rax), %rdx
movq -0x48(%rbp), %r8
movq -0x30(%rbp), %rax
leaq 0x40b19(%rip), %rsi     # 0xabb60
movl $0x2, %ecx
movl $0x1, %r9d
movq %rax, (%rsp)
callq 0x6e3e0
movq %rax, -0xa0(%rbp)
movq -0x30(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6b070
jmp 0x6b135
movq -0x10(%rbp), %rdi
movq -0xa0(%rbp), %rsi
movq -0x60(%rbp), %rdx
movq -0x38(%rbp), %rcx
movq -0x30(%rbp), %r8
callq 0x6dad0
movq -0x30(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6b09a
jmp 0x6b135
movq -0xa0(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x30(%rbp), %r8
movq -0x50(%rbp), %rdx
movq -0x38(%rbp), %rcx
xorl %esi, %esi
callq 0x38230
movq %rax, -0xa0(%rbp)
movq -0x30(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6b0d2
jmp 0x6b135
movq -0x10(%rbp), %rdi
movq -0xa0(%rbp), %rsi
movq -0x70(%rbp), %rdx
movq -0x40(%rbp), %rcx
movq -0x30(%rbp), %r8
callq 0x6dad0
movq -0x30(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6b0f9
jmp 0x6b135
movq -0x10(%rbp), %rdi
movq -0x78(%rbp), %rax
movq (%rax), %rdx
movq -0x30(%rbp), %rcx
movl $0x2, %esi
callq 0x6d920
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x148(%rax)
movq -0x30(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6b12b
jmp 0x6b135
movq -0x18(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x6b14f
movq -0x18(%rbp), %rdi
callq 0x36ee0
movq -0x20(%rbp), %rdi
callq 0x36ee0
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0xd0, %rsp
popq %rbp
retq
nopl (%rax)