// File: /workspace/github_c_makefile_star2_O0/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:
subq $0x128, %rsp            # imm = 0x128
movl $0x0, 0x124(%rsp)
movl %edi, 0x120(%rsp)
movq %rsi, 0x118(%rsp)
xorl %eax, %eax
cmpl $0x1, 0x120(%rsp)
movb %al, 0x8f(%rsp)
jle 0x2e40
movq 0x118(%rsp), %rax
movq 0x8(%rax), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
sete %al
movb %al, 0x8f(%rsp)
movb 0x8f(%rsp), %al
testb $0x1, %al
jne 0x2e50
jmp 0x2f88
movl 0x120(%rsp), %eax
decl %eax
movl %eax, 0x120(%rsp)
movq 0x118(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x118(%rsp)
movq 0x118(%rsp), %rax
movq (%rax), %rax
movsbl 0x1(%rax), %eax
addl $-0x65, %eax
movl %eax, %ecx
movq %rcx, 0x80(%rsp)
subl $0xe, %eax
ja 0x2f83
movq 0x80(%rsp), %rax
leaq 0x815c(%rip), %rcx      # 0xb004
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl 0xd72d(%rip), %eax      # 0x105e4
addl $0x1, %eax
movl %eax, 0xd724(%rip)      # 0x105e4
jmp 0x2f83
movl 0xd71d(%rip), %eax      # 0x105e8
addl $0x1, %eax
movl %eax, 0xd714(%rip)      # 0x105e8
jmp 0x2f83
movq 0x118(%rsp), %rax
movq (%rax), %rsi
addq $0x2, %rsi
leaq 0x100(%rsp), %rdi
callq 0x2600
leaq 0xd6a4(%rip), %rdi      # 0x105a0
leaq 0x100(%rsp), %rsi
callq 0x3750
leaq 0x100(%rsp), %rdi
callq 0x34c0
movl $0x1, 0xd6cc(%rip)      # 0x105ec
jmp 0x2f83
movq 0x118(%rsp), %rax
movq (%rax), %rsi
addq $0x2, %rsi
leaq 0xd698(%rip), %rdi      # 0x105d0
callq 0x2880
movl $0x1, 0xd6a9(%rip)      # 0x105f0
jmp 0x2f83
movq 0x118(%rsp), %rax
movq (%rax), %rdi
addq $0x2, %rdi
callq 0x21b0
movl %eax, 0xd201(%rip)      # 0x10164
jmp 0x2f83
movq 0x118(%rsp), %rax
movq (%rax), %rdi
addq $0x2, %rdi
callq 0x2bc0
movl $0x1, 0xd669(%rip)      # 0x105ec
jmp 0x2e11
cmpl $0x0, 0xd65d(%rip)      # 0x105ec
jne 0x2ff3
movq 0xd020(%rip), %rax      # 0xffb8
movq (%rax), %rdx
leaq 0xd20e(%rip), %rdi      # 0x101b0
movl $0x3e8, %esi            # imm = 0x3E8
callq 0x21c0
cmpq $0x0, %rax
jne 0x2fbe
leaq 0x80fd(%rip), %rdi      # 0xb0b6
callq 0x9430
leaq 0xe8(%rsp), %rdi
leaq 0xd1e3(%rip), %rsi      # 0x101b0
callq 0x2600
leaq 0xd5c7(%rip), %rdi      # 0x105a0
leaq 0xe8(%rsp), %rsi
callq 0x3750
leaq 0xe8(%rsp), %rdi
callq 0x34c0
cmpl $0x0, 0xd5f6(%rip)      # 0x105f0
jne 0x303c
movq 0xcfb5(%rip), %rax      # 0xffb8
movq (%rax), %rdx
leaq 0xd1a3(%rip), %rdi      # 0x101b0
movl $0x3e8, %esi            # imm = 0x3E8
callq 0x21c0
cmpq $0x0, %rax
jne 0x3029
leaq 0x80a4(%rip), %rdi      # 0xb0c8
callq 0x9430
leaq 0xd5a0(%rip), %rdi      # 0x105d0
leaq 0xd179(%rip), %rsi      # 0x101b0
callq 0x2880
leaq 0xd5e2(%rip), %rsi      # 0x10625
movq %rsi, 0x78(%rsp)
leaq 0xd4(%rsp), %rdi
callq 0x3520
movq 0x78(%rsp), %rsi
leaq 0xc0(%rsp), %rdi
callq 0x3520
leaq 0xa8(%rsp), %rdi
callq 0x3480
callq 0x9df0
jmp 0x307b
leaq 0xd576(%rip), %rdi      # 0x105f8
callq 0x3800
cmpq $0x0, %rax
jne 0x30ca
leaq 0xd564(%rip), %rdi      # 0x105f8
leaq 0xd505(%rip), %rsi      # 0x105a0
callq 0x3790
jmp 0x30a2
jmp 0x30ca
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xa0(%rsp)
movl %eax, 0x9c(%rsp)
leaq 0xa8(%rsp), %rdi
callq 0x34c0
jmp 0x346f
movl $0x0, 0x98(%rsp)
movb $0x1, %al
cmpl $-0x1, 0xd086(%rip)     # 0x10164
movb %al, 0x77(%rsp)
je 0x30f8
movl 0x98(%rsp), %eax
cmpl 0xd073(%rip), %eax      # 0x10164
setle %al
movb %al, 0x77(%rsp)
movb 0x77(%rsp), %al
testb $0x1, %al
jne 0x3105
jmp 0x3453
movq 0xceb4(%rip), %rdi      # 0xffc0
leaq 0x7fc7(%rip), %rsi      # 0xb0da
callq 0x2110
movq %rax, 0x68(%rsp)
jmp 0x311f
movq 0x68(%rsp), %rdi
movl 0x98(%rsp), %esi
callq 0x2210
movq %rax, 0x60(%rsp)
jmp 0x3137
movq 0x60(%rsp), %rdi
leaq 0x7f9f(%rip), %rsi      # 0xb0e2
callq 0x2110
movq %rax, 0x58(%rsp)
jmp 0x314f
movq 0x58(%rsp), %rdi
movq 0xce6d(%rip), %rsi      # 0xffc8
callq 0x2150
jmp 0x3162
movl $0x0, 0x94(%rsp)
movslq 0x94(%rsp), %rax
movq %rax, 0x50(%rsp)
leaq 0xd477(%rip), %rdi      # 0x105f8
callq 0x3800
movq %rax, %rcx
movq 0x50(%rsp), %rax
cmpq %rcx, %rax
jae 0x33ec
movslq 0x94(%rsp), %rsi
leaq 0xd452(%rip), %rdi      # 0x105f8
callq 0x3c10
movq %rax, %rdi
callq 0x2cb0
jmp 0x31b5
movl $0x0, 0x90(%rsp)
xorl %eax, %eax
cmpl $0x30, 0x90(%rsp)
movb %al, 0x4f(%rsp)
jge 0x31f6
movb $0x1, %al
cmpl $0x1, 0x90(%rsp)
movb %al, 0x4e(%rsp)
jl 0x31ee
cmpl $0x0, 0xd3fd(%rip)      # 0x105e4
setne %al
movb %al, 0x4e(%rsp)
movb 0x4e(%rsp), %al
movb %al, 0x4f(%rsp)
movb 0x4f(%rsp), %al
testb $0x1, %al
jne 0x3203
jmp 0x33d4
movslq 0x90(%rsp), %rcx
leaq 0xd95e(%rip), %rax      # 0x10b70
imulq $0x12, %rcx, %rcx
addq %rcx, %rax
movzbl (%rax), %eax
movl $0x3, %ecx
cltd
idivl %ecx
cmpl $0x0, %edx
je 0x322e
jmp 0x33be
cmpl $0x0, 0xd3b3(%rip)      # 0x105e8
je 0x3264
movq 0xd392(%rip), %rax      # 0x105d0
movq %rax, 0xc0(%rsp)
movq 0xd38b(%rip), %rax      # 0x105d8
movq %rax, 0xc8(%rsp)
movl 0xd385(%rip), %eax      # 0x105e0
movl %eax, 0xd0(%rsp)
jmp 0x327c
leaq 0xd365(%rip), %rdi      # 0x105d0
leaq 0xc0(%rsp), %rsi
callq 0x6f80
jmp 0x327a
jmp 0x327c
movl 0x90(%rsp), %esi
leaq 0xc0(%rsp), %rdi
leaq 0xd4(%rsp), %rdx
callq 0x9670
jmp 0x329a
movl 0x98(%rsp), %ecx
leaq 0xd4(%rsp), %rdi
xorl %esi, %esi
leaq 0xa8(%rsp), %rdx
callq 0x29d0
movl %eax, 0x48(%rsp)
jmp 0x32be
movl 0x48(%rsp), %eax
cmpl $0x0, %eax
je 0x33bc
movq 0xccee(%rip), %rdi      # 0xffc0
movq 0xcccf(%rip), %rsi      # 0xffa8
callq 0x2150
movq %rax, 0x40(%rsp)
jmp 0x32e5
movq 0x40(%rsp), %rdi
leaq 0x7dfc(%rip), %rsi      # 0xb0ed
callq 0x2110
movq %rax, 0x38(%rsp)
jmp 0x32fd
movq 0x38(%rsp), %rdi
movl 0x94(%rsp), %esi
callq 0x2210
movq %rax, 0x30(%rsp)
jmp 0x3315
movq 0x30(%rsp), %rdi
movq 0xcc87(%rip), %rsi      # 0xffa8
callq 0x2150
jmp 0x3328
cmpl $0x0, 0x90(%rsp)
je 0x3379
movq 0xcc87(%rip), %rdi      # 0xffc0
leaq 0x7dc7(%rip), %rsi      # 0xb107
callq 0x2110
movq %rax, 0x28(%rsp)
jmp 0x334c
movq 0x28(%rsp), %rdi
movl 0x90(%rsp), %esi
callq 0x2210
movq %rax, 0x20(%rsp)
jmp 0x3364
movq 0x20(%rsp), %rdi
movq 0xcc38(%rip), %rsi      # 0xffa8
callq 0x2150
jmp 0x3377
jmp 0x3379
leaq 0xa8(%rsp), %rdi
callq 0x93e0
movq %rax, 0x18(%rsp)
jmp 0x338d
movq 0x18(%rsp), %rsi
movq 0xcc27(%rip), %rdi      # 0xffc0
callq 0x2110
jmp 0x33a0
movq 0xcc19(%rip), %rdi      # 0xffc0
movq 0xcbfa(%rip), %rsi      # 0xffa8
callq 0x2150
jmp 0x33b5
xorl %edi, %edi
callq 0x2180
jmp 0x33be
movl 0x90(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x90(%rsp)
jmp 0x31c0
jmp 0x33d6
movl 0x94(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x94(%rsp)
jmp 0x316d
movq 0xcbcd(%rip), %rdi      # 0xffc0
leaq 0x7c66(%rip), %rsi      # 0xb060
callq 0x2110
movq %rax, 0x10(%rsp)
jmp 0x3406
callq 0x9df0
movsd %xmm0, 0x8(%rsp)
jmp 0x3413
movsd 0x8(%rsp), %xmm0
movq 0x10(%rsp), %rdi
callq 0x2230
movq %rax, (%rsp)
jmp 0x3429
movq (%rsp), %rdi
movq 0xcb74(%rip), %rsi      # 0xffa8
callq 0x2150
jmp 0x343b
jmp 0x343d
movl 0x98(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x98(%rsp)
jmp 0x30d5
leaq 0xa8(%rsp), %rdi
callq 0x34c0
movl 0x124(%rsp), %eax
addq $0x128, %rsp            # imm = 0x128
retq
movq 0xa0(%rsp), %rdi
callq 0x2220
nopl (%rax)