// File: /workspace/github_c_makefile_star2_O0/vtereshkov[P]umka-lang/src/umka_expr.c
// Function: parseLogicalTerm
static void parseLogicalTerm(Compiler *comp, const Type **type, Const *constant)
{
    parseRelation(comp, type, constant);

    while (comp->lex.tok.kind == TOK_ANDAND)
    {
        TokenKind op = comp->lex.tok.kind;
        lexNext(&comp->lex);

        if (constant)
        {
            if (constant->intVal)
            {
                Const rightConstantBuf, *rightConstant = &rightConstantBuf;

                const Type *rightType = *type;
                parseRelation(comp, &rightType, rightConstant);
                doApplyOperator(comp, type, &rightType, constant, rightConstant, op, false, true);
                constant->intVal = rightConstant->intVal;
            }
            else
                constant->intVal = false;
        }
        else
        {
            genShortCircuitProlog(&comp->gen);

            blocksEnter(&comp->blocks);

            const Type *rightType = *type;
            parseRelation(comp, &rightType, NULL);
            doApplyOperator(comp, type, &rightType, NULL, NULL, op, false, true);

            doGarbageCollection(comp);
            identWarnIfUnusedAll(&comp->idents, blocksCurrent(&comp->blocks));
            blocksLeave(&comp->blocks);

            genShortCircuitEpilog(&comp->gen, op);
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0x15e40
movq -0x8(%rbp), %rax
cmpl $0x2a, 0x4bd0(%rax)
jne 0x15e3a
movq -0x8(%rbp), %rax
movl 0x4bd0(%rax), %eax
movl %eax, -0x1c(%rbp)
movq -0x8(%rbp), %rdi
addq $0x4ba8, %rdi           # imm = 0x4BA8
callq 0x1ad90
cmpq $0x0, -0x18(%rbp)
je 0x15d76
movq -0x18(%rbp), %rax
cmpq $0x0, (%rax)
je 0x15d66
leaq -0x28(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rdx
leaq -0x38(%rbp), %rsi
callq 0x15e40
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rcx
movq -0x30(%rbp), %r8
movl -0x1c(%rbp), %r9d
leaq -0x38(%rbp), %rdx
xorl %eax, %eax
movl $0x0, (%rsp)
movl $0x1, 0x8(%rsp)
callq 0xe1d0
movq -0x30(%rbp), %rax
movq (%rax), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
jmp 0x15d71
movq -0x18(%rbp), %rax
movq $0x0, (%rax)
jmp 0x15e35
movq -0x8(%rbp), %rdi
addq $0x4e70, %rdi           # imm = 0x4E70
callq 0x18a50
movq -0x8(%rbp), %rdi
addq $0x4220, %rdi           # imm = 0x4220
callq 0x5e60
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rdi
leaq -0x40(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x15e40
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl -0x1c(%rbp), %r9d
leaq -0x40(%rbp), %rdx
xorl %eax, %eax
movl %eax, %r8d
xorl %eax, %eax
movq %r8, %rcx
movl $0x0, (%rsp)
movl $0x1, 0x8(%rsp)
callq 0xe1d0
movq -0x8(%rbp), %rdi
callq 0x1d3a0
movq -0x8(%rbp), %rax
addq $0x4e38, %rax           # imm = 0x4E38
movq %rax, -0x48(%rbp)
movq -0x8(%rbp), %rdi
addq $0x4220, %rdi           # imm = 0x4220
callq 0x6020
movq -0x48(%rbp), %rdi
movl %eax, %esi
callq 0x1a7e0
movq -0x8(%rbp), %rdi
addq $0x4220, %rdi           # imm = 0x4220
callq 0x5fa0
movq -0x8(%rbp), %rdi
addq $0x4e70, %rdi           # imm = 0x4E70
movl -0x1c(%rbp), %esi
callq 0x18a90
jmp 0x15cc5
addq $0x60, %rsp
popq %rbp
retq