// File: /workspace/github_cpp_makefile_star2_O2/kmyk[P]codevs-for-student-2016/Main.cpp
// Function: void chokudai_search<AI::think(primitive::input_t const&)::'lambda2'(std::shared_ptr<photon_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&)>>>>&, primitive::config_t const&, int, int, int, int, std::shared_ptr<photon_t> const&, long long, AI::think(primitive::input_t const&)::'lambda2'(std::shared_ptr<photon_t> const&))
void chokudai_search(deque<functional_priority_queue<pair<double, weak_ptr<photon_t> > > > & que, config_t const & config, int initial_turn, int beam_width, int beam_depth, int beam_generation, shared_ptr<photon_t> const & initial, ll time_limit_msec, F cont) {
    assert (initial_turn + beam_depth < config.packs.size());
    assert (beam_depth + 1 < que.size());
    clock_check check(time_limit_msec);
    int begin = 0;
    int loop = 0;
    while (check() and begin < beam_depth) {
        repeat_from (i, begin, beam_depth) {
            repeat (j, beam_width) {
                loop += 1;
                if (que[i].empty()) {
                    if (i == begin) ++ begin;
                    break;
                }
                shared_ptr<photon_t> pho = que[i].top().second.lock(); que[i].pop();
                if (not pho) { -- j; continue; } // 無視して同じ深さをもう一度
                step_photon_all(pho, config.packs[initial_turn + i]);
                repeat_from (x, - pack_size + 1, width) repeat (r, 4) {
                    shared_ptr<photon_t> npho = pho->next[x+pack_size-1][r];
                    if (not npho) continue;
                    npho = cont(npho);
                    if (not npho) continue;
                    if (npho->beam_generation == beam_generation) continue;
                    que[i+1].emplace(npho->evaluation.score, npho);
                    if (beam_generation != -1) npho->beam_generation = beam_generation;
                }
                if (loop % 100 == 0) {
                    anneal_photon(initial, outputs_photon_from(pho, initial_turn), config, que, beam_generation, cont);
                }
            }
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xe8, %rsp
movl %r9d, %ebp
movl %r8d, %ebx
movl %ecx, 0x4c(%rsp)
movl %edx, %r14d
movq %rsi, 0x78(%rsp)
movq %rdi, %r15
callq 0x2030
imulq $0xf4240, 0x128(%rsp), %rcx # imm = 0xF4240
addq %rax, %rcx
movq %rcx, 0x90(%rsp)
movq %r15, 0xa0(%rsp)
addq $0x10, %r15
movl %ebx, 0x44(%rsp)
movslq %ebx, %rax
movq %rax, 0x98(%rsp)
movl %r14d, 0x48(%rsp)
movslq %r14d, %rax
movq %rax, 0xa8(%rsp)
xorl %r12d, %r12d
leaq 0xc0(%rsp), %r14
leaq 0x50(%rsp), %r13
leaq 0xd8(%rsp), %rbx
movl $0x0, 0x30(%rsp)
movq %r15, 0x88(%rsp)
callq 0x2030
cmpq 0x90(%rsp), %rax
jge 0x7aa0
movq %r12, %rcx
cmpl 0x44(%rsp), %ecx
jge 0x7aa0
movslq %ecx, %rax
movq %rax, 0x38(%rsp)
movq 0x38(%rsp), %r15
movl 0x30(%rsp), %r12d
movq %rcx, 0x70(%rsp)
cmpq 0x98(%rsp), %r15
jge 0x7a93
leaq 0x1(%r15), %rax
movq %rax, 0x38(%rsp)
movl $0x0, 0x34(%rsp)
movq %r15, 0x80(%rsp)
movl 0x34(%rsp), %eax
cmpl 0x4c(%rsp), %eax
jge 0x7a70
incl %r12d
movl %r12d, 0x30(%rsp)
movq 0x88(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x8c96
movq (%rax), %rcx
cmpq 0x8(%rax), %rcx
je 0x7a7f
movq %r12, %rdi
movq %r15, %rsi
callq 0x8c96
movq (%rax), %rsi
addq $0x8, %rsi
leaq 0x60(%rsp), %rdi
callq 0xcb24
movq %r12, %rdi
movq %r15, %rsi
callq 0x8c96
movq %rax, %rdi
callq 0x71ea
movl 0x30(%rsp), %r12d
cmpq $0x0, 0x60(%rsp)
je 0x7a59
movq 0x80(%rsp), %rax
leaq (%rax,%rax,8), %rax
movq 0x78(%rsp), %rcx
addq (%rcx), %rax
movq 0xa8(%rsp), %rcx
leaq (%rcx,%rcx,8), %rsi
addq %rax, %rsi
leaq 0x60(%rsp), %rdi
callq 0x3676
movl $0x138, %r15d           # imm = 0x138
pushq $-0x2
popq %r12
cmpq $0xa, %r12
je 0x79be
xorl %r14d, %r14d
cmpq $0x40, %r14
je 0x79aa
movq 0x60(%rsp), %rsi
addq %r15, %rsi
addq %r14, %rsi
movq %r13, %rdi
callq 0x605a
cmpq $0x0, 0x50(%rsp)
je 0x7997
movq %rbx, %rdi
leaq 0x130(%rsp), %rsi
movq %r13, %rdx
callq 0x7252
movq %r13, %rdi
movq %rbx, %rsi
callq 0xc96a
leaq 0xe0(%rsp), %rdi
callq 0x5f78
movq 0x50(%rsp), %rax
testq %rax, %rax
je 0x7997
cmpl %ebp, 0x100(%rax)
je 0x7997
movq 0x88(%rsp), %rdi
movq 0x38(%rsp), %rsi
callq 0x8c96
movq 0x50(%rsp), %rsi
movl $0xc8, %ecx
addq %rcx, %rsi
movq %rax, %rdi
movq %r13, %rdx
callq 0x6cbe
cmpl $-0x1, %ebp
je 0x7997
movq 0x50(%rsp), %rax
movl %ebp, 0x100(%rax)
leaq 0x58(%rsp), %rdi
callq 0x5f78
addq $0x10, %r14
jmp 0x78fb
incq %r12
addq $0x40, %r15
leaq 0xc0(%rsp), %r14
jmp 0x78ee
movl 0x30(%rsp), %eax
cltd
pushq $0x64
popq %rcx
idivl %ecx
testl %edx, %edx
jne 0x7a50
movq %r14, %r12
leaq 0xb0(%rsp), %r14
movq %r14, %rdi
leaq 0x60(%rsp), %rsi
callq 0x605a
movq %r12, %rdi
movq %r14, %rsi
movl 0x48(%rsp), %edx
callq 0x38ea
leaq 0x130(%rsp), %rax
movups (%rax), %xmm0
movups 0x10(%rax), %xmm1
movups 0x20(%rax), %xmm2
movups %xmm2, 0x20(%rsp)
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movq 0x120(%rsp), %rdi
movq %r12, %rsi
movq 0x78(%rsp), %rdx
movq 0xa0(%rsp), %rcx
movl %ebp, %r8d
callq 0x748e
movq %r12, %r14
movq %r12, %rdi
callq 0xcb98
leaq 0xb8(%rsp), %rdi
callq 0x5f78
incl 0x34(%rsp)
movl 0x30(%rsp), %r12d
leaq 0x68(%rsp), %rdi
callq 0x5f78
movq 0x80(%rsp), %r15
jmp 0x7841
movq 0x38(%rsp), %r15
movq 0x70(%rsp), %rcx
jmp 0x781a
xorl %eax, %eax
movq 0x70(%rsp), %rcx
cmpl %r15d, %ecx
sete %al
addl %eax, %ecx
jmp 0x780b
movl %r12d, 0x30(%rsp)
movq %rcx, %r12
jmp 0x77e3
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0xc0(%rsp), %rdi
callq 0xcb98
jmp 0x7ac7
movq %rax, %rbx
leaq 0xb8(%rsp), %rdi
jmp 0x7ae0
movq %rax, %rbx
jmp 0x7ae5
jmp 0x7ad8
movq %rax, %rbx
leaq 0x58(%rsp), %rdi
callq 0x5f78
leaq 0x68(%rsp), %rdi
callq 0x5f78
movq %rbx, %rdi
callq 0x2250