// File: /workspace/github_c_makefile_star2_O2/micahstairs[P]ScrambleChecker/movedelta.cpp
// Function: main
int main(int argc, char *argv[]) {
   while (argc > 1 && argv[1][0] == '-') {
      argc-- ;
      argv++ ;
      switch (argv[0][1]) {
case 'm':
         consider_rotations++ ;
         break ;
case 'i':
         invert_position++ ;
         break ;
case 's':
         scramble = parsemoveseq(argv[0] + 2) ;
         scramble_parsed = 1 ;
         break;
case 'p':
         parseposition(loaded, argv[0] + 2) ;
         position_parsed = 1 ;
         break;
case 'e':
         max_errors = atoi (argv[0] + 2) ;
         break;
case 'f':
         loadfile(argv[0] + 2) ;
         scramble_parsed = 1 ;
         break ;
      }
   }
   if (scramble_parsed == 0) {
     if (fgets(buf, 1000, stdin) == 0)
      error("! need a scramble");
     scramble = parsemoveseq(buf);
   }
   if (position_parsed == 0) {
     if (fgets(buf, 1000, stdin) == 0)
        error("! need a position");
     parseposition(loaded, buf);
   }
   cubepos cp, cp2 ;
   moveseq r ;
   duration() ;
   if (scrambleset.size() == 0)
      scrambleset.push_back(scramble) ;
   for (int d=0; max_errors == -1 || d <= max_errors; d++) {
      cout << "Trying " << d << " mistakes " << flush ;
      for (int j=0; j<scrambleset.size(); j++) {
         setup_scramble(scrambleset[j]) ;
         for (int m=0; m<M && (m < 1 || consider_rotations); m++) {
            if (cubepos::move_map[m][0] % TWISTS != 0)
               continue ; // ignore mirror remaps
            if (invert_position)
               cp2 = loaded ;
            else
               loaded.invert_into(cp2) ;
            cp2.remap_into(m, cp) ;
            if (solveit(cp, 0, r, d)) {
               cout << endl << "Found a solution against " << j << endl ;
               if (m != 0)
                  cout << "Reoriented at " << m << endl ;
               cout << cubepos::moveseq_string(r) ;
               cout << endl ; 
               exit(0) ;
            }
         }
      }
      cout << "in " << duration() << endl ;
   }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rsi, %rbx
movl %edi, %ebp
addq $0x8, %rbx
leaq 0x25c7(%rip), %r13      # 0x5004
leaq 0x5b9c(%rip), %r14      # 0x85e0
movq %rsp, %r15
leaq 0x5b62(%rip), %r12      # 0x85b0
cmpl $0x2, %ebp
jl 0x2af7
movq (%rbx), %rsi
cmpb $0x2d, (%rsi)
jne 0x2af7
movzbl 0x1(%rsi), %eax
addl $-0x65, %eax
cmpl $0xe, %eax
ja 0x2aec
movslq (%r13,%rax,4), %rax
addq %r13, %rax
jmpq *%rax
addq $0x2, %rsi
movq %rsi, %rdi
callq 0x21d0
movl %eax, 0x56e9(%rip)      # 0x8174
jmp 0x2aec
incl 0x5b65(%rip)            # 0x85f8
jmp 0x2aec
addq $0x2, %rsi
movq %r15, %rdi
callq 0x24d7
movq %r12, %rdi
movq %r15, %rsi
callq 0x3286
movq %r15, %rdi
callq 0x2f7c
jmp 0x2ac2
addq $0x2, %rsi
movq %rsi, %rdi
callq 0x2867
movl $0x1, 0x5b30(%rip)      # 0x85fc
jmp 0x2aec
incl 0x5b20(%rip)            # 0x85f4
jmp 0x2aec
addq $0x2, %rsi
movq %r14, %rdi
callq 0x263f
movl $0x1, 0x5b14(%rip)      # 0x8600
addq $0x8, %rbx
decl %ebp
jmp 0x2a4e
cmpl $0x0, 0x5afe(%rip)      # 0x85fc
jne 0x2b55
movq 0x54b9(%rip), %rax      # 0x7fc0
movq (%rax), %rdx
leaq 0x56af(%rip), %rdi      # 0x81c0
movl $0x3e8, %esi            # imm = 0x3E8
callq 0x21e0
testq %rax, %rax
jne 0x2b2c
leaq 0x259f(%rip), %rdi      # 0x50c6
callq 0x48e6
leaq 0x568d(%rip), %rsi      # 0x81c0
movq %rsp, %rbx
movq %rbx, %rdi
callq 0x24d7
leaq 0x5a6b(%rip), %rdi      # 0x85b0
movq %rbx, %rsi
callq 0x3286
movq %rbx, %rdi
callq 0x2f7c
cmpl $0x0, 0x5aa4(%rip)      # 0x8600
jne 0x2b9d
movq 0x545b(%rip), %rax      # 0x7fc0
movq (%rax), %rdx
leaq 0x5651(%rip), %rdi      # 0x81c0
movl $0x3e8, %esi            # imm = 0x3E8
callq 0x21e0
testq %rax, %rax
jne 0x2b8a
leaq 0x2553(%rip), %rdi      # 0x50d8
callq 0x48e6
leaq 0x5a4f(%rip), %rdi      # 0x85e0
leaq 0x5628(%rip), %rsi      # 0x81c0
callq 0x263f
leaq 0x5a91(%rip), %rax      # 0x8635
movl 0x10(%rax), %ecx
movl %ecx, 0x50(%rsp)
movups (%rax), %xmm0
movaps %xmm0, 0x40(%rsp)
movl %ecx, 0x30(%rsp)
movaps %xmm0, 0x20(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
andq $0x0, 0x10(%rsp)
callq 0x4d5c
movq 0x5a3b(%rip), %rax      # 0x8610
cmpq 0x5a2c(%rip), %rax      # 0x8608
jne 0x2bf1
leaq 0x5a23(%rip), %rdi      # 0x8608
leaq 0x59c4(%rip), %rsi      # 0x85b0
callq 0x2e58
xorl %ebx, %ebx
movq 0x53ce(%rip), %r13      # 0x7fc8
movb $0x3, %r12b
leaq 0x40(%rsp), %r15
movl 0x556c(%rip), %eax      # 0x8174
cmpl $-0x1, %eax
sete %cl
cmpl %eax, %ebx
setle %al
orb %cl, %al
je 0x2d43
movq %r13, %rdi
leaq 0x24c5(%rip), %rsi      # 0x50ea
callq 0x2120
movq %rax, %rdi
movl %ebx, %esi
callq 0x2240
movq %rax, %rdi
leaq 0x24b4(%rip), %rsi      # 0x50f2
callq 0x2120
movq %rax, %rdi
callq 0x20c0
xorl %r13d, %r13d
movq 0x59bb(%rip), %rax      # 0x8610
movq 0x59ac(%rip), %rdi      # 0x8608
subq %rdi, %rax
cqto
pushq $0x18
popq %rcx
idivq %rcx
cmpq %r13, %rax
jbe 0x2d0e
imulq $0x18, %r13, %rax
addq %rax, %rdi
callq 0x294f
leaq 0x5efd(%rip), %rbp      # 0x8b80
xorl %r14d, %r14d
cmpq $0x30, %r14
je 0x2d06
testq %r14, %r14
je 0x2c9a
cmpl $0x0, 0x595c(%rip)      # 0x85f4
je 0x2d06
movzbl (%rbp), %eax
divb %r12b
movzbl %ah, %eax
testb %al, %al
jne 0x2cfd
cmpl $0x0, 0x5949(%rip)      # 0x85f8
je 0x2cc9
movl 0x5939(%rip), %eax      # 0x85f0
movl %eax, 0x30(%rsp)
movups 0x591e(%rip), %xmm0     # 0x85e0
movaps %xmm0, 0x20(%rsp)
jmp 0x2cda
leaq 0x5910(%rip), %rdi      # 0x85e0
leaq 0x20(%rsp), %rsi
callq 0x3734
leaq 0x20(%rsp), %rdi
movl %r14d, %esi
movq %r15, %rdx
callq 0x49e0
movq %r15, %rdi
xorl %esi, %esi
movq %rsp, %rdx
movl %ebx, %ecx
callq 0x2702
testl %eax, %eax
jne 0x2d5c
incq %r14
addq $0x12, %rbp
jmp 0x2c86
incq %r13
jmp 0x2c4e
movq 0x52b3(%rip), %r13      # 0x7fc8
movq %r13, %rdi
leaq 0x2351(%rip), %rsi      # 0x5070
callq 0x2120
movq %rax, %r14
callq 0x4d5c
movq %r14, %rdi
callq 0x21f0
movq %rax, %rdi
callq 0x2080
incl %ebx
jmp 0x2c02
movq %rsp, %rdi
callq 0x2f7c
xorl %eax, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x5265(%rip), %rdi      # 0x7fc8
callq 0x2080
leaq 0x238e(%rip), %rsi      # 0x50fd
movq %rax, %rdi
callq 0x2120
movq %rax, %rdi
movl %r13d, %esi
callq 0x2240
movq %rax, %rdi
callq 0x2080
testq %r14, %r14
jne 0x2db9
movq %rsp, %rdi
callq 0x48a4
movq 0x522a(%rip), %rdi      # 0x7fc8
movq %rax, %rsi
callq 0x2120
movq 0x521b(%rip), %rdi      # 0x7fc8
callq 0x2080
xorl %edi, %edi
callq 0x21a0
movq 0x5208(%rip), %rdi      # 0x7fc8
leaq 0x2350(%rip), %rsi      # 0x5117
callq 0x2120
movq %rax, %rdi
movl %r14d, %esi
callq 0x2240
movq %rax, %rdi
callq 0x2080
jmp 0x2d8f
jmp 0x2de9
jmp 0x2de9
jmp 0x2de9
jmp 0x2de9
movq %rax, %rbx
movq %rsp, %rdi
callq 0x2f7c
movq %rbx, %rdi
callq 0x2250