// File: /workspace/github_cpp_makefile_star2_O1/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 0x1260(%rip), %rsi      # 0x305a
movq %r14, %rdi
callq 0x1050
testl %eax, %eax
je 0x1e98
leaq 0x124b(%rip), %rsi      # 0x305c
movq %r14, %rdi
callq 0x1050
testl %eax, %eax
je 0x1eee
leaq 0x1236(%rip), %rsi      # 0x305e
movq %r14, %rdi
callq 0x1050
testl %eax, %eax
je 0x1f48
leaq 0x1221(%rip), %rsi      # 0x3060
movq %r14, %rdi
callq 0x1050
testl %eax, %eax
je 0x1f9a
movq 0x317a(%rip), %rbx      # 0x4fd0
leaq 0x122f(%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 0x1fec
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 0x1ed6
movl %esi, %r10d
cmpq %r10, %rdi
je 0x1ed4
movslq %esi, %rax
movl %r9d, (%r8,%rax,4)
movl $0x0, (%rdx,%rdi,4)
movb $0x1, %al
decl %esi
addq $-0x1, %rdi
jb 0x1eb3
incq %rcx
addq $0x10, %rdx
cmpq $0x4, %rcx
jne 0x1e9f
jmp 0x1fec
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 0x1f2c
movl %esi, %r10d
cmpq %r10, %rdi
je 0x1f2a
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 0x1f03
incq %rdx
addq $0x4, %rcx
cmpq $0x4, %rdx
jne 0x1ef6
jmp 0x1fec
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 0x1f82
movl %r8d, %r10d
cmpq %r10, %rdi
je 0x1f7f
movslq %r8d, %rax
movl %r9d, (%rsi,%rax,4)
movl $0x0, (%rdx,%rdi,4)
movb $0x1, %al
incl %r8d
incq %rdi
cmpq $0x4, %rdi
jne 0x1f5e
incq %rcx
addq $0x10, %rdx
cmpq $0x4, %rcx
jne 0x1f4f
jmp 0x1fec
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 0x1fd2
movl %r8d, %r10d
cmpq %r10, %rdi
je 0x1fcf
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 0x1fa9
incq %rcx
addq $0x4, %rdx
cmpq $0x4, %rcx
jne 0x1fa1
andb $0x1, %al
popq %rbx
popq %r14
popq %rbp
retq
nop