// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r14
pushq %rbx
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x532(%rip), %rsi       # 0x305a
movq %r14, %rdi
callq 0x2cdd
testb %al, %al
je 0x2b86
xorl %ecx, %ecx
pushq $0x3
popq %rdx
xorl %eax, %eax
cmpq $0x4, %rcx
je 0x2cd6
movq %rcx, %rsi
shlq $0x4, %rsi
addq %rbx, %rsi
movl %edx, %edi
movl %edx, %r8d
testl %r8d, %r8d
js 0x2b81
movl %r8d, %r10d
movl (%rsi,%r10,4), %r9d
testl %r9d, %r9d
je 0x2b7c
cmpl %edi, %r8d
je 0x2b7a
leaq (%rsi,%r10,4), %rax
movslq %edi, %r10
movl %r9d, (%rsi,%r10,4)
andl $0x0, (%rax)
movb $0x1, %al
decl %edi
decl %r8d
jmp 0x2b54
incq %rcx
jmp 0x2b3b
leaq 0x4cf(%rip), %rsi       # 0x305c
movq %r14, %rdi
callq 0x2cdd
testb %al, %al
je 0x2beb
xorl %ecx, %ecx
pushq $0x3
popq %rdx
xorl %eax, %eax
cmpq $0x4, %rcx
je 0x2cd6
movl %edx, %esi
movl %edx, %edi
testl %edi, %edi
js 0x2be6
movl %edi, %r9d
shlq $0x4, %r9
addq %rbx, %r9
movl (%r9,%rcx,4), %r8d
testl %r8d, %r8d
je 0x2be2
cmpl %esi, %edi
je 0x2be0
leaq (%r9,%rcx,4), %rax
movslq %esi, %r9
shlq $0x4, %r9
addq %rbx, %r9
movl %r8d, (%r9,%rcx,4)
andl $0x0, (%rax)
movb $0x1, %al
decl %esi
decl %edi
jmp 0x2bae
incq %rcx
jmp 0x2ba0
leaq 0x46c(%rip), %rsi       # 0x305e
movq %r14, %rdi
callq 0x2cdd
testb %al, %al
je 0x2c53
xorl %ecx, %ecx
movq %rbx, %rdx
xorl %eax, %eax
cmpq $0x4, %rcx
je 0x2cd6
xorl %esi, %esi
movq %rcx, %rdi
shlq $0x4, %rdi
addq %rbx, %rdi
xorl %r8d, %r8d
cmpq $0x4, %rsi
je 0x2c4a
movl (%rdx,%rsi,4), %r9d
testl %r9d, %r9d
je 0x2c45
movl %r8d, %r10d
cmpq %r10, %rsi
je 0x2c42
movslq %r8d, %rax
movl %r9d, (%rdi,%rax,4)
andl $0x0, (%rdx,%rsi,4)
movb $0x1, %al
incl %r8d
incq %rsi
jmp 0x2c1e
incq %rcx
addq $0x10, %rdx
jmp 0x2c05
leaq 0x406(%rip), %rsi       # 0x3060
movq %r14, %rdi
callq 0x2cdd
testb %al, %al
je 0x2cb9
xorl %ecx, %ecx
movq %rbx, %rdx
xorl %eax, %eax
cmpq $0x4, %rcx
je 0x2cd6
xorl %esi, %esi
movq %rdx, %rdi
xorl %r8d, %r8d
cmpq $0x4, %rsi
je 0x2cb0
movl (%rdi), %r9d
testl %r9d, %r9d
je 0x2ca7
movl %r8d, %r10d
cmpq %r10, %rsi
je 0x2ca4
movslq %r8d, %rax
shlq $0x4, %rax
addq %rbx, %rax
movl %r9d, (%rax,%rcx,4)
andl $0x0, (%rdi)
movb $0x1, %al
incl %r8d
incq %rsi
addq $0x10, %rdi
jmp 0x2c7b
incq %rcx
addq $0x4, %rdx
jmp 0x2c6d
movq 0x2310(%rip), %rdi      # 0x4fd0
leaq 0x3c5(%rip), %rsi       # 0x308c
callq 0x2110
movq %rax, %rdi
callq 0x20b0
xorl %eax, %eax
andb $0x1, %al
popq %rbx
popq %r14
popq %rbp
retq