// File: /workspace/github_c_makefile_star2_O0/Encryptr[P]O-plus-plus/opp/compiler/compile_expr.c
// Function: opp_compile_logic_assign
static Opp_Obj opp_compile_logic_assign(struct Opp_Context* opp, struct Opp_Node* logic)
{
	Opp_Obj type_info = {0};
	struct Opp_Cond save = opp->cond_state;

	switch (logic->logic_expr.tok) 
	{
		case TEQEQ: case TNOTEQ: case TLT:
		case TGT: case TLE: case TGE: {
			Opp_Obj lhs = opp_compile_expr(opp, logic->logic_expr.left);
			Opp_Obj rhs = opp_compile_expr(opp, logic->logic_expr.right);

			// temp
			type_info = lhs;
			assert(lhs.unsign == 0 && rhs.unsign == 0);
			assert(lhs.decl->t_type != TYPE_FLOAT && lhs.decl->t_type != TYPE_DOUBLE);
			// check sign vs unsign
			// cast types 

			OPCODE_START();
				OPCODE_TYPE(OPCODE_CMP);
				opp->ir.opcodes[opp->ir.instr_idx].cmp.imm = 0; // add imm
			OPCODE_END();

			OPCODE_START();
				OPCODE_TYPE(OPCODE_JMP);
				if (opp->cond_state.use_op)
					opp->ir.opcodes[opp->ir.instr_idx].jmp.type = 
						jmp_opposites[logic->logic_expr.tok];
				else
					opp->ir.opcodes[opp->ir.instr_idx].jmp.type = 
						logic->logic_expr.tok;

				opp->ir.opcodes[opp->ir.instr_idx].jmp.loc = opp->cond_state.jloc;
			OPCODE_END();
			break;
		}

		case TOR: {
			opp->cond_state.curr_logic = TOR;

			if (logic->logic_expr.left->logic_expr.tok == TAND) {
				opp->cond_state.locs[1] = opp->info.label_loc++;
			}

			opp->cond_state.use_op = 0;
			opp->cond_state.jloc = opp->cond_state.locs[0];
			opp->cond_state.hs = 0;
			type_info = opp_compile_logic_assign(opp, logic->logic_expr.left);

			if (logic->logic_expr.left->logic_expr.tok == TAND) {
				OPCODE_START();
					OPCODE_TYPE(OPCODE_LABEL);
					opp->ir.opcodes[opp->ir.instr_idx].constant.val.imm_i32
						= opp->cond_state.locs[1];
				OPCODE_END();

				opp->cond_state.locs[1] = save.locs[1];
			}

			if (save.curr_logic == TOR && save.hs == 0) {
				opp->cond_state.use_op = 0;
				opp->cond_state.jloc = opp->cond_state.locs[0];
			}
			else if (save.hs == 1 && save.curr_logic == TOR) {
				opp->cond_state.use_op = 0;
				opp->cond_state.jloc = opp->cond_state.locs[0];
			}
			else {
				opp->cond_state.use_op = 1;
				opp->cond_state.jloc = opp->cond_state.locs[1];
			}
			opp->cond_state.hs = 1;
			opp->cond_state.curr_logic = save.curr_logic;
			opp_compile_logic_assign(opp, logic->logic_expr.right);
			break;
		}

		case TAND: {
			opp->cond_state.curr_logic = TAND;

			if (logic->logic_expr.left->logic_expr.tok == TOR) {
				opp->cond_state.locs[0] = opp->info.label_loc++;
			}

			opp->cond_state.use_op = 1;
			opp->cond_state.jloc = opp->cond_state.locs[1];
			opp->cond_state.hs = 0;
			type_info = opp_compile_logic_assign(opp, logic->logic_expr.left);

			if (logic->logic_expr.left->logic_expr.tok == TOR) {
				OPCODE_START();
					OPCODE_TYPE(OPCODE_LABEL);
					opp->ir.opcodes[opp->ir.instr_idx].constant.val.imm_i32 = opp->cond_state.locs[0];
				OPCODE_END();

				opp->cond_state.locs[0] = save.locs[0];
			}

			if (save.curr_logic == TOR && save.hs == 0) {
				opp->cond_state.use_op = 0;
				opp->cond_state.jloc = opp->cond_state.locs[0];
			}
			else if (save.hs == 1 && save.curr_logic == TOR) {
				opp->cond_state.use_op = 0;
				opp->cond_state.jloc = opp->cond_state.locs[0];
			}
			else {
				opp->cond_state.use_op = 1;
				opp->cond_state.jloc = opp->cond_state.locs[1];
			}
			opp->cond_state.hs = 1;
			opp->cond_state.curr_logic = save.curr_logic;
			opp_compile_logic_assign(opp, logic->logic_expr.right);
			break;
		}

		default: break;
	}

	opp->cond_state = save;
	return type_info;
}

