// File: kmyk[P]codevs-for-student-2016/Main.cpp
// Function: evaluate_photon_for_output(std::shared_ptr<photon_t> const&, int, opponent_info_t const&)
double evaluate_photon_for_output(shared_ptr<photon_t> const & pho, int base_turn, opponent_info_t const & oppo) {
    int age = pho->turn - base_turn;
    double acc = 0;
    if (is_effective_firing(pho->result.score, pho->obstacles, age, oppo)) {
        if (pho->obstacles < 40) {
            double k = pow(1 + 0.18, -age+1);
            acc += 400 + k * (1.2 * pho->result.score); // 発火した それが可能でしかも勝てるというのは大きい
            acc -= 5 * pho->dropped_obstacles;
            acc -= 3 * max(0, pho->obstacles);
        } else {
            acc = pho->result.score; // 負けてる時はもう全力で
        }
    } else {
        if (pho->result.chain >= chain_of_fire) {
            double k = pow(1 + 0.18, -age+1);
            acc += k * pho->result.score;
            acc -= 3 * max(0, min(30, pho->obstacles));
        } else {
            acc += max(0.1, 1 - 0.03 * (age - 1)) * pho->evaluation.score;
        }
    }
    return acc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rdi
callq 0x76d0
movl (%rax), %eax
subl -0xc(%rbp), %eax
movl %eax, -0x1c(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x28(%rbp)
movq -0x8(%rbp), %rdi
callq 0x76d0
movl 0xbc(%rax), %eax
movl %eax, -0x5c(%rbp)
movq -0x8(%rbp), %rdi
callq 0x76d0
movl -0x5c(%rbp), %edi
movl 0x8(%rax), %esi
movl -0x1c(%rbp), %edx
movq -0x18(%rbp), %rcx
callq 0x4d00
testb $0x1, %al
jne 0x4e25
jmp 0x4f09
movq -0x8(%rbp), %rdi
callq 0x76d0
cmpl $0x28, 0x8(%rax)
jge 0x4eee
xorl %edi, %edi
subl -0x1c(%rbp), %edi
addl $0x1, %edi
movsd 0x21358(%rip), %xmm0    # 0x261a0
callq 0x7ca0
movsd %xmm0, -0x30(%rbp)
movsd -0x30(%rbp), %xmm0
movsd %xmm0, -0x68(%rbp)
movq -0x8(%rbp), %rdi
callq 0x76d0
movsd -0x68(%rbp), %xmm0
cvtsi2sdl 0xbc(%rax), %xmm2
movsd 0x21336(%rip), %xmm1    # 0x261b0
mulsd %xmm2, %xmm1
mulsd %xmm1, %xmm0
movsd 0x2131e(%rip), %xmm1    # 0x261a8
addsd %xmm1, %xmm0
addsd -0x28(%rbp), %xmm0
movsd %xmm0, -0x28(%rbp)
movq -0x8(%rbp), %rdi
callq 0x76d0
imull $0x5, 0xc(%rax), %eax
cvtsi2sd %eax, %xmm1
movsd -0x28(%rbp), %xmm0
subsd %xmm1, %xmm0
movsd %xmm0, -0x28(%rbp)
movl $0x0, -0x34(%rbp)
movq -0x8(%rbp), %rdi
callq 0x76d0
movq %rax, %rsi
addq $0x8, %rsi
leaq -0x34(%rbp), %rdi
callq 0x66f0
imull $0x3, (%rax), %eax
cvtsi2sd %eax, %xmm1
movsd -0x28(%rbp), %xmm0
subsd %xmm1, %xmm0
movsd %xmm0, -0x28(%rbp)
jmp 0x4f04
movq -0x8(%rbp), %rdi
callq 0x76d0
cvtsi2sdl 0xbc(%rax), %xmm0
movsd %xmm0, -0x28(%rbp)
jmp 0x5029
movq -0x8(%rbp), %rdi
callq 0x76d0
cmpl $0x6, 0xc0(%rax)
jl 0x4fb5
xorl %edi, %edi
subl -0x1c(%rbp), %edi
addl $0x1, %edi
movsd 0x21271(%rip), %xmm0    # 0x261a0
callq 0x7ca0
movsd %xmm0, -0x40(%rbp)
movsd -0x40(%rbp), %xmm0
movsd %xmm0, -0x70(%rbp)
movq -0x8(%rbp), %rdi
callq 0x76d0
movsd -0x70(%rbp), %xmm0
cvtsi2sdl 0xbc(%rax), %xmm2
movsd -0x28(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x28(%rbp)
movl $0x0, -0x44(%rbp)
movl $0x1e, -0x48(%rbp)
movq -0x8(%rbp), %rdi
callq 0x76d0
movq %rax, %rsi
addq $0x8, %rsi
leaq -0x48(%rbp), %rdi
callq 0x6730
movq %rax, %rsi
leaq -0x44(%rbp), %rdi
callq 0x66f0
imull $0x3, (%rax), %eax
cvtsi2sd %eax, %xmm1
movsd -0x28(%rbp), %xmm0
subsd %xmm1, %xmm0
movsd %xmm0, -0x28(%rbp)
jmp 0x5027
movsd 0x211db(%rip), %xmm0    # 0x26198
movsd %xmm0, -0x50(%rbp)
movl -0x1c(%rbp), %eax
subl $0x1, %eax
cvtsi2sd %eax, %xmm0
movsd 0x211bc(%rip), %xmm1    # 0x26190
mulsd %xmm1, %xmm0
movsd 0x211a0(%rip), %xmm1    # 0x26180
addsd %xmm1, %xmm0
movsd %xmm0, -0x58(%rbp)
leaq -0x50(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x7cd0
movsd (%rax), %xmm0
movsd %xmm0, -0x78(%rbp)
movq -0x8(%rbp), %rdi
callq 0x76d0
movsd -0x78(%rbp), %xmm0
movsd 0xc8(%rax), %xmm2
movsd -0x28(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x28(%rbp)
jmp 0x5029
movsd -0x28(%rbp), %xmm0
addq $0x80, %rsp
popq %rbp
retq
nopw (%rax,%rax)