// File: /workspace/github_cpp_makefile_star2_O3/aaronshim[P]SATurday/main.cpp
// Function: main
int main(int argc, char **argv) {
  if (argc != 2) {
    cerr << "usage: saturday <filename>" << endl;
    return 1;
  }

  // Get file pointer for <filename>.
  char *fname = argv[1];
  FILE *file = Parser::open(fname);
  if (file == NULL) {
    cerr << "File '" << fname << "' failed to open!" << endl;
    return 1;
  }

  // Parse the file.
  Formula *formula = Parser::parse(file);
  fclose(file);

  if (DEBUG >= 5)
    cout << formula->toString();

  // // model testing code
  // Model *testModel = new Model(5);
  // testModel->setVar(1);
  // testModel->setVar(2);
  // testModel->clearVar(2);
  // cout << testModel->toString() << endl;

  Model *model = Solver::solve(formula);

  if (model == NULL) {
    cout << "s UNSATISFIABLE" << endl;
  } else {
    cout << "s SATISFIABLE" << endl;
    cout << "v " << model->toString() << endl;
  }

  return 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x20, %rsp
cmpl $0x2, %edi
jne 0x33f4
movq 0x8(%rsi), %r14
leaq 0xd3f(%rip), %rsi       # 0x4037
movq %r14, %rdi
callq 0x2190
testq %rax, %rax
je 0x340c
movq %rax, %rbx
movq %rax, %rdi
callq 0x2f48
movq %rax, %r14
movq %rbx, %rdi
callq 0x2150
movq %r14, %rdi
callq 0x3092
testq %rax, %rax
je 0x3448
movq %rax, %rbx
movq 0x2c96(%rip), %r14      # 0x5fd0
leaq 0xd3c(%rip), %rsi       # 0x407d
movl $0xd, %edx
movq %r14, %rdi
callq 0x2180
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2130
movsbl %al, %esi
movq %r14, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20e0
leaq 0xd0f(%rip), %rsi       # 0x408b
movl $0x2, %edx
movq %r14, %rdi
callq 0x2180
movq %rsp, %r15
movq %r15, %rdi
movq %rbx, %rsi
callq 0x24d8
movq (%r15), %rsi
movq 0x8(%r15), %rdx
movq %r14, %rdi
callq 0x2180
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2130
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20e0
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x348a
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x2170
jmp 0x348a
movq 0x2bf5(%rip), %rbx      # 0x5ff0
leaq 0xc37(%rip), %rsi       # 0x4039
movl $0x1a, %edx
jmp 0x34b1
movq 0x2bdd(%rip), %rbx      # 0x5ff0
leaq 0xc3a(%rip), %rsi       # 0x4054
movl $0x6, %edx
movq %rbx, %rdi
callq 0x2180
testq %r14, %r14
je 0x348e
movq %r14, %rdi
callq 0x2080
movq 0x2bb5(%rip), %rdi      # 0x5ff0
movq %r14, %rsi
movq %rax, %rdx
callq 0x2180
jmp 0x34a5
movq 0x2b81(%rip), %rbx      # 0x5fd0
leaq 0xc17(%rip), %rsi       # 0x406d
movl $0xf, %edx
movq %rbx, %rdi
callq 0x2180
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2130
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20e0
xorl %eax, %eax
jmp 0x34e5
movq (%rbx), %rax
movq -0x18(%rax), %rax
leaq (%rbx,%rax), %rdi
movl 0x20(%rbx,%rax), %esi
orl $0x1, %esi
callq 0x21e0
leaq 0xbaf(%rip), %rsi       # 0x405b
movl $0x11, %edx
movq %rbx, %rdi
callq 0x2180
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2130
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20e0
movl $0x1, %eax
addq $0x20, %rsp
popq %rbx
popq %r14
popq %r15
retq
movq %rax, %rbx
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x350d
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x2170
movq %rbx, %rdi
callq 0x2210
nop