// File: /workspace/github_cpp_makefile_star2_O3/kmyk[P]codevs-for-student-2016/Main.cpp
// Function: void anneal_photon<AI::think(primitive::input_t const&)::'lambda2'(std::shared_ptr<photon_t> const&)>(std::shared_ptr<photon_t> const&, std::vector<primitive::output_t, std::allocator<primitive::output_t>>, primitive::config_t const&, std::deque<std::priority_queue<std::pair<double, std::weak_ptr<photon_t>>, std::vector<std::pair<double, std::weak_ptr<photon_t>>, std::allocator<std::pair<double, std::weak_ptr<photon_t>>>>, std::function<bool (std::pair<double, std::weak_ptr<photon_t>> const&, std::pair<double, std::weak_ptr<photon_t>> const&)>>, std::allocator<std::priority_queue<std::pair<double, std::weak_ptr<photon_t>>, std::vector<std::pair<double, std::weak_ptr<photon_t>>, std::allocator<std::pair<double, std::weak_ptr<photon_t>>>>, std::function<bool (std::pair<double, std::weak_ptr<photon_t>> const&, std::pair<double, std::weak_ptr<photon_t>> const&)>>>>&, int, AI::think(primitive::input_t const&)::'lambda2'(std::shared_ptr<photon_t> const&))
void anneal_photon(shared_ptr<photon_t> const & initial, vector<output_t> outputs, config_t const & config, deque<functional_priority_queue<pair<double, weak_ptr<photon_t> > > > & que, int beam_generation, F cont) {
    shared_ptr<photon_t> pho = initial;
    repeat (i, outputs.size()) {
        repeat_from (x, - pack_size + 1, width) repeat (r, 4) {
            shared_ptr<photon_t> npho = step_photon(pho, config.packs[pho->turn], make_output(x, r));
            if (not npho) continue;
            npho = cont(npho);
            if (not npho) continue;
            if (npho->beam_generation != beam_generation) {
                que[i+1].emplace(npho->evaluation.score, npho);
                if (beam_generation != -1) npho->beam_generation = beam_generation;
            }
            repeat_from (j, i+1, outputs.size()) {
                npho = step_photon(npho, config.packs[npho->turn], outputs[j]);
                if (not npho) break;
                npho = cont(npho);
                if (not npho) break;
                if (npho->beam_generation != beam_generation) {
                    que[j+1].emplace(npho->evaluation.score, npho);
                    if (beam_generation != -1) npho->beam_generation = beam_generation;
                }
            }
        }
        pho = step_photon(pho, config.packs[pho->turn], outputs[i]);
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movl %r8d, %ebx
movq %rcx, 0x38(%rsp)
movq %rdx, 0x40(%rsp)
movq %rsi, %r12
movq (%rdi), %rax
movq %rax, 0x20(%rsp)
movq 0x8(%rdi), %rax
movq %rax, 0x28(%rsp)
testq %rax, %rax
je 0x8bae
movq 0xc420(%rip), %rcx      # 0x14fc0
cmpb $0x0, (%rcx)
je 0x8baa
incl 0x8(%rax)
jmp 0x8bae
lock
incl 0x8(%rax)
movq 0x8(%r12), %rax
cmpq (%r12), %rax
je 0x8e6f
addq $0x10, 0x38(%rsp)
movl $0x1, %eax
movq %rax, 0x48(%rsp)
xorl %eax, %eax
movq %rsp, %rbp
movq %rax, 0x50(%rsp)
incq %rax
movq %rax, 0x30(%rsp)
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
movl %esi, %esi
xorl %r13d, %r13d
movq 0x20(%rsp), %rax
movslq (%rax), %rax
leaq (%rax,%rax,8), %rdx
movq 0x40(%rsp), %rax
addq (%rax), %rdx
movq %r13, %rcx
shlq $0x20, %rcx
movq %rsi, %r15
orq %rsi, %rcx
movq %rbp, %rdi
leaq 0x20(%rsp), %rsi
callq 0x3b67
cmpq $0x0, (%rsp)
je 0x8ddc
leaq 0x10(%rsp), %rdi
leaq 0x90(%rsp), %rsi
movq %rbp, %rdx
callq 0x8838
movq 0x10(%rsp), %rax
movq 0x18(%rsp), %rcx
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq %rax, (%rsp)
movq 0x8(%rsp), %rdi
movq %rcx, 0x8(%rsp)
testq %rdi, %rdi
je 0x8c74
callq 0x730e
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x8c70
callq 0x730e
movq (%rsp), %rax
testq %rax, %rax
je 0x8ddc
cmpl %ebx, 0x100(%rax)
je 0x8cba
movq 0x38(%rsp), %rdi
movq 0x30(%rsp), %rsi
callq 0xa59e
movq (%rsp), %rsi
movl $0xc8, %ecx
addq %rcx, %rsi
movq %rax, %rdi
movq %rbp, %rdx
callq 0x80c2
cmpl $-0x1, %ebx
je 0x8cba
movq (%rsp), %rax
movl %ebx, 0x100(%rax)
movq (%r12), %rax
movq 0x8(%r12), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
cmpq 0x30(%rsp), %rcx
jbe 0x8ddc
movq 0x48(%rsp), %r14
movq (%rsp), %rcx
movslq (%rcx), %rcx
leaq (%rcx,%rcx,8), %rdx
movq 0x40(%rsp), %rcx
addq (%rcx), %rdx
movq (%rax,%r14,8), %rcx
leaq 0x10(%rsp), %rdi
movq %rbp, %rsi
callq 0x3b67
movq 0x10(%rsp), %rax
movq 0x18(%rsp), %rcx
movq %rax, (%rsp)
movq 0x8(%rsp), %rdi
movq %rcx, 0x8(%rsp)
testq %rdi, %rdi
je 0x8d24
callq 0x730e
movq (%rsp), %rax
testq %rax, %rax
je 0x8ddc
leaq 0x10(%rsp), %rdi
leaq 0x90(%rsp), %rsi
movq %rbp, %rdx
callq 0x8838
movq 0x10(%rsp), %rax
movq 0x18(%rsp), %rcx
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq %rax, (%rsp)
movq 0x8(%rsp), %rdi
movq %rcx, 0x8(%rsp)
testq %rdi, %rdi
je 0x8d7f
callq 0x730e
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x8d7b
callq 0x730e
movq (%rsp), %rax
testq %rax, %rax
je 0x8ddc
cmpl %ebx, 0x100(%rax)
je 0x8dc0
leal 0x1(%r14), %esi
movq 0x38(%rsp), %rdi
callq 0xa59e
movq (%rsp), %rsi
movl $0xc8, %ecx
addq %rcx, %rsi
movq %rax, %rdi
movq %rbp, %rdx
callq 0x80c2
cmpl $-0x1, %ebx
je 0x8dc0
movq (%rsp), %rax
movl %ebx, 0x100(%rax)
incq %r14
movq (%r12), %rax
movq 0x8(%r12), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %r14, %rcx
ja 0x8cda
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x8deb
callq 0x730e
incq %r13
cmpq $0x4, %r13
movq %r15, %rsi
jne 0x8be9
incl %esi
cmpl $0xa, %esi
jne 0x8be4
movq 0x20(%rsp), %rax
movslq (%rax), %rax
leaq (%rax,%rax,8), %rdx
movq 0x40(%rsp), %rax
addq (%rax), %rdx
movq (%r12), %rax
movq 0x50(%rsp), %rcx
movq (%rax,%rcx,8), %rcx
movq %rbp, %rdi
leaq 0x20(%rsp), %rsi
callq 0x3b67
movq 0x28(%rsp), %rdi
movaps (%rsp), %xmm0
movaps %xmm0, 0x20(%rsp)
testq %rdi, %rdi
je 0x8e4c
callq 0x730e
movq 0x8(%r12), %rax
subq (%r12), %rax
sarq $0x3, %rax
incq 0x48(%rsp)
movq 0x30(%rsp), %rcx
cmpq %rcx, %rax
movq %rcx, %rax
ja 0x8bd2
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x8e7e
callq 0x730e
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x8e93
jmp 0x8e9c
jmp 0x8e9c
movq %rax, %rbx
jmp 0x8eae
jmp 0x8e9c
jmp 0x8e9c
movq %rax, %rbx
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x8eae
callq 0x730e
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x8ebd
callq 0x730e
movq %rbx, %rdi
callq 0x2230