// File: /workspace/github_cpp_makefile_star2_O3/Rubenmp[P]Rubik/src/searchBugs.cpp
// Function: main
int main(int argc, char* argv[]){
   Rubik rubik, aux;
   ofstream os;
   vector<char> solution;
   bool boolean = true;
   string file;
   int i = 1;

   if (argv[1][0] == '-' && argv[1][1] == 's' && argc == 2){ // Search mode
     for (unsigned int j=0; j<100000 && boolean; j++){
       aux = rubik = Rubik::randomRubik();
       
       rubik.solve(solution);
       if(!rubik.isSolved()){
         file += "./data/error" + i;
         os.open(file);
         
         // Original rubik is solved, we want original positions to debug
         os << aux;
         os.close();

         file = "";
         boolean = false;
         ++i;
       }
     }
     if (!boolean)
       cout << "There are bugs :D" << endl;
     else
       cout << "There aren't any bugs" << endl;
   }
   else{ // Fix bugs mode
     ifstream is(argv[1]);

     is >> rubik;
     cout << rubik;

     rubik.solveStepByStep(solution);
     cout << rubik;
   }
   
   cout << endl;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x4b8, %rsp            # imm = 0x4B8
movq %rsi, %r14
movl %edi, %ebx
leaq 0x44(%rsp), %rdi
callq 0x8912
leaq 0x7a(%rsp), %rdi
callq 0x8912
leaq 0xb0(%rsp), %rdi
callq 0x2230
xorl %eax, %eax
movq %rax, 0x10(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
leaq 0x30(%rsp), %rbp
movq %rbp, -0x10(%rbp)
movq %rax, -0x8(%rbp)
movb $0x0, (%rbp)
movq 0x8(%r14), %rsi
cmpb $0x2d, (%rsi)
jne 0x252c
cmpl $0x2, %ebx
jne 0x252c
cmpb $0x73, 0x1(%rsi)
jne 0x252c
xorl %ebx, %ebx
leaq 0x2b0(%rsp), %r14
leaq 0x44(%rsp), %r15
leaq 0x7a(%rsp), %r12
movq %rsp, %r13
movq %r14, %rdi
callq 0xa5c2
movq %r15, %rdi
movq %r14, %rsi
callq 0x8946
movq %r12, %rdi
movq %rax, %rsi
callq 0x8946
movb $0x42, 0x2b0(%rsp)
movq %r15, %rdi
movq %r13, %rsi
movq %r14, %rdx
callq 0xa394
movq %r15, %rdi
callq 0x8af8
testb %al, %al
je 0x2591
cmpl $0x1869f, %ebx          # imm = 0x1869F
leal 0x1(%rbx), %ecx
setb %dl
movl %ecx, %ebx
testb %al, %dl
jne 0x24c5
movl $0x15, %edx
leaq 0x9afc(%rip), %rsi      # 0xc023
jmp 0x25fe
leaq 0x2b0(%rsp), %rdi
movl $0x8, %edx
callq 0x2260
leaq 0x2b0(%rsp), %rdi
leaq 0x44(%rsp), %rsi
callq 0xb88e
movq 0xea71(%rip), %rdi      # 0x10fc8
leaq 0x44(%rsp), %rsi
callq 0xa5d8
leaq 0x44(%rsp), %rdi
movq %rsp, %rsi
callq 0xa016
movq 0xea53(%rip), %rdi      # 0x10fc8
leaq 0x44(%rsp), %rsi
callq 0xa5d8
leaq 0x2b0(%rsp), %rdi
callq 0x2050
jmp 0x2638
leaq 0x9a6d(%rip), %rsi      # 0xc005
leaq 0x20(%rsp), %rdi
callq 0x2270
leaq 0xb0(%rsp), %rdi
leaq 0x20(%rsp), %rsi
movl $0x10, %edx
callq 0x2080
leaq 0xb0(%rsp), %rdi
leaq 0x7a(%rsp), %rsi
callq 0xa5d8
leaq 0xb0(%rsp), %rdi
callq 0x21c0
leaq 0x20(%rsp), %rdi
movq 0x8(%rdi), %rdx
leaq 0xb239(%rip), %rcx      # 0xd821
xorl %esi, %esi
xorl %r8d, %r8d
callq 0x2210
movl $0x11, %edx
leaq 0x9a13(%rip), %rsi      # 0xc011
movq 0xe9c3(%rip), %r14      # 0x10fc8
movq %r14, %rdi
callq 0x2190
movq (%r14), %rax
addq -0x18(%rax), %r14
movq %r14, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq 0xe99d(%rip), %rdi      # 0x10fc8
callq 0x2030
movq %rax, %rdi
callq 0x20e0
movq 0xe989(%rip), %rdi      # 0x10fc8
movq (%rdi), %rax
addq -0x18(%rax), %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq 0xe96e(%rip), %rdi      # 0x10fc8
callq 0x2030
movq %rax, %rdi
callq 0x20e0
movq 0x20(%rsp), %rdi
cmpq %rbp, %rdi
je 0x267e
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x2180
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x2694
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x2180
movq 0xe925(%rip), %rax      # 0x10fc0
movq (%rax), %rcx
movq 0x18(%rax), %rax
leaq 0xb8(%rsp), %rdi
movq %rcx, -0x8(%rdi)
movq -0x18(%rcx), %rcx
movq %rax, 0xb0(%rsp,%rcx)
callq 0x2110
leaq 0x1a8(%rsp), %rdi
callq 0x2070
xorl %eax, %eax
addq $0x4b8, %rsp            # imm = 0x4B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x26fc
jmp 0x26fc
movq %rax, %rbx
leaq 0x2b0(%rsp), %rdi
callq 0x2050
jmp 0x26ff
jmp 0x26fc
jmp 0x26fc
jmp 0x26fc
movq %rax, %rbx
movq 0x20(%rsp), %rdi
cmpq %rbp, %rdi
je 0x2716
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x2180
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x272c
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x2180
leaq 0xb0(%rsp), %rdi
callq 0x21e0
movq %rbx, %rdi
callq 0x2240
nopl (%rax)