// File: /workspace/github_cpp_makefile_star2_O1/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 0x89fc
movq 0xc5d2(%rip), %rcx      # 0x14fc0
cmpb $0x0, (%rcx)
je 0x89f8
incl 0x8(%rax)
jmp 0x89fc
lock
incl 0x8(%rax)
movq 0x8(%r12), %rax
cmpq (%r12), %rax
je 0x8cca
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 0x3ab8
cmpq $0x0, (%rsp)
je 0x8c21
leaq 0x10(%rsp), %rdi
leaq 0x90(%rsp), %rsi
movq %rbp, %rdx
callq 0x8686
movaps 0x10(%rsp), %xmm0
xorps %xmm1, %xmm1
movaps %xmm1, 0x10(%rsp)
movq 0x8(%rsp), %rdi
movups %xmm0, (%rsp)
testq %rdi, %rdi
je 0x8aa5
callq 0x7136
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x8ab4
callq 0x7136
movq (%rsp), %rax
testq %rax, %rax
je 0x8c21
cmpl %ebx, 0x100(%rax)
je 0x8afe
movq 0x38(%rsp), %rdi
movq 0x30(%rsp), %rsi
callq 0xa520
movq (%rsp), %rsi
movl $0xc8, %ecx
addq %rcx, %rsi
movq %rax, %rdi
movq %rbp, %rdx
callq 0x7f5a
cmpl $-0x1, %ebx
je 0x8afe
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 0x8c21
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 0x3ab8
movaps 0x10(%rsp), %xmm0
xorps %xmm1, %xmm1
movaps %xmm1, 0x10(%rsp)
movq 0x8(%rsp), %rdi
movups %xmm0, (%rsp)
testq %rdi, %rdi
je 0x8b62
callq 0x7136
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x8b71
callq 0x7136
cmpq $0x0, (%rsp)
je 0x8c21
leaq 0x10(%rsp), %rdi
leaq 0x90(%rsp), %rsi
movq %rbp, %rdx
callq 0x8686
movaps 0x10(%rsp), %xmm0
xorps %xmm1, %xmm1
movaps %xmm1, 0x10(%rsp)
movq 0x8(%rsp), %rdi
movups %xmm0, (%rsp)
testq %rdi, %rdi
je 0x8bb1
callq 0x7136
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x8bc0
callq 0x7136
movq (%rsp), %rax
testq %rax, %rax
je 0x8c21
cmpl %ebx, 0x100(%rax)
je 0x8c05
leal 0x1(%r14), %esi
movq 0x38(%rsp), %rdi
callq 0xa520
movq (%rsp), %rsi
movl $0xc8, %ecx
addq %rcx, %rsi
movq %rax, %rdi
movq %rbp, %rdx
callq 0x7f5a
cmpl $-0x1, %ebx
je 0x8c05
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 0x8b1e
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x8c30
callq 0x7136
incq %r13
cmpq $0x4, %r13
movq %r15, %rsi
jne 0x8a37
incl %esi
cmpl $0xa, %esi
jne 0x8a32
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 0x3ab8
movaps (%rsp), %xmm0
xorps %xmm1, %xmm1
movaps %xmm1, (%rsp)
movq 0x28(%rsp), %rdi
movups %xmm0, 0x20(%rsp)
testq %rdi, %rdi
je 0x8c98
callq 0x7136
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x8ca7
callq 0x7136
movq 0x8(%r12), %rax
subq (%r12), %rax
sarq $0x3, %rax
incq 0x48(%rsp)
movq 0x30(%rsp), %rcx
cmpq %rcx, %rax
movq %rcx, %rax
ja 0x8a20
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x8cd9
callq 0x7136
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x8cee
jmp 0x8cf7
jmp 0x8cf7
movq %rax, %rbx
jmp 0x8d09
jmp 0x8cf7
jmp 0x8cf7
movq %rax, %rbx
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x8d09
callq 0x7136
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x8d18
callq 0x7136
movq %rbx, %rdi
callq 0x2230