// File: /workspace/github_cpp_makefile_star2_O2/kmyk[P]codevs-for-student-2016/Main.cpp
// Function: step_photon_inner(std::shared_ptr<photon_t> const&, int, int, primitive::blocks_t<3ul, 3ul> const&, int, int)
void step_photon_inner(shared_ptr<photon_t> const & pho, int numbers, int consumed, pack_t const & filled_pack, int x, rotate_t r) {
    if (pho->cached[x+pack_size-1][r]) return;
    pho->cached[x+pack_size-1][r] = true;
    shared_ptr<photon_t> npho = make_shared<photon_t>();
    npho->output = make_output(x, r);
    int erased;
    try {
        tie(npho->result, erased, npho->field) = simulate_with_output(pho->field, filled_pack, npho->output);
    } catch (simulate_invalid_output_exception e) {
        return;
    } catch (simulate_gameover_exception e) {
        return;
    }
    npho->turn = pho->turn + 1;
    npho->score = pho->score + npho->result.score;
    npho->obstacles = pho->obstacles - consumed - count_obstacles_from_delta(pho->score, npho->result.score);
    npho->dropped_obstacles = pho->dropped_obstacles + consumed;
    npho->dropped_numbers = pho->dropped_numbers + numbers - erased;
    npho->beam_generation = 0;
    npho->parent = pho;
    pho->next[x+pack_size-1][r] = npho;
    evaluate_photon_for_search(npho);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
movq %rcx, %r13
movq (%rdi), %rax
movslq %r8d, %r15
leaq (%rax,%r15,4), %rcx
addq $0x8, %rcx
movslq %r9d, %r14
cmpb $0x0, 0x104(%r14,%rcx)
jne 0x353b
movl %esi, %ebp
movq %rdi, %rbx
movl %edx, 0x4(%rsp)
leaq (%rax,%r15,4), %rax
addq $0x10c, %rax            # imm = 0x10C
movb $0x1, (%rax,%r14)
leaq 0x8(%rsp), %r12
movq %r12, %rdi
callq 0x45a4
movq %r14, %rax
shlq $0x20, %rax
movl %r15d, %edx
orq %rax, %rdx
movq (%r12), %rcx
movq %rdx, 0xb4(%rcx)
addq $0xb4, %rcx
movq (%rbx), %rsi
addq $0x14, %rsi
leaq 0x1c(%rsp), %rdi
movq %r13, %rdx
callq 0x2966
addq $0x2, %r15
leaq 0x8(%rsp), %rax
movq (%rax), %r12
leaq 0x14(%r12), %rdi
leaq 0x1c(%rsp), %rsi
movq 0xa4(%rsi), %r13
movq %r13, 0xbc(%r12)
subl 0xa0(%rsi), %ebp
movl $0xa0, %edx
callq 0x2130
movq (%rbx), %rdi
movq (%rdi), %xmm0
movd %r13d, %xmm1
movdqa 0x9cf4(%rip), %xmm2     # 0xd190
punpckldq %xmm1, %xmm2    # xmm2 = xmm2[0],xmm1[0],xmm2[1],xmm1[1]
paddd %xmm0, %xmm2
movq %xmm2, (%r12)
movl 0x4(%rdi), %ecx
movl 0x8(%rdi), %r8d
addl %ecx, %r13d
pushq $-0x5
popq %rsi
movl %r13d, %eax
cltd
idivl %esi
movl %eax, %esi
pushq $0x5
popq %r9
movl %ecx, %eax
cltd
idivl %r9d
movl 0x4(%rsp), %ecx
subl %ecx, %r8d
addl %eax, %r8d
addl %esi, %r8d
movl %r8d, 0x8(%r12)
addl 0xc(%rdi), %ecx
movl %ecx, 0xc(%r12)
addl 0x10(%rdi), %ebp
movl %ebp, 0x10(%r12)
andl $0x0, 0x100(%r12)
addq $0xf0, %r12
movq %r12, %rdi
movq %rbx, %rsi
callq 0xcac6
shlq $0x6, %r15
addq (%rbx), %r15
shlq $0x4, %r14
leaq (%r14,%r15), %rdi
addq $0x138, %rdi            # imm = 0x138
leaq 0x8(%rsp), %rbx
movq %rbx, %rsi
callq 0x5ff4
movq %rbx, %rdi
callq 0x3187
leaq 0x10(%rsp), %rdi
callq 0x5f78
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x5f78
movq %rbx, %rdi
callq 0x2250
movq %rax, %rbx
cmpl $0x2, %edx
jne 0x3579
movq %rbx, %rdi
callq 0x2080
callq 0x2210
jmp 0x3531
cmpl $0x1, %edx
jne 0x3550
movq %rbx, %rdi
callq 0x2080
callq 0x2210
jmp 0x3531
jmp 0x354d
jmp 0x354d