// File: kmyk[P]codevs-for-student-2016/Main.cpp
// Function: evaluate_photon_for_search(std::shared_ptr<photon_t> const&)
void evaluate_photon_for_search(shared_ptr<photon_t> const & pho) {
    vector<pair<result_t, int> > estimateds = estimate_with_erasing_all(pho->field);
    pho->evaluation.estimateds.resize(min<int>(3, estimateds.size()));
    partial_sort_copy(estimateds.begin(), estimateds.end(), pho->evaluation.estimateds.begin(), pho->evaluation.estimateds.end(), [&](pair<result_t, int> const & a, pair<result_t, int> const & b) {
        return make_tuple(a.first.score, a.first.chain, - a.second) > make_tuple(b.first.score, b.first.chain, - b.second); // reversed
    });
    double acc = 0;
    acc += pho->score; // scoreを基準に
    repeat (i, pho->evaluation.estimateds.size()) {
        double k1 = i == 0 ? 1.0 : 0.2;
        acc += k1 * pho->evaluation.estimateds[i].first.score; // 不正確な値だけど比較可能だろうからよい
        acc += k1 * pho->evaluation.estimateds[i].first.chain * 40; // 大連鎖だと誤差、小連鎖でscoreを気にされると不利
        acc -= k1 * pho->evaluation.estimateds[i].second * 4;
    }
    acc += 21 * pho->dropped_numbers; // 無駄に消すべきでない
    pho->evaluation.score = acc + pho->evaluation.permanent_bonus;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xf0, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
callq 0x76d0
movq %rax, %rsi
addq $0x14, %rsi
leaq -0x20(%rbp), %rdi
movq %rdi, -0x98(%rbp)
callq 0x36e0
movq -0x8(%rbp), %rdi
callq 0x76d0
movq -0x98(%rbp), %rdi
addq $0xd8, %rax
movq %rax, -0x90(%rbp)
movl $0x3, -0x24(%rbp)
callq 0x7970
movl %eax, -0x28(%rbp)
leaq -0x24(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x6730
movq %rax, -0x88(%rbp)
jmp 0x4381
movq -0x90(%rbp), %rdi
movq -0x88(%rbp), %rax
movslq (%rax), %rsi
callq 0x78e0
jmp 0x4399
leaq -0x20(%rbp), %rdi
movq %rdi, -0xa8(%rbp)
callq 0x79a0
movq -0xa8(%rbp), %rdi
movq %rax, -0x40(%rbp)
callq 0x79d0
movq %rax, -0x48(%rbp)
movq -0x8(%rbp), %rdi
callq 0x76d0
movq %rax, %rdi
addq $0xd8, %rdi
callq 0x79a0
movq %rax, -0x50(%rbp)
movq -0x8(%rbp), %rdi
callq 0x76d0
movq %rax, %rdi
addq $0xd8, %rdi
callq 0x79d0
movq %rax, -0x58(%rbp)
movq -0x40(%rbp), %rdi
movq -0x48(%rbp), %rsi
movq -0x50(%rbp), %rdx
movq -0x58(%rbp), %rcx
callq 0x4680
movq %rax, -0xa0(%rbp)
jmp 0x4413
movq -0xa0(%rbp), %rax
movq %rax, -0x68(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x70(%rbp)
movq -0x8(%rbp), %rdi
callq 0x76d0
cvtsi2sdl 0x4(%rax), %xmm0
addsd -0x70(%rbp), %xmm0
movsd %xmm0, -0x70(%rbp)
movl $0x0, -0x74(%rbp)
movslq -0x74(%rbp), %rax
movq %rax, -0xb0(%rbp)
movq -0x8(%rbp), %rdi
callq 0x76d0
movq %rax, %rdi
addq $0xc8, %rdi
addq $0x10, %rdi
callq 0x7970
movq %rax, %rcx
movq -0xb0(%rbp), %rax
cmpq %rcx, %rax
jae 0x45fb
movl -0x74(%rbp), %eax
movsd 0x21cf6(%rip), %xmm0    # 0x26180
movsd 0x21cf6(%rip), %xmm1    # 0x26188
movsd %xmm1, -0xc0(%rbp)
cmpl $0x0, %eax
movsd %xmm0, -0xb8(%rbp)
je 0x44b7
movsd -0xc0(%rbp), %xmm0
movsd %xmm0, -0xb8(%rbp)
movsd -0xb8(%rbp), %xmm0
movsd %xmm0, -0x80(%rbp)
movsd -0x80(%rbp), %xmm0
movsd %xmm0, -0xd8(%rbp)
movq -0x8(%rbp), %rdi
callq 0x76d0
movq %rax, %rdi
addq $0xc8, %rdi
addq $0x10, %rdi
movslq -0x74(%rbp), %rsi
callq 0x7a00
movsd -0xd8(%rbp), %xmm0
cvtsi2sdl (%rax), %xmm2
movsd -0x70(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x70(%rbp)
movsd -0x80(%rbp), %xmm0
movsd %xmm0, -0xd0(%rbp)
movq -0x8(%rbp), %rdi
callq 0x76d0
movq %rax, %rdi
addq $0xc8, %rdi
addq $0x10, %rdi
movslq -0x74(%rbp), %rsi
callq 0x7a00
movsd -0xd0(%rbp), %xmm0
cvtsi2sdl 0x4(%rax), %xmm1
mulsd %xmm1, %xmm0
movsd -0x70(%rbp), %xmm1
movsd 0x21c1e(%rip), %xmm2    # 0x26178
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x70(%rbp)
movsd -0x80(%rbp), %xmm0
movsd %xmm0, -0xc8(%rbp)
movq -0x8(%rbp), %rdi
callq 0x76d0
movq %rax, %rdi
addq $0xc8, %rdi
addq $0x10, %rdi
movslq -0x74(%rbp), %rsi
callq 0x7a00
movsd -0xc8(%rbp), %xmm0
cvtsi2sdl 0x8(%rax), %xmm1
mulsd %xmm1, %xmm0
movsd -0x70(%rbp), %xmm1
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd 0x21ba7(%rip), %xmm2    # 0x26170
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x70(%rbp)
movl -0x74(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x74(%rbp)
jmp 0x4445
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x20(%rbp), %rdi
callq 0x73c0
jmp 0x466f
movq -0x8(%rbp), %rdi
callq 0x76d0
imull $0x15, 0x10(%rax), %eax
cvtsi2sd %eax, %xmm0
addsd -0x70(%rbp), %xmm0
movsd %xmm0, -0x70(%rbp)
movsd -0x70(%rbp), %xmm0
movsd %xmm0, -0xe8(%rbp)
movq -0x8(%rbp), %rdi
callq 0x76d0
movsd -0xe8(%rbp), %xmm0
addsd 0xd0(%rax), %xmm0
movsd %xmm0, -0xe0(%rbp)
movq -0x8(%rbp), %rdi
callq 0x76d0
movsd -0xe0(%rbp), %xmm0
movsd %xmm0, 0xc8(%rax)
leaq -0x20(%rbp), %rdi
callq 0x73c0
addq $0xf0, %rsp
popq %rbp
retq
movq -0x30(%rbp), %rdi
callq 0x22f0
nopl (%rax,%rax)