// File: /workspace/github_cpp_makefile_star2_O3/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), %ecx
cmpl %esi, %ecx
je 0x7b01
movq %rdi, %r14
movl %ecx, %r10d
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 0x7996
incq %rdx
addq $0x3, %r8
cmpq $0x3, %rdx
jne 0x7993
cmpl %r10d, %edi
cmovll %edi, %r10d
movl %r10d, %r8d
xorl %edx, %edx
xorl %ebx, %ebx
xorl %edi, %edi
cmpb $0x1, (%rcx,%rdi)
adcl $0x0, %ebx
incq %rdi
cmpq $0x3, %rdi
jne 0x79c4
incq %rdx
addq $0x3, %rcx
cmpq $0x3, %rdx
jne 0x79c2
xorl %ecx, %ecx
movl %r8d, %ebp
testl %r8d, %r8d
cmovlel %ecx, %ebp
cmpl %esi, %ebx
cmovgel %esi, %ebx
testl %ebx, %ebx
cmovlel %ecx, %ebx
movl %esi, 0x8(%rax)
movq %r14, %rdi
callq 0x367d
cmpl %ebx, %ebp
jne 0x7b10
movl %ebp, %r13d
movq $-0x2, %rax
movl $0x104, %ebx            # imm = 0x104
movl $0x140, %r15d           # imm = 0x140
movq %rax, 0x20(%rsp)
movq %r15, %r12
xorl %ebp, %ebp
movq (%r14), %rcx
leaq (%rcx,%rbx), %rax
cmpb $0x1, (%rbp,%rax)
jne 0x7ad6
movq -0x8(%rcx,%r12), %rax
movq %rax, 0x10(%rsp)
movq (%rcx,%r12), %rcx
movq %rcx, 0x18(%rsp)
testq %rcx, %rcx
je 0x7a6c
movq 0xd567(%rip), %rdx      # 0x14fc0
cmpb $0x0, (%rdx)
je 0x7a63
incl 0x8(%rcx)
jmp 0x7a6c
lock
incl 0x8(%rcx)
movq 0x10(%rsp), %rax
testq %rax, %rax
je 0x7ac7
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 %r13d, %esi
addl %ecx, %esi
addl %eax, %esi
leaq 0x10(%rsp), %rdi
movq 0x8(%rsp), %rdx
movq (%rsp), %rcx
callq 0x7952
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x7ad6
callq 0x730e
incq %rbp
addq $0x10, %r12
cmpq $0x4, %rbp
jne 0x7a28
movq 0x20(%rsp), %rax
incq %rax
addq $0x4, %rbx
addq $0x40, %r15
cmpq $0xa, %rax
jne 0x7a1e
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 0x7b4b
callq 0x730e
incq %rbp
addq $0x10, %r13
cmpq $0x4, %rbp
jne 0x7b28
incq %rbx
addq $0x4, %r15
addq $0x40, %r12
cmpq $0xa, %rbx
jne 0x7b23
movq (%rsp), %rdi
movq %r14, %rsi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x8180
movq %rax, %rbx
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x7b95
callq 0x730e
movq %rbx, %rdi
callq 0x2230
nop