// File: /workspace/github_cpp_makefile_star2_O1/cpirc[P]Monochrome/src/search.cpp
// Function: quiesce(SearchController&, Position&, int, int, SearchStack*)
int quiesce(SearchController& sc, Position& pos, int alpha, int beta,
            SearchStack* ss) {
    assert(ss);

    if (ss->ply >= MAX_PLY) {
        return evaluate(pos);
    }

    // Check time left
    clock_t current_time = clock() * 1000 / CLOCKS_PER_SEC;
    if (current_time >= sc.search_end_time) {
        return 0;
    }

    int movecount, value;

    value = evaluate(pos);
    if (value >= beta) return beta;

    if (value > alpha) alpha = value;

    movecount = generate_captures(pos, ss->ml);

    ++ss->stats->node_count;

    score_moves(pos, ss, movecount, 0);

    Move move;
    while ((move = next_move(ss, movecount))) {
        Position npos = pos;

        make_move(npos, move);
        if (is_checked(npos, THEM)) {
            continue;
        }

        value = -quiesce(sc, npos, -beta, -alpha, ss + 1);

        if (value >= beta) {
            return beta;
        }
        if (value > alpha) {
            alpha = value;
        }
    }

    return alpha;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
testq %r8, %r8
je 0x7e94
movq %r8, %r15
movq %rsi, %r12
cmpb $0x40, (%r8)
jb 0x7c30
movq %r12, %rdi
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3bbb
movl %ecx, %r13d
movl %edx, %ebx
movq %rdi, %r14
callq 0x3110
movabsq $0x20c49ba5e353f7cf, %rcx # imm = 0x20C49BA5E353F7CF
imulq %rcx
movq %rdx, %rax
shrq $0x3f, %rax
sarq $0x7, %rdx
addq %rax, %rdx
xorl %eax, %eax
cmpq 0x80(%r14), %rdx
jge 0x7e5e
movq %r12, %rdi
callq 0x3bbb
cmpl %r13d, %eax
jge 0x7e59
movq %r14, -0x48(%rbp)
cmpl %ebx, %eax
cmovgl %eax, %ebx
leaq 0x4(%r15), %rsi
movq %r12, %rdi
callq 0x60cd
leaq -0x34(%rbp), %r14
movl %eax, (%r14)
movq 0x810(%r15), %rcx
incq (%rcx)
movq %r12, %rdi
movq %r15, %rsi
movl %eax, %edx
xorl %ecx, %ecx
callq 0x7a40
movq %r15, %rdi
movq %r14, %rsi
callq 0x7b5f
testl %eax, %eax
je 0x7e5c
movl %eax, %r14d
leaq 0x50(%r12), %rax
movq %rax, -0x50(%rbp)
movl %r13d, -0x2c(%rbp)
negl %r13d
movl %r13d, -0x30(%rbp)
leaq 0x818(%r15), %rax
movq %rax, -0x40(%rbp)
leaq -0xb8(%rbp), %r13
movl $0xa, %ecx
movq %r13, %rdi
movq %r12, %rsi
rep  movsq (%rsi), %es:(%rdi)
leaq -0x68(%rbp), %rdi
movq -0x50(%rbp), %rsi
callq 0x5692
movq %r13, %rdi
movl %r14d, %esi
callq 0x4ac0
movq -0x90(%rbp), %rax
movq -0x80(%rbp), %rcx
andq %rax, %rcx
je 0x7e75
bsfq %rcx, %rsi
movq -0x88(%rbp), %rcx
movq -0x80(%rbp), %rdi
orq %rcx, %rdi
leal (,%rsi,8), %edx
movq -0xb8(%rbp), %r8
leaq 0x9476(%rip), %r9       # 0x111c0
andq 0x200(%r9,%rdx), %r8
movq -0xb0(%rbp), %r9
leaq 0x9860(%rip), %r10      # 0x115c0
andq (%r10,%rdx), %r9
orq %r8, %r9
leaq 0x4732(%rip), %r8       # 0xc4a0
movq (%r8,%rdx), %r8
andq %rdi, %r8
leaq 0x4524(%rip), %r10      # 0xc2a0
imulq (%r10,%rdx), %r8
shrq $0x37, %r8
movl %esi, %r10d
shll $0xc, %r10d
addq 0x921d(%rip), %r10      # 0x10fb0
movq (%r10,%r8,8), %r8
movq -0xa8(%rbp), %r10
andq %r8, %r10
orq %r9, %r10
leaq 0x41f5(%rip), %r9       # 0xbfa0
andq (%r9,%rdx), %rdi
leaq 0x3fea(%rip), %r9       # 0xbda0
imulq (%r9,%rdx), %rdi
shrq $0x34, %rdi
shll $0xf, %esi
addq 0x91cf(%rip), %rsi      # 0x10f98
movq (%rsi,%rdi,8), %rsi
movq -0xa0(%rbp), %rdi
andq %rsi, %rdi
orq %r10, %rdi
orq %r8, %rsi
leaq 0x99dc(%rip), %r8       # 0x117c0
andq (%r8,%rdx), %rax
andq -0x98(%rbp), %rsi
orq %rdi, %rax
orq %rsi, %rax
movl $0x2, %r14d
testq %rcx, %rax
jne 0x7e2c
movl %ebx, %ecx
negl %ecx
movq -0x48(%rbp), %rdi
movq %r13, %rsi
movl -0x30(%rbp), %edx
movq -0x40(%rbp), %r8
callq 0x7bee
negl %eax
movl $0x1, %r14d
cmpl -0x2c(%rbp), %eax
jge 0x7e2c
cmpl %eax, %ebx
cmovlel %eax, %ebx
xorl %r14d, %r14d
movq -0x68(%rbp), %rdi
testq %rdi, %rdi
je 0x7e3a
callq 0x31a0
testb $0x1, %r14b
jne 0x7e70
movq %r15, %rdi
leaq -0x34(%rbp), %rsi
callq 0x7b5f
movl %eax, %r14d
testl %eax, %eax
jne 0x7ce9
jmp 0x7e5c
movl %r13d, %ebx
movl %ebx, %eax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl -0x2c(%rbp), %ebx
jmp 0x7e5c
leaq 0x3dd4(%rip), %rdi      # 0xbc50
leaq 0x3dd0(%rip), %rsi      # 0xbc53
leaq 0x3dd8(%rip), %rcx      # 0xbc62
movl $0x3e, %edx
callq 0x3100
leaq 0x50e5(%rip), %rdi      # 0xcf80
leaq 0x50e1(%rip), %rsi      # 0xcf83
leaq 0x514b(%rip), %rcx      # 0xcff4
movl $0x6a, %edx
callq 0x3100
movq %rax, %rbx
movq -0x68(%rbp), %rdi
testq %rdi, %rdi
je 0x7ec4
callq 0x31a0
movq %rbx, %rdi
callq 0x32d0