// File: /workspace/github_cpp_makefile_star2_O3/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 0x1280(%rip), %rsi      # 0x305a
movq %r14, %rdi
callq 0x1050
testl %eax, %eax
je 0x1e78
leaq 0x126b(%rip), %rsi      # 0x305c
movq %r14, %rdi
callq 0x1050
testl %eax, %eax
je 0x1ece
leaq 0x1256(%rip), %rsi      # 0x305e
movq %r14, %rdi
callq 0x1050
testl %eax, %eax
je 0x1f28
leaq 0x1241(%rip), %rsi      # 0x3060
movq %r14, %rdi
callq 0x1050
testl %eax, %eax
je 0x1f7a
movq 0x319a(%rip), %rbx      # 0x4fd0
leaq 0x124f(%rip), %rsi      # 0x308c
movl $0x12, %edx
movq %rbx, %rdi
callq 0x1110
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x10d0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x1030
movq %rax, %rdi
callq 0x1080
xorl %eax, %eax
jmp 0x1fcc
xorl %ecx, %ecx
movq %rbx, %rdx
xorl %eax, %eax
movl $0x3, %esi
movl $0x3, %edi
movq %rcx, %r8
shlq $0x4, %r8
addq %rbx, %r8
movl (%rdx,%rdi,4), %r9d
testl %r9d, %r9d
je 0x1eb6
movl %esi, %r10d
cmpq %r10, %rdi
je 0x1eb4
movslq %esi, %rax
movl %r9d, (%r8,%rax,4)
movl $0x0, (%rdx,%rdi,4)
movb $0x1, %al
decl %esi
addq $-0x1, %rdi
jb 0x1e93
incq %rcx
addq $0x10, %rdx
cmpq $0x4, %rcx
jne 0x1e7f
jmp 0x1fcc
leaq 0x30(%rbx), %rcx
xorl %edx, %edx
xorl %eax, %eax
movl $0x3, %esi
movl $0x3, %edi
movq %rcx, %r8
movl (%r8), %r9d
testl %r9d, %r9d
je 0x1f0c
movl %esi, %r10d
cmpq %r10, %rdi
je 0x1f0a
movslq %esi, %rax
shlq $0x4, %rax
addq %rbx, %rax
movl %r9d, (%rax,%rdx,4)
movl $0x0, (%r8)
movb $0x1, %al
decl %esi
addq $-0x10, %r8
addq $-0x1, %rdi
jb 0x1ee3
incq %rdx
addq $0x4, %rcx
cmpq $0x4, %rdx
jne 0x1ed6
jmp 0x1fcc
xorl %ecx, %ecx
movq %rbx, %rdx
xorl %eax, %eax
movq %rcx, %rsi
shlq $0x4, %rsi
addq %rbx, %rsi
xorl %edi, %edi
xorl %r8d, %r8d
movl (%rdx,%rdi,4), %r9d
testl %r9d, %r9d
je 0x1f62
movl %r8d, %r10d
cmpq %r10, %rdi
je 0x1f5f
movslq %r8d, %rax
movl %r9d, (%rsi,%rax,4)
movl $0x0, (%rdx,%rdi,4)
movb $0x1, %al
incl %r8d
incq %rdi
cmpq $0x4, %rdi
jne 0x1f3e
incq %rcx
addq $0x10, %rdx
cmpq $0x4, %rcx
jne 0x1f2f
jmp 0x1fcc
xorl %ecx, %ecx
movq %rbx, %rdx
xorl %eax, %eax
movq %rdx, %rsi
xorl %edi, %edi
xorl %r8d, %r8d
movl (%rsi), %r9d
testl %r9d, %r9d
je 0x1fb2
movl %r8d, %r10d
cmpq %r10, %rdi
je 0x1faf
movslq %r8d, %rax
shlq $0x4, %rax
addq %rbx, %rax
movl %r9d, (%rax,%rcx,4)
movl $0x0, (%rsi)
movb $0x1, %al
incl %r8d
incq %rdi
addq $0x10, %rsi
cmpq $0x4, %rdi
jne 0x1f89
incq %rcx
addq $0x4, %rdx
cmpq $0x4, %rcx
jne 0x1f81
andb $0x1, %al
popq %rbx
popq %r14
popq %rbp
retq
nop