// File: /workspace/github_cpp_makefile_star2_O1/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 $0x28, %rsp
movq %rcx, (%rsp)
movq %rdx, 0x8(%rsp)
movq (%rdi), %rax
movl 0x8(%rax), %ebx
cmpl %esi, %ebx
je 0x7943
movq %rdi, %r14
movslq (%rax), %rcx
leaq (%rcx,%rcx,8), %rcx
movq 0x8(%rsp), %rdx
addq (%rdx), %rcx
xorl %edx, %edx
movq %rcx, %r8
xorl %edi, %edi
xorl %r9d, %r9d
cmpb $0x1, (%r8,%r9)
adcl $0x0, %edi
incq %r9
cmpq $0x3, %r9
jne 0x77e3
incq %rdx
addq $0x3, %r8
cmpq $0x3, %rdx
jne 0x77e0
cmpl %ebx, %edi
cmovll %edi, %ebx
xorl %edx, %edx
xorl %ebp, %ebp
xorl %edi, %edi
cmpb $0x1, (%rcx,%rdi)
adcl $0x0, %ebp
incq %rdi
cmpq $0x3, %rdi
jne 0x780c
incq %rdx
addq $0x3, %rcx
cmpq $0x3, %rdx
jne 0x780a
xorl %ecx, %ecx
testl %ebx, %ebx
cmovlel %ecx, %ebx
cmpl %esi, %ebp
cmovgel %esi, %ebp
testl %ebp, %ebp
cmovlel %ecx, %ebp
movl %esi, 0x8(%rax)
movq %r14, %rdi
callq 0x35af
cmpl %ebp, %ebx
jne 0x7952
movq $-0x2, %rax
movl $0x104, %ebx            # imm = 0x104
movl $0x140, %r15d           # imm = 0x140
movq %rax, 0x20(%rsp)
movq %r15, %r12
xorl %r13d, %r13d
movq (%r14), %rax
leaq (%rax,%rbx), %rcx
cmpb $0x1, (%r13,%rcx)
jne 0x7918
movq -0x8(%rax,%r12), %rcx
movq %rcx, 0x10(%rsp)
movq (%rax,%r12), %rax
movq %rax, 0x18(%rsp)
testq %rax, %rax
je 0x78aa
movq 0xd724(%rip), %rcx      # 0x14fc0
cmpb $0x0, (%rcx)
je 0x78a6
incl 0x8(%rax)
jmp 0x78aa
lock
incl 0x8(%rax)
movq 0x10(%rsp), %rax
testq %rax, %rax
je 0x7909
movq (%r14), %rcx
movl 0x8(%rcx), %esi
movslq 0x4(%rcx), %rcx
movl 0xbc(%rax), %eax
addl %ecx, %eax
cltq
imulq $-0x66666667, %rax, %rax # imm = 0x99999999
movq %rax, %rdx
shrq $0x3f, %rdx
sarq $0x21, %rax
addl %edx, %eax
imulq $0x66666667, %rcx, %rcx # imm = 0x66666667
movq %rcx, %rdx
shrq $0x3f, %rdx
sarq $0x21, %rcx
addl %edx, %ecx
subl %ebp, %esi
addl %ecx, %esi
addl %eax, %esi
leaq 0x10(%rsp), %rdi
movq 0x8(%rsp), %rdx
movq (%rsp), %rcx
callq 0x77a2
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x7918
callq 0x7136
incq %r13
addq $0x10, %r12
cmpq $0x4, %r13
jne 0x786a
movq 0x20(%rsp), %rax
incq %rax
addq $0x4, %rbx
addq $0x40, %r15
cmpq $0xa, %rax
jne 0x785f
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq $-0x2, %rbx
movl $0x104, %r15d           # imm = 0x104
movl $0x140, %r12d           # imm = 0x140
movq %r12, %r13
xorl %ebp, %ebp
movq (%r14), %rax
leaq (%rax,%r15), %rcx
movb $0x0, (%rbp,%rcx)
movq (%rax,%r13), %rdi
xorps %xmm0, %xmm0
movups %xmm0, -0x8(%rax,%r13)
testq %rdi, %rdi
je 0x798d
callq 0x7136
incq %rbp
addq $0x10, %r13
cmpq $0x4, %rbp
jne 0x796a
incq %rbx
addq $0x4, %r15
addq $0x40, %r12
cmpq $0xa, %rbx
jne 0x7965
movq (%rsp), %rdi
movq %r14, %rsi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x8060
movq %rax, %rbx
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x79d7
callq 0x7136
movq %rbx, %rdi
callq 0x2230
nop