// File: /workspace/github_c_makefile_star2_O0/Ihsoh[P]ilang/compiler/frontend/irgen_llvmir.c
// Function: ir_expr_mul
static void _ir_expr_mul(
	IRGeneratorLlvmirContext *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_MUL
			|| node->type == FE_NODE_EXPR_MUL_ASSIGN);

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

	ParserASTNode *node_type = FE_EXPR_AST_NODE_GET_TYPE_NODE(node);
	uint8_t type = FE_EXPR_AST_NODE_GET_TYPE(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(ctx, func_symbol, &rstr_tmp_label_val);

	if (fe_sem_is_signed_type(type)) {
		rstr_appendf(
			&(expr_result->rstr_for_result),
			"%s = mul nsw %s, %s\n",
			RSTR_CSTR(&rstr_tmp_label_val),
			RSTR_CSTR(&(result_lhs_casted.rstr_result)),
			RSTR_CSTR(&(result_rhs_casted.rstr_result_val))
		);
	} else if (fe_sem_is_unsigned_type(type)) {
		rstr_appendf(
			&(expr_result->rstr_for_result),
			"%s = mul %s, %s\n",
			RSTR_CSTR(&rstr_tmp_label_val),
			RSTR_CSTR(&(result_lhs_casted.rstr_result)),
			RSTR_CSTR(&(result_rhs_casted.rstr_result_val))
		);
	} else if (fe_sem_is_float_type(type)) {
		rstr_appendf(
			&(expr_result->rstr_for_result),
			"%s = fmul %s, %s\n",
			RSTR_CSTR(&rstr_tmp_label_val),
			RSTR_CSTR(&(result_lhs_casted.rstr_result)),
			RSTR_CSTR(&(result_rhs_casted.rstr_result_val))
		);
	} else {
		assert(0);
	}
	_expr_result_set_result(
		expr_result,
		RSTR_CSTR(&(result_lhs_casted.rstr_result_type)),
		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);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x310, %rsp            # imm = 0x310
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 0x35d18
jmp 0x35d37
leaq 0x46837(%rip), %rdi     # 0x7c556
leaq 0x423aa(%rip), %rsi     # 0x780d0
movl $0xb31, %edx            # imm = 0xB31
leaq 0x43046(%rip), %rcx     # 0x78d78
callq 0x30a0
cmpq $0x0, -0x10(%rbp)
je 0x35d40
jmp 0x35d5f
leaq 0x3cdc7(%rip), %rdi     # 0x72b0e
leaq 0x42382(%rip), %rsi     # 0x780d0
movl $0xb32, %edx            # imm = 0xB32
leaq 0x4301e(%rip), %rcx     # 0x78d78
callq 0x30a0
cmpq $0x0, -0x20(%rbp)
je 0x35d68
jmp 0x35d87
leaq 0x3eea4(%rip), %rdi     # 0x74c13
leaq 0x4235a(%rip), %rsi     # 0x780d0
movl $0xb33, %edx            # imm = 0xB33
leaq 0x42ff6(%rip), %rcx     # 0x78d78
callq 0x30a0
cmpq $0x0, -0x28(%rbp)
je 0x35d90
jmp 0x35daf
leaq 0x4023c(%rip), %rdi     # 0x75fd3
leaq 0x42332(%rip), %rsi     # 0x780d0
movl $0xb34, %edx            # imm = 0xB34
leaq 0x42fce(%rip), %rcx     # 0x78d78
callq 0x30a0
movq -0x28(%rbp), %rax
cmpl $0xeb0, (%rax)          # imm = 0xEB0
je 0x35dc7
movq -0x28(%rbp), %rax
cmpl $0xe13, (%rax)          # imm = 0xE13
jne 0x35dc9
jmp 0x35de8
leaq 0x3f68e(%rip), %rdi     # 0x7545e
leaq 0x422f9(%rip), %rsi     # 0x780d0
movl $0xb36, %edx            # imm = 0xB36
leaq 0x42f95(%rip), %rcx     # 0x78d78
callq 0x30a0
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x35dfd
jmp 0x35e1c
leaq 0x4036f(%rip), %rdi     # 0x76173
leaq 0x422c5(%rip), %rsi     # 0x780d0
movl $0xb39, %edx            # imm = 0xB39
leaq 0x42f61(%rip), %rcx     # 0x78d78
callq 0x30a0
movq -0x28(%rbp), %rax
movq 0x68(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x28(%rbp), %rax
movb 0x60(%rax), %al
movb %al, -0x39(%rbp)
movq -0x28(%rbp), %rax
movq 0x48(%rax), %rax
movq (%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x28(%rbp), %rax
movq 0x48(%rax), %rax
movq 0x8(%rax), %rax
movq %rax, -0x50(%rbp)
leaq -0xd0(%rbp), %rdi
callq 0x2a260
leaq -0x150(%rbp), %rdi
callq 0x2a260
leaq -0x1d0(%rbp), %rdi
callq 0x2a260
leaq -0x250(%rbp), %rdi
callq 0x2a260
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x48(%rbp), %rcx
leaq -0xd0(%rbp), %rdx
callq 0x2d590
movq -0x10(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
addq $0x10, %rsi
callq 0x9100
movq -0x10(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x9100
cmpq $0x0, -0x18(%rbp)
je 0x35ed8
movq -0x18(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
addq $0x50, %rsi
callq 0x9100
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x50(%rbp), %rcx
leaq -0x150(%rbp), %rdx
callq 0x2d590
movq -0x10(%rbp), %rdi
leaq -0x150(%rbp), %rsi
addq $0x10, %rsi
callq 0x9100
movq -0x10(%rbp), %rdi
leaq -0x150(%rbp), %rsi
callq 0x9100
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rdx
movq -0x48(%rbp), %rax
movq 0x68(%rax), %r8
leaq -0x1d0(%rbp), %rsi
leaq -0xd0(%rbp), %rcx
callq 0x2a360
movq -0x10(%rbp), %rdi
leaq -0x1d0(%rbp), %rsi
addq $0x10, %rsi
callq 0x9100
movq -0x10(%rbp), %rdi
leaq -0x1d0(%rbp), %rsi
callq 0x9100
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rdx
movq -0x50(%rbp), %rax
movq 0x68(%rax), %r8
leaq -0x250(%rbp), %rsi
leaq -0x150(%rbp), %rcx
callq 0x2a360
movq -0x10(%rbp), %rdi
leaq -0x250(%rbp), %rsi
addq $0x10, %rsi
callq 0x9100
movq -0x10(%rbp), %rdi
leaq -0x250(%rbp), %rsi
callq 0x9100
leaq -0x260(%rbp), %rdi
callq 0x8c90
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rsi
leaq -0x260(%rbp), %rdx
callq 0x35980
movzbl -0x39(%rbp), %edi
callq 0x4d310
testb $0x1, %al
jne 0x35fd4
jmp 0x360a2
movq -0x20(%rbp), %rax
movq %rax, -0x268(%rbp)
cmpq $0x0, -0x258(%rbp)
jne 0x35ff9
leaq 0x418c5(%rip), %rax     # 0x778b5
movq %rax, -0x270(%rbp)
jmp 0x36007
movq -0x258(%rbp), %rax
movq %rax, -0x270(%rbp)
movq -0x270(%rbp), %rax
movq %rax, -0x278(%rbp)
cmpq $0x0, -0x1a8(%rbp)
jne 0x3602f
leaq 0x4188f(%rip), %rax     # 0x778b5
movq %rax, -0x280(%rbp)
jmp 0x3603d
movq -0x1a8(%rbp), %rax
movq %rax, -0x280(%rbp)
movq -0x280(%rbp), %rax
movq %rax, -0x288(%rbp)
cmpq $0x0, -0x208(%rbp)
jne 0x36065
leaq 0x41859(%rip), %rax     # 0x778b5
movq %rax, -0x290(%rbp)
jmp 0x36073
movq -0x208(%rbp), %rax
movq %rax, -0x290(%rbp)
movq -0x288(%rbp), %rcx
movq -0x278(%rbp), %rdx
movq -0x268(%rbp), %rdi
movq -0x290(%rbp), %r8
leaq 0x42d56(%rip), %rsi     # 0x78dec
movb $0x0, %al
callq 0x94d0
jmp 0x36282
movzbl -0x39(%rbp), %edi
callq 0x4d360
testb $0x1, %al
jne 0x360b4
jmp 0x36182
movq -0x20(%rbp), %rax
movq %rax, -0x298(%rbp)
cmpq $0x0, -0x258(%rbp)
jne 0x360d9
leaq 0x417e5(%rip), %rax     # 0x778b5
movq %rax, -0x2a0(%rbp)
jmp 0x360e7
movq -0x258(%rbp), %rax
movq %rax, -0x2a0(%rbp)
movq -0x2a0(%rbp), %rax
movq %rax, -0x2a8(%rbp)
cmpq $0x0, -0x1a8(%rbp)
jne 0x3610f
leaq 0x417af(%rip), %rax     # 0x778b5
movq %rax, -0x2b0(%rbp)
jmp 0x3611d
movq -0x1a8(%rbp), %rax
movq %rax, -0x2b0(%rbp)
movq -0x2b0(%rbp), %rax
movq %rax, -0x2b8(%rbp)
cmpq $0x0, -0x208(%rbp)
jne 0x36145
leaq 0x41779(%rip), %rax     # 0x778b5
movq %rax, -0x2c0(%rbp)
jmp 0x36153
movq -0x208(%rbp), %rax
movq %rax, -0x2c0(%rbp)
movq -0x2b8(%rbp), %rcx
movq -0x2a8(%rbp), %rdx
movq -0x298(%rbp), %rdi
movq -0x2c0(%rbp), %r8
leaq 0x42c8b(%rip), %rsi     # 0x78e01
movb $0x0, %al
callq 0x94d0
jmp 0x36280
movzbl -0x39(%rbp), %edi
callq 0x4d400
testb $0x1, %al
jne 0x36194
jmp 0x3625f
movq -0x20(%rbp), %rax
movq %rax, -0x2c8(%rbp)
cmpq $0x0, -0x258(%rbp)
jne 0x361b9
leaq 0x41705(%rip), %rax     # 0x778b5
movq %rax, -0x2d0(%rbp)
jmp 0x361c7
movq -0x258(%rbp), %rax
movq %rax, -0x2d0(%rbp)
movq -0x2d0(%rbp), %rax
movq %rax, -0x2d8(%rbp)
cmpq $0x0, -0x1a8(%rbp)
jne 0x361ef
leaq 0x416cf(%rip), %rax     # 0x778b5
movq %rax, -0x2e0(%rbp)
jmp 0x361fd
movq -0x1a8(%rbp), %rax
movq %rax, -0x2e0(%rbp)
movq -0x2e0(%rbp), %rax
movq %rax, -0x2e8(%rbp)
cmpq $0x0, -0x208(%rbp)
jne 0x36225
leaq 0x41699(%rip), %rax     # 0x778b5
movq %rax, -0x2f0(%rbp)
jmp 0x36233
movq -0x208(%rbp), %rax
movq %rax, -0x2f0(%rbp)
movq -0x2e8(%rbp), %rcx
movq -0x2d8(%rbp), %rdx
movq -0x2c8(%rbp), %rdi
movq -0x2f0(%rbp), %r8
leaq 0x42bbc(%rip), %rsi     # 0x78e12
movb $0x0, %al
callq 0x94d0
jmp 0x3627e
leaq 0x3c1f5(%rip), %rdi     # 0x7245b
leaq 0x41e63(%rip), %rsi     # 0x780d0
movl $0xb8b, %edx            # imm = 0xB8B
leaq 0x42aff(%rip), %rcx     # 0x78d78
callq 0x30a0
jmp 0x36280
jmp 0x36282
movq -0x20(%rbp), %rax
movq %rax, -0x2f8(%rbp)
cmpq $0x0, -0x198(%rbp)
jne 0x362a7
leaq 0x41617(%rip), %rax     # 0x778b5
movq %rax, -0x300(%rbp)
jmp 0x362b5
movq -0x198(%rbp), %rax
movq %rax, -0x300(%rbp)
movq -0x300(%rbp), %rax
movq %rax, -0x308(%rbp)
cmpq $0x0, -0x258(%rbp)
jne 0x362dd
leaq 0x415e1(%rip), %rax     # 0x778b5
movq %rax, -0x310(%rbp)
jmp 0x362eb
movq -0x258(%rbp), %rax
movq %rax, -0x310(%rbp)
movq -0x308(%rbp), %rsi
movq -0x2f8(%rbp), %rdi
movq -0x310(%rbp), %rdx
callq 0x358a0
leaq -0xd0(%rbp), %rdi
callq 0x2c6a0
leaq -0x150(%rbp), %rdi
callq 0x2c6a0
leaq -0x1d0(%rbp), %rdi
callq 0x2c6a0
leaq -0x250(%rbp), %rdi
callq 0x2c6a0
leaq -0x260(%rbp), %rdi
callq 0x9310
addq $0x310, %rsp            # imm = 0x310
popq %rbp
retq
nopw (%rax,%rax)