// File: biotomas[P]ipasir/app/ipasir-check-satunsat/ipasir-check-satunsat.cc
// Function: main
int main(int argc, char* argv[])
{
  std::cout << "Norbert Manthey -- IPASIR iterative satunsat checker" << std::endl;
  std::cout << "  add formula that has sub formulas of blocks" << std::endl
            << "  use almost full stack of assumptions, except last variable for each block" << std::endl
            << "  and modify last polarities per call" << std::endl;
  if(argc < 3) {
    std::cout << "usage: " << argv[0] << " X Y Z ... with 2 < X < 2^30, 1 < Y < 10, 1 < Z" << std::endl;
    return 1;
  }
  
  int X = atoi(argv[1]);
  int Y = atoi(argv[2]);
  int Z = atoi(argv[3]);
  
  if(X<3) {
    std::cout << "error: given first number " << X << " is not in limits" << std::endl;
    return 1;
  }
  
  if(Y<1 || Y>9) {
    std::cout << "error: given second number " << Y << " is not in limits" << std::endl;
    return 1;
  }
  
  if(Z < 2)  {
    std::cout << "error: given third number " << Z << " is not in limits" << std::endl;
    return 1;
  }

  SATSolver solver;
  
  const int periodsize = (1 << Y);
  vector<int> clause(Y,0);
  int index = 0;
  int clauses = 0;
  int maxvar = 0;
  for(int i = 1 ; i < periodsize; ++i) {
    index = i;
    int sum = 0;
    for(int j = 0 ; j < Y; ++j) {
      clause[j] = ((index & 1) == 0) ? j+1 : -j-1;
      sum += clause[j] > 0 ? 1 : -1;
      index = index >> 1;
    }
    assert(sum < (int)clause.size() && "clause with positive literals only should not be created");
    
    for(int j = 0; j < Z; ++ j) {
      if(j>0) {
	for(int k=0; k < Y; ++k) {
	  clause[k] = clause[k] > 0 ? clause[k] + Y : clause[k] - Y;
	  maxvar = maxvar > clause[k] ? maxvar : clause[k];
	}
      }
      solver.addClause(clause);
      clauses ++;
    }
  }
  
  std::cout << "created formula with " << clauses << " clauses, and maxvar " << maxvar << std::endl;
  
  vector<int> assumptions;
  std::vector<int> model;
  std::vector<int> conflict;
  
  for(int i = 1 ; i <= maxvar; ++i) 
  {
    // do not add last variable per block
    if((i % periodsize) != 0 ) assumptions.push_back(-i);
  }

  // create a map with pointers to the assumption vector
  int *map[maxvar + 1];
  int fakeentry = 0;
  int pointat = 0;
  for(int i = 1; i <= maxvar; ++i)
  {
    if((i % periodsize) != 0 ) {
      map[i] = &(assumptions[pointat]);
      pointat++;
    } else {
      map[i] = &fakeentry;
    }
  }

  int ret = solver.solve(assumptions, model, conflict);
  std::cout << "initial call returned with " << ret << std::endl;
  if(ret != 10)
  {
    std::cout << "error: first call did not result in model, but " << ret << ", abort" << std::endl;
    return 1;
  }
  
  double runtime = cpuTime();
  int call = 0, satresults = 0, unsatresults = 0;
  for(int i = 2; i <= X; ++ i)
  {
    // modify last bits of assumptions
    int mask = call;
    int index = 1;
    bool expectUNSAT = false;
    while(mask > 0 && index <= maxvar) {
      if((mask & 1)==1) {
        *(map[maxvar - index]) = -(*(map[maxvar - index]));
        if(map[maxvar - index] != &fakeentry && !expectUNSAT) {
          expectUNSAT = true;
        }
      }
      mask = mask >> 1;
      index ++;
    }
    conflict.clear();
    int ret = solver.solve(assumptions, model, conflict);
    call ++;
    if(i % 256 == 0) std::cout << "  after " << i << " calls: " << (double)X / (cpuTime()-runtime) << " calls per second" << std::endl;
    if (ret==20) {
      ++ unsatresults;
      solver.addClause(conflict);
    } else {
      ++ satresults;
    }

    if(expectUNSAT && ret != 20 && call!=1) {
      std::cout << "error: in call " << call << ", did not detect conflict (but " << ret << ") on unsatisfiable input, abort" << std::endl;
      std::cout << "used assumptions: " << assumptions << std::endl;
      return 1;
    } else if (!expectUNSAT && ret != 10) {
      std::cout << "error: in call " << call << ", did not detect model (but " << ret << ") on satisfiable input, abort" << std::endl;
      std::cout << "used assumptions: " << assumptions << std::endl;
      return 1;
    }

    // modify last bits of assumptions back to negative
    mask = call;
    index = 1;
    while(mask > 0 && index <= maxvar) {
      if(*(map[maxvar - index]) > 0) {
        *(map[maxvar - index]) = -(*(map[maxvar - index]));
      }
      mask = mask >> 1;
      index ++;
    }
  }
  runtime = cpuTime() - runtime;
  std::cout << "performed " << (double)X / runtime << " calls per second, " 
            << satresults << " SAT, " << unsatresults << " UNSAT"
            << std::endl;
  
  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2c0, %rsp            # imm = 0x2C0
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq 0x22b08(%rip), %rdi     # 0x24fc8
leaq 0x1ab49(%rip), %rsi     # 0x1d010
callq 0x2170
movq %rax, %rdi
movq 0x22ae2(%rip), %rsi     # 0x24fb8
callq 0x21a0
movq 0x22ae6(%rip), %rdi     # 0x24fc8
leaq 0x1ab5c(%rip), %rsi     # 0x1d045
callq 0x2170
movq %rax, %rdi
movq 0x22ac0(%rip), %rsi     # 0x24fb8
callq 0x21a0
movq %rax, %rdi
leaq 0x1ab6c(%rip), %rsi     # 0x1d073
callq 0x2170
movq %rax, %rdi
movq 0x22aa2(%rip), %rsi     # 0x24fb8
callq 0x21a0
movq %rax, %rdi
leaq 0x1ab9a(%rip), %rsi     # 0x1d0bf
callq 0x2170
movq %rax, %rdi
movq 0x22a84(%rip), %rsi     # 0x24fb8
callq 0x21a0
cmpl $0x3, -0x8(%rbp)
jge 0x258b
movq 0x22a82(%rip), %rdi     # 0x24fc8
leaq 0x1ab98(%rip), %rsi     # 0x1d0e5
callq 0x2170
movq %rax, %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rsi
callq 0x2170
movq %rax, %rdi
leaq 0x1ab82(%rip), %rsi     # 0x1d0ed
callq 0x2170
movq %rax, %rdi
movq 0x22a3e(%rip), %rsi     # 0x24fb8
callq 0x21a0
movl $0x1, -0x4(%rbp)
jmp 0x33d3
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x22c0
movl %eax, -0x14(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x22c0
movl %eax, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x22c0
movl %eax, -0x1c(%rbp)
cmpl $0x3, -0x14(%rbp)
jge 0x2609
movq 0x22a00(%rip), %rdi     # 0x24fc8
leaq 0x1ab4e(%rip), %rsi     # 0x1d11d
callq 0x2170
movq %rax, %rdi
movl -0x14(%rbp), %esi
callq 0x2300
movq %rax, %rdi
leaq 0x1ab4f(%rip), %rsi     # 0x1d138
callq 0x2170
movq %rax, %rdi
movq 0x229c0(%rip), %rsi     # 0x24fb8
callq 0x21a0
movl $0x1, -0x4(%rbp)
jmp 0x33d3
cmpl $0x1, -0x18(%rbp)
jl 0x2615
cmpl $0x9, -0x18(%rbp)
jle 0x265d
movq 0x229ac(%rip), %rdi     # 0x24fc8
leaq 0x1ab27(%rip), %rsi     # 0x1d14a
callq 0x2170
movq %rax, %rdi
movl -0x18(%rbp), %esi
callq 0x2300
movq %rax, %rdi
leaq 0x1aafb(%rip), %rsi     # 0x1d138
callq 0x2170
movq %rax, %rdi
movq 0x2296c(%rip), %rsi     # 0x24fb8
callq 0x21a0
movl $0x1, -0x4(%rbp)
jmp 0x33d3
cmpl $0x2, -0x1c(%rbp)
jge 0x26ab
movq 0x2295e(%rip), %rdi     # 0x24fc8
leaq 0x1aaf5(%rip), %rsi     # 0x1d166
callq 0x2170
movq %rax, %rdi
movl -0x1c(%rbp), %esi
callq 0x2300
movq %rax, %rdi
leaq 0x1aaad(%rip), %rsi     # 0x1d138
callq 0x2170
movq %rax, %rdi
movq 0x2291e(%rip), %rsi     # 0x24fb8
callq 0x21a0
movl $0x1, -0x4(%rbp)
jmp 0x33d3
leaq -0x30(%rbp), %rdi
callq 0x33f0
movb -0x18(%rbp), %cl
movl $0x1, %eax
shll %cl, %eax
movl %eax, -0x34(%rbp)
movslq -0x18(%rbp), %rax
movq %rax, -0x138(%rbp)
movl $0x0, -0x54(%rbp)
leaq -0x55(%rbp), %rdi
movq %rdi, -0x130(%rbp)
callq 0x34e0
movq -0x138(%rbp), %rsi
movq -0x130(%rbp), %rcx
leaq -0x50(%rbp), %rdi
leaq -0x54(%rbp), %rdx
callq 0x3500
jmp 0x2700
leaq -0x55(%rbp), %rdi
callq 0x3580
movl $0x0, -0x68(%rbp)
movl $0x0, -0x6c(%rbp)
movl $0x0, -0x70(%rbp)
movl $0x1, -0x74(%rbp)
movl -0x74(%rbp), %eax
cmpl -0x34(%rbp), %eax
jge 0x29a1
movl -0x74(%rbp), %eax
movl %eax, -0x68(%rbp)
movl $0x0, -0x78(%rbp)
movl $0x0, -0x7c(%rbp)
movl -0x7c(%rbp), %eax
cmpl -0x18(%rbp), %eax
jge 0x27ee
movl -0x68(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
jne 0x276a
movl -0x7c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x13c(%rbp)
jmp 0x2778
xorl %eax, %eax
subl -0x7c(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x13c(%rbp)
movl -0x13c(%rbp), %eax
movl %eax, -0x140(%rbp)
movslq -0x7c(%rbp), %rsi
leaq -0x50(%rbp), %rdi
callq 0x35a0
movl -0x140(%rbp), %ecx
movl %ecx, (%rax)
movslq -0x7c(%rbp), %rsi
leaq -0x50(%rbp), %rdi
callq 0x35a0
movl (%rax), %edx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl $0x1, %ecx
cmpl $0x0, %edx
cmovgl %ecx, %eax
addl -0x78(%rbp), %eax
movl %eax, -0x78(%rbp)
movl -0x68(%rbp), %eax
sarl %eax
movl %eax, -0x68(%rbp)
movl -0x7c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x7c(%rbp)
jmp 0x2745
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x55(%rbp), %rdi
callq 0x3580
jmp 0x33c8
movl -0x78(%rbp), %eax
movl %eax, -0x148(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x35c0
movl -0x148(%rbp), %ecx
movl %eax, %edx
xorl %eax, %eax
cmpl %edx, %ecx
movb %al, -0x141(%rbp)
jge 0x281e
movb $0x1, %al
movb %al, -0x141(%rbp)
jmp 0x281e
movb -0x141(%rbp), %al
testb $0x1, %al
jne 0x282a
jmp 0x282c
jmp 0x284b
leaq 0x1a987(%rip), %rdi     # 0x1d1ba
leaq 0x1a9d7(%rip), %rsi     # 0x1d211
movl $0x47, %edx
leaq 0x1a9e4(%rip), %rcx     # 0x1d22a
callq 0x20e0
movl $0x0, -0x80(%rbp)
movl -0x80(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x2991
cmpl $0x0, -0x80(%rbp)
jle 0x295a
movl $0x0, -0x84(%rbp)
movl -0x84(%rbp), %eax
cmpl -0x18(%rbp), %eax
jge 0x2958
movslq -0x84(%rbp), %rsi
leaq -0x50(%rbp), %rdi
callq 0x35a0
cmpl $0x0, (%rax)
jle 0x28b3
movslq -0x84(%rbp), %rsi
leaq -0x50(%rbp), %rdi
callq 0x35a0
movl (%rax), %eax
addl -0x18(%rbp), %eax
movl %eax, -0x14c(%rbp)
jmp 0x28ce
movslq -0x84(%rbp), %rsi
leaq -0x50(%rbp), %rdi
callq 0x35a0
movl (%rax), %eax
subl -0x18(%rbp), %eax
movl %eax, -0x14c(%rbp)
movl -0x14c(%rbp), %eax
movl %eax, -0x154(%rbp)
movslq -0x84(%rbp), %rsi
leaq -0x50(%rbp), %rdi
callq 0x35a0
movl -0x154(%rbp), %ecx
movl %ecx, (%rax)
movl -0x70(%rbp), %eax
movl %eax, -0x150(%rbp)
movslq -0x84(%rbp), %rsi
leaq -0x50(%rbp), %rdi
callq 0x35a0
movq %rax, %rcx
movl -0x150(%rbp), %eax
cmpl (%rcx), %eax
jle 0x2923
movl -0x70(%rbp), %eax
movl %eax, -0x158(%rbp)
jmp 0x293b
movslq -0x84(%rbp), %rsi
leaq -0x50(%rbp), %rdi
callq 0x35a0
movl (%rax), %eax
movl %eax, -0x158(%rbp)
movl -0x158(%rbp), %eax
movl %eax, -0x70(%rbp)
movl -0x84(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x84(%rbp)
jmp 0x2872
jmp 0x295a
leaq -0x30(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x35e0
jmp 0x2969
movl -0x6c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6c(%rbp)
movl -0x80(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x80(%rbp)
jmp 0x2852
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x33bf
jmp 0x2993
movl -0x74(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x74(%rbp)
jmp 0x2725
movq 0x22620(%rip), %rdi     # 0x24fc8
leaq 0x1a892(%rip), %rsi     # 0x1d241
callq 0x2170
movq %rax, -0x160(%rbp)
jmp 0x29bd
movq -0x160(%rbp), %rdi
movl -0x6c(%rbp), %esi
callq 0x2300
movq %rax, -0x168(%rbp)
jmp 0x29d5
movq -0x168(%rbp), %rdi
leaq 0x1a874(%rip), %rsi     # 0x1d257
callq 0x2170
movq %rax, -0x170(%rbp)
jmp 0x29f1
movq -0x170(%rbp), %rdi
movl -0x70(%rbp), %esi
callq 0x2300
movq %rax, -0x178(%rbp)
jmp 0x2a09
movq -0x178(%rbp), %rdi
movq 0x225a1(%rip), %rsi     # 0x24fb8
callq 0x21a0
jmp 0x2a1e
leaq -0xa0(%rbp), %rdi
callq 0x36f0
leaq -0xb8(%rbp), %rdi
callq 0x36f0
leaq -0xd0(%rbp), %rdi
callq 0x36f0
movl $0x1, -0xd4(%rbp)
movl -0xd4(%rbp), %eax
cmpl -0x70(%rbp), %eax
jg 0x2ad6
movl -0xd4(%rbp), %eax
cltd
idivl -0x34(%rbp)
cmpl $0x0, %edx
je 0x2ac0
movl -0xd4(%rbp), %eax
negl %eax
movl %eax, -0xd8(%rbp)
leaq -0xa0(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
callq 0x3710
jmp 0x2a89
jmp 0x2ac0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0xd0(%rbp), %rdi
callq 0x3b10
leaq -0xb8(%rbp), %rdi
callq 0x3b10
leaq -0xa0(%rbp), %rdi
callq 0x3b10
jmp 0x33bf
jmp 0x2ac2
movl -0xd4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xd4(%rbp)
jmp 0x2a4c
movl -0x70(%rbp), %eax
incl %eax
movq %rsp, %rcx
movq %rcx, -0xe0(%rbp)
leaq 0xf(,%rax,8), %rdx
andq $-0x10, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0x180(%rbp)
movq %rcx, %rsp
movq %rax, -0xe8(%rbp)
movl $0x0, -0xec(%rbp)
movl $0x0, -0xf0(%rbp)
movl $0x1, -0xf4(%rbp)
movl -0xf4(%rbp), %eax
cmpl -0x70(%rbp), %eax
jg 0x2ba5
movl -0xf4(%rbp), %eax
cltd
idivl -0x34(%rbp)
cmpl $0x0, %edx
je 0x2b79
movslq -0xf0(%rbp), %rsi
leaq -0xa0(%rbp), %rdi
callq 0x35a0
movq %rax, %rdx
movq -0x180(%rbp), %rax
movslq -0xf4(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0xf0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xf0(%rbp)
jmp 0x2b92
movq -0x180(%rbp), %rax
movslq -0xf4(%rbp), %rcx
leaq -0xec(%rbp), %rdx
movq %rdx, (%rax,%rcx,8)
jmp 0x2b94
movl -0xf4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xf4(%rbp)
jmp 0x2b26
leaq -0x30(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
leaq -0xb8(%rbp), %rdx
leaq -0xd0(%rbp), %rcx
callq 0x3740
movl %eax, -0x184(%rbp)
jmp 0x2bcb
movl -0x184(%rbp), %eax
movl %eax, -0xf8(%rbp)
movq 0x223ea(%rip), %rdi     # 0x24fc8
leaq 0x1a688(%rip), %rsi     # 0x1d26d
callq 0x2170
movq %rax, -0x190(%rbp)
jmp 0x2bf3
movq -0x190(%rbp), %rdi
movl -0xf8(%rbp), %esi
callq 0x2300
movq %rax, -0x198(%rbp)
jmp 0x2c0e
movq -0x198(%rbp), %rdi
movq 0x2239c(%rip), %rsi     # 0x24fb8
callq 0x21a0
jmp 0x2c23
cmpl $0xa, -0xf8(%rbp)
je 0x2caa
movq 0x22395(%rip), %rdi     # 0x24fc8
leaq 0x1a64f(%rip), %rsi     # 0x1d289
callq 0x2170
movq %rax, -0x1a0(%rbp)
jmp 0x2c48
movq -0x1a0(%rbp), %rdi
movl -0xf8(%rbp), %esi
callq 0x2300
movq %rax, -0x1a8(%rbp)
jmp 0x2c63
movq -0x1a8(%rbp), %rdi
leaq 0x1a702(%rip), %rsi     # 0x1d373
callq 0x2170
movq %rax, -0x1b0(%rbp)
jmp 0x2c7f
movq -0x1b0(%rbp), %rdi
movq 0x2232b(%rip), %rsi     # 0x24fb8
callq 0x21a0
jmp 0x2c94
movl $0x1, -0x4(%rbp)
movl $0x1, -0xfc(%rbp)
jmp 0x337d
callq 0x3a20
movsd %xmm0, -0x1b8(%rbp)
jmp 0x2cb9
movsd -0x1b8(%rbp), %xmm0
movsd %xmm0, -0x108(%rbp)
movl $0x0, -0x10c(%rbp)
movl $0x0, -0x110(%rbp)
movl $0x0, -0x114(%rbp)
movl $0x2, -0x118(%rbp)
movl -0x118(%rbp), %eax
cmpl -0x14(%rbp), %eax
jg 0x3260
movl -0x10c(%rbp), %eax
movl %eax, -0x11c(%rbp)
movl $0x1, -0x120(%rbp)
movb $0x0, -0x121(%rbp)
xorl %eax, %eax
cmpl $0x0, -0x11c(%rbp)
movb %al, -0x1b9(%rbp)
jle 0x2d40
movl -0x120(%rbp), %eax
cmpl -0x70(%rbp), %eax
setle %al
movb %al, -0x1b9(%rbp)
movb -0x1b9(%rbp), %al
testb $0x1, %al
jne 0x2d4f
jmp 0x2dd7
movl -0x11c(%rbp), %eax
andl $0x1, %eax
cmpl $0x1, %eax
jne 0x2db5
movq -0x180(%rbp), %rax
movl -0x70(%rbp), %ecx
subl -0x120(%rbp), %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rcx
xorl %edx, %edx
subl (%rcx), %edx
movl -0x70(%rbp), %ecx
subl -0x120(%rbp), %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rcx
movl %edx, (%rcx)
movl -0x70(%rbp), %ecx
subl -0x120(%rbp), %ecx
movslq %ecx, %rcx
leaq -0xec(%rbp), %rdx
cmpq %rdx, (%rax,%rcx,8)
je 0x2db3
testb $0x1, -0x121(%rbp)
jne 0x2db3
movb $0x1, -0x121(%rbp)
jmp 0x2db5
movl -0x11c(%rbp), %eax
sarl %eax
movl %eax, -0x11c(%rbp)
movl -0x120(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x120(%rbp)
jmp 0x2d1d
leaq -0xd0(%rbp), %rdi
movq %rdi, -0x1c8(%rbp)
callq 0x3a70
movq -0x1c8(%rbp), %rcx
leaq -0x30(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
leaq -0xb8(%rbp), %rdx
callq 0x3740
movl %eax, -0x1c0(%rbp)
jmp 0x2e10
movl -0x1c0(%rbp), %eax
movl %eax, -0x128(%rbp)
movl -0x10c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10c(%rbp)
movl -0x118(%rbp), %eax
movl $0x100, %ecx            # imm = 0x100
cltd
idivl %ecx
cmpl $0x0, %edx
jne 0x2f19
movq 0x2217f(%rip), %rdi     # 0x24fc8
leaq 0x1a469(%rip), %rsi     # 0x1d2b9
callq 0x2170
movq %rax, -0x1d0(%rbp)
jmp 0x2e5e
movq -0x1d0(%rbp), %rdi
movl -0x118(%rbp), %esi
callq 0x2300
movq %rax, -0x1d8(%rbp)
jmp 0x2e79
movq -0x1d8(%rbp), %rdi
leaq 0x1a43b(%rip), %rsi     # 0x1d2c2
callq 0x2170
movq %rax, -0x1e0(%rbp)
jmp 0x2e95
cvtsi2sdl -0x14(%rbp), %xmm0
movsd %xmm0, -0x1f0(%rbp)
callq 0x3a20
movsd %xmm0, -0x1e8(%rbp)
jmp 0x2eb1
movq -0x1e0(%rbp), %rdi
movsd -0x1f0(%rbp), %xmm0
movsd -0x1e8(%rbp), %xmm1
movsd -0x108(%rbp), %xmm2
subsd %xmm2, %xmm1
divsd %xmm1, %xmm0
callq 0x2340
movq %rax, -0x1f8(%rbp)
jmp 0x2ee6
movq -0x1f8(%rbp), %rdi
leaq 0x1a3d7(%rip), %rsi     # 0x1d2cb
callq 0x2170
movq %rax, -0x200(%rbp)
jmp 0x2f02
movq -0x200(%rbp), %rdi
movq 0x220a8(%rip), %rsi     # 0x24fb8
callq 0x21a0
jmp 0x2f17
jmp 0x2f19
cmpl $0x14, -0x128(%rbp)
jne 0x2f44
movl -0x114(%rbp), %eax
incl %eax
movl %eax, -0x114(%rbp)
leaq -0x30(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x35e0
jmp 0x2f42
jmp 0x2f53
movl -0x110(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x110(%rbp)
testb $0x1, -0x121(%rbp)
je 0x307c
cmpl $0x14, -0x128(%rbp)
je 0x307c
cmpl $0x1, -0x10c(%rbp)
je 0x307c
movq 0x22047(%rip), %rdi     # 0x24fc8
leaq 0x1a355(%rip), %rsi     # 0x1d2dd
callq 0x2170
movq %rax, -0x208(%rbp)
jmp 0x2f96
movq -0x208(%rbp), %rdi
movl -0x10c(%rbp), %esi
callq 0x2300
movq %rax, -0x210(%rbp)
jmp 0x2fb1
movq -0x210(%rbp), %rdi
leaq 0x1a32e(%rip), %rsi     # 0x1d2ed
callq 0x2170
movq %rax, -0x218(%rbp)
jmp 0x2fcd
movq -0x218(%rbp), %rdi
movl -0x128(%rbp), %esi
callq 0x2300
movq %rax, -0x220(%rbp)
jmp 0x2fe8
movq -0x220(%rbp), %rdi
leaq 0x1a317(%rip), %rsi     # 0x1d30d
callq 0x2170
movq %rax, -0x228(%rbp)
jmp 0x3004
movq -0x228(%rbp), %rdi
movq 0x21fa6(%rip), %rsi     # 0x24fb8
callq 0x21a0
jmp 0x3019
movq 0x21fa8(%rip), %rdi     # 0x24fc8
leaq 0x1a306(%rip), %rsi     # 0x1d32d
callq 0x2170
movq %rax, -0x230(%rbp)
jmp 0x3035
movq -0x230(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x3a90
movq %rax, -0x238(%rbp)
jmp 0x3051
movq -0x238(%rbp), %rdi
movq 0x21f59(%rip), %rsi     # 0x24fb8
callq 0x21a0
jmp 0x3066
movl $0x1, -0x4(%rbp)
movl $0x1, -0xfc(%rbp)
jmp 0x337d
testb $0x1, -0x121(%rbp)
jne 0x3198
cmpl $0xa, -0x128(%rbp)
je 0x3198
movq 0x21f2b(%rip), %rdi     # 0x24fc8
leaq 0x1a239(%rip), %rsi     # 0x1d2dd
callq 0x2170
movq %rax, -0x240(%rbp)
jmp 0x30b2
movq -0x240(%rbp), %rdi
movl -0x10c(%rbp), %esi
callq 0x2300
movq %rax, -0x248(%rbp)
jmp 0x30cd
movq -0x248(%rbp), %rdi
leaq 0x1a265(%rip), %rsi     # 0x1d340
callq 0x2170
movq %rax, -0x250(%rbp)
jmp 0x30e9
movq -0x250(%rbp), %rdi
movl -0x128(%rbp), %esi
callq 0x2300
movq %rax, -0x258(%rbp)
jmp 0x3104
movq -0x258(%rbp), %rdi
leaq 0x1a24b(%rip), %rsi     # 0x1d35d
callq 0x2170
movq %rax, -0x260(%rbp)
jmp 0x3120
movq -0x260(%rbp), %rdi
movq 0x21e8a(%rip), %rsi     # 0x24fb8
callq 0x21a0
jmp 0x3135
movq 0x21e8c(%rip), %rdi     # 0x24fc8
leaq 0x1a1ea(%rip), %rsi     # 0x1d32d
callq 0x2170
movq %rax, -0x268(%rbp)
jmp 0x3151
movq -0x268(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x3a90
movq %rax, -0x270(%rbp)
jmp 0x316d
movq -0x270(%rbp), %rdi
movq 0x21e3d(%rip), %rsi     # 0x24fb8
callq 0x21a0
jmp 0x3182
movl $0x1, -0x4(%rbp)
movl $0x1, -0xfc(%rbp)
jmp 0x337d
jmp 0x319a
movl -0x10c(%rbp), %eax
movl %eax, -0x11c(%rbp)
movl $0x1, -0x120(%rbp)
xorl %eax, %eax
cmpl $0x0, -0x11c(%rbp)
movb %al, -0x271(%rbp)
jle 0x31d3
movl -0x120(%rbp), %eax
cmpl -0x70(%rbp), %eax
setle %al
movb %al, -0x271(%rbp)
movb -0x271(%rbp), %al
testb $0x1, %al
jne 0x31df
jmp 0x324a
movq -0x180(%rbp), %rax
movl -0x70(%rbp), %ecx
subl -0x120(%rbp), %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
cmpl $0x0, (%rax)
jle 0x3228
movq -0x180(%rbp), %rax
movl -0x70(%rbp), %ecx
subl -0x120(%rbp), %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rdx
xorl %ecx, %ecx
subl (%rdx), %ecx
movl -0x70(%rbp), %edx
subl -0x120(%rbp), %edx
movslq %edx, %rdx
movq (%rax,%rdx,8), %rax
movl %ecx, (%rax)
movl -0x11c(%rbp), %eax
sarl %eax
movl %eax, -0x11c(%rbp)
movl -0x120(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x120(%rbp)
jmp 0x31b0
jmp 0x324c
movl -0x118(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x118(%rbp)
jmp 0x2cf1
callq 0x3a20
movsd %xmm0, -0x280(%rbp)
jmp 0x326f
movsd -0x280(%rbp), %xmm0
movsd -0x108(%rbp), %xmm1
subsd %xmm1, %xmm0
movsd %xmm0, -0x108(%rbp)
movq 0x21d36(%rip), %rdi     # 0x24fc8
leaq 0x1a0e2(%rip), %rsi     # 0x1d37b
callq 0x2170
movq %rax, -0x288(%rbp)
jmp 0x32a7
movq -0x288(%rbp), %rdi
cvtsi2sdl -0x14(%rbp), %xmm0
movsd -0x108(%rbp), %xmm1
divsd %xmm1, %xmm0
callq 0x2340
movq %rax, -0x290(%rbp)
jmp 0x32cd
movq -0x290(%rbp), %rdi
leaq 0x1a0ab(%rip), %rsi     # 0x1d386
callq 0x2170
movq %rax, -0x298(%rbp)
jmp 0x32e9
movq -0x298(%rbp), %rdi
movl -0x110(%rbp), %esi
callq 0x2300
movq %rax, -0x2a0(%rbp)
jmp 0x3304
movq -0x2a0(%rbp), %rdi
leaq 0x1a088(%rip), %rsi     # 0x1d39a
callq 0x2170
movq %rax, -0x2a8(%rbp)
jmp 0x3320
movq -0x2a8(%rbp), %rdi
movl -0x114(%rbp), %esi
callq 0x2300
movq %rax, -0x2b0(%rbp)
jmp 0x333b
movq -0x2b0(%rbp), %rdi
leaq 0x1a058(%rip), %rsi     # 0x1d3a1
callq 0x2170
movq %rax, -0x2b8(%rbp)
jmp 0x3357
movq -0x2b8(%rbp), %rdi
movq 0x21c53(%rip), %rsi     # 0x24fb8
callq 0x21a0
jmp 0x336c
movl $0x0, -0x4(%rbp)
movl $0x1, -0xfc(%rbp)
movq -0xe0(%rbp), %rax
movq %rax, %rsp
leaq -0xd0(%rbp), %rdi
callq 0x3b10
leaq -0xb8(%rbp), %rdi
callq 0x3b10
leaq -0xa0(%rbp), %rdi
callq 0x3b10
leaq -0x50(%rbp), %rdi
callq 0x3b10
leaq -0x30(%rbp), %rdi
callq 0x3b70
jmp 0x33d3
leaq -0x50(%rbp), %rdi
callq 0x3b10
leaq -0x30(%rbp), %rdi
callq 0x3b70
jmp 0x33db
movl -0x4(%rbp), %eax
movq %rbp, %rsp
popq %rbp
retq
movq -0x60(%rbp), %rdi
callq 0x2310
nopw %cs:(%rax,%rax)
nop