// File: /workspace/github_cpp_makefile_star2_O2/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 $0x68, %rsp
movl %r8d, %ebp
movq %rcx, %rbx
movq %rdx, 0x20(%rsp)
movq %rsi, %r12
movq %rdi, %rsi
leaq 0x30(%rsp), %rdi
callq 0x605a
addq $0x10, %rbx
movq %rbx, 0x48(%rsp)
xorl %ecx, %ecx
leaq 0x8(%rsp), %r14
leaq 0x58(%rsp), %rbx
movq 0x8(%r12), %rax
subq (%r12), %rax
sarq $0x3, %rax
cmpq %rcx, %rax
jbe 0x7707
movq %rcx, 0x18(%rsp)
leaq 0x1(%rcx), %rax
movq %rax, 0x40(%rsp)
pushq $-0x2
popq %rax
leaq 0x30(%rsp), %rsi
cmpl $0xa, %eax
je 0x76bc
movl %eax, 0x2c(%rsp)
movl %eax, %eax
movq %rax, 0x50(%rsp)
xorl %r13d, %r13d
cmpq $0x4, %r13
je 0x76b1
movq 0x30(%rsp), %rax
movslq (%rax), %rax
leaq (%rax,%rax,8), %rdx
movq 0x20(%rsp), %rax
addq (%rax), %rdx
movq %r13, %rcx
shlq $0x20, %rcx
addq 0x50(%rsp), %rcx
movq %r14, %rdi
callq 0x3591
cmpq $0x0, 0x8(%rsp)
je 0x769a
movq %rbx, %rdi
leaq 0xa0(%rsp), %rsi
movq %r14, %rdx
callq 0x7252
movq %r14, %rdi
movq %rbx, %rsi
callq 0xc96a
leaq 0x60(%rsp), %rdi
callq 0x5f78
movq 0x8(%rsp), %rax
testq %rax, %rax
je 0x769a
movq 0x18(%rsp), %r15
cmpl %ebp, 0x100(%rax)
je 0x75c1
movq 0x48(%rsp), %rdi
movq 0x40(%rsp), %rsi
callq 0x8c96
movq 0x8(%rsp), %rsi
movl $0xc8, %ecx
addq %rcx, %rsi
movq %rax, %rdi
movq %r14, %rdx
callq 0x6cbe
movq 0x18(%rsp), %r15
jmp 0x7681
incq %r15
movq (%r12), %rax
movq 0x8(%r12), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %r15, %rcx
jbe 0x769a
movq 0x8(%rsp), %rcx
movslq (%rcx), %rcx
leaq (%rcx,%rcx,8), %rdx
movq 0x20(%rsp), %rcx
addq (%rcx), %rdx
movq (%rax,%r15,8), %rcx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3591
movq %r14, %rdi
movq %rbx, %rsi
callq 0xc96a
leaq 0x60(%rsp), %rdi
callq 0x5f78
cmpq $0x0, 0x8(%rsp)
je 0x769a
movq %rbx, %rdi
leaq 0xa0(%rsp), %rsi
movq %r14, %rdx
callq 0x7252
movq %r14, %rdi
movq %rbx, %rsi
callq 0xc96a
leaq 0x60(%rsp), %rdi
callq 0x5f78
movq 0x8(%rsp), %rax
testq %rax, %rax
je 0x769a
cmpl %ebp, 0x100(%rax)
je 0x75c1
leaq 0x1(%r15), %rsi
movq 0x48(%rsp), %rdi
callq 0x8c96
movq 0x8(%rsp), %rsi
movl $0xc8, %ecx
addq %rcx, %rsi
movq %rax, %rdi
movq %r14, %rdx
callq 0x6cbe
cmpl $-0x1, %ebp
je 0x75c1
movq 0x8(%rsp), %rax
movl %ebp, 0x100(%rax)
jmp 0x75c1
leaq 0x10(%rsp), %rdi
callq 0x5f78
incq %r13
leaq 0x30(%rsp), %rsi
jmp 0x750f
movl 0x2c(%rsp), %eax
incl %eax
jmp 0x74f8
movq 0x30(%rsp), %rax
movslq (%rax), %rax
leaq (%rax,%rax,8), %rdx
movq 0x20(%rsp), %rax
addq (%rax), %rdx
movq (%r12), %rax
movq 0x18(%rsp), %rcx
movq (%rax,%rcx,8), %rcx
movq %r14, %rdi
movq %rsi, %r15
callq 0x3591
movq %r15, %rdi
movq %r14, %rsi
callq 0xc96a
leaq 0x10(%rsp), %rdi
callq 0x5f78
movq 0x40(%rsp), %rcx
jmp 0x74cc
leaq 0x38(%rsp), %rdi
callq 0x5f78
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x7726
jmp 0x772f
jmp 0x772f
movq %rax, %rbx
jmp 0x773c
jmp 0x772f
jmp 0x772f
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x5f78
leaq 0x38(%rsp), %rdi
callq 0x5f78
movq %rbx, %rdi
callq 0x2250