// File: /workspace/github_c_makefile_star2_O0/Ihsoh[P]ilang/compiler/frontend/irgen.c
// Function: ir_expr_sub
static void _ir_expr_sub(
	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_SUB
			|| node->type == FE_NODE_EXPR_SUB_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),
			"sub %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),
			"sub %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
subq $0x280, %rsp            # imm = 0x280
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
cmpq $0x0, -0x8(%rbp)
je 0x1c118
jmp 0x1c137
leaq 0x60437(%rip), %rdi     # 0x7c556
leaq 0x5826e(%rip), %rsi     # 0x74394
movl $0x8e1, %edx            # imm = 0x8E1
leaq 0x59629(%rip), %rcx     # 0x7575b
callq 0x30a0
cmpq $0x0, -0x10(%rbp)
je 0x1c140
jmp 0x1c15f
leaq 0x569c7(%rip), %rdi     # 0x72b0e
leaq 0x58246(%rip), %rsi     # 0x74394
movl $0x8e2, %edx            # imm = 0x8E2
leaq 0x59601(%rip), %rcx     # 0x7575b
callq 0x30a0
cmpq $0x0, -0x20(%rbp)
je 0x1c168
jmp 0x1c187
leaq 0x58aa4(%rip), %rdi     # 0x74c13
leaq 0x5821e(%rip), %rsi     # 0x74394
movl $0x8e3, %edx            # imm = 0x8E3
leaq 0x595d9(%rip), %rcx     # 0x7575b
callq 0x30a0
cmpq $0x0, -0x28(%rbp)
je 0x1c190
jmp 0x1c1af
leaq 0x59e3c(%rip), %rdi     # 0x75fd3
leaq 0x581f6(%rip), %rsi     # 0x74394
movl $0x8e4, %edx            # imm = 0x8E4
leaq 0x595b1(%rip), %rcx     # 0x7575b
callq 0x30a0
movq -0x28(%rbp), %rax
cmpl $0xea1, (%rax)          # imm = 0xEA1
je 0x1c1c7
movq -0x28(%rbp), %rax
cmpl $0xe12, (%rax)          # imm = 0xE12
jne 0x1c1c9
jmp 0x1c1e8
leaq 0x595f9(%rip), %rdi     # 0x757c9
leaq 0x581bd(%rip), %rsi     # 0x74394
movl $0x8e6, %edx            # imm = 0x8E6
leaq 0x59578(%rip), %rcx     # 0x7575b
callq 0x30a0
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x1c1fd
jmp 0x1c21c
leaq 0x59f6f(%rip), %rdi     # 0x76173
leaq 0x58189(%rip), %rsi     # 0x74394
movl $0x8e9, %edx            # imm = 0x8E9
leaq 0x59544(%rip), %rcx     # 0x7575b
callq 0x30a0
movq -0x28(%rbp), %rax
movq 0x48(%rax), %rax
movq (%rax), %rax
movb 0x60(%rax), %al
movb %al, -0x31(%rbp)
movq -0x28(%rbp), %rax
movq 0x48(%rax), %rax
movq 0x8(%rax), %rax
movb 0x60(%rax), %al
movb %al, -0x32(%rbp)
movzbl -0x31(%rbp), %edi
callq 0x4d4a0
testb $0x1, %al
jne 0x1c251
jmp 0x1c487
movzbl -0x32(%rbp), %edi
callq 0x4d3b0
testb $0x1, %al
jne 0x1c263
jmp 0x1c487
movq -0x28(%rbp), %rax
movq 0x48(%rax), %rax
movq (%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x28(%rbp), %rax
movq 0x48(%rax), %rax
movq 0x8(%rax), %rax
movq %rax, -0x48(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x113b0
leaq -0xc8(%rbp), %rdi
callq 0x113b0
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x40(%rbp), %rcx
leaq -0x88(%rbp), %rdx
callq 0x13d10
movq -0x10(%rbp), %rdi
leaq -0x88(%rbp), %rsi
addq $0x10, %rsi
callq 0x9100
movq -0x10(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x9100
cmpq $0x0, -0x18(%rbp)
je 0x1c2f1
movq -0x18(%rbp), %rdi
leaq -0x88(%rbp), %rsi
addq $0x30, %rsi
callq 0x9100
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x48(%rbp), %rcx
leaq -0xc8(%rbp), %rdx
callq 0x13d10
movq -0x10(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
addq $0x10, %rsi
callq 0x9100
movq -0x10(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0x9100
leaq -0xd8(%rbp), %rdi
callq 0x8c90
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x28(%rbp), %rax
movq 0x68(%rax), %rcx
leaq -0xd8(%rbp), %rdx
callq 0x1ab00
movq -0x20(%rbp), %rax
movq %rax, -0x208(%rbp)
cmpq $0x0, -0xd0(%rbp)
jne 0x1c37a
leaq 0x5b544(%rip), %rax     # 0x778b5
movq %rax, -0x210(%rbp)
jmp 0x1c388
movq -0xd0(%rbp), %rax
movq %rax, -0x210(%rbp)
movq -0x210(%rbp), %rax
movq %rax, -0x218(%rbp)
cmpq $0x0, -0x60(%rbp)
jne 0x1c3ad
leaq 0x5b511(%rip), %rax     # 0x778b5
movq %rax, -0x220(%rbp)
jmp 0x1c3b8
movq -0x60(%rbp), %rax
movq %rax, -0x220(%rbp)
movq -0x220(%rbp), %rax
movq %rax, -0x228(%rbp)
cmpq $0x0, -0xa0(%rbp)
jne 0x1c3e0
leaq 0x5b4de(%rip), %rax     # 0x778b5
movq %rax, -0x230(%rbp)
jmp 0x1c3ee
movq -0xa0(%rbp), %rax
movq %rax, -0x230(%rbp)
movq -0x228(%rbp), %rcx
movq -0x218(%rbp), %rdx
movq -0x208(%rbp), %rdi
movq -0x230(%rbp), %r8
leaq 0x59400(%rip), %rsi     # 0x75811
movb $0x0, %al
callq 0x94d0
movq -0x20(%rbp), %rax
movq %rax, -0x238(%rbp)
cmpq $0x0, -0xd0(%rbp)
jne 0x1c43d
leaq 0x5b481(%rip), %rax     # 0x778b5
movq %rax, -0x240(%rbp)
jmp 0x1c44b
movq -0xd0(%rbp), %rax
movq %rax, -0x240(%rbp)
movq -0x238(%rbp), %rdi
movq -0x240(%rbp), %rsi
callq 0x1a6c0
leaq -0x88(%rbp), %rdi
callq 0x130a0
leaq -0xc8(%rbp), %rdi
callq 0x130a0
leaq -0xd8(%rbp), %rdi
callq 0x9310
jmp 0x1c7d7
movzbl -0x31(%rbp), %edi
callq 0x4d4e0
testb $0x1, %al
jne 0x1c499
jmp 0x1c7b6
movzbl -0x32(%rbp), %edi
callq 0x4d4e0
testb $0x1, %al
jne 0x1c4ab
jmp 0x1c7b6
movq -0x28(%rbp), %rax
movq 0x68(%rax), %rax
movq %rax, -0xe0(%rbp)
movq -0x28(%rbp), %rax
movq 0x48(%rax), %rax
movq (%rax), %rax
movq %rax, -0xe8(%rbp)
movq -0x28(%rbp), %rax
movq 0x48(%rax), %rax
movq 0x8(%rax), %rax
movq %rax, -0xf0(%rbp)
leaq -0x130(%rbp), %rdi
callq 0x113b0
leaq -0x170(%rbp), %rdi
callq 0x113b0
leaq -0x1b0(%rbp), %rdi
callq 0x113b0
leaq -0x1f0(%rbp), %rdi
callq 0x113b0
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0xe8(%rbp), %rcx
leaq -0x130(%rbp), %rdx
callq 0x13d10
movq -0x10(%rbp), %rdi
leaq -0x130(%rbp), %rsi
addq $0x10, %rsi
callq 0x9100
movq -0x10(%rbp), %rdi
leaq -0x130(%rbp), %rsi
callq 0x9100
cmpq $0x0, -0x18(%rbp)
je 0x1c569
movq -0x18(%rbp), %rdi
leaq -0x130(%rbp), %rsi
addq $0x30, %rsi
callq 0x9100
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0xf0(%rbp), %rcx
leaq -0x170(%rbp), %rdx
callq 0x13d10
movq -0x10(%rbp), %rdi
leaq -0x170(%rbp), %rsi
addq $0x10, %rsi
callq 0x9100
movq -0x10(%rbp), %rdi
leaq -0x170(%rbp), %rsi
callq 0x9100
movq -0x8(%rbp), %rdi
movq -0xe0(%rbp), %rdx
movq -0xe8(%rbp), %rax
movq 0x68(%rax), %r8
leaq -0x1b0(%rbp), %rsi
leaq -0x130(%rbp), %rcx
callq 0x11460
movq -0x10(%rbp), %rdi
leaq -0x1b0(%rbp), %rsi
addq $0x10, %rsi
callq 0x9100
movq -0x10(%rbp), %rdi
leaq -0x1b0(%rbp), %rsi
callq 0x9100
movq -0x8(%rbp), %rdi
movq -0xe0(%rbp), %rdx
movq -0xf0(%rbp), %rax
movq 0x68(%rax), %r8
leaq -0x1f0(%rbp), %rsi
leaq -0x170(%rbp), %rcx
callq 0x11460
movq -0x10(%rbp), %rdi
leaq -0x1f0(%rbp), %rsi
addq $0x10, %rsi
callq 0x9100
movq -0x10(%rbp), %rdi
leaq -0x1f0(%rbp), %rsi
callq 0x9100
leaq -0x200(%rbp), %rdi
callq 0x8c90
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0xe0(%rbp), %rcx
leaq -0x200(%rbp), %rdx
callq 0x1ab00
movq -0x20(%rbp), %rax
movq %rax, -0x248(%rbp)
cmpq $0x0, -0x1f8(%rbp)
jne 0x1c68e
leaq 0x5b230(%rip), %rax     # 0x778b5
movq %rax, -0x250(%rbp)
jmp 0x1c69c
movq -0x1f8(%rbp), %rax
movq %rax, -0x250(%rbp)
movq -0x250(%rbp), %rax
movq %rax, -0x258(%rbp)
cmpq $0x0, -0x188(%rbp)
jne 0x1c6c4
leaq 0x5b1fa(%rip), %rax     # 0x778b5
movq %rax, -0x260(%rbp)
jmp 0x1c6d2
movq -0x188(%rbp), %rax
movq %rax, -0x260(%rbp)
movq -0x260(%rbp), %rax
movq %rax, -0x268(%rbp)
cmpq $0x0, -0x1c8(%rbp)
jne 0x1c6fa
leaq 0x5b1c4(%rip), %rax     # 0x778b5
movq %rax, -0x270(%rbp)
jmp 0x1c708
movq -0x1c8(%rbp), %rax
movq %rax, -0x270(%rbp)
movq -0x268(%rbp), %rcx
movq -0x258(%rbp), %rdx
movq -0x248(%rbp), %rdi
movq -0x270(%rbp), %r8
leaq 0x590e6(%rip), %rsi     # 0x75811
movb $0x0, %al
callq 0x94d0
movq -0x20(%rbp), %rax
movq %rax, -0x278(%rbp)
cmpq $0x0, -0x1f8(%rbp)
jne 0x1c757
leaq 0x5b167(%rip), %rax     # 0x778b5
movq %rax, -0x280(%rbp)
jmp 0x1c765
movq -0x1f8(%rbp), %rax
movq %rax, -0x280(%rbp)
movq -0x278(%rbp), %rdi
movq -0x280(%rbp), %rsi
callq 0x1a6c0
leaq -0x130(%rbp), %rdi
callq 0x130a0
leaq -0x170(%rbp), %rdi
callq 0x130a0
leaq -0x1b0(%rbp), %rdi
callq 0x130a0
leaq -0x1f0(%rbp), %rdi
callq 0x130a0
leaq -0x200(%rbp), %rdi
callq 0x9310
jmp 0x1c7d5
leaq 0x55c9e(%rip), %rdi     # 0x7245b
leaq 0x57bd0(%rip), %rsi     # 0x74394
movl $0x96f, %edx            # imm = 0x96F
leaq 0x58f8b(%rip), %rcx     # 0x7575b
callq 0x30a0
jmp 0x1c7d7
addq $0x280, %rsp            # imm = 0x280
popq %rbp
retq