// File: /workspace/github_cpp_makefile_star2_O2/kmyk[P]codevs-for-student-2016/Main.cpp
// Function: void update_photon_obstacles<AI::think(primitive::input_t const&)::'lambda'(std::shared_ptr<photon_t> const&)>(std::shared_ptr<photon_t> const&, int, std::vector<primitive::blocks_t<3ul, 3ul>, std::allocator<primitive::blocks_t<3ul, 3ul>>> const&, AI::think(primitive::input_t const&)::'lambda'(std::shared_ptr<photon_t> const&))
void update_photon_obstacles(shared_ptr<photon_t> const & pho, int updated_obstacles, vector<pack_t> const & packs, F cont) {
    if (pho->obstacles == updated_obstacles) {
        // nop
    } else {
        int         consumed = count_consumed_obstacles(packs[pho->turn],    pho->obstacles);
        int updated_consumed = count_consumed_obstacles(packs[pho->turn], updated_obstacles);
        pho->obstacles = updated_obstacles;
        evaluate_photon_for_search(pho);
        if (consumed != updated_consumed) {
            repeat_from (x, - pack_size + 1, width) repeat (r, 4) {
                pho->cached[x+pack_size-1][r] = false;
                pho->next[x+pack_size-1][r] = nullptr; // 開放
            }
            cont(pho);
        } else {
            repeat_from (x, - pack_size + 1, width) repeat (r, 4) {
                if (not pho->cached[x+pack_size-1][r]) continue;
                shared_ptr<photon_t> npho = pho->next[x+pack_size-1][r];
                if (not npho) continue;
                int next_obstacles = pho->obstacles - updated_consumed - count_obstacles_from_delta(pho->score, npho->result.score);
                update_photon_obstacles(npho, next_obstacles, packs, cont);
            }
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rcx, 0x28(%rsp)
movq %rdx, (%rsp)
movl %esi, %r12d
movq (%rdi), %rax
movl 0x8(%rax), %esi
cmpl %r12d, %esi
je 0x69ab
movq %rdi, %r14
movslq (%rax), %rax
leaq (%rax,%rax,8), %rdi
movq (%rsp), %rbx
addq (%rbx), %rdi
callq 0x2753
movl %eax, %ebp
movq (%r14), %rax
movslq (%rax), %rax
leaq (%rax,%rax,8), %rdi
addq (%rbx), %rdi
movl %r12d, %esi
callq 0x2753
movl %eax, %r13d
movq (%r14), %rax
movl %r12d, 0x8(%rax)
movq %r14, %rdi
callq 0x3187
pushq $-0x2
popq %rax
cmpl %r13d, %ebp
jne 0x692d
movl $0x104, %ebx            # imm = 0x104
movl $0x138, %r15d           # imm = 0x138
leaq 0x10(%rsp), %r13
cmpq $0xa, %rax
je 0x69ab
movq %rax, 0x8(%rsp)
movq %r15, 0x30(%rsp)
xorl %r12d, %r12d
cmpq $0x4, %r12
je 0x6913
movq (%r14), %rsi
leaq (%rsi,%rbx), %rax
cmpb $0x1, (%r12,%rax)
jne 0x690a
addq %r15, %rsi
movq %r13, %rdi
callq 0x605a
movq 0x10(%rsp), %rax
testq %rax, %rax
je 0x6900
movq (%r14), %rdx
movl 0x4(%rdx), %ecx
movl 0x8(%rdx), %esi
movl 0xbc(%rax), %eax
addl %ecx, %eax
cltd
pushq $-0x5
popq %rdi
idivl %edi
movl %eax, %edi
movl %ecx, %eax
cltd
pushq $0x5
popq %rcx
idivl %ecx
subl %ebp, %esi
addl %eax, %esi
addl %edi, %esi
movq %r13, %rdi
movq (%rsp), %rdx
movq 0x28(%rsp), %rcx
callq 0x6804
leaq 0x18(%rsp), %rdi
callq 0x5f78
incq %r12
addq $0x10, %r15
jmp 0x689f
movq 0x8(%rsp), %rax
incq %rax
addq $0x4, %rbx
movq 0x30(%rsp), %r15
addq $0x40, %r15
jmp 0x6888
movl $0x104, %r13d           # imm = 0x104
movl $0x138, %ebp            # imm = 0x138
leaq 0x18(%rsp), %r15
leaq 0x10(%rsp), %r12
cmpq $0xa, %rax
je 0x699e
movq %rax, (%rsp)
movq %rbp, 0x8(%rsp)
xorl %ebx, %ebx
cmpq $0x4, %rbx
je 0x6988
movq (%r14), %rdi
leaq (%rdi,%r13), %rax
movb $0x0, (%rbx,%rax)
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
addq %rbp, %rdi
movq %r12, %rsi
callq 0xc96a
movq %r15, %rdi
callq 0x5f78
incq %rbx
addq $0x10, %rbp
jmp 0x6953
movq (%rsp), %rax
incq %rax
addq $0x4, %r13
movq 0x8(%rsp), %rbp
addq $0x40, %rbp
jmp 0x6942
movq 0x28(%rsp), %rdi
movq %r14, %rsi
callq 0x6d50
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x5f78
movq %rbx, %rdi
callq 0x2250
nop