// File: biotomas[P]ipasir/app/ipasir-check-iterative/ipasir-check-iterative.cc
// Function: main
int main(int argc, char* argv[])
{
  std::cout << "Norbert Manthey -- IPASIR iterative load checker" << std::endl;
  std::cout << "  add formula that has sub formulas of blocks" << std::endl
            << "  use full stack of assumptions 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) assumptions.push_back(-i);
  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;
  for(int i = 2; i <= X; ++ i)
  {
    // modify last bits of assumptions
    int mask = call;
    int index = 1;
    while(mask > 0 && index <= assumptions.size()) {
      if((mask & 1)==1) assumptions[assumptions.size() - index] = -assumptions[assumptions.size() - index];
      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) {
      solver.addClause(conflict);
    } else if (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;
    }

    // modify last bits of assumptions
    mask = call;
    index = 1;
    while(mask > 0 && index <= assumptions.size()) {
      if(assumptions[assumptions.size() - index] > 0) assumptions[assumptions.size() - index] = -assumptions[assumptions.size() - index];
      mask = mask >> 1;
      index ++;
    }
  }
  runtime = cpuTime() - runtime;
  std::cout << "performed " << (double)X / runtime << " calls per second" << std::endl;
  
  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x250, %rsp            # imm = 0x250
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 0x1ab58(%rip), %rsi     # 0x1d041
callq 0x2170
movq %rax, %rdi
movq 0x22ac0(%rip), %rsi     # 0x24fb8
callq 0x21a0
movq %rax, %rdi
leaq 0x1ab68(%rip), %rsi     # 0x1d06f
callq 0x2170
movq %rax, %rdi
movq 0x22aa2(%rip), %rsi     # 0x24fb8
callq 0x21a0
cmpl $0x3, -0x8(%rbp)
jge 0x256d
movq 0x22aa0(%rip), %rdi     # 0x24fc8
leaq 0x1ab84(%rip), %rsi     # 0x1d0b3
callq 0x2170
movq %rax, %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rsi
callq 0x2170
movq %rax, %rdi
leaq 0x1ab6e(%rip), %rsi     # 0x1d0bb
callq 0x2170
movq %rax, %rdi
movq 0x22a5c(%rip), %rsi     # 0x24fb8
callq 0x21a0
movl $0x1, -0x4(%rbp)
jmp 0x3175
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 0x25eb
movq 0x22a1e(%rip), %rdi     # 0x24fc8
leaq 0x1ab3a(%rip), %rsi     # 0x1d0eb
callq 0x2170
movq %rax, %rdi
movl -0x14(%rbp), %esi
callq 0x2300
movq %rax, %rdi
leaq 0x1ab3b(%rip), %rsi     # 0x1d106
callq 0x2170
movq %rax, %rdi
movq 0x229de(%rip), %rsi     # 0x24fb8
callq 0x21a0
movl $0x1, -0x4(%rbp)
jmp 0x3175
cmpl $0x1, -0x18(%rbp)
jl 0x25f7
cmpl $0x9, -0x18(%rbp)
jle 0x263f
movq 0x229ca(%rip), %rdi     # 0x24fc8
leaq 0x1ab13(%rip), %rsi     # 0x1d118
callq 0x2170
movq %rax, %rdi
movl -0x18(%rbp), %esi
callq 0x2300
movq %rax, %rdi
leaq 0x1aae7(%rip), %rsi     # 0x1d106
callq 0x2170
movq %rax, %rdi
movq 0x2298a(%rip), %rsi     # 0x24fb8
callq 0x21a0
movl $0x1, -0x4(%rbp)
jmp 0x3175
cmpl $0x2, -0x1c(%rbp)
jge 0x268d
movq 0x2297c(%rip), %rdi     # 0x24fc8
leaq 0x1aae1(%rip), %rsi     # 0x1d134
callq 0x2170
movq %rax, %rdi
movl -0x1c(%rbp), %esi
callq 0x2300
movq %rax, %rdi
leaq 0x1aa99(%rip), %rsi     # 0x1d106
callq 0x2170
movq %rax, %rdi
movq 0x2293c(%rip), %rsi     # 0x24fb8
callq 0x21a0
movl $0x1, -0x4(%rbp)
jmp 0x3175
leaq -0x30(%rbp), %rdi
callq 0x3190
movb -0x18(%rbp), %cl
movl $0x1, %eax
shll %cl, %eax
movl %eax, -0x34(%rbp)
movslq -0x18(%rbp), %rax
movq %rax, -0x110(%rbp)
movl $0x0, -0x54(%rbp)
leaq -0x55(%rbp), %rdi
movq %rdi, -0x108(%rbp)
callq 0x3280
movq -0x110(%rbp), %rsi
movq -0x108(%rbp), %rcx
leaq -0x50(%rbp), %rdi
leaq -0x54(%rbp), %rdx
callq 0x32a0
jmp 0x26e2
leaq -0x55(%rbp), %rdi
callq 0x3320
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 0x2983
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 0x27d0
movl -0x68(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
jne 0x274c
movl -0x7c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x114(%rbp)
jmp 0x275a
xorl %eax, %eax
subl -0x7c(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x114(%rbp)
movl -0x114(%rbp), %eax
movl %eax, -0x118(%rbp)
movslq -0x7c(%rbp), %rsi
leaq -0x50(%rbp), %rdi
callq 0x3340
movl -0x118(%rbp), %ecx
movl %ecx, (%rax)
movslq -0x7c(%rbp), %rsi
leaq -0x50(%rbp), %rdi
callq 0x3340
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 0x2727
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x55(%rbp), %rdi
callq 0x3320
jmp 0x316a
movl -0x78(%rbp), %eax
movl %eax, -0x120(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x3360
movl -0x120(%rbp), %ecx
movl %eax, %edx
xorl %eax, %eax
cmpl %edx, %ecx
movb %al, -0x119(%rbp)
jge 0x2800
movb $0x1, %al
movb %al, -0x119(%rbp)
jmp 0x2800
movb -0x119(%rbp), %al
testb $0x1, %al
jne 0x280c
jmp 0x280e
jmp 0x282d
leaq 0x1a973(%rip), %rdi     # 0x1d188
leaq 0x1a9c3(%rip), %rsi     # 0x1d1df
movl $0x46, %edx
leaq 0x1a9d1(%rip), %rcx     # 0x1d1f9
callq 0x20e0
movl $0x0, -0x80(%rbp)
movl -0x80(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x2973
cmpl $0x0, -0x80(%rbp)
jle 0x293c
movl $0x0, -0x84(%rbp)
movl -0x84(%rbp), %eax
cmpl -0x18(%rbp), %eax
jge 0x293a
movslq -0x84(%rbp), %rsi
leaq -0x50(%rbp), %rdi
callq 0x3340
cmpl $0x0, (%rax)
jle 0x2895
movslq -0x84(%rbp), %rsi
leaq -0x50(%rbp), %rdi
callq 0x3340
movl (%rax), %eax
addl -0x18(%rbp), %eax
movl %eax, -0x124(%rbp)
jmp 0x28b0
movslq -0x84(%rbp), %rsi
leaq -0x50(%rbp), %rdi
callq 0x3340
movl (%rax), %eax
subl -0x18(%rbp), %eax
movl %eax, -0x124(%rbp)
movl -0x124(%rbp), %eax
movl %eax, -0x12c(%rbp)
movslq -0x84(%rbp), %rsi
leaq -0x50(%rbp), %rdi
callq 0x3340
movl -0x12c(%rbp), %ecx
movl %ecx, (%rax)
movl -0x70(%rbp), %eax
movl %eax, -0x128(%rbp)
movslq -0x84(%rbp), %rsi
leaq -0x50(%rbp), %rdi
callq 0x3340
movq %rax, %rcx
movl -0x128(%rbp), %eax
cmpl (%rcx), %eax
jle 0x2905
movl -0x70(%rbp), %eax
movl %eax, -0x130(%rbp)
jmp 0x291d
movslq -0x84(%rbp), %rsi
leaq -0x50(%rbp), %rdi
callq 0x3340
movl (%rax), %eax
movl %eax, -0x130(%rbp)
movl -0x130(%rbp), %eax
movl %eax, -0x70(%rbp)
movl -0x84(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x84(%rbp)
jmp 0x2854
jmp 0x293c
leaq -0x30(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x3380
jmp 0x294b
movl -0x6c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6c(%rbp)
movl -0x80(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x80(%rbp)
jmp 0x2834
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x3161
jmp 0x2975
movl -0x74(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x74(%rbp)
jmp 0x2707
movq 0x2263e(%rip), %rdi     # 0x24fc8
leaq 0x1a87f(%rip), %rsi     # 0x1d210
callq 0x2170
movq %rax, -0x138(%rbp)
jmp 0x299f
movq -0x138(%rbp), %rdi
movl -0x6c(%rbp), %esi
callq 0x2300
movq %rax, -0x140(%rbp)
jmp 0x29b7
movq -0x140(%rbp), %rdi
leaq 0x1a861(%rip), %rsi     # 0x1d226
callq 0x2170
movq %rax, -0x148(%rbp)
jmp 0x29d3
movq -0x148(%rbp), %rdi
movl -0x70(%rbp), %esi
callq 0x2300
movq %rax, -0x150(%rbp)
jmp 0x29eb
movq -0x150(%rbp), %rdi
movq 0x225bf(%rip), %rsi     # 0x24fb8
callq 0x21a0
jmp 0x2a00
leaq -0xa0(%rbp), %rdi
callq 0x3490
leaq -0xb8(%rbp), %rdi
callq 0x3490
leaq -0xd0(%rbp), %rdi
callq 0x3490
movl $0x1, -0xd4(%rbp)
movl -0xd4(%rbp), %eax
cmpl -0x70(%rbp), %eax
jg 0x2aa4
movl -0xd4(%rbp), %eax
negl %eax
movl %eax, -0xd8(%rbp)
leaq -0xa0(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
callq 0x34b0
jmp 0x2a5c
jmp 0x2a5e
movl -0xd4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xd4(%rbp)
jmp 0x2a2e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0xd0(%rbp), %rdi
callq 0x38b0
leaq -0xb8(%rbp), %rdi
callq 0x38b0
leaq -0xa0(%rbp), %rdi
callq 0x38b0
jmp 0x3161
leaq -0x30(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
leaq -0xb8(%rbp), %rdx
leaq -0xd0(%rbp), %rcx
callq 0x34e0
movl %eax, -0x154(%rbp)
jmp 0x2aca
movl -0x154(%rbp), %eax
movl %eax, -0xdc(%rbp)
movq 0x224eb(%rip), %rdi     # 0x24fc8
leaq 0x1a758(%rip), %rsi     # 0x1d23c
callq 0x2170
movq %rax, -0x160(%rbp)
jmp 0x2af2
movq -0x160(%rbp), %rdi
movl -0xdc(%rbp), %esi
callq 0x2300
movq %rax, -0x168(%rbp)
jmp 0x2b0d
movq -0x168(%rbp), %rdi
movq 0x2249d(%rip), %rsi     # 0x24fb8
callq 0x21a0
jmp 0x2b22
cmpl $0xa, -0xdc(%rbp)
je 0x2ba9
movq 0x22496(%rip), %rdi     # 0x24fc8
leaq 0x1a71f(%rip), %rsi     # 0x1d258
callq 0x2170
movq %rax, -0x170(%rbp)
jmp 0x2b47
movq -0x170(%rbp), %rdi
movl -0xdc(%rbp), %esi
callq 0x2300
movq %rax, -0x178(%rbp)
jmp 0x2b62
movq -0x178(%rbp), %rdi
leaq 0x1a784(%rip), %rsi     # 0x1d2f4
callq 0x2170
movq %rax, -0x180(%rbp)
jmp 0x2b7e
movq -0x180(%rbp), %rdi
movq 0x2242c(%rip), %rsi     # 0x24fb8
callq 0x21a0
jmp 0x2b93
movl $0x1, -0x4(%rbp)
movl $0x1, -0xe0(%rbp)
jmp 0x3129
callq 0x37c0
movsd %xmm0, -0x188(%rbp)
jmp 0x2bb8
movsd -0x188(%rbp), %xmm0
movsd %xmm0, -0xe8(%rbp)
movl $0x0, -0xec(%rbp)
movl $0x2, -0xf0(%rbp)
movl -0xf0(%rbp), %eax
cmpl -0x14(%rbp), %eax
jg 0x307a
movl -0xec(%rbp), %eax
movl %eax, -0xf4(%rbp)
movl $0x1, -0xf8(%rbp)
xorl %eax, %eax
cmpl $0x0, -0xf4(%rbp)
movb %al, -0x189(%rbp)
jle 0x2c42
movslq -0xf8(%rbp), %rax
movq %rax, -0x198(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x3360
movq %rax, %rcx
movq -0x198(%rbp), %rax
cmpq %rcx, %rax
setbe %al
movb %al, -0x189(%rbp)
movb -0x189(%rbp), %al
testb $0x1, %al
jne 0x2c51
jmp 0x2ce0
movl -0xf4(%rbp), %eax
andl $0x1, %eax
cmpl $0x1, %eax
jne 0x2cbe
leaq -0xa0(%rbp), %rdi
callq 0x3360
movq %rax, %rsi
movslq -0xf8(%rbp), %rax
subq %rax, %rsi
leaq -0xa0(%rbp), %rdi
callq 0x3340
movq %rax, %rcx
xorl %eax, %eax
subl (%rcx), %eax
movl %eax, -0x19c(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x3360
movq %rax, %rsi
movslq -0xf8(%rbp), %rax
subq %rax, %rsi
leaq -0xa0(%rbp), %rdi
callq 0x3340
movl -0x19c(%rbp), %ecx
movl %ecx, (%rax)
movl -0xf4(%rbp), %eax
sarl %eax
movl %eax, -0xf4(%rbp)
movl -0xf8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xf8(%rbp)
jmp 0x2c01
leaq -0xd0(%rbp), %rdi
movq %rdi, -0x1a8(%rbp)
callq 0x3810
movq -0x1a8(%rbp), %rcx
leaq -0x30(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
leaq -0xb8(%rbp), %rdx
callq 0x34e0
movl %eax, -0x1a0(%rbp)
jmp 0x2d19
movl -0x1a0(%rbp), %eax
movl %eax, -0xfc(%rbp)
movl -0xec(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xec(%rbp)
movl -0xf0(%rbp), %eax
movl $0x100, %ecx            # imm = 0x100
cltd
idivl %ecx
cmpl $0x0, %edx
jne 0x2e22
movq 0x22276(%rip), %rdi     # 0x24fc8
leaq 0x1a52f(%rip), %rsi     # 0x1d288
callq 0x2170
movq %rax, -0x1b0(%rbp)
jmp 0x2d67
movq -0x1b0(%rbp), %rdi
movl -0xf0(%rbp), %esi
callq 0x2300
movq %rax, -0x1b8(%rbp)
jmp 0x2d82
movq -0x1b8(%rbp), %rdi
leaq 0x1a501(%rip), %rsi     # 0x1d291
callq 0x2170
movq %rax, -0x1c0(%rbp)
jmp 0x2d9e
cvtsi2sdl -0x14(%rbp), %xmm0
movsd %xmm0, -0x1d0(%rbp)
callq 0x37c0
movsd %xmm0, -0x1c8(%rbp)
jmp 0x2dba
movq -0x1c0(%rbp), %rdi
movsd -0x1d0(%rbp), %xmm0
movsd -0x1c8(%rbp), %xmm1
movsd -0xe8(%rbp), %xmm2
subsd %xmm2, %xmm1
divsd %xmm1, %xmm0
callq 0x2340
movq %rax, -0x1d8(%rbp)
jmp 0x2def
movq -0x1d8(%rbp), %rdi
leaq 0x1a49d(%rip), %rsi     # 0x1d29a
callq 0x2170
movq %rax, -0x1e0(%rbp)
jmp 0x2e0b
movq -0x1e0(%rbp), %rdi
movq 0x2219f(%rip), %rsi     # 0x24fb8
callq 0x21a0
jmp 0x2e20
jmp 0x2e22
cmpl $0x14, -0xfc(%rbp)
jne 0x2e42
leaq -0x30(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x3380
jmp 0x2e3d
jmp 0x2f53
cmpl $0x1, -0xec(%rbp)
je 0x2f51
movq 0x22172(%rip), %rdi     # 0x24fc8
leaq 0x1a44f(%rip), %rsi     # 0x1d2ac
callq 0x2170
movq %rax, -0x1e8(%rbp)
jmp 0x2e6b
movq -0x1e8(%rbp), %rdi
movl -0xec(%rbp), %esi
callq 0x2300
movq %rax, -0x1f0(%rbp)
jmp 0x2e86
movq -0x1f0(%rbp), %rdi
leaq 0x1a428(%rip), %rsi     # 0x1d2bc
callq 0x2170
movq %rax, -0x1f8(%rbp)
jmp 0x2ea2
movq -0x1f8(%rbp), %rdi
movl -0xfc(%rbp), %esi
callq 0x2300
movq %rax, -0x200(%rbp)
jmp 0x2ebd
movq -0x200(%rbp), %rdi
leaq 0x1a411(%rip), %rsi     # 0x1d2dc
callq 0x2170
movq %rax, -0x208(%rbp)
jmp 0x2ed9
movq -0x208(%rbp), %rdi
movq 0x220d1(%rip), %rsi     # 0x24fb8
callq 0x21a0
jmp 0x2eee
movq 0x220d3(%rip), %rdi     # 0x24fc8
leaq 0x1a400(%rip), %rsi     # 0x1d2fc
callq 0x2170
movq %rax, -0x210(%rbp)
jmp 0x2f0a
movq -0x210(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x3830
movq %rax, -0x218(%rbp)
jmp 0x2f26
movq -0x218(%rbp), %rdi
movq 0x22084(%rip), %rsi     # 0x24fb8
callq 0x21a0
jmp 0x2f3b
movl $0x1, -0x4(%rbp)
movl $0x1, -0xe0(%rbp)
jmp 0x3129
jmp 0x2f53
movl -0xec(%rbp), %eax
movl %eax, -0xf4(%rbp)
movl $0x1, -0xf8(%rbp)
xorl %eax, %eax
cmpl $0x0, -0xf4(%rbp)
movb %al, -0x219(%rbp)
jle 0x2faa
movslq -0xf8(%rbp), %rax
movq %rax, -0x228(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x3360
movq %rax, %rcx
movq -0x228(%rbp), %rax
cmpq %rcx, %rax
setbe %al
movb %al, -0x219(%rbp)
movb -0x219(%rbp), %al
testb $0x1, %al
jne 0x2fb9
jmp 0x3064
leaq -0xa0(%rbp), %rdi
callq 0x3360
movq %rax, %rsi
movslq -0xf8(%rbp), %rax
subq %rax, %rsi
leaq -0xa0(%rbp), %rdi
callq 0x3340
cmpl $0x0, (%rax)
jle 0x3042
leaq -0xa0(%rbp), %rdi
callq 0x3360
movq %rax, %rsi
movslq -0xf8(%rbp), %rax
subq %rax, %rsi
leaq -0xa0(%rbp), %rdi
callq 0x3340
movq %rax, %rcx
xorl %eax, %eax
subl (%rcx), %eax
movl %eax, -0x22c(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x3360
movq %rax, %rsi
movslq -0xf8(%rbp), %rax
subq %rax, %rsi
leaq -0xa0(%rbp), %rdi
callq 0x3340
movl -0x22c(%rbp), %ecx
movl %ecx, (%rax)
movl -0xf4(%rbp), %eax
sarl %eax
movl %eax, -0xf4(%rbp)
movl -0xf8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xf8(%rbp)
jmp 0x2f69
jmp 0x3066
movl -0xf0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xf0(%rbp)
jmp 0x2bdc
callq 0x37c0
movsd %xmm0, -0x238(%rbp)
jmp 0x3089
movsd -0x238(%rbp), %xmm0
movsd -0xe8(%rbp), %xmm1
subsd %xmm1, %xmm0
movsd %xmm0, -0xe8(%rbp)
movq 0x21f1c(%rip), %rdi     # 0x24fc8
leaq 0x1a25c(%rip), %rsi     # 0x1d30f
callq 0x2170
movq %rax, -0x240(%rbp)
jmp 0x30c1
movq -0x240(%rbp), %rdi
cvtsi2sdl -0x14(%rbp), %xmm0
movsd -0xe8(%rbp), %xmm1
divsd %xmm1, %xmm0
callq 0x2340
movq %rax, -0x248(%rbp)
jmp 0x30e7
movq -0x248(%rbp), %rdi
leaq 0x1a1a5(%rip), %rsi     # 0x1d29a
callq 0x2170
movq %rax, -0x250(%rbp)
jmp 0x3103
movq -0x250(%rbp), %rdi
movq 0x21ea7(%rip), %rsi     # 0x24fb8
callq 0x21a0
jmp 0x3118
movl $0x0, -0x4(%rbp)
movl $0x1, -0xe0(%rbp)
leaq -0xd0(%rbp), %rdi
callq 0x38b0
leaq -0xb8(%rbp), %rdi
callq 0x38b0
leaq -0xa0(%rbp), %rdi
callq 0x38b0
leaq -0x50(%rbp), %rdi
callq 0x38b0
leaq -0x30(%rbp), %rdi
callq 0x3910
jmp 0x3175
leaq -0x50(%rbp), %rdi
callq 0x38b0
leaq -0x30(%rbp), %rdi
callq 0x3910
jmp 0x3181
movl -0x4(%rbp), %eax
addq $0x250, %rsp            # imm = 0x250
popq %rbp
retq
movq -0x60(%rbp), %rdi
callq 0x2310
nopw (%rax,%rax)