// File: /workspace/github_c_makefile_star2_O0/Ihsoh[P]ilang/compiler/frontend/irgen_llvmir.c
// Function: ir_expr_bitwise
static void _ir_expr_bitwise(
	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_BAND
			|| node->type == FE_NODE_EXPR_BAND_ASSIGN
			|| node->type == FE_NODE_EXPR_BXOR
			|| node->type == FE_NODE_EXPR_BXOR_ASSIGN
			|| node->type == FE_NODE_EXPR_BOR
			|| node->type == FE_NODE_EXPR_BOR_ASSIGN);

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

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

	ParserASTNode *node_type = FE_EXPR_AST_NODE_GET_TYPE_NODE(node);

	ParserASTNode *node_lhs_type = FE_EXPR_AST_NODE_GET_TYPE_NODE(node_lhs);
	ParserASTNode *node_rhs_type = FE_EXPR_AST_NODE_GET_TYPE_NODE(node_rhs);

	_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,
		node_lhs_type
	);
	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,
		node_rhs_type
	);
	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);

	#define	_A(cmd)	\
		rstr_appendf(	\
			&(expr_result->rstr_for_result),	\
			"%s = "cmd" %s, %s\n",	\
			RSTR_CSTR(&rstr_tmp_label_val),	\
			RSTR_CSTR(&(result_lhs_casted.rstr_result)),	\
			RSTR_CSTR(&(result_rhs_casted.rstr_result_val))	\
		);

	switch (node->type) {
		case FE_NODE_EXPR_BAND:
		case FE_NODE_EXPR_BAND_ASSIGN: {
			_A("and")
			break;
		}
		case FE_NODE_EXPR_BXOR:
		case FE_NODE_EXPR_BXOR_ASSIGN: {
			_A("xor")
			break;
		}
		case FE_NODE_EXPR_BOR:
		case FE_NODE_EXPR_BOR_ASSIGN: {
			_A("or")
			break;
		}
		default: {
			assert(0);
		}
	}

	#undef	_A

	_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 $0x340, %rsp            # imm = 0x340
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 0x38ec8
jmp 0x38ee7
leaq 0x43687(%rip), %rdi     # 0x7c556
leaq 0x3f1fa(%rip), %rsi     # 0x780d0
movl $0xfdb, %edx            # imm = 0xFDB
leaq 0x40660(%rip), %rcx     # 0x79542
callq 0x30a0
cmpq $0x0, -0x10(%rbp)
je 0x38ef0
jmp 0x38f0f
leaq 0x39c17(%rip), %rdi     # 0x72b0e
leaq 0x3f1d2(%rip), %rsi     # 0x780d0
movl $0xfdc, %edx            # imm = 0xFDC
leaq 0x40638(%rip), %rcx     # 0x79542
callq 0x30a0
cmpq $0x0, -0x20(%rbp)
je 0x38f18
jmp 0x38f37
leaq 0x3bcf4(%rip), %rdi     # 0x74c13
leaq 0x3f1aa(%rip), %rsi     # 0x780d0
movl $0xfdd, %edx            # imm = 0xFDD
leaq 0x40610(%rip), %rcx     # 0x79542
callq 0x30a0
cmpq $0x0, -0x28(%rbp)
je 0x38f40
jmp 0x38f5f
leaq 0x3d08c(%rip), %rdi     # 0x75fd3
leaq 0x3f182(%rip), %rsi     # 0x780d0
movl $0xfde, %edx            # imm = 0xFDE
leaq 0x405e8(%rip), %rcx     # 0x79542
callq 0x30a0
movq -0x28(%rbp), %rax
cmpl $0xe60, (%rax)          # imm = 0xE60
je 0x38fa7
movq -0x28(%rbp), %rax
cmpl $0xe16, (%rax)          # imm = 0xE16
je 0x38fa7
movq -0x28(%rbp), %rax
cmpl $0xe50, (%rax)          # imm = 0xE50
je 0x38fa7
movq -0x28(%rbp), %rax
cmpl $0xe18, (%rax)          # imm = 0xE18
je 0x38fa7
movq -0x28(%rbp), %rax
cmpl $0xe40, (%rax)          # imm = 0xE40
je 0x38fa7
movq -0x28(%rbp), %rax
cmpl $0xe17, (%rax)          # imm = 0xE17
jne 0x38fa9
jmp 0x38fc8
leaq 0x3cc17(%rip), %rdi     # 0x75bc7
leaq 0x3f119(%rip), %rsi     # 0x780d0
movl $0xfe4, %edx            # imm = 0xFE4
leaq 0x4057f(%rip), %rcx     # 0x79542
callq 0x30a0
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x38fdd
jmp 0x38ffc
leaq 0x3d18f(%rip), %rdi     # 0x76173
leaq 0x3f0e5(%rip), %rsi     # 0x780d0
movl $0xfe7, %edx            # imm = 0xFE7
leaq 0x4054b(%rip), %rcx     # 0x79542
callq 0x30a0
movq -0x28(%rbp), %rax
movq 0x48(%rax), %rax
movq (%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x28(%rbp), %rax
movq 0x48(%rax), %rax
movq 0x8(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x28(%rbp), %rax
movq 0x68(%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x38(%rbp), %rax
movq 0x68(%rax), %rax
movq %rax, -0x50(%rbp)
movq -0x40(%rbp), %rax
movq 0x68(%rax), %rax
movq %rax, -0x58(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0x2a260
leaq -0x158(%rbp), %rdi
callq 0x2a260
leaq -0x1d8(%rbp), %rdi
callq 0x2a260
leaq -0x258(%rbp), %rdi
callq 0x2a260
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x38(%rbp), %rcx
leaq -0xd8(%rbp), %rdx
callq 0x2d590
movq -0x10(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
addq $0x10, %rsi
callq 0x9100
movq -0x10(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
callq 0x9100
cmpq $0x0, -0x18(%rbp)
je 0x390c6
movq -0x18(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
addq $0x50, %rsi
callq 0x9100
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x40(%rbp), %rcx
leaq -0x158(%rbp), %rdx
movq %rdx, -0x288(%rbp)
callq 0x2d590
movq -0x10(%rbp), %rdi
leaq -0x148(%rbp), %rsi
callq 0x9100
movq -0x288(%rbp), %rsi
movq -0x10(%rbp), %rdi
callq 0x9100
movq -0x8(%rbp), %rdi
movq -0x48(%rbp), %rdx
movq -0x50(%rbp), %r8
leaq -0x1d8(%rbp), %rsi
movq %rsi, -0x290(%rbp)
leaq -0xd8(%rbp), %rcx
callq 0x2a360
movq -0x10(%rbp), %rdi
leaq -0x1c8(%rbp), %rsi
callq 0x9100
movq -0x290(%rbp), %rsi
movq -0x10(%rbp), %rdi
callq 0x9100
movq -0x288(%rbp), %rcx
movq -0x8(%rbp), %rdi
movq -0x48(%rbp), %rdx
movq -0x58(%rbp), %r8
leaq -0x258(%rbp), %rsi
movq %rsi, -0x280(%rbp)
callq 0x2a360
movq -0x10(%rbp), %rdi
leaq -0x248(%rbp), %rsi
callq 0x9100
movq -0x280(%rbp), %rsi
movq -0x10(%rbp), %rdi
callq 0x9100
leaq -0x268(%rbp), %rdi
movq %rdi, -0x278(%rbp)
callq 0x8c90
movq -0x278(%rbp), %rdx
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x35980
movq -0x28(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x26c(%rbp)
subl $0xe16, %eax            # imm = 0xE16
je 0x3922c
jmp 0x391cd
movl -0x26c(%rbp), %eax
subl $0xe17, %eax            # imm = 0xE17
je 0x393c8
jmp 0x391e0
movl -0x26c(%rbp), %eax
subl $0xe18, %eax            # imm = 0xE18
je 0x392fa
jmp 0x391f3
movl -0x26c(%rbp), %eax
subl $0xe40, %eax            # imm = 0xE40
je 0x393c8
jmp 0x39206
movl -0x26c(%rbp), %eax
subl $0xe50, %eax            # imm = 0xE50
je 0x392fa
jmp 0x39219
movl -0x26c(%rbp), %eax
subl $0xe60, %eax            # imm = 0xE60
jne 0x39493
jmp 0x3922c
movq -0x20(%rbp), %rax
movq %rax, -0x298(%rbp)
cmpq $0x0, -0x260(%rbp)
jne 0x39251
leaq 0x3e66d(%rip), %rax     # 0x778b5
movq %rax, -0x2a0(%rbp)
jmp 0x3925f
movq -0x260(%rbp), %rax
movq %rax, -0x2a0(%rbp)
movq -0x2a0(%rbp), %rax
movq %rax, -0x2a8(%rbp)
cmpq $0x0, -0x1b0(%rbp)
jne 0x39287
leaq 0x3e637(%rip), %rax     # 0x778b5
movq %rax, -0x2b0(%rbp)
jmp 0x39295
movq -0x1b0(%rbp), %rax
movq %rax, -0x2b0(%rbp)
movq -0x2b0(%rbp), %rax
movq %rax, -0x2b8(%rbp)
cmpq $0x0, -0x210(%rbp)
jne 0x392bd
leaq 0x3e601(%rip), %rax     # 0x778b5
movq %rax, -0x2c0(%rbp)
jmp 0x392cb
movq -0x210(%rbp), %rax
movq %rax, -0x2c0(%rbp)
movq -0x2b8(%rbp), %rcx
movq -0x2a8(%rbp), %rdx
movq -0x298(%rbp), %rdi
movq -0x2c0(%rbp), %r8
leaq 0x402cc(%rip), %rsi     # 0x795ba
movb $0x0, %al
callq 0x94d0
jmp 0x394b2
movq -0x20(%rbp), %rax
movq %rax, -0x2c8(%rbp)
cmpq $0x0, -0x260(%rbp)
jne 0x3931f
leaq 0x3e59f(%rip), %rax     # 0x778b5
movq %rax, -0x2d0(%rbp)
jmp 0x3932d
movq -0x260(%rbp), %rax
movq %rax, -0x2d0(%rbp)
movq -0x2d0(%rbp), %rax
movq %rax, -0x2d8(%rbp)
cmpq $0x0, -0x1b0(%rbp)
jne 0x39355
leaq 0x3e569(%rip), %rax     # 0x778b5
movq %rax, -0x2e0(%rbp)
jmp 0x39363
movq -0x1b0(%rbp), %rax
movq %rax, -0x2e0(%rbp)
movq -0x2e0(%rbp), %rax
movq %rax, -0x2e8(%rbp)
cmpq $0x0, -0x210(%rbp)
jne 0x3938b
leaq 0x3e533(%rip), %rax     # 0x778b5
movq %rax, -0x2f0(%rbp)
jmp 0x39399
movq -0x210(%rbp), %rax
movq %rax, -0x2f0(%rbp)
movq -0x2e8(%rbp), %rcx
movq -0x2d8(%rbp), %rdx
movq -0x2c8(%rbp), %rdi
movq -0x2f0(%rbp), %r8
leaq 0x4020f(%rip), %rsi     # 0x795cb
movb $0x0, %al
callq 0x94d0
jmp 0x394b2
movq -0x20(%rbp), %rax
movq %rax, -0x2f8(%rbp)
cmpq $0x0, -0x260(%rbp)
jne 0x393ed
leaq 0x3e4d1(%rip), %rax     # 0x778b5
movq %rax, -0x300(%rbp)
jmp 0x393fb
movq -0x260(%rbp), %rax
movq %rax, -0x300(%rbp)
movq -0x300(%rbp), %rax
movq %rax, -0x308(%rbp)
cmpq $0x0, -0x1b0(%rbp)
jne 0x39423
leaq 0x3e49b(%rip), %rax     # 0x778b5
movq %rax, -0x310(%rbp)
jmp 0x39431
movq -0x1b0(%rbp), %rax
movq %rax, -0x310(%rbp)
movq -0x310(%rbp), %rax
movq %rax, -0x318(%rbp)
cmpq $0x0, -0x210(%rbp)
jne 0x39459
leaq 0x3e465(%rip), %rax     # 0x778b5
movq %rax, -0x320(%rbp)
jmp 0x39467
movq -0x210(%rbp), %rax
movq %rax, -0x320(%rbp)
movq -0x318(%rbp), %rcx
movq -0x308(%rbp), %rdx
movq -0x2f8(%rbp), %rdi
movq -0x320(%rbp), %r8
leaq 0x40152(%rip), %rsi     # 0x795dc
movb $0x0, %al
callq 0x94d0
jmp 0x394b2
leaq 0x38fc1(%rip), %rdi     # 0x7245b
leaq 0x3ec2f(%rip), %rsi     # 0x780d0
movl $0x103c, %edx           # imm = 0x103C
leaq 0x40095(%rip), %rcx     # 0x79542
callq 0x30a0
movq -0x20(%rbp), %rax
movq %rax, -0x328(%rbp)
cmpq $0x0, -0x1a0(%rbp)
jne 0x394d7
leaq 0x3e3e7(%rip), %rax     # 0x778b5
movq %rax, -0x330(%rbp)
jmp 0x394e5
movq -0x1a0(%rbp), %rax
movq %rax, -0x330(%rbp)
movq -0x330(%rbp), %rax
movq %rax, -0x338(%rbp)
cmpq $0x0, -0x260(%rbp)
jne 0x3950d
leaq 0x3e3b1(%rip), %rax     # 0x778b5
movq %rax, -0x340(%rbp)
jmp 0x3951b
movq -0x260(%rbp), %rax
movq %rax, -0x340(%rbp)
movq -0x338(%rbp), %rsi
movq -0x328(%rbp), %rdi
movq -0x340(%rbp), %rdx
callq 0x358a0
leaq -0xd8(%rbp), %rdi
callq 0x2c6a0
leaq -0x158(%rbp), %rdi
callq 0x2c6a0
leaq -0x1d8(%rbp), %rdi
callq 0x2c6a0
leaq -0x258(%rbp), %rdi
callq 0x2c6a0
leaq -0x268(%rbp), %rdi
callq 0x9310
addq $0x340, %rsp            # imm = 0x340
popq %rbp
retq
nopw (%rax,%rax)