// File: /workspace/github_cpp_makefile_star2_O2/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 0x7aae
leaq 0x7a(%rsp), %rdi
callq 0x7aae
leaq 0x2b8(%rsp), %rdi
callq 0x2220
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
andq $0x0, 0x10(%rsp)
leaq 0x30(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq 0x8(%r14), %rsi
cmpb $0x2d, (%rsi)
jne 0x2514
cmpl $0x2, %ebx
jne 0x2514
cmpb $0x73, 0x1(%rsi)
jne 0x2514
xorl %r15d, %r15d
pushq $0x1
popq %r13
movb $0x1, %r12b
leaq 0xb0(%rsp), %rbx
leaq 0x44(%rsp), %r14
leaq 0x2b8(%rsp), %rbp
cmpl $0x1869f, %r15d         # imm = 0x1869F
ja 0x2574
testb $0x1, %r12b
je 0x2574
movq %rbx, %rdi
callq 0x93d4
movq %r14, %rdi
movq %rbx, %rsi
callq 0x7ae2
leaq 0x7a(%rsp), %rdi
movq %rax, %rsi
callq 0x7ae2
movb $0x42, 0xb0(%rsp)
movq %r14, %rdi
movq %rsp, %rsi
movq %rbx, %rdx
callq 0x9294
movq %r14, %rdi
callq 0x7cbc
movl %eax, %r12d
testb %al, %al
jne 0x250c
movslq %r13d, %rsi
leaq 0x8b3e(%rip), %rax      # 0xb004
addq %rax, %rsi
leaq 0x20(%rsp), %rdi
callq 0x2260
movq %rbp, %rdi
leaq 0x20(%rsp), %rsi
pushq $0x10
popq %rdx
callq 0x20b0
movq %rbp, %rdi
leaq 0x7a(%rsp), %rsi
callq 0x93ea
movq %rbp, %rdi
callq 0x21c0
leaq 0x20(%rsp), %rdi
leaq 0xa32d(%rip), %rsi      # 0xc831
callq 0x2270
incl %r13d
incl %r15d
jmp 0x2460
leaq 0xb0(%rsp), %rdi
pushq $0x8
popq %rdx
callq 0x2250
leaq 0xb0(%rsp), %rdi
leaq 0x44(%rsp), %rsi
callq 0xa02a
movq 0xda8b(%rip), %rdi      # 0xffc8
leaq 0x44(%rsp), %rsi
callq 0x93ea
leaq 0x44(%rsp), %rdi
movq %rsp, %rsi
callq 0x8faa
movq 0xda6d(%rip), %rdi      # 0xffc8
leaq 0x44(%rsp), %rsi
callq 0x93ea
leaq 0xb0(%rsp), %rdi
callq 0x2040
jmp 0x259e
leaq 0x8aa8(%rip), %rax      # 0xb023
leaq 0x8a8f(%rip), %rsi      # 0xb011
testb $0x1, %r12b
cmovneq %rax, %rsi
movq 0xda37(%rip), %rdi      # 0xffc8
callq 0x2170
movq %rax, %rdi
callq 0x20c0
movq 0xda23(%rip), %rdi      # 0xffc8
callq 0x20c0
leaq 0x20(%rsp), %rdi
callq 0x20a0
movq %rsp, %rdi
callq 0x262c
leaq 0x2b8(%rsp), %rdi
callq 0x21e0
xorl %eax, %eax
addq $0x4b8, %rsp            # imm = 0x4B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x25f7
jmp 0x25f7
movq %rax, %rbx
leaq 0xb0(%rsp), %rdi
callq 0x2040
jmp 0x25fa
jmp 0x25f7
jmp 0x25f7
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x20a0
movq %rsp, %rdi
callq 0x262c
leaq 0x2b8(%rsp), %rdi
callq 0x21e0
movq %rbx, %rdi
callq 0x2230