// Assembly:
subq $0xc8, %rsp
movq %rdi, 0xa8(%rsp)
movq %rsi, 0xa0(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0xb0(%rsp)
movq 0xa8(%rsp), %rax
movl 0x88(%rax), %ecx
movl %ecx, 0x90(%rsp)
movups 0x68(%rax), %xmm0
movups 0x78(%rax), %xmm1
movaps %xmm1, 0x80(%rsp)
movaps %xmm0, 0x70(%rsp)
movq 0xa0(%rsp), %rax
movl 0x10(%rax), %eax
movl %eax, 0xc(%rsp)
subl $0x7, %eax
je 0x76e6
jmp 0x74a6
movl 0xc(%rsp), %eax
subl $0x8, %eax
je 0x791c
jmp 0x74b5
movl 0xc(%rsp), %eax
addl $-0x9, %eax
subl $0x5, %eax
ja 0x7b4f
jmp 0x74c7
movq 0xa8(%rsp), %rdi
movq 0xa0(%rsp), %rax
movq 0x20(%rax), %rsi
callq 0x5d60
movq %rax, 0x60(%rsp)
movq %rdx, 0x68(%rsp)
movq 0xa8(%rsp), %rdi
movq 0xa0(%rsp), %rax
movq 0x18(%rax), %rsi
callq 0x5d60
movq %rax, 0x50(%rsp)
movq %rdx, 0x58(%rsp)
movq 0x60(%rsp), %rax
movq %rax, 0xb0(%rsp)
movq 0x68(%rsp), %rax
movq %rax, 0xb8(%rsp)
movb 0x6c(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x7545
movb 0x5c(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x7545
jmp 0x7564
leaq 0xcbb4(%rip), %rdi      # 0x14100
leaq 0xcbd0(%rip), %rsi      # 0x14123
movl $0x15b, %edx            # imm = 0x15B
leaq 0xcbe0(%rip), %rcx      # 0x1413f
callq 0x10e0
movq 0x60(%rsp), %rax
cmpl $0x5, 0x8(%rax)
je 0x757c
movq 0x60(%rsp), %rax
cmpl $0x6, 0x8(%rax)
je 0x757c
jmp 0x759b
leaq 0xcc06(%rip), %rdi      # 0x14189
leaq 0xcb99(%rip), %rsi      # 0x14123
movl $0x15c, %edx            # imm = 0x15C
leaq 0xcba9(%rip), %rcx      # 0x1413f
callq 0x10e0
movq 0xa8(%rsp), %rdi
callq 0x5600
movq 0xa8(%rsp), %rax
movq 0x58(%rax), %rax
movq 0xa8(%rsp), %rcx
imulq $0x28, 0x48(%rcx), %rcx
addq %rcx, %rax
movl $0x7, (%rax)
movq 0xa8(%rsp), %rax
movq 0x58(%rax), %rax
movq 0xa8(%rsp), %rcx
imulq $0x28, 0x48(%rcx), %rcx
addq %rcx, %rax
movb $0x0, 0x8(%rax)
movq 0xa8(%rsp), %rax
movq 0x48(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x48(%rax)
movq 0xa8(%rsp), %rdi
callq 0x5600
movq 0xa8(%rsp), %rax
movq 0x58(%rax), %rax
movq 0xa8(%rsp), %rcx
imulq $0x28, 0x48(%rcx), %rcx
addq %rcx, %rax
movl $0x8, (%rax)
movq 0xa8(%rsp), %rax
testb $0x1, 0x80(%rax)
je 0x7676
movq 0xa0(%rsp), %rax
movl 0x10(%rax), %eax
movl %eax, %ecx
leaq 0x11ace(%rip), %rax     # 0x19120
movl (%rax,%rcx,4), %ecx
movq 0xa8(%rsp), %rax
movq 0x58(%rax), %rax
movq 0xa8(%rsp), %rdx
imulq $0x28, 0x48(%rdx), %rdx
addq %rdx, %rax
movl %ecx, 0x8(%rax)
jmp 0x76a0
movq 0xa0(%rsp), %rax
movl 0x10(%rax), %ecx
movq 0xa8(%rsp), %rax
movq 0x58(%rax), %rax
movq 0xa8(%rsp), %rdx
imulq $0x28, 0x48(%rdx), %rdx
addq %rdx, %rax
movl %ecx, 0x8(%rax)
movq 0xa8(%rsp), %rax
movl 0x84(%rax), %ecx
movq 0xa8(%rsp), %rax
movq 0x58(%rax), %rax
movq 0xa8(%rsp), %rdx
imulq $0x28, 0x48(%rdx), %rdx
addq %rdx, %rax
movl %ecx, 0xc(%rax)
movq 0xa8(%rsp), %rax
movq 0x48(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x48(%rax)
jmp 0x7b51
movq 0xa8(%rsp), %rax
movl $0x7, 0x7c(%rax)
movq 0xa0(%rsp), %rax
movq 0x20(%rax), %rax
cmpl $0x8, 0x10(%rax)
jne 0x7725
movq 0xa8(%rsp), %rax
movl 0x24(%rax), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, 0x24(%rax)
movq 0xa8(%rsp), %rax
movl %ecx, 0x74(%rax)
movq 0xa8(%rsp), %rax
movb $0x0, 0x80(%rax)
movq 0xa8(%rsp), %rax
movl 0x70(%rax), %ecx
movq 0xa8(%rsp), %rax
movl %ecx, 0x84(%rax)
movq 0xa8(%rsp), %rax
movl $0x0, 0x88(%rax)
movq 0xa8(%rsp), %rdi
movq 0xa0(%rsp), %rax
movq 0x20(%rax), %rsi
callq 0x7440
movq %rax, 0x40(%rsp)
movq %rdx, 0x48(%rsp)
movq 0x40(%rsp), %rax
movq %rax, 0xb0(%rsp)
movq 0x48(%rsp), %rax
movq %rax, 0xb8(%rsp)
movq 0xa0(%rsp), %rax
movq 0x20(%rax), %rax
cmpl $0x8, 0x10(%rax)
jne 0x782a
movq 0xa8(%rsp), %rdi
callq 0x5600
movq 0xa8(%rsp), %rax
movq 0x58(%rax), %rax
movq 0xa8(%rsp), %rcx
imulq $0x28, 0x48(%rcx), %rcx
addq %rcx, %rax
movl $0xa, (%rax)
movq 0xa8(%rsp), %rax
movl 0x74(%rax), %ecx
movq 0xa8(%rsp), %rax
movq 0x58(%rax), %rax
movq 0xa8(%rsp), %rdx
imulq $0x28, 0x48(%rdx), %rdx
addq %rdx, %rax
movl %ecx, 0x10(%rax)
movq 0xa8(%rsp), %rax
movq 0x48(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x48(%rax)
movl 0x7c(%rsp), %ecx
movq 0xa8(%rsp), %rax
movl %ecx, 0x74(%rax)
cmpl $0x7, 0x84(%rsp)
jne 0x7868
cmpl $0x0, 0x90(%rsp)
jne 0x7868
movq 0xa8(%rsp), %rax
movb $0x0, 0x80(%rax)
movq 0xa8(%rsp), %rax
movl 0x70(%rax), %ecx
movq 0xa8(%rsp), %rax
movl %ecx, 0x84(%rax)
jmp 0x78d0
cmpl $0x1, 0x90(%rsp)
jne 0x78a6
cmpl $0x7, 0x84(%rsp)
jne 0x78a6
movq 0xa8(%rsp), %rax
movb $0x0, 0x80(%rax)
movq 0xa8(%rsp), %rax
movl 0x70(%rax), %ecx
movq 0xa8(%rsp), %rax
movl %ecx, 0x84(%rax)
jmp 0x78ce
movq 0xa8(%rsp), %rax
movb $0x1, 0x80(%rax)
movq 0xa8(%rsp), %rax
movl 0x74(%rax), %ecx
movq 0xa8(%rsp), %rax
movl %ecx, 0x84(%rax)
jmp 0x78d0
movq 0xa8(%rsp), %rax
movl $0x1, 0x88(%rax)
movl 0x84(%rsp), %ecx
movq 0xa8(%rsp), %rax
movl %ecx, 0x7c(%rax)
movq 0xa8(%rsp), %rdi
movq 0xa0(%rsp), %rax
movq 0x18(%rax), %rsi
callq 0x7440
movq %rax, 0x30(%rsp)
movq %rdx, 0x38(%rsp)
jmp 0x7b51
movq 0xa8(%rsp), %rax
movl $0x8, 0x7c(%rax)
movq 0xa0(%rsp), %rax
movq 0x20(%rax), %rax
cmpl $0x7, 0x10(%rax)
jne 0x795b
movq 0xa8(%rsp), %rax
movl 0x24(%rax), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, 0x24(%rax)
movq 0xa8(%rsp), %rax
movl %ecx, 0x70(%rax)
movq 0xa8(%rsp), %rax
movb $0x1, 0x80(%rax)
movq 0xa8(%rsp), %rax
movl 0x74(%rax), %ecx
movq 0xa8(%rsp), %rax
movl %ecx, 0x84(%rax)
movq 0xa8(%rsp), %rax
movl $0x0, 0x88(%rax)
movq 0xa8(%rsp), %rdi
movq 0xa0(%rsp), %rax
movq 0x20(%rax), %rsi
callq 0x7440
movq %rax, 0x20(%rsp)
movq %rdx, 0x28(%rsp)
movq 0x20(%rsp), %rax
movq %rax, 0xb0(%rsp)
movq 0x28(%rsp), %rax
movq %rax, 0xb8(%rsp)
movq 0xa0(%rsp), %rax
movq 0x20(%rax), %rax
cmpl $0x7, 0x10(%rax)
jne 0x7a60
movq 0xa8(%rsp), %rdi
callq 0x5600
movq 0xa8(%rsp), %rax
movq 0x58(%rax), %rax
movq 0xa8(%rsp), %rcx
imulq $0x28, 0x48(%rcx), %rcx
addq %rcx, %rax
movl $0xa, (%rax)
movq 0xa8(%rsp), %rax
movl 0x70(%rax), %ecx
movq 0xa8(%rsp), %rax
movq 0x58(%rax), %rax
movq 0xa8(%rsp), %rdx
imulq $0x28, 0x48(%rdx), %rdx
addq %rdx, %rax
movl %ecx, 0x10(%rax)
movq 0xa8(%rsp), %rax
movq 0x48(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x48(%rax)
movl 0x78(%rsp), %ecx
movq 0xa8(%rsp), %rax
movl %ecx, 0x70(%rax)
cmpl $0x7, 0x84(%rsp)
jne 0x7a9e
cmpl $0x0, 0x90(%rsp)
jne 0x7a9e
movq 0xa8(%rsp), %rax
movb $0x0, 0x80(%rax)
movq 0xa8(%rsp), %rax
movl 0x70(%rax), %ecx
movq 0xa8(%rsp), %rax
movl %ecx, 0x84(%rax)
jmp 0x7b06
cmpl $0x1, 0x90(%rsp)
jne 0x7adc
cmpl $0x7, 0x84(%rsp)
jne 0x7adc
movq 0xa8(%rsp), %rax
movb $0x0, 0x80(%rax)
movq 0xa8(%rsp), %rax
movl 0x70(%rax), %ecx
movq 0xa8(%rsp), %rax
movl %ecx, 0x84(%rax)
jmp 0x7b04
movq 0xa8(%rsp), %rax
movb $0x1, 0x80(%rax)
movq 0xa8(%rsp), %rax
movl 0x74(%rax), %ecx
movq 0xa8(%rsp), %rax
movl %ecx, 0x84(%rax)
jmp 0x7b06
movq 0xa8(%rsp), %rax
movl $0x1, 0x88(%rax)
movl 0x84(%rsp), %ecx
movq 0xa8(%rsp), %rax
movl %ecx, 0x7c(%rax)
movq 0xa8(%rsp), %rdi
movq 0xa0(%rsp), %rax
movq 0x18(%rax), %rsi
callq 0x7440
movq %rax, 0x10(%rsp)
movq %rdx, 0x18(%rsp)
jmp 0x7b51
jmp 0x7b51
movq 0xa8(%rsp), %rax
movl 0x90(%rsp), %ecx
movl %ecx, 0x88(%rax)
movaps 0x70(%rsp), %xmm0
movaps 0x80(%rsp), %xmm1
movups %xmm1, 0x78(%rax)
movups %xmm0, 0x68(%rax)
movq 0xb0(%rsp), %rax
movq 0xb8(%rsp), %rdx
addq $0xc8, %rsp
retq
nopw %cs:(%rax,%rax)