// File: jswaff[P]prophet3/src/think.cpp
// Function: print_search_summary(int, search_stats*)
void print_search_summary(int last_depth,search_stats *stats) {
    uint64 total_nodes = stats->nodes + stats->qnodes;

    float interior_pct = stats->nodes / (total_nodes/100.0);
    float qnode_pct = stats->qnodes / (total_nodes/100.0);

    print("\n");
    print("# depth: %d\n",last_depth);
    print("# nodes: %lluk, interior: %lluk (%.2f%%), quiescence: %lluk (%.2f%%)\n",
            total_nodes/1000,stats->nodes/1000,interior_pct,stats->qnodes/1000,qnode_pct);

    int32 search_time_ms = milli_timer() - get_start_time() + 1; // add 1 ms just to avoid div by 0
    float search_time = search_time_ms / 1000.0;
    uint64 nps = (stats->nodes+stats->qnodes) / search_time_ms;
    print("# search time: %.2f seconds, rate: %llu kn/s\n",search_time,nps);

    uint64 hash_hits = htbl.hits;
    uint64 hash_probes = htbl.probes;
    uint64 hash_collisions = htbl.collisions;
    float hash_hit_pct = hash_hits / ((hash_probes+1)/100.0);
    float hash_collision_pct = hash_collisions / ((hash_probes+1)/100.0);
    print("# hash probes: %lluk, hits: %lluk (%.2f%%), collisions: %lluk (%.2f%%)\n",
            hash_probes/1000,
            hash_hits/1000,hash_hit_pct,
            hash_collisions/1000,hash_collision_pct);

    uint64 pawn_hash_hits = phtbl.hits;
    uint64 pawn_hash_probes = phtbl.probes;
    uint64 pawn_hash_collisions = phtbl.collisions;
    float pawn_hash_hit_pct = pawn_hash_hits / ((pawn_hash_probes+1)/100.0);
    float pawn_hash_collision_pct = pawn_hash_collisions / ((pawn_hash_probes+1)/100.0);
    print("# pawn hash probes: %lluk, hits: %lluk (%.2f%%), collisions: %lluk (%.2f%%)\n",
            pawn_hash_probes/1000,
            pawn_hash_hits/1000,pawn_hash_hit_pct,
            pawn_hash_collisions/1000,pawn_hash_collision_pct);

    float fail_high_pct = stats->fail_highs / ((hash_probes+1)/100.0);
    float fail_low_pct = stats->fail_lows / ((hash_probes+1)/100.0);
    float exact_score_pct = stats->hash_exact_scores / ((hash_probes+1)/100.0);

    print("# fail highs: %lluk (%.2f%%), fail lows: %lluk (%.2f%%), exact scores: %lluk (%.2f%%)\n",
            stats->fail_highs,fail_high_pct,
            stats->fail_lows,fail_low_pct,
            stats->hash_exact_scores,exact_score_pct);

    print("# prunes: %llu\n", stats->prunes);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xf0, %rsp
movl %edi, -0x4(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rcx
movq 0x18(%rcx), %rax
movq 0x20(%rcx), %rcx
addq %rcx, %rax
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %xmm0
movaps 0x24c7b(%rip), %xmm4    # 0x38760
movaps %xmm4, -0xa0(%rbp)
punpckldq %xmm4, %xmm0    # xmm0 = xmm0[0],xmm4[0],xmm0[1],xmm4[1]
movapd 0x24c78(%rip), %xmm3    # 0x38770
movaps %xmm3, -0x90(%rbp)
subpd %xmm3, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movq -0x18(%rbp), %xmm1
punpckldq %xmm4, %xmm1    # xmm1 = xmm1[0],xmm4[0],xmm1[1],xmm4[1]
subpd %xmm3, %xmm1
movaps %xmm1, %xmm2
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm2, %xmm1
movsd 0x24c1a(%rip), %xmm2    # 0x38748
movsd %xmm2, -0xa8(%rbp)
divsd %xmm2, %xmm1
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %xmm0
punpckldq %xmm4, %xmm0    # xmm0 = xmm0[0],xmm4[0],xmm0[1],xmm4[1]
subpd %xmm3, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movq -0x18(%rbp), %xmm1
punpckldq %xmm4, %xmm1    # xmm1 = xmm1[0],xmm4[0],xmm1[1],xmm4[1]
subpd %xmm3, %xmm1
movaps %xmm1, %xmm3
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm3, %xmm1
divsd %xmm2, %xmm1
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x20(%rbp)
leaq 0x22cf2(%rip), %rdi     # 0x36885
xorl %eax, %eax
movl %eax, -0xd0(%rbp)
movb %al, -0xe1(%rbp)
callq 0x8c60
movb -0xe1(%rbp), %al
movl -0x4(%rbp), %esi
leaq 0x24ead(%rip), %rdi     # 0x38a63
callq 0x8c60
movq -0x18(%rbp), %rax
shrq $0x3, %rax
movabsq $0x20c49ba5e353f7cf, %rcx # imm = 0x20C49BA5E353F7CF
movq %rcx, -0xc0(%rbp)
mulq %rcx
movq %rdx, %rsi
shrq $0x4, %rsi
movq -0x10(%rbp), %rdx
movq 0x18(%rdx), %rax
movq 0x20(%rdx), %rdx
movq %rdx, -0xe0(%rbp)
shrq $0x3, %rax
mulq %rcx
movq -0xe0(%rbp), %rax
shrq $0x4, %rdx
movq %rdx, -0xd8(%rbp)
movss -0x1c(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
shrq $0x3, %rax
mulq %rcx
movq %rdx, %rcx
movq -0xd8(%rbp), %rdx
shrq $0x4, %rcx
movss -0x20(%rbp), %xmm1
cvtss2sd %xmm1, %xmm1
leaq 0x24e38(%rip), %rdi     # 0x38a70
movb $0x2, %al
movb %al, -0xb1(%rbp)
callq 0x8c60
callq 0x14080
movl %eax, -0xcc(%rbp)
callq 0x10220
movl -0xd0(%rbp), %edx
movl %eax, %ecx
movl -0xcc(%rbp), %eax
subl %ecx, %eax
incl %eax
movl %eax, -0x24(%rbp)
cvtsi2sdl -0x24(%rbp), %xmm0
movsd 0x24ad9(%rip), %xmm1    # 0x38750
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x28(%rbp)
movq -0x10(%rbp), %rcx
movq 0x18(%rcx), %rax
movq 0x20(%rcx), %rcx
addq %rcx, %rax
movslq -0x24(%rbp), %rcx
divq %rcx
movq %rax, -0x30(%rbp)
movss -0x28(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movq -0x30(%rbp), %rsi
leaq 0x24e04(%rip), %rdi     # 0x38ab6
movb $0x1, %al
callq 0x8c60
movq -0xc0(%rbp), %rcx
movsd -0xa8(%rbp), %xmm2
movaps -0xa0(%rbp), %xmm4
movaps -0x90(%rbp), %xmm3
leaq 0xef3d3(%rip), %rax     # 0x1030b0
movq 0x20(%rax), %rdx
movq %rdx, -0x38(%rbp)
movq 0x18(%rax), %rdx
movq %rdx, -0x40(%rbp)
movq 0x28(%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x38(%rbp), %xmm0
punpckldq %xmm4, %xmm0    # xmm0 = xmm0[0],xmm4[0],xmm0[1],xmm4[1]
subpd %xmm3, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movq -0x40(%rbp), %rax
incq %rax
movq %rax, %xmm1
punpckldq %xmm4, %xmm1    # xmm1 = xmm1[0],xmm4[0],xmm1[1],xmm4[1]
subpd %xmm3, %xmm1
movaps %xmm1, %xmm5
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm5, %xmm1
divsd %xmm2, %xmm1
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x4c(%rbp)
movq -0x48(%rbp), %xmm0
punpckldq %xmm4, %xmm0    # xmm0 = xmm0[0],xmm4[0],xmm0[1],xmm4[1]
subpd %xmm3, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movq -0x40(%rbp), %rax
incq %rax
movq %rax, %xmm1
punpckldq %xmm4, %xmm1    # xmm1 = xmm1[0],xmm4[0],xmm1[1],xmm4[1]
subpd %xmm3, %xmm1
movaps %xmm1, %xmm3
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm3, %xmm1
divsd %xmm2, %xmm1
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x50(%rbp)
movq -0x40(%rbp), %rax
shrq $0x3, %rax
mulq %rcx
movq %rdx, %rsi
shrq $0x4, %rsi
movq -0x38(%rbp), %rax
shrq $0x3, %rax
mulq %rcx
shrq $0x4, %rdx
movq %rdx, -0xc8(%rbp)
movss -0x4c(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movq -0x48(%rbp), %rax
shrq $0x3, %rax
mulq %rcx
movb -0xb1(%rbp), %al
movq %rdx, %rcx
movq -0xc8(%rbp), %rdx
shrq $0x4, %rcx
movss -0x50(%rbp), %xmm1
cvtss2sd %xmm1, %xmm1
leaq 0x24cff(%rip), %rdi     # 0x38ae4
callq 0x8c60
movq -0xc0(%rbp), %rcx
movsd -0xa8(%rbp), %xmm2
movaps -0xa0(%rbp), %xmm4
movaps -0x90(%rbp), %xmm3
leaq 0xef2d2(%rip), %rax     # 0x1030e0
movq 0x20(%rax), %rdx
movq %rdx, -0x58(%rbp)
movq 0x18(%rax), %rdx
movq %rdx, -0x60(%rbp)
movq 0x28(%rax), %rax
movq %rax, -0x68(%rbp)
movq -0x58(%rbp), %xmm0
punpckldq %xmm4, %xmm0    # xmm0 = xmm0[0],xmm4[0],xmm0[1],xmm4[1]
subpd %xmm3, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movq -0x60(%rbp), %rax
incq %rax
movq %rax, %xmm1
punpckldq %xmm4, %xmm1    # xmm1 = xmm1[0],xmm4[0],xmm1[1],xmm4[1]
subpd %xmm3, %xmm1
movaps %xmm1, %xmm5
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm5, %xmm1
divsd %xmm2, %xmm1
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x6c(%rbp)
movq -0x68(%rbp), %xmm0
punpckldq %xmm4, %xmm0    # xmm0 = xmm0[0],xmm4[0],xmm0[1],xmm4[1]
subpd %xmm3, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movq -0x60(%rbp), %rax
incq %rax
movq %rax, %xmm1
punpckldq %xmm4, %xmm1    # xmm1 = xmm1[0],xmm4[0],xmm1[1],xmm4[1]
subpd %xmm3, %xmm1
movaps %xmm1, %xmm3
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm3, %xmm1
divsd %xmm2, %xmm1
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x70(%rbp)
movq -0x60(%rbp), %rax
shrq $0x3, %rax
mulq %rcx
movq %rdx, %rsi
shrq $0x4, %rsi
movq -0x58(%rbp), %rax
shrq $0x3, %rax
mulq %rcx
shrq $0x4, %rdx
movq %rdx, -0xb0(%rbp)
movss -0x6c(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movq -0x68(%rbp), %rax
shrq $0x3, %rax
mulq %rcx
movb -0xb1(%rbp), %al
movq %rdx, %rcx
movq -0xb0(%rbp), %rdx
shrq $0x4, %rcx
movss -0x70(%rbp), %xmm1
cvtss2sd %xmm1, %xmm1
leaq 0x24c16(%rip), %rdi     # 0x38b2c
callq 0x8c60
movsd -0xa8(%rbp), %xmm4
movaps -0xa0(%rbp), %xmm3
movaps -0x90(%rbp), %xmm2
movq -0x10(%rbp), %rax
movq (%rax), %xmm0
punpckldq %xmm3, %xmm0    # xmm0 = xmm0[0],xmm3[0],xmm0[1],xmm3[1]
subpd %xmm2, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movq -0x40(%rbp), %rax
incq %rax
movq %rax, %xmm1
punpckldq %xmm3, %xmm1    # xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1]
subpd %xmm2, %xmm1
movaps %xmm1, %xmm5
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm5, %xmm1
divsd %xmm4, %xmm1
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x74(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %xmm0
punpckldq %xmm3, %xmm0    # xmm0 = xmm0[0],xmm3[0],xmm0[1],xmm3[1]
subpd %xmm2, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movq -0x40(%rbp), %rax
incq %rax
movq %rax, %xmm1
punpckldq %xmm3, %xmm1    # xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1]
subpd %xmm2, %xmm1
movaps %xmm1, %xmm5
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm5, %xmm1
divsd %xmm4, %xmm1
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x78(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %xmm0
punpckldq %xmm3, %xmm0    # xmm0 = xmm0[0],xmm3[0],xmm0[1],xmm3[1]
subpd %xmm2, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movq -0x40(%rbp), %rax
incq %rax
movq %rax, %xmm1
punpckldq %xmm3, %xmm1    # xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1]
subpd %xmm2, %xmm1
movaps %xmm1, %xmm2
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm2, %xmm1
movsd 0x2473d(%rip), %xmm2    # 0x38748
divsd %xmm2, %xmm1
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x7c(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rsi
movss -0x74(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdx
movss -0x78(%rbp), %xmm1
cvtss2sd %xmm1, %xmm1
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rcx
movss -0x7c(%rbp), %xmm2
cvtss2sd %xmm2, %xmm2
leaq 0x24b24(%rip), %rdi     # 0x38b79
movb $0x3, %al
callq 0x8c60
movq -0x10(%rbp), %rax
movq 0x678(%rax), %rsi
leaq 0x24b62(%rip), %rdi     # 0x38bd0
movb $0x0, %al
callq 0x8c60
addq $0xf0, %rsp
popq %rbp
retq
nop