// File: sanket143[P]2048-Terminal-Game/./src/board.h
// Function: gb::Board::shift(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
bool shift(std::string direction) {
        int non_zero;
        bool changed = false;
        if(direction == "R") {
          for(int row = 0; row < 4; row++) {
            non_zero = 3;
            for(int col = 3; col >= 0; col--) {
              if(tiles[row][col] != 0) {
                if(col != non_zero){
                  tiles[row][non_zero] = tiles[row][col];
                  tiles[row][col] = 0;
                  changed = true;
                }
                non_zero -= 1;
              }
            }
          }
        }
        else if(direction == "D") {
          for(int col = 0; col < 4; col++) {
            non_zero = 3;
            for(int row = 3; row >= 0; row--) {
              if(tiles[row][col] != 0) {
                if(row != non_zero) {
                  tiles[non_zero][col] = tiles[row][col];
                  tiles[row][col] = 0;
                  changed = true;
                }
                non_zero -= 1;
              }
            }
          }
        }
        else if(direction == "L") {
          for(int row = 0; row < 4; row++) {
            non_zero = 0;
            for(int col = 0; col < 4; col++) {
              if(tiles[row][col] != 0) {
                if(col != non_zero) {
                  tiles[row][non_zero] = tiles[row][col];
                  tiles[row][col] = 0;
                  changed = true;
                }
                non_zero += 1;
              }
            }
          }
        }
        else if(direction == "U") {
          for(int col = 0; col < 4; col++) {
            non_zero = 0;
            for(int row = 0; row < 4; row++) {
              if(tiles[row][col] != 0) {
                if(row != non_zero) {
                  tiles[non_zero][col] = tiles[row][col];
                  tiles[row][col] = 0;
                  changed = true;
                }
                non_zero += 1;
              }
            }
          }
        } else {
          std::cout << "Invalid Direction." << std::endl;
        }
        return changed;
      }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rsi, -0x50(%rbp)
