// File: /workspace/github_c_makefile_star2_O3/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
cmpl $0x2, %edi
jl 0x2f08
movq %rsi, %rbx
movl %edi, %ebp
addq $0x8, %rbx
incl %ebp
leaq 0x3224(%rip), %r12      # 0x6030
leaq 0x67ed(%rip), %r14      # 0x9600
movq %rsp, %r15
movq (%rbx), %rsi
cmpb $0x2d, (%rsi)
jne 0x2f08
movzbl 0x1(%rsi), %eax
addl $-0x65, %eax
cmpl $0xe, %eax
ja 0x2ef9
movslq (%r12,%rax,4), %rax
addq %r12, %rax
jmpq *%rax
addq $0x2, %rsi
movq %rsi, %rdi
callq 0x21f0
movl %eax, 0x6347(%rip)      # 0x9194
jmp 0x2ef9
incl 0x67c0(%rip)            # 0x9618
jmp 0x2ef9
addq $0x2, %rsi
movq %r15, %rdi
callq 0x2651
movq 0x6760(%rip), %rdi      # 0x95d0
movq 0x6769(%rip), %rsi      # 0x95e0
movaps (%rsp), %xmm0
movaps %xmm0, 0x674e(%rip)     # 0x95d0
movq 0x10(%rsp), %rax
movq %rax, 0x6752(%rip)      # 0x95e0
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
movq $0x0, 0x10(%rsp)
testq %rdi, %rdi
je 0x2ecf
subq %rdi, %rsi
callq 0x2180
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x2ecf
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x2180
jmp 0x2ecf
addq $0x2, %rsi
movq %rsi, %rdi
callq 0x2ad2
movl $0x1, 0x6743(%rip)      # 0x961c
jmp 0x2ef9
incl 0x6733(%rip)            # 0x9614
jmp 0x2ef9
addq $0x2, %rsi
movq %r14, %rdi
callq 0x2828
movl $0x1, 0x6727(%rip)      # 0x9620
addq $0x8, %rbx
decl %ebp
cmpl $0x2, %ebp
ja 0x2e16
cmpl $0x0, 0x670d(%rip)      # 0x961c
je 0x318c
cmpl $0x0, 0x6704(%rip)      # 0x9620
jne 0x2f5d
movq 0x609b(%rip), %rax      # 0x8fc0
movq (%rax), %rdx
leaq 0x62b1(%rip), %rdi      # 0x91e0
movl $0x3e8, %esi            # imm = 0x3E8
callq 0x2200
testq %rax, %rax
jne 0x2f4a
leaq 0x31af(%rip), %rdi      # 0x60f4
callq 0x5324
leaq 0x66af(%rip), %rdi      # 0x9600
leaq 0x6288(%rip), %rsi      # 0x91e0
callq 0x2828
leaq 0x66e4(%rip), %rax      # 0x9648
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)
movq $0x0, 0x10(%rsp)
callq 0x5843
movq 0x6698(%rip), %rax      # 0x9630
cmpq 0x6689(%rip), %rax      # 0x9628
jne 0x2fb4
leaq 0x6680(%rip), %rdi      # 0x9628
leaq 0x6621(%rip), %rsi      # 0x95d0
callq 0x336c
cmpl $-0x1, 0x61d9(%rip)     # 0x9194
jl 0x3165
xorl %r12d, %r12d
movq 0x5ffd(%rip), %r13      # 0x8fc8
leaq 0x20(%rsp), %r14
leaq 0x40(%rsp), %r15
movl $0x7, %edx
movq %r13, %rdi
leaq 0x3122(%rip), %rsi      # 0x6106
callq 0x21a0
movq %r13, %rdi
movl %r12d, %esi
callq 0x2270
movq %rax, %rbx
movl $0xa, %edx
movq %rax, %rdi
leaq 0x3108(%rip), %rsi      # 0x610e
callq 0x21a0
movq %rbx, %rdi
callq 0x20e0
movq 0x660e(%rip), %rax      # 0x9628
cmpq %rax, 0x660f(%rip)      # 0x9630
je 0x30f1
xorl %ebp, %ebp
leaq (,%rbp,2), %rcx
addq %rbp, %rcx
leaq (%rax,%rcx,8), %rdi
callq 0x2c52
leaq 0x6b4c(%rip), %r13      # 0x9b90
xorl %ebx, %ebx
testq %rbx, %rbx
je 0x3054
cmpl $0x0, 0x65c2(%rip)      # 0x9614
je 0x30c2
movzbl (%r13), %eax
imull $-0x55, %eax, %eax
cmpb $0x55, %al
ja 0x30b5
cmpl $0x0, 0x65b1(%rip)      # 0x9618
je 0x3081
movl 0x65a1(%rip), %eax      # 0x9610
movl %eax, 0x30(%rsp)
movups 0x6586(%rip), %xmm0     # 0x9600
movaps %xmm0, 0x20(%rsp)
jmp 0x3090
leaq 0x6578(%rip), %rdi      # 0x9600
movq %r14, %rsi
callq 0x3a98
movq %r14, %rdi
movl %ebx, %esi
movq %r15, %rdx
callq 0x5482
movq %r15, %rdi
xorl %esi, %esi
movq %rsp, %rdx
movl %r12d, %ecx
callq 0x290d
testl %eax, %eax
jne 0x322b
incq %rbx
addq $0x12, %r13
cmpq $0x30, %rbx
jne 0x3046
incq %rbp
movq 0x6564(%rip), %rcx      # 0x9630
movq 0x6555(%rip), %rax      # 0x9628
subq %rax, %rcx
sarq $0x3, %rcx
movabsq $-0x5555555555555555, %rdx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rdx, %rcx
cmpq %rbp, %rcx
ja 0x3029
movl $0x3, %edx
movq 0x5ecb(%rip), %r13      # 0x8fc8
movq %r13, %rdi
leaq 0x2f85(%rip), %rsi      # 0x608c
callq 0x21a0
callq 0x5843
movq %r13, %rdi
callq 0x2210
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2140
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20e0
movl 0x604b(%rip), %eax      # 0x9194
cmpl $-0x1, %eax
sete %cl
cmpl %eax, %r12d
leal 0x1(%r12), %eax
setl %dl
orb %cl, %dl
movl %eax, %r12d
jne 0x2fd5
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x317b
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x2180
xorl %eax, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x5e2d(%rip), %rax      # 0x8fc0
movq (%rax), %rdx
leaq 0x6043(%rip), %rdi      # 0x91e0
movl $0x3e8, %esi            # imm = 0x3E8
callq 0x2200
testq %rax, %rax
jne 0x31b8
leaq 0x2f2f(%rip), %rdi      # 0x60e2
callq 0x5324
leaq 0x6021(%rip), %rsi      # 0x91e0
movq %rsp, %rbx
movq %rbx, %rdi
callq 0x2651
movq 0x63ff(%rip), %rdi      # 0x95d0
movq 0x6408(%rip), %rsi      # 0x95e0
movaps (%rbx), %xmm0
movaps %xmm0, 0x63ee(%rip)     # 0x95d0
movq 0x10(%rbx), %rax
movq %rax, 0x63f3(%rip)      # 0x95e0
xorps %xmm0, %xmm0
movaps %xmm0, (%rbx)
movq $0x0, 0x10(%rbx)
testq %rdi, %rdi
je 0x2f15
subq %rdi, %rsi
callq 0x2180
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x2f15
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x2180
jmp 0x2f15
movq 0x5d96(%rip), %rdi      # 0x8fc8
callq 0x20a0
movq %rax, %r14
leaq 0x2ed8(%rip), %rsi      # 0x6119
movl $0x19, %edx
movq %rax, %rdi
callq 0x21a0
movq %r14, %rdi
movl %ebp, %esi
callq 0x2270
movq %rax, %rdi
callq 0x20a0
testq %rbx, %rbx
jne 0x328f
movq %rsp, %rdi
callq 0x52e2
movq 0x5d54(%rip), %rdi      # 0x8fc8
movq %rax, %rsi
callq 0x2150
movq 0x5d45(%rip), %rdi      # 0x8fc8
callq 0x20a0
xorl %edi, %edi
callq 0x21c0
movq 0x5d32(%rip), %rdi      # 0x8fc8
leaq 0x2e96(%rip), %rsi      # 0x6133
movl $0xe, %edx
callq 0x21a0
movq 0x5d1a(%rip), %rdi      # 0x8fc8
movl %ebx, %esi
callq 0x2270
movq %rax, %rdi
callq 0x20a0
jmp 0x3265
jmp 0x32c7
jmp 0x32c7
jmp 0x32c7
jmp 0x32c7
movq %rax, %rbx
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x32e0
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x2180
movq %rbx, %rdi
callq 0x2280