// File: gogakoreli[P]snake/snake.cpp
// Function: Snake::update_movement()
void Snake::update_movement(void)
{
    pair<int, int> movement_part;
    enum Direction direction = get_direction();
    switch (direction)
    {
    case West:
        movement_part = make_pair(snake_head.first, snake_head.second - 1);
        break;
    case North:
        movement_part = make_pair(snake_head.first - 1, snake_head.second);
        break;
    case East:
        movement_part = make_pair(snake_head.first, snake_head.second + 1);
        break;
    case South:
        movement_part = make_pair(snake_head.first + 1, snake_head.second);
        break;
    }
    snake_head = movement_part;
    snake_parts.push_back(movement_part);
    food_eaten = snake_head.first == snake_food.first && snake_head.second == snake_food.second;
    if (food_eaten)
    {
        length++;
    }
    else
    {
        pair<int, int> tail = snake_parts.front();
        snake_world_array[tail.first][tail.second]--;
        snake_parts.erase(snake_parts.begin());
    }
    int head_value = ++snake_world_array[snake_head.first][snake_head.second];
    if (head_value > 1)
    {
        is_dead = true;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x80(%rbp)
leaq -0x10(%rbp), %rdi
callq 0x1d60
movq -0x80(%rbp), %rdi
callq 0x1a80
movl %eax, -0x14(%rbp)
movl -0x14(%rbp), %eax
movq %rax, -0x78(%rbp)
subq $0x3, %rax
ja 0x1c04
movq -0x78(%rbp), %rax
leaq 0x24ec(%rip), %rcx      # 0x4024
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x80(%rbp), %rax
movq %rax, %rdi
addq $0x18, %rdi
movl 0x1c(%rax), %eax
subl $0x1, %eax
movl %eax, -0x20(%rbp)
leaq -0x20(%rbp), %rsi
callq 0x1d80
movq %rax, -0x1c(%rbp)
leaq -0x10(%rbp), %rdi
leaq -0x1c(%rbp), %rsi
callq 0x1db0
jmp 0x1c04
movq -0x80(%rbp), %rsi
movl 0x18(%rsi), %eax
subl $0x1, %eax
movl %eax, -0x2c(%rbp)
addq $0x18, %rsi
addq $0x4, %rsi
leaq -0x2c(%rbp), %rdi
callq 0x1de0
movq %rax, -0x28(%rbp)
leaq -0x10(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x1db0
jmp 0x1c04
movq -0x80(%rbp), %rax
movq %rax, %rdi
addq $0x18, %rdi
movl 0x1c(%rax), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
leaq -0x38(%rbp), %rsi
callq 0x1d80
movq %rax, -0x34(%rbp)
leaq -0x10(%rbp), %rdi
leaq -0x34(%rbp), %rsi
callq 0x1db0
jmp 0x1c04
movq -0x80(%rbp), %rsi
movl 0x18(%rsi), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
addq $0x18, %rsi
addq $0x4, %rsi
leaq -0x44(%rbp), %rdi
callq 0x1de0
movq %rax, -0x40(%rbp)
leaq -0x10(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x1db0
movq -0x80(%rbp), %rdi
addq $0x18, %rdi
leaq -0x10(%rbp), %rsi
callq 0x1e10
movq -0x80(%rbp), %rdi
leaq -0x10(%rbp), %rsi
callq 0x1e40
movq -0x80(%rbp), %rdx
movl 0x18(%rdx), %ecx
xorl %eax, %eax
cmpl 0x58(%rdx), %ecx
movb %al, -0x81(%rbp)
jne 0x1c49
movq -0x80(%rbp), %rcx
movl 0x1c(%rcx), %eax
cmpl 0x5c(%rcx), %eax
sete %al
movb %al, -0x81(%rbp)
movq -0x80(%rbp), %rax
movb -0x81(%rbp), %cl
andb $0x1, %cl
movb %cl, 0x20(%rax)
testb $0x1, 0x20(%rax)
je 0x1c6e
movq -0x80(%rbp), %rax
movl 0x24(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x24(%rax)
jmp 0x1cc8
movq -0x80(%rbp), %rdi
callq 0x1eb0
movq -0x80(%rbp), %rdi
movq (%rax), %rax
movq %rax, -0x4c(%rbp)
movq %rdi, %rax
addq $0x60, %rax
movslq -0x4c(%rbp), %rcx
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movslq -0x48(%rbp), %rcx
movl (%rax,%rcx,4), %edx
addl $-0x1, %edx
movl %edx, (%rax,%rcx,4)
callq 0x1f50
movq %rax, -0x60(%rbp)
leaq -0x58(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x1f80
movq -0x80(%rbp), %rdi
movq -0x58(%rbp), %rsi
callq 0x1ee0
movq %rax, -0x68(%rbp)
movq -0x80(%rbp), %rax
movq %rax, %rcx
addq $0x60, %rcx
movslq 0x18(%rax), %rdx
imulq $0x50, %rdx, %rdx
addq %rdx, %rcx
movslq 0x1c(%rax), %rdx
movl (%rcx,%rdx,4), %eax
addl $0x1, %eax
movl %eax, (%rcx,%rdx,4)
movl %eax, -0x6c(%rbp)
cmpl $0x1, -0x6c(%rbp)
jle 0x1cfc
movq -0x80(%rbp), %rax
movb $0x1, 0x21(%rax)
addq $0x90, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)