// File: /workspace/github_c_makefile_star2_O3/Ihsoh[P]ilang/compiler/frontend/irgen.c
// Function: ir_expr_add
static void _ir_expr_add(
	IRGeneratorContext *ctx,
	ResizableString *rstr,
	ResizableString *rstr_result_lhs_ptr,
	_ExprResult *expr_result,
	ParserASTNode *node
) {
	assert(ctx);
	assert(rstr);
	assert(expr_result);
	assert(node);
	assert(node->type == FE_NODE_EXPR_ADD
			|| node->type == FE_NODE_EXPR_ADD_ASSIGN);

	ParserSymbol *func_symbol = ctx->func_symbol;
	assert(func_symbol);

	uint8_t type1 = FE_EXPR_AST_NODE_GET_TYPE(node->childs[0]);
	uint8_t type2 = FE_EXPR_AST_NODE_GET_TYPE(node->childs[1]);

	if (fe_sem_is_pointer_type(type1) && fe_sem_is_integer_type(type2)) {
		ParserASTNode *node_lhs = node->childs[0];
		ParserASTNode *node_rhs = node->childs[1];

		_ExprResult result_lhs;
		_ExprResult result_rhs;

		_expr_result_init(&result_lhs);
		_expr_result_init(&result_rhs);

		_ir_expr(ctx, rstr, &result_lhs, node_lhs);
		rstr_append_with_rstr(rstr, &(result_lhs.rstr_for_result_ptr));
		rstr_append_with_rstr(rstr, &(result_lhs.rstr_for_result));

		if (rstr_result_lhs_ptr != NULL) {
			rstr_append_with_rstr(
				rstr_result_lhs_ptr,
				&(result_lhs.rstr_result_ptr)
			);
		}

		_ir_expr(ctx, rstr, &result_rhs, node_rhs);
		rstr_append_with_rstr(rstr, &(result_rhs.rstr_for_result_ptr));
		rstr_append_with_rstr(rstr, &(result_rhs.rstr_for_result));

		ResizableString rstr_tmp_label_val;
		rstr_init(&rstr_tmp_label_val);
		_generate_func_tmp_var(
			ctx,
			func_symbol,
			&rstr_tmp_label_val,
			FE_EXPR_AST_NODE_GET_TYPE_NODE(node)
		);

		rstr_appendf(
			&(expr_result->rstr_for_result),
			"add %s, %s, %s;\n",
			RSTR_CSTR(&rstr_tmp_label_val),
			RSTR_CSTR(&(result_lhs.rstr_result)),
			RSTR_CSTR(&(result_rhs.rstr_result))
		);

		_expr_result_set_result(
			expr_result,
			RSTR_CSTR(&rstr_tmp_label_val)
		);

		_expr_result_free(&result_lhs);
		_expr_result_free(&result_rhs);
		rstr_free(&rstr_tmp_label_val);
	} else if (fe_sem_is_number_type(type1) && fe_sem_is_number_type(type2)) {
		ParserASTNode *node_type = FE_EXPR_AST_NODE_GET_TYPE_NODE(node);

		ParserASTNode *node_lhs = node->childs[0];
		ParserASTNode *node_rhs = node->childs[1];

		_ExprResult result_lhs;
		_ExprResult result_rhs;
		_ExprResult result_lhs_casted;
		_ExprResult result_rhs_casted;

		_expr_result_init(&result_lhs);
		_expr_result_init(&result_rhs);
		_expr_result_init(&result_lhs_casted);
		_expr_result_init(&result_rhs_casted);

		_ir_expr(ctx, rstr, &result_lhs, node_lhs);
		rstr_append_with_rstr(rstr, &(result_lhs.rstr_for_result_ptr));
		rstr_append_with_rstr(rstr, &(result_lhs.rstr_for_result));

		if (rstr_result_lhs_ptr != NULL) {
			rstr_append_with_rstr(
				rstr_result_lhs_ptr,
				&(result_lhs.rstr_result_ptr)
			);
		}

		_ir_expr(ctx, rstr, &result_rhs, node_rhs);
		rstr_append_with_rstr(rstr, &(result_rhs.rstr_for_result_ptr));
		rstr_append_with_rstr(rstr, &(result_rhs.rstr_for_result));

		_expr_result_cast(
			ctx,
			&result_lhs_casted,
			node_type,
			&result_lhs,
			FE_EXPR_AST_NODE_GET_TYPE_NODE(node_lhs)
		);
		rstr_append_with_rstr(rstr, &(result_lhs_casted.rstr_for_result_ptr));
		rstr_append_with_rstr(rstr, &(result_lhs_casted.rstr_for_result));

		_expr_result_cast(
			ctx,
			&result_rhs_casted,
			node_type,
			&result_rhs,
			FE_EXPR_AST_NODE_GET_TYPE_NODE(node_rhs)
		);
		rstr_append_with_rstr(rstr, &(result_rhs_casted.rstr_for_result_ptr));
		rstr_append_with_rstr(rstr, &(result_rhs_casted.rstr_for_result));

		ResizableString rstr_tmp_label_val;
		rstr_init(&rstr_tmp_label_val);
		_generate_func_tmp_var(
			ctx,
			func_symbol,
			&rstr_tmp_label_val,
			node_type
		);

		rstr_appendf(
			&(expr_result->rstr_for_result),
			"add %s, %s, %s;\n",
			RSTR_CSTR(&rstr_tmp_label_val),
			RSTR_CSTR(&(result_lhs_casted.rstr_result)),
			RSTR_CSTR(&(result_rhs_casted.rstr_result))
		);

		_expr_result_set_result(
			expr_result,
			RSTR_CSTR(&rstr_tmp_label_val)
		);

		_expr_result_free(&result_lhs);
		_expr_result_free(&result_rhs);
		_expr_result_free(&result_lhs_casted);
		_expr_result_free(&result_rhs_casted);
		rstr_free(&rstr_tmp_label_val);
	} else {
		assert(0);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x138, %rsp            # imm = 0x138
testq %rcx, %rcx
je 0x11942
movq %r8, %r15
movq %rsi, %r12
movq %rdi, %r14
movl (%r8), %eax
cmpl $0xe11, %eax            # imm = 0xE11
je 0x11593
cmpl $0xea0, %eax            # imm = 0xEA0
jne 0x11980
movq %rdx, -0x38(%rbp)
movq %rcx, -0x48(%rbp)
movq 0x40(%r14), %rax
movq %rax, -0x40(%rbp)
testq %rax, %rax
je 0x11961
movq 0x48(%r15), %rax
movq (%rax), %rcx
movq 0x8(%rax), %rax
movb 0x60(%rax), %bl
movzbl 0x60(%rcx), %r13d
movl %r13d, %edi
callq 0x2a496
movzbl %bl, %ebx
testb %al, %al
je 0x1170f
movl %ebx, %edi
callq 0x2a465
testb %al, %al
je 0x1170f
movq 0x48(%r15), %rax
movq (%rax), %r13
movq 0x8(%rax), %rax
movq %rax, -0x30(%rbp)
leaq -0xc8(%rbp), %rbx
movq %rbx, %rdi
callq 0xcdbe
leaq -0x88(%rbp), %rdi
callq 0xcdbe
movq %r14, %rdi
movq %r12, %rsi
movq %rbx, %rdx
movq %r13, %rcx
callq 0xdc0b
leaq -0xb8(%rbp), %rsi
movq %r12, %rdi
callq 0x769e
movq %r12, %rdi
movq %rbx, %rsi
callq 0x769e
movq -0x38(%rbp), %rdi
testq %rdi, %rdi
je 0x1164b
leaq -0x98(%rbp), %rsi
callq 0x769e
leaq -0x88(%rbp), %rbx
movq %r14, %rdi
movq %r12, %rsi
movq %rbx, %rdx
movq -0x30(%rbp), %rcx
callq 0xdc0b
leaq -0x78(%rbp), %r13
movq %r12, %rdi
movq %r13, %rsi
callq 0x769e
movq %r12, %rdi
movq %rbx, %rsi
callq 0x769e
leaq -0x108(%rbp), %rbx
movq %rbx, %rdi
callq 0x7354
movq 0x68(%r15), %rcx
movq %r14, %rdi
movq -0x40(%rbp), %rsi
movq %rbx, %rdx
callq 0x10c3e
movq 0x8(%rbx), %rdx
testq %rdx, %rdx
leaq 0x31858(%rip), %r15     # 0x42f06
cmoveq %r15, %rdx
leaq -0xc8(%rbp), %r14
movq 0x28(%r14), %rcx
testq %rcx, %rcx
cmoveq %r15, %rcx
movq 0x18(%r13), %r8
testq %r8, %r8
cmoveq %r15, %r8
leaq 0x308e5(%rip), %rsi     # 0x41fbb
movq -0x48(%rbp), %r12
movq %r12, %rdi
xorl %eax, %eax
callq 0x7945
movq 0x8(%rbx), %rsi
testq %rsi, %rsi
cmoveq %r15, %rsi
addq $0x20, %r12
movq %r12, %rdi
callq 0x73db
movq %r14, %rdi
callq 0xd508
leaq -0x88(%rbp), %rdi
jmp 0x11904
movl %r13d, %edi
callq 0x2a4a2
testb %al, %al
je 0x11923
movl %ebx, %edi
callq 0x2a4a2
testb %al, %al
je 0x11923
movq 0x48(%r15), %rax
movq 0x68(%r15), %rcx
movq %rcx, -0x30(%rbp)
movq (%rax), %rbx
movq 0x8(%rax), %r15
leaq -0xc8(%rbp), %r13
movq %r13, %rdi
callq 0xcdbe
leaq -0x88(%rbp), %rdi
callq 0xcdbe
leaq -0x108(%rbp), %rdi
callq 0xcdbe
leaq -0x158(%rbp), %rdi
callq 0xcdbe
movq %r14, %rdi
movq %r12, %rsi
movq %r13, %rdx
movq %rbx, %rcx
callq 0xdc0b
leaq -0xb8(%rbp), %rsi
movq %r12, %rdi
callq 0x769e
movq %r12, %rdi
movq %r13, %rsi
callq 0x769e
movq -0x38(%rbp), %rdi
testq %rdi, %rdi
je 0x117b4
leaq -0x98(%rbp), %rsi
callq 0x769e
leaq -0x88(%rbp), %r13
movq %r14, %rdi
movq %r12, %rsi
movq %r13, %rdx
movq %r15, %rcx
callq 0xdc0b
leaq -0x78(%rbp), %rsi
movq %r12, %rdi
callq 0x769e
movq %r12, %rdi
movq %r13, %rsi
callq 0x769e
movq 0x68(%rbx), %r8
leaq -0x108(%rbp), %rbx
leaq -0xc8(%rbp), %rcx
movq %r14, %rdi
movq %rbx, %rsi
movq -0x30(%rbp), %r13
movq %r13, %rdx
callq 0xce14
leaq -0xf8(%rbp), %rsi
movq %r12, %rdi
callq 0x769e
movq %r12, %rdi
movq %rbx, %rsi
callq 0x769e
movq 0x68(%r15), %r8
leaq -0x158(%rbp), %rbx
movq %r14, %rdi
movq %rbx, %rsi
movq %r13, %rdx
leaq -0x88(%rbp), %rcx
callq 0xce14
leaq -0x148(%rbp), %r15
movq %r12, %rdi
movq %r15, %rsi
callq 0x769e
movq %r12, %rdi
movq %rbx, %rsi
movq %rbx, %r12
callq 0x769e
leaq -0x118(%rbp), %rbx
movq %rbx, %rdi
callq 0x7354
movq %r14, %rdi
movq -0x40(%rbp), %rsi
movq %rbx, %rdx
movq %r13, %rcx
callq 0x10c3e
movq 0x8(%rbx), %rdx
testq %rdx, %rdx
leaq 0x31676(%rip), %r14     # 0x42f06
cmoveq %r14, %rdx
leaq -0xf8(%rbp), %rax
movq 0x18(%rax), %rcx
testq %rcx, %rcx
cmoveq %r14, %rcx
movq 0x18(%r15), %r8
testq %r8, %r8
cmoveq %r14, %r8
leaq 0x30703(%rip), %rsi     # 0x41fbb
movq -0x48(%rbp), %r15
movq %r15, %rdi
xorl %eax, %eax
callq 0x7945
movq 0x8(%rbx), %rsi
testq %rsi, %rsi
cmoveq %r14, %rsi
addq $0x20, %r15
movq %r15, %rdi
callq 0x73db
leaq -0xc8(%rbp), %rdi
callq 0xd508
leaq -0x88(%rbp), %rdi
callq 0xd508
leaq -0x108(%rbp), %rdi
callq 0xd508
movq %r12, %rdi
callq 0xd508
movq %rbx, %rdi
callq 0x7852
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2da36(%rip), %rdi     # 0x3f360
leaq 0x2fa33(%rip), %rsi     # 0x41364
leaq 0x30b7c(%rip), %rcx     # 0x424b4
movl $0x8d6, %edx            # imm = 0x8D6
callq 0x30a0
leaq 0x3028b(%rip), %rdi     # 0x41bd4
leaq 0x2fa14(%rip), %rsi     # 0x41364
leaq 0x30b5d(%rip), %rcx     # 0x424b4
movl $0x84a, %edx            # imm = 0x84A
callq 0x30a0
leaq 0x315ff(%rip), %rdi     # 0x42f67
leaq 0x2f9f5(%rip), %rsi     # 0x41364
leaq 0x30b3e(%rip), %rcx     # 0x424b4
movl $0x850, %edx            # imm = 0x850
callq 0x30a0
leaq 0x30b9b(%rip), %rdi     # 0x42522
leaq 0x2f9d6(%rip), %rsi     # 0x41364
leaq 0x30b1f(%rip), %rcx     # 0x424b4
movl $0x84d, %edx            # imm = 0x84D
callq 0x30a0