movq %rdi, %rax
movq -0x50(%rbp), %rdi
movq %rdi, -0x48(%rbp)
movq %rax, -0x8(%rbp)
movq %rdi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x40(%rbp)
movb $0x0, -0x15(%rbp)
leaq 0x1828(%rip), %rsi      # 0x505a
callq 0x3bc0
testb $0x1, %al
jne 0x3840
jmp 0x3900
movl $0x0, -0x1c(%rbp)
cmpl $0x4, -0x1c(%rbp)
jge 0x38fb
movl $0x3, -0x14(%rbp)
movl $0x3, -0x20(%rbp)
cmpl $0x0, -0x20(%rbp)
jl 0x38eb
movq -0x40(%rbp), %rax
movslq -0x1c(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movslq -0x20(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,4)
je 0x38db
movl -0x20(%rbp), %eax
cmpl -0x14(%rbp), %eax
je 0x38d2
movq -0x40(%rbp), %rax
movslq -0x1c(%rbp), %rdx
shlq $0x4, %rdx
movq %rax, %rcx
addq %rdx, %rcx
movslq -0x20(%rbp), %rdx
movl (%rcx,%rdx,4), %esi
movslq -0x1c(%rbp), %rdx
shlq $0x4, %rdx
movq %rax, %rcx
addq %rdx, %rcx
movslq -0x14(%rbp), %rdx
movl %esi, (%rcx,%rdx,4)
movslq -0x1c(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movslq -0x20(%rbp), %rcx
movl $0x0, (%rax,%rcx,4)
movb $0x1, -0x15(%rbp)
movl -0x14(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x38dd
movl -0x20(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x385f
jmp 0x38ed
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x3847
jmp 0x3bb0
movq -0x48(%rbp), %rdi
leaq 0x1751(%rip), %rsi      # 0x505c
callq 0x3bc0
testb $0x1, %al
jne 0x3919
jmp 0x39d9
movl $0x0, -0x24(%rbp)
cmpl $0x4, -0x24(%rbp)
jge 0x39d4
movl $0x3, -0x14(%rbp)
movl $0x3, -0x28(%rbp)
cmpl $0x0, -0x28(%rbp)
jl 0x39c4
movq -0x40(%rbp), %rax
movslq -0x28(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movslq -0x24(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,4)
je 0x39b4
movl -0x28(%rbp), %eax
cmpl -0x14(%rbp), %eax
je 0x39ab
movq -0x40(%rbp), %rax
movslq -0x28(%rbp), %rdx
shlq $0x4, %rdx
movq %rax, %rcx
addq %rdx, %rcx
movslq -0x24(%rbp), %rdx
movl (%rcx,%rdx,4), %esi
movslq -0x14(%rbp), %rdx
shlq $0x4, %rdx
movq %rax, %rcx
addq %rdx, %rcx
movslq -0x24(%rbp), %rdx
movl %esi, (%rcx,%rdx,4)
movslq -0x28(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movslq -0x24(%rbp), %rcx
movl $0x0, (%rax,%rcx,4)
movb $0x1, -0x15(%rbp)
movl -0x14(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x39b6
movl -0x28(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x3938
jmp 0x39c6
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x3920
jmp 0x3bae
movq -0x48(%rbp), %rdi
leaq 0x167a(%rip), %rsi      # 0x505e
callq 0x3bc0
testb $0x1, %al
jne 0x39f2
jmp 0x3ab2
movl $0x0, -0x2c(%rbp)
cmpl $0x4, -0x2c(%rbp)
jge 0x3aad
movl $0x0, -0x14(%rbp)
movl $0x0, -0x30(%rbp)
cmpl $0x4, -0x30(%rbp)
jge 0x3a9d
movq -0x40(%rbp), %rax
movslq -0x2c(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movslq -0x30(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,4)
je 0x3a8d
movl -0x30(%rbp), %eax
cmpl -0x14(%rbp), %eax
je 0x3a84
movq -0x40(%rbp), %rax
movslq -0x2c(%rbp), %rdx
shlq $0x4, %rdx
movq %rax, %rcx
addq %rdx, %rcx
movslq -0x30(%rbp), %rdx
movl (%rcx,%rdx,4), %esi
movslq -0x2c(%rbp), %rdx
shlq $0x4, %rdx
movq %rax, %rcx
addq %rdx, %rcx
movslq -0x14(%rbp), %rdx
movl %esi, (%rcx,%rdx,4)
movslq -0x2c(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movslq -0x30(%rbp), %rcx
movl $0x0, (%rax,%rcx,4)
movb $0x1, -0x15(%rbp)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x3a8f
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x3a11
jmp 0x3a9f
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x39f9
jmp 0x3bac
movq -0x48(%rbp), %rdi
leaq 0x15a3(%rip), %rsi      # 0x5060
callq 0x3bc0
testb $0x1, %al
jne 0x3acb
jmp 0x3b88
movl $0x0, -0x34(%rbp)
cmpl $0x4, -0x34(%rbp)
jge 0x3b86
movl $0x0, -0x14(%rbp)
movl $0x0, -0x38(%rbp)
cmpl $0x4, -0x38(%rbp)
jge 0x3b76
movq -0x40(%rbp), %rax
movslq -0x38(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movslq -0x34(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,4)
je 0x3b66
movl -0x38(%rbp), %eax
cmpl -0x14(%rbp), %eax
je 0x3b5d
movq -0x40(%rbp), %rax
movslq -0x38(%rbp), %rdx
shlq $0x4, %rdx
movq %rax, %rcx
addq %rdx, %rcx
movslq -0x34(%rbp), %rdx
movl (%rcx,%rdx,4), %esi
movslq -0x14(%rbp), %rdx
shlq $0x4, %rdx
movq %rax, %rcx
addq %rdx, %rcx
movslq -0x34(%rbp), %rdx
movl %esi, (%rcx,%rdx,4)
movslq -0x38(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movslq -0x34(%rbp), %rcx
movl $0x0, (%rax,%rcx,4)
movb $0x1, -0x15(%rbp)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x3b68
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x3aea
jmp 0x3b78
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x3ad2
jmp 0x3baa
movq 0x4441(%rip), %rdi      # 0x7fd0
leaq 0x14f6(%rip), %rsi      # 0x508c
callq 0x2170
movq %rax, %rdi
movq 0x441b(%rip), %rsi      # 0x7fc0
callq 0x21a0
jmp 0x3bac
jmp 0x3bae
jmp 0x3bb0
movb -0x15(%rbp), %al
andb $0x1, %al
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax,%rax)