// File: /workspace/github_c_makefile_star2_O0/Yamsman[P]scc/src/gen.c
// Function: gen_expr_logic_andor
void gen_expr_logic_andor(asm_f *f, ast_n *n) {
	//Logical-and expressions can short circuit if the LHS is 0,
	//and logical-or expressions can if the LHS is 1
	int jmp_i = -1;
	int pass_val = -1;
	char *lbl_sc = gen_numlabel(f);
	char *lbl_end = gen_numlabel(f);
	switch (n->dat.expr.kind) {
		case EXPR_LOGIC_AND: jmp_i = INST_JNZ; pass_val = 0; break;
		case EXPR_LOGIC_OR:  jmp_i = INST_JZ;  pass_val = 1; break;
	}

	//Generate LHS, compare the pass_value, and short-circuit if possible
	gen_expr(f, n->dat.expr.left);
	asmf_add_inst(f, mk_inst(INST_TEST, 2,
		mk_oprd(OPRD_REG, RAX),
		mk_oprd(OPRD_REG, RAX)
	));
	asmf_add_inst(f, mk_inst(INST_JZ, 1, mk_oprd_label(lbl_sc)));

	//Generate RHS, compare the pass_value, and short-circuit if possible
	gen_expr(f, n->dat.expr.right);
	asmf_add_inst(f, mk_inst(INST_TEST, 2,
		mk_oprd(OPRD_REG, RAX),
		mk_oprd(OPRD_REG, RAX)
	));
	asmf_add_inst(f, mk_inst(INST_JZ, 1, mk_oprd_label(lbl_sc)));

	//If this point was reached, 'and' is true or 'or' is false
	asmf_add_inst(f, mk_inst(INST_MOV, 2,
		mk_oprd(OPRD_REG, RAX),
		mk_oprd(OPRD_IMM, !pass_val)
	));
	asmf_add_inst(f, mk_inst(INST_JZ, 1, mk_oprd_label(lbl_end)));

	//Short-circuit result
	asmf_add_inst(f, mk_label(lbl_sc));
	asmf_add_inst(f, mk_inst(INST_MOV, 2,
		mk_oprd(OPRD_REG, RAX),
		mk_oprd(OPRD_IMM, pass_val)
	));
	asmf_add_inst(f, mk_label(lbl_end));

	return;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x220, %rsp            # imm = 0x220
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0xffffffff, -0x14(%rbp) # imm = 0xFFFFFFFF
movl $0xffffffff, -0x18(%rbp) # imm = 0xFFFFFFFF
movq -0x8(%rbp), %rdi
callq 0x43f0
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rdi
callq 0x43f0
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x18c(%rbp)
subl $0x1, %eax
je 0x44ec
jmp 0x44cf
movl -0x18c(%rbp), %eax
subl $0x2, %eax
jne 0x44fa
jmp 0x44dc
movl $0x3b, -0x14(%rbp)
movl $0x0, -0x18(%rbp)
jmp 0x44fa
movl $0x39, -0x14(%rbp)
movl $0x1, -0x18(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rsi
callq 0x4920
movq -0x8(%rbp), %rax
movq %rax, -0x1d8(%rbp)
leaq -0x48(%rbp), %rdi
xorl %edx, %edx
movl %edx, %esi
callq 0x63c0
leaq -0x68(%rbp), %rdi
xorl %edx, %edx
movl %edx, %esi
callq 0x63c0
movl $0x3d, %edi
movl $0x2, %esi
leaq -0x48(%rbp), %rcx
leaq -0x68(%rbp), %rax
movq (%rcx), %rdx
movq %rdx, (%rsp)
movq 0x8(%rcx), %rdx
movq %rdx, 0x8(%rsp)
movq 0x10(%rcx), %rdx
movq %rdx, 0x10(%rsp)
movq 0x18(%rcx), %rcx
movq %rcx, 0x18(%rsp)
movq (%rax), %rcx
movq %rcx, 0x20(%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x28(%rsp)
movq 0x10(%rax), %rcx
movq %rcx, 0x30(%rsp)
movq 0x18(%rax), %rax
movq %rax, 0x38(%rsp)
movb $0x0, %al
callq 0x6460
movq -0x1d8(%rbp), %rdi
movq %rax, %rsi
callq 0x68f0
movq -0x8(%rbp), %rax
movq %rax, -0x1d0(%rbp)
movq -0x20(%rbp), %rsi
leaq -0x88(%rbp), %rdi
callq 0x6420
movl $0x39, %edi
movl $0x1, %esi
leaq -0x88(%rbp), %rax
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rcx
movq %rcx, 0x10(%rsp)
movq 0x18(%rax), %rax
movq %rax, 0x18(%rsp)
movb $0x0, %al
callq 0x6460
movq -0x1d0(%rbp), %rdi
movq %rax, %rsi
callq 0x68f0
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rsi
callq 0x4920
movq -0x8(%rbp), %rax
movq %rax, -0x1c8(%rbp)
leaq -0xa8(%rbp), %rdi
xorl %edx, %edx
movl %edx, %esi
callq 0x63c0
leaq -0xc8(%rbp), %rdi
xorl %edx, %edx
movl %edx, %esi
callq 0x63c0
movl $0x3d, %edi
movl $0x2, %esi
leaq -0xa8(%rbp), %rcx
leaq -0xc8(%rbp), %rax
movq (%rcx), %rdx
movq %rdx, (%rsp)
movq 0x8(%rcx), %rdx
movq %rdx, 0x8(%rsp)
movq 0x10(%rcx), %rdx
movq %rdx, 0x10(%rsp)
movq 0x18(%rcx), %rcx
movq %rcx, 0x18(%rsp)
movq (%rax), %rcx
movq %rcx, 0x20(%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x28(%rsp)
movq 0x10(%rax), %rcx
movq %rcx, 0x30(%rsp)
movq 0x18(%rax), %rax
movq %rax, 0x38(%rsp)
movb $0x0, %al
callq 0x6460
movq -0x1c8(%rbp), %rdi
movq %rax, %rsi
callq 0x68f0
movq -0x8(%rbp), %rax
movq %rax, -0x1c0(%rbp)
movq -0x20(%rbp), %rsi
leaq -0xe8(%rbp), %rdi
callq 0x6420
movl $0x39, %edi
movl $0x1, %esi
leaq -0xe8(%rbp), %rax
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rcx
movq %rcx, 0x10(%rsp)
movq 0x18(%rax), %rax
movq %rax, 0x18(%rsp)
movb $0x0, %al
callq 0x6460
movq -0x1c0(%rbp), %rdi
movq %rax, %rsi
callq 0x68f0
movq -0x8(%rbp), %rax
movq %rax, -0x1b8(%rbp)
leaq -0x108(%rbp), %rdi
xorl %edx, %edx
movl %edx, %esi
callq 0x63c0
cmpl $0x0, -0x18(%rbp)
setne %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %edx
leaq -0x128(%rbp), %rdi
movl $0x1, %esi
callq 0x63c0
movl $0x3e, %edi
movl $0x2, %esi
leaq -0x108(%rbp), %rcx
leaq -0x128(%rbp), %rax
movq (%rcx), %rdx
movq %rdx, (%rsp)
movq 0x8(%rcx), %rdx
movq %rdx, 0x8(%rsp)
movq 0x10(%rcx), %rdx
movq %rdx, 0x10(%rsp)
movq 0x18(%rcx), %rcx
movq %rcx, 0x18(%rsp)
movq (%rax), %rcx
movq %rcx, 0x20(%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x28(%rsp)
movq 0x10(%rax), %rcx
movq %rcx, 0x30(%rsp)
movq 0x18(%rax), %rax
movq %rax, 0x38(%rsp)
movb $0x0, %al
callq 0x6460
movq -0x1b8(%rbp), %rdi
movq %rax, %rsi
callq 0x68f0
movq -0x8(%rbp), %rax
movq %rax, -0x1b0(%rbp)
movq -0x28(%rbp), %rsi
leaq -0x148(%rbp), %rdi
callq 0x6420
movl $0x39, %edi
movl $0x1, %esi
leaq -0x148(%rbp), %rax
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rcx
movq %rcx, 0x10(%rsp)
movq 0x18(%rax), %rax
movq %rax, 0x18(%rsp)
movb $0x0, %al
callq 0x6460
movq -0x1b0(%rbp), %rdi
movq %rax, %rsi
callq 0x68f0
movq -0x8(%rbp), %rax
movq %rax, -0x1a8(%rbp)
movq -0x20(%rbp), %rdi
callq 0x65a0
movq -0x1a8(%rbp), %rdi
movq %rax, %rsi
callq 0x68f0
movq -0x8(%rbp), %rax
movq %rax, -0x1a0(%rbp)
leaq -0x168(%rbp), %rdi
xorl %edx, %edx
movl %edx, %esi
callq 0x63c0
movl -0x18(%rbp), %edx
leaq -0x188(%rbp), %rdi
movl $0x1, %esi
callq 0x63c0
movl $0x3e, %edi
movl $0x2, %esi
leaq -0x168(%rbp), %rcx
leaq -0x188(%rbp), %rax
movq (%rcx), %rdx
movq %rdx, (%rsp)
movq 0x8(%rcx), %rdx
movq %rdx, 0x8(%rsp)
movq 0x10(%rcx), %rdx
movq %rdx, 0x10(%rsp)
movq 0x18(%rcx), %rcx
movq %rcx, 0x18(%rsp)
movq (%rax), %rcx
movq %rcx, 0x20(%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x28(%rsp)
movq 0x10(%rax), %rcx
movq %rcx, 0x30(%rsp)
movq 0x18(%rax), %rax
movq %rax, 0x38(%rsp)
movb $0x0, %al
callq 0x6460
movq -0x1a0(%rbp), %rdi
movq %rax, %rsi
callq 0x68f0
movq -0x8(%rbp), %rax
movq %rax, -0x198(%rbp)
movq -0x28(%rbp), %rdi
callq 0x65a0
movq -0x198(%rbp), %rdi
movq %rax, %rsi
callq 0x68f0
addq $0x220, %rsp            # imm = 0x220
popq %rbp
retq
nopw %cs:(%rax,%rax)