// File: /workspace/github_c_makefile_star2_O1/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 0x2e95
movq %rsi, %rbx
movl %edi, %ebp
addq $0x8, %rbx
incl %ebp
leaq 0x3262(%rip), %r13      # 0x6030
leaq 0x682b(%rip), %r14      # 0x9600
movq %rsp, %r15
leaq 0x67f1(%rip), %r12      # 0x95d0
movq (%rbx), %rsi
cmpb $0x2d, (%rsi)
jne 0x2e95
movzbl 0x1(%rsi), %eax
addl $-0x65, %eax
cmpl $0xe, %eax
ja 0x2e86
movslq (%r13,%rax,4), %rax
addq %r13, %rax
jmpq *%rax
addq $0x2, %rsi
movq %rsi, %rdi
callq 0x21f0
movl %eax, 0x637d(%rip)      # 0x9194
jmp 0x2e86
incl 0x67f9(%rip)            # 0x9618
jmp 0x2e86
addq $0x2, %rsi
movq %r15, %rdi
callq 0x2641
movq %r12, %rdi
movq %r15, %rsi
callq 0x35d6
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x2e5c
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x2180
jmp 0x2e5c
addq $0x2, %rsi
movq %rsi, %rdi
callq 0x2ad0
movl $0x1, 0x67b6(%rip)      # 0x961c
jmp 0x2e86
incl 0x67a6(%rip)            # 0x9614
jmp 0x2e86
addq $0x2, %rsi
movq %r14, %rdi
callq 0x281c
movl $0x1, 0x679a(%rip)      # 0x9620
addq $0x8, %rbx
decl %ebp
cmpl $0x2, %ebp
jg 0x2ddf
cmpl $0x0, 0x6780(%rip)      # 0x961c
jne 0x2f00
movq 0x611b(%rip), %rax      # 0x8fc0
movq (%rax), %rdx
leaq 0x6331(%rip), %rdi      # 0x91e0
movl $0x3e8, %esi            # imm = 0x3E8
callq 0x2200
testq %rax, %rax
jne 0x2eca
leaq 0x321d(%rip), %rdi      # 0x60e2
callq 0x4eca
leaq 0x630f(%rip), %rsi      # 0x91e0
movq %rsp, %rbx
movq %rbx, %rdi
callq 0x2641
leaq 0x66ed(%rip), %rdi      # 0x95d0
movq %rbx, %rsi
callq 0x35d6
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x2f00
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x2180
cmpl $0x0, 0x6719(%rip)      # 0x9620
jne 0x2f48
movq 0x60b0(%rip), %rax      # 0x8fc0
movq (%rax), %rdx
leaq 0x62c6(%rip), %rdi      # 0x91e0
movl $0x3e8, %esi            # imm = 0x3E8
callq 0x2200
testq %rax, %rax
jne 0x2f35
leaq 0x31c4(%rip), %rdi      # 0x60f4
callq 0x4eca
leaq 0x66c4(%rip), %rdi      # 0x9600
leaq 0x629d(%rip), %rsi      # 0x91e0
callq 0x281c
leaq 0x66f9(%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 0x53fd
movq 0x66ad(%rip), %rax      # 0x9630
cmpq 0x669e(%rip), %rax      # 0x9628
jne 0x2f9f
leaq 0x6695(%rip), %rdi      # 0x9628
leaq 0x6636(%rip), %rsi      # 0x95d0
callq 0x32b2
cmpl $-0x1, 0x61ee(%rip)     # 0x9194
jl 0x3150
xorl %r12d, %r12d
movq 0x6012(%rip), %r13      # 0x8fc8
leaq 0x20(%rsp), %r14
leaq 0x40(%rsp), %r15
movl $0x7, %edx
movq %r13, %rdi
leaq 0x3137(%rip), %rsi      # 0x6106
callq 0x21a0
movq %r13, %rdi
movl %r12d, %esi
callq 0x2270
movq %rax, %rbx
movl $0xa, %edx
movq %rax, %rdi
leaq 0x311d(%rip), %rsi      # 0x610e
callq 0x21a0
movq %rbx, %rdi
callq 0x20e0
movq 0x6623(%rip), %rax      # 0x9628
cmpq %rax, 0x6624(%rip)      # 0x9630
je 0x30dc
xorl %ebp, %ebp
leaq (,%rbp,2), %rcx
addq %rbp, %rcx
leaq (%rax,%rcx,8), %rdi
callq 0x2c14
leaq 0x6b61(%rip), %r13      # 0x9b90
xorl %ebx, %ebx
testq %rbx, %rbx
je 0x303f
cmpl $0x0, 0x65d7(%rip)      # 0x9614
je 0x30ad
movzbl (%r13), %eax
imull $-0x55, %eax, %eax
cmpb $0x55, %al
ja 0x30a0
cmpl $0x0, 0x65c6(%rip)      # 0x9618
je 0x306c
movl 0x65b6(%rip), %eax      # 0x9610
movl %eax, 0x30(%rsp)
movups 0x659b(%rip), %xmm0     # 0x9600
movaps %xmm0, 0x20(%rsp)
jmp 0x307b
leaq 0x658d(%rip), %rdi      # 0x9600
movq %r14, %rsi
callq 0x3a18
movq %r14, %rdi
movl %ebx, %esi
movq %r15, %rdx
callq 0x5028
movq %r15, %rdi
xorl %esi, %esi
movq %rsp, %rdx
movl %r12d, %ecx
callq 0x2901
testl %eax, %eax
jne 0x3177
incq %rbx
addq $0x12, %r13
cmpq $0x30, %rbx
jne 0x3031
incq %rbp
movq 0x6579(%rip), %rcx      # 0x9630
movq 0x656a(%rip), %rax      # 0x9628
subq %rax, %rcx
sarq $0x3, %rcx
movabsq $-0x5555555555555555, %rdx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rdx, %rcx
cmpq %rbp, %rcx
ja 0x3014
movl $0x3, %edx
movq 0x5ee0(%rip), %r13      # 0x8fc8
movq %r13, %rdi
leaq 0x2f9a(%rip), %rsi      # 0x608c
callq 0x21a0
callq 0x53fd
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 0x6060(%rip), %eax      # 0x9194
cmpl $-0x1, %eax
sete %cl
cmpl %eax, %r12d
leal 0x1(%r12), %eax
setl %dl
orb %cl, %dl
movl %eax, %r12d
jne 0x2fc0
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x3166
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 0x5e4a(%rip), %rdi      # 0x8fc8
callq 0x20a0
movq %rax, %r14
leaq 0x2f8c(%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 0x31db
movq %rsp, %rdi
callq 0x4e88
movq 0x5e08(%rip), %rdi      # 0x8fc8
movq %rax, %rsi
callq 0x2150
movq 0x5df9(%rip), %rdi      # 0x8fc8
callq 0x20a0
xorl %edi, %edi
callq 0x21c0
movq 0x5de6(%rip), %rdi      # 0x8fc8
leaq 0x2f4a(%rip), %rsi      # 0x6133
movl $0xe, %edx
callq 0x21a0
movq 0x5dce(%rip), %rdi      # 0x8fc8
movl %ebx, %esi
callq 0x2270
movq %rax, %rdi
callq 0x20a0
jmp 0x31b1
jmp 0x3213
jmp 0x3213
jmp 0x3213
jmp 0x3213
movq %rax, %rbx
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x322c
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x2180
movq %rbx, %rdi
callq 0x2280