// File: biotomas[P]ipasir/app/ipasir-check-conflict/ipasir-check-conflict.cc
// Function: main
int main(int argc, char* argv[])
{
  std::cout << "Norbert Manthey -- IPASIR conflict checker" << std::endl;
  std::cout << "  reserve max len for conflict of size X and try force a conflict clause of size Y" << std::endl
            << "  and a full stack of assumption literals" << std::endl;
  if(argc < 3) {
    std::cout << "usage: " << argv[0] << " X Y ... with 0 < X < Y < 2^30" << std::endl;
    return 1;
  }
  int X = atoi(argv[1]);
  int Y = atoi(argv[2]);
  if(X<1) {
    std::cout << "error: given first number " << X << " is not in limits" << std::endl;
    return 1;
  }
  if(Y<1) {
    std::cout << "error: given second number " << Y << " is not in limits" << std::endl;
    return 1;
  }
  
  vector<int> assumptions;
  vector<int> positive, negative;
  
  std::vector<int> model;
  std::vector<int> conflict;
  
  SATSolver solver;
  solver.addLearnStatHook(X, learnhook);
  
  double runtime = cpuTime();
  for(int i = 1; i < Y; ++ i)
  {
    assumptions.push_back(-i);
    positive.push_back(i);
    negative.push_back(i);
  }
  positive.push_back(Y);
  negative.push_back(-Y);
  
  solver.addClause(positive);
  std::cout << "add clause " << positive << std::endl;
  solver.addClause(negative);
  std::cout << "add clause " << negative << std::endl;
  
  std::cout << "solve with assumptions " << assumptions << std::endl;
  int ret = solver.solve(assumptions, model, conflict);
  if(ret!=20) {
    std::cout << "error: solver fails learning a huge clause with status " << ret << std::endl;
    return 1;
  }
  
  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x120, %rsp            # imm = 0x120
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq 0x22aa8(%rip), %rdi     # 0x24fc8
leaq 0x1ab03(%rip), %rsi     # 0x1d02a
callq 0x2170
movq %rax, %rdi
movq 0x22a82(%rip), %rsi     # 0x24fb8
callq 0x21a0
movq 0x22a86(%rip), %rdi     # 0x24fc8
leaq 0x1ab0c(%rip), %rsi     # 0x1d055
callq 0x2170
movq %rax, %rdi
movq 0x22a60(%rip), %rsi     # 0x24fb8
callq 0x21a0
movq %rax, %rdi
leaq 0x1ab41(%rip), %rsi     # 0x1d0a8
callq 0x2170
movq %rax, %rdi
movq 0x22a42(%rip), %rsi     # 0x24fb8
callq 0x21a0
cmpl $0x3, -0x8(%rbp)
jge 0x25cd
movq 0x22a40(%rip), %rdi     # 0x24fc8
leaq 0x1ab43(%rip), %rsi     # 0x1d0d2
callq 0x2170
movq %rax, %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rsi
callq 0x2170
movq %rax, %rdi
leaq 0x1ab2d(%rip), %rsi     # 0x1d0da
callq 0x2170
movq %rax, %rdi
movq 0x229fc(%rip), %rsi     # 0x24fb8
callq 0x21a0
movl $0x1, -0x4(%rbp)
jmp 0x29ee
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)
cmpl $0x1, -0x14(%rbp)
jge 0x263b
movq 0x229ce(%rip), %rdi     # 0x24fc8
leaq 0x1aaf8(%rip), %rsi     # 0x1d0f9
callq 0x2170
movq %rax, %rdi
movl -0x14(%rbp), %esi
callq 0x2300
movq %rax, %rdi
leaq 0x1aaf9(%rip), %rsi     # 0x1d114
callq 0x2170
movq %rax, %rdi
movq 0x2298e(%rip), %rsi     # 0x24fb8
callq 0x21a0
movl $0x1, -0x4(%rbp)
jmp 0x29ee
cmpl $0x1, -0x18(%rbp)
jge 0x2689
movq 0x22980(%rip), %rdi     # 0x24fc8
leaq 0x1aad7(%rip), %rsi     # 0x1d126
callq 0x2170
movq %rax, %rdi
movl -0x18(%rbp), %esi
callq 0x2300
movq %rax, %rdi
leaq 0x1aaab(%rip), %rsi     # 0x1d114
callq 0x2170
movq %rax, %rdi
movq 0x22940(%rip), %rsi     # 0x24fb8
callq 0x21a0
movl $0x1, -0x4(%rbp)
jmp 0x29ee
leaq -0x30(%rbp), %rdi
callq 0x2a10
leaq -0x48(%rbp), %rdi
callq 0x2a10
leaq -0x60(%rbp), %rdi
callq 0x2a10
leaq -0x78(%rbp), %rdi
callq 0x2a10
leaq -0x90(%rbp), %rdi
callq 0x2a10
leaq -0xa0(%rbp), %rdi
callq 0x2a30
jmp 0x26c7
movl -0x14(%rbp), %esi
leaq -0x241(%rip), %rdx      # 0x2490
leaq -0xa0(%rbp), %rdi
callq 0x2b20
jmp 0x26df
callq 0x2b60
movsd %xmm0, -0xd8(%rbp)
jmp 0x26ee
movsd -0xd8(%rbp), %xmm0
movsd %xmm0, -0xb8(%rbp)
movl $0x1, -0xbc(%rbp)
movl -0xbc(%rbp), %eax
cmpl -0x18(%rbp), %eax
jge 0x27a8
movl -0xbc(%rbp), %eax
negl %eax
movl %eax, -0xc0(%rbp)
leaq -0x30(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
callq 0x2bb0
jmp 0x2737
leaq -0x48(%rbp), %rdi
leaq -0xbc(%rbp), %rsi
callq 0x2be0
jmp 0x2749
leaq -0x60(%rbp), %rdi
leaq -0xbc(%rbp), %rsi
callq 0x2be0
jmp 0x275b
jmp 0x275d
movl -0xbc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xbc(%rbp)
jmp 0x2708
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa8(%rbp)
movl %eax, -0xac(%rbp)
jmp 0x29bc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa8(%rbp)
movl %eax, -0xac(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x30c0
jmp 0x29bc
leaq -0x48(%rbp), %rdi
leaq -0x18(%rbp), %rsi
callq 0x2be0
jmp 0x27b7
movl -0x18(%rbp), %eax
negl %eax
movl %eax, -0xc4(%rbp)
leaq -0x60(%rbp), %rdi
leaq -0xc4(%rbp), %rsi
callq 0x2bb0
jmp 0x27d4
leaq -0xa0(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x2c50
jmp 0x27e6
movq 0x227db(%rip), %rdi     # 0x24fc8
leaq 0x1a94e(%rip), %rsi     # 0x1d142
callq 0x2170
movq %rax, -0xe0(%rbp)
jmp 0x2802
movq -0xe0(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x2d60
movq %rax, -0xe8(%rbp)
jmp 0x281b
movq -0xe8(%rbp), %rdi
movq 0x2278f(%rip), %rsi     # 0x24fb8
callq 0x21a0
jmp 0x2830
leaq -0xa0(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x2c50
jmp 0x2842
movq 0x2277f(%rip), %rdi     # 0x24fc8
leaq 0x1a8f2(%rip), %rsi     # 0x1d142
callq 0x2170
movq %rax, -0xf0(%rbp)
jmp 0x285e
movq -0xf0(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x2d60
movq %rax, -0xf8(%rbp)
jmp 0x2877
movq -0xf8(%rbp), %rdi
movq 0x22733(%rip), %rsi     # 0x24fb8
callq 0x21a0
jmp 0x288c
movq 0x22735(%rip), %rdi     # 0x24fc8
leaq 0x1a8b4(%rip), %rsi     # 0x1d14e
callq 0x2170
movq %rax, -0x100(%rbp)
jmp 0x28a8
movq -0x100(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x2d60
movq %rax, -0x108(%rbp)
jmp 0x28c1
movq -0x108(%rbp), %rdi
movq 0x226e9(%rip), %rsi     # 0x24fb8
callq 0x21a0
jmp 0x28d6
leaq -0xa0(%rbp), %rdi
leaq -0x30(%rbp), %rsi
leaq -0x78(%rbp), %rdx
leaq -0x90(%rbp), %rcx
callq 0x2de0
movl %eax, -0x10c(%rbp)
jmp 0x28f9
movl -0x10c(%rbp), %eax
movl %eax, -0xc8(%rbp)
cmpl $0x14, -0xc8(%rbp)
je 0x296d
movq 0x226b3(%rip), %rdi     # 0x24fc8
leaq 0x1a84a(%rip), %rsi     # 0x1d166
callq 0x2170
movq %rax, -0x118(%rbp)
jmp 0x292a
movq -0x118(%rbp), %rdi
movl -0xc8(%rbp), %esi
callq 0x2300
movq %rax, -0x120(%rbp)
jmp 0x2945
movq -0x120(%rbp), %rdi
movq 0x22665(%rip), %rsi     # 0x24fb8
callq 0x21a0
jmp 0x295a
movl $0x1, -0x4(%rbp)
movl $0x1, -0xcc(%rbp)
jmp 0x297e
movl $0x0, -0x4(%rbp)
movl $0x1, -0xcc(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x30c0
leaq -0x90(%rbp), %rdi
callq 0x3100
leaq -0x78(%rbp), %rdi
callq 0x3100
leaq -0x60(%rbp), %rdi
callq 0x3100
leaq -0x48(%rbp), %rdi
callq 0x3100
leaq -0x30(%rbp), %rdi
callq 0x3100
jmp 0x29ee
leaq -0x90(%rbp), %rdi
callq 0x3100
leaq -0x78(%rbp), %rdi
callq 0x3100
leaq -0x60(%rbp), %rdi
callq 0x3100
leaq -0x48(%rbp), %rdi
callq 0x3100
leaq -0x30(%rbp), %rdi
callq 0x3100
jmp 0x29fa
movl -0x4(%rbp), %eax
addq $0x120, %rsp            # imm = 0x120
popq %rbp
retq
movq -0xa8(%rbp), %rdi
callq 0x2310
nopw %cs:(%rax,%rax)