// File: 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
movq %rsp, %rbp
subq $0x180, %rsp            # imm = 0x180
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movq %rcx, -0x18(%rbp)
movl %r8d, -0x1c(%rbp)
movl %r9d, -0x20(%rbp)
movq -0x8(%rbp), %rdi
callq 0x76d0
movq %rax, %rdi
addq $0x104, %rdi            # imm = 0x104
movl -0x1c(%rbp), %eax
addl $0x3, %eax
subl $0x1, %eax
movslq %eax, %rsi
callq 0x7a20
movq %rax, %rdi
movslq -0x20(%rbp), %rsi
callq 0x7a50
testb $0x1, (%rax)
je 0x473b
jmp 0x4ab9
movq -0x8(%rbp), %rdi
callq 0x76d0
movq %rax, %rdi
addq $0x104, %rdi            # imm = 0x104
movl -0x1c(%rbp), %eax
addl $0x2, %eax
movslq %eax, %rsi
callq 0x7a20
movq %rax, %rdi
movslq -0x20(%rbp), %rsi
callq 0x7a50
movb $0x1, (%rax)
leaq -0x30(%rbp), %rdi
movq %rdi, -0x138(%rbp)
callq 0x7660
movl -0x1c(%rbp), %edi
movl -0x20(%rbp), %esi
callq 0x2930
movq -0x138(%rbp), %rdi
movq %rax, -0x38(%rbp)
callq 0x76d0
movq -0x38(%rbp), %rcx
movq %rcx, 0xb4(%rax)
movq -0x8(%rbp), %rdi
callq 0x76d0
movq -0x138(%rbp), %rdi
addq $0x14, %rax
movq %rax, -0x130(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x128(%rbp)
callq 0x76d0
movq -0x130(%rbp), %rsi
movq -0x128(%rbp), %rdx
movq %rax, %rcx
addq $0xb4, %rcx
leaq -0xe8(%rbp), %rdi
callq 0x3290
jmp 0x47f2
leaq -0x30(%rbp), %rdi
callq 0x76d0
addq $0xbc, %rax
movq %rax, -0x140(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x76d0
movq -0x140(%rbp), %rsi
movq %rax, %rcx
addq $0x14, %rcx
leaq -0x110(%rbp), %rdi
leaq -0x3c(%rbp), %rdx
callq 0x7a80
leaq -0x110(%rbp), %rdi
leaq -0xe8(%rbp), %rsi
callq 0x7ac0
jmp 0x48dc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xf0(%rbp)
movl %eax, -0xf4(%rbp)
movl -0xf4(%rbp), %eax
movl %eax, -0x144(%rbp)
movl $0x2, %ecx
cmpl %ecx, %eax
jne 0x488b
movq -0xf0(%rbp), %rdi
callq 0x2090
movl $0x1, -0x118(%rbp)
callq 0x22b0
jmp 0x48d7
movl -0x144(%rbp), %eax
movl $0x1, %ecx
cmpl %ecx, %eax
jne 0x4ac2
movq -0xf0(%rbp), %rdi
callq 0x2090
movl $0x1, -0x118(%rbp)
callq 0x22b0
jmp 0x48bb
jmp 0x4ab0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xf0(%rbp)
movl %eax, -0xf4(%rbp)
jmp 0x4ac2
jmp 0x4ab0
movq -0x8(%rbp), %rdi
callq 0x76d0
movl (%rax), %eax
incl %eax
movl %eax, -0x178(%rbp)
leaq -0x30(%rbp), %rdi
movq %rdi, -0x150(%rbp)
callq 0x76d0
movl -0x178(%rbp), %ecx
movl %ecx, (%rax)
movq -0x8(%rbp), %rdi
callq 0x76d0
movq -0x150(%rbp), %rdi
movl 0x4(%rax), %eax
movl %eax, -0x174(%rbp)
callq 0x76d0
movq -0x150(%rbp), %rdi
movq %rax, %rcx
movl -0x174(%rbp), %eax
movl 0xbc(%rcx), %ecx
addl %ecx, %eax
movl %eax, -0x170(%rbp)
callq 0x76d0
movl -0x170(%rbp), %ecx
movl %ecx, 0x4(%rax)
movq -0x8(%rbp), %rdi
callq 0x76d0
movl 0x8(%rax), %eax
movl -0x10(%rbp), %ecx
subl %ecx, %eax
movl %eax, -0x168(%rbp)
movq -0x8(%rbp), %rdi
callq 0x76d0
movq -0x150(%rbp), %rdi
movl 0x4(%rax), %eax
movl %eax, -0x16c(%rbp)
callq 0x76d0
movl -0x16c(%rbp), %edi
movl 0xbc(%rax), %esi
callq 0x2dc0
movq -0x150(%rbp), %rdi
movl %eax, %ecx
movl -0x168(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x164(%rbp)
callq 0x76d0
movl -0x164(%rbp), %ecx
movl %ecx, 0x8(%rax)
movq -0x8(%rbp), %rdi
callq 0x76d0
movq -0x150(%rbp), %rdi
movl 0xc(%rax), %eax
movl -0x10(%rbp), %ecx
addl %ecx, %eax
movl %eax, -0x160(%rbp)
callq 0x76d0
movl -0x160(%rbp), %ecx
movl %ecx, 0xc(%rax)
movq -0x8(%rbp), %rdi
callq 0x76d0
movq -0x150(%rbp), %rdi
movl 0x10(%rax), %eax
movl -0xc(%rbp), %ecx
addl %ecx, %eax
movl -0x3c(%rbp), %ecx
subl %ecx, %eax
movl %eax, -0x15c(%rbp)
callq 0x76d0
movl -0x15c(%rbp), %ecx
movq -0x150(%rbp), %rdi
movl %ecx, 0x10(%rax)
callq 0x76d0
movq -0x150(%rbp), %rdi
movl $0x0, 0x100(%rax)
movq -0x8(%rbp), %rax
movq %rax, -0x158(%rbp)
callq 0x76d0
movq -0x158(%rbp), %rsi
movq %rax, %rdi
addq $0xf0, %rdi
callq 0x7b00
movq -0x8(%rbp), %rdi
callq 0x76d0
movq %rax, %rdi
addq $0x138, %rdi            # imm = 0x138
movl -0x1c(%rbp), %eax
addl $0x2, %eax
movslq %eax, %rsi
callq 0x7b30
movq %rax, %rdi
movslq -0x20(%rbp), %rsi
callq 0x7b60
movq -0x150(%rbp), %rsi
movq %rax, %rdi
callq 0x7b90
movq -0x150(%rbp), %rdi
callq 0x4310
jmp 0x4aa6
movl $0x0, -0x118(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x78c0
addq $0x180, %rsp            # imm = 0x180
popq %rbp
retq
leaq -0x30(%rbp), %rdi
callq 0x78c0
movq -0xf0(%rbp), %rdi
callq 0x22f0
nopw (%rax,%rax)