// File: /workspace/github_cpp_makefile_star2_O2/lukasz-wiecaszek[P]h264iframedecoder/picture.cpp
// Function: ymn::h264::picture::calculate_neighbours_part1()
void picture::calculate_neighbours_part1()
{
    int y = m_context_variables.mb_y;
    int n = m_context_variables.mb_pos;
    int mb_width = m_decoder.m_dimensions.mb_width;
    mb& mb = m_mbs[n];

    if (m_context_variables.mb_aff_frame) {
        int shift = y & 1 ? 3 * mb_width : 2 * mb_width;

        mb.A = (n % mb_width) ? get_mb(n - 1 - (y & 1) * mb_width) : nullptr;
        mb.B = get_mb(n - shift);
        mb.C = ((n + 1) % mb_width) ? get_mb(n - shift + 1) : nullptr;
        mb.D = (n % mb_width) ? get_mb(n - shift - 1) : nullptr;
    }
    else {
        if (m_picture_structure == picture_structure_e::frame) {
            mb.A = (n % mb_width) ? get_mb(n - 1) : nullptr;
            mb.B = get_mb(n - mb_width);
            mb.C = ((n + 1) % mb_width) ? get_mb(n - mb_width + 1) : nullptr;
            mb.D = (n % mb_width) ? get_mb(n - mb_width - 1) : nullptr;
        }
        else {
            int shift = 2 * mb_width;

            mb.A = (n % mb_width) ? get_mb(n - 1) : nullptr;
            mb.B = get_mb(n - shift);
            mb.C = ((n + 1) % mb_width) ? get_mb(n - shift + 1) : nullptr;
            mb.D = (n % mb_width) ? get_mb(n - shift - 1) : nullptr;
        }
    }

    /* To calculate left and top references it is necessary to know
    whether the current macroblock is a frame or field macroblock.
    This is why left and top references will be calculated later (in part2)
    when current macroblock frame/field status is already known. */
    mb.left = nullptr;
    mb.left_pair[0] = nullptr;
    mb.left_pair[1] = nullptr;
    mb.top = nullptr;
}

// Assembly:
pushq %rbx
movslq 0x24(%rdi), %rcx
movq 0x8(%rdi), %rax
movl 0x88340(%rax), %r9d
movq 0xdb8(%rdi), %r10
imulq $0xb0, %rcx, %r8
addq %r10, %r8
cmpb $0x1, 0x18(%rdi)
jne 0x1180e
movl 0x20(%rdi), %ebx
leal (%r9,%r9), %eax
andl $0x1, %ebx
leal (%r9,%r9,2), %r11d
cmovel %eax, %r11d
movl %ecx, %eax
cltd
idivl %r9d
movl %edx, %esi
testl %edx, %edx
je 0x11847
imull %r9d, %ebx
notl %ebx
addl %ecx, %ebx
movslq %ebx, %rax
imulq $0xb0, %rax, %rdx
addq %rdx, %r10
xorl %edx, %edx
cmpl %eax, %ecx
cmovlq %rdx, %r10
testl %eax, %eax
cmovsq %rdx, %r10
jmp 0x1184a
cmpl $0x0, 0x10(%rdi)
je 0x118b3
movl %ecx, %eax
cltd
idivl %r9d
movl %edx, %esi
leaq -0xb0(%r8), %rax
xorl %r11d, %r11d
testl %ecx, %ecx
cmovleq %r11, %rax
testl %edx, %edx
cmoveq %r11, %rax
leal (%r9,%r9), %edx
movq %rax, 0x18(%r8)
movl %ecx, %eax
subl %edx, %eax
jmp 0x118da
xorl %r10d, %r10d
movq %r10, 0x18(%r8)
movl %ecx, %eax
subl %r11d, %eax
movslq %eax, %r10
imulq $0xb0, %r10, %r11
movq 0xdb8(%rdi), %rax
addq %r11, %rax
xorl %ebx, %ebx
cmpl %r10d, 0x24(%rdi)
cmovlq %rbx, %rax
testl %r10d, %r10d
cmovsq %rbx, %rax
movq %rax, 0x20(%r8)
leal 0x1(%rcx), %eax
cltd
idivl %r9d
testl %edx, %edx
je 0x118aa
addq 0xdb8(%rdi), %r11
addq $0xb0, %r11
xorl %eax, %eax
cmpl %r10d, 0x24(%rdi)
cmovleq %rax, %r11
cmpl $-0x1, %r10d
cmovlq %rax, %r11
movq %r11, %rbx
movq %rbx, 0x28(%r8)
jmp 0x11933
movl %ecx, %eax
cltd
idivl %r9d
movl %edx, %esi
leaq -0xb0(%r8), %rax
xorl %r11d, %r11d
testl %ecx, %ecx
cmovleq %r11, %rax
testl %edx, %edx
cmoveq %r11, %rax
movq %rax, 0x18(%r8)
movl %ecx, %eax
subl %r9d, %eax
movslq %eax, %r10
imulq $0xb0, %r10, %rbx
movq 0xdb8(%rdi), %rax
addq %rbx, %rax
cmpl %r10d, 0x24(%rdi)
cmovlq %r11, %rax
testl %r10d, %r10d
cmovsq %r11, %rax
movq %rax, 0x20(%r8)
leal 0x1(%rcx), %eax
cltd
idivl %r9d
testl %edx, %edx
je 0x1192f
addq 0xdb8(%rdi), %rbx
addq $0xb0, %rbx
xorl %eax, %eax
cmpl %r10d, 0x24(%rdi)
cmovleq %rax, %rbx
cmpl $-0x1, %r10d
cmovlq %rax, %rbx
movq %rbx, %r11
movq %r11, 0x28(%r8)
testl %esi, %esi
je 0x1195e
leal -0x1(%r10), %eax
movslq %eax, %rcx
imulq $0xb0, %rcx, %rax
addq 0xdb8(%rdi), %rax
xorl %edx, %edx
cmpl %ecx, 0x24(%rdi)
cmovlq %rdx, %rax
testl %r10d, %r10d
cmovleq %rdx, %rax
jmp 0x11960
xorl %eax, %eax
movq %rax, 0x30(%r8)
xorps %xmm0, %xmm0
movups %xmm0, 0x38(%r8)
movups %xmm0, 0x48(%r8)
popq %rbx
retq
nop