// File: /workspace/github_cpp_makefile_star2_O1/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 0x87ca
leaq 0x7a(%rsp), %rdi
callq 0x87ca
leaq 0xb0(%rsp), %rdi
callq 0x2230
xorl %eax, %eax
movq %rax, 0x30(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
leaq 0x10(%rsp), %r15
movq %r15, -0x10(%r15)
movq %rax, -0x8(%r15)
movb $0x0, (%r15)
movq 0x8(%r14), %rsi
cmpb $0x2d, (%rsi)
jne 0x25ed
cmpl $0x2, %ebx
jne 0x25ed
cmpb $0x73, 0x1(%rsi)
jne 0x25ed
movb $0x1, %r13b
movl $0x1, %r12d
xorl %r15d, %r15d
leaq 0x2b0(%rsp), %rbx
leaq 0x44(%rsp), %r14
leaq 0xb0(%rsp), %rbp
movq %rbx, %rdi
callq 0xa5b8
movq %r14, %rdi
movq %rbx, %rsi
callq 0x8870
leaq 0x7a(%rsp), %rdi
movq %rax, %rsi
callq 0x8870
movb $0x42, 0x2b0(%rsp)
movq %r14, %rdi
leaq 0x20(%rsp), %rsi
movq %rbx, %rdx
callq 0xa2fa
movq %r14, %rdi
callq 0x8a22
testb %al, %al
jne 0x2571
movslq %r12d, %rsi
leaq 0x9ae2(%rip), %rax      # 0xc004
addq %rax, %rsi
movq %rsp, %rdi
callq 0x2270
movq %rbp, %rdi
movq %rsp, %rsi
movl $0x10, %edx
callq 0x2080
movq %rbp, %rdi
leaq 0x7a(%rsp), %rsi
callq 0xa5ce
movq %rbp, %rdi
callq 0x21c0
movq 0x8(%rsp), %rdx
movq %rsp, %rdi
xorl %esi, %esi
leaq 0xb28a(%rip), %rcx      # 0xd7ed
xorl %r8d, %r8d
callq 0x2210
incl %r12d
xorl %r13d, %r13d
cmpl $0x1869e, %r15d         # imm = 0x1869E
ja 0x2587
incl %r15d
testb $0x1, %r13b
jne 0x24d4
leaq 0x9a95(%rip), %rax      # 0xc023
leaq 0x9a7c(%rip), %rsi      # 0xc011
testb $0x1, %r13b
cmovneq %rax, %rsi
movzbl %r13b, %eax
andl $0x1, %eax
leaq 0x11(,%rax,4), %rdx
movq 0xea15(%rip), %rbx      # 0x10fc8
movq %rbx, %rdi
leaq 0x10(%rsp), %r15
callq 0x2190
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq 0xe9ea(%rip), %rdi      # 0x10fc8
callq 0x2030
movq %rax, %rdi
callq 0x20e0
jmp 0x264f
leaq 0x2b0(%rsp), %rdi
movl $0x8, %edx
callq 0x2260
leaq 0x2b0(%rsp), %rdi
leaq 0x44(%rsp), %rsi
callq 0xb872
movq 0xe9b0(%rip), %rdi      # 0x10fc8
leaq 0x44(%rsp), %rsi
callq 0xa5ce
leaq 0x44(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x9f7c
movq 0xe990(%rip), %rdi      # 0x10fc8
leaq 0x44(%rsp), %rsi
callq 0xa5ce
leaq 0x2b0(%rsp), %rdi
callq 0x2050
movq 0xe972(%rip), %rdi      # 0x10fc8
movq (%rdi), %rax
addq -0x18(%rax), %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq 0xe957(%rip), %rdi      # 0x10fc8
callq 0x2030
movq %rax, %rdi
callq 0x20e0
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x2694
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x2180
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x26ab
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x2180
movq 0xe90e(%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 0x2711
movq %rax, %rbx
leaq 0x2b0(%rsp), %rdi
callq 0x2050
jmp 0x2714
jmp 0x2711
jmp 0x2711
jmp 0x2711
movq %rax, %rbx
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x272f
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x2180
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x2746
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x2180
leaq 0xb0(%rsp), %rdi
callq 0x21e0
movq %rbx, %rdi
callq 0x2240
nop