// File: zvrba[P]nonogram/main.cpp
// Function: main
int main(int argc, char** argv)
{
  try {
    if (argc != 2)
      throw std::runtime_error("input file argument missing");

    std::ifstream ifs(argv[1]);
    if (!ifs)
      throw std::runtime_error("cannot open file");
    
    Description d;
    if (!(ifs >> d))
      throw std::runtime_error("cannot parse input file");
    
    std::vector<Solver::Solution> solutions;
    Solver solver(d, solutions);
    solver.solve();
    
    cout << "FOUND " << solutions.size() << " SOLUTIONS\n";
    for(size_t i = 0; i < solutions.size(); ++i) {
      cout << "\n\nSOLUTION " << i << '\n';
      print_solution(solutions[i]);
    }
  } catch (std::exception& err) {
    std::cerr << "ERROR: " << err.what() << '\n';
    return 1;
  }
  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x340, %rsp            # imm = 0x340
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpl $0x2, -0x8(%rbp)
je 0x362b1
movl $0x10, %edi
callq 0x30e0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x2c8(%rbp)
leaq 0x22ca(%rip), %rsi      # 0x38527
callq 0x3090
jmp 0x36264
movq -0x2c8(%rbp), %rdi
movq 0x22d7e(%rip), %rsi     # 0x58ff0
movq 0x22d37(%rip), %rdx     # 0x58fb0
callq 0x32e0
jmp 0x366bf
movq -0x2c8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
callq 0x3160
jmp 0x36601
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
jmp 0x36601
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rsi
leaq -0x228(%rbp), %rdi
movl $0x8, %edx
callq 0x3320
jmp 0x362cc
movq -0x228(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x228(%rbp,%rax), %rdi
callq 0x30d0
movb %al, -0x2c9(%rbp)
jmp 0x362ec
movb -0x2c9(%rbp), %al
testb $0x1, %al
jne 0x362f8
jmp 0x3636a
movl $0x10, %edi
callq 0x30e0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x2d8(%rbp)
leaq 0x222d(%rip), %rsi      # 0x38543
callq 0x3090
jmp 0x3631d
movq -0x2d8(%rbp), %rdi
movq 0x22cc5(%rip), %rsi     # 0x58ff0
movq 0x22c7e(%rip), %rdx     # 0x58fb0
callq 0x32e0
jmp 0x366bf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
jmp 0x365f5
movq -0x2d8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
callq 0x3160
jmp 0x365f5
leaq -0x258(%rbp), %rdi
movq %rdi, -0x2e8(%rbp)
callq 0x79c0
movq -0x2e8(%rbp), %rsi
leaq -0x228(%rbp), %rdi
callq 0x3fe0
movq %rax, -0x2e0(%rbp)
jmp 0x36399
movq -0x2e0(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x30d0
movb %al, -0x2e9(%rbp)
jmp 0x363b7
movb -0x2e9(%rbp), %al
testb $0x1, %al
jne 0x363c3
jmp 0x36435
movl $0x10, %edi
callq 0x30e0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x2f8(%rbp)
leaq 0x2173(%rip), %rsi      # 0x38554
callq 0x3090
jmp 0x363e8
movq -0x2f8(%rbp), %rdi
movq 0x22bfa(%rip), %rsi     # 0x58ff0
movq 0x22bb3(%rip), %rdx     # 0x58fb0
callq 0x32e0
jmp 0x366bf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
jmp 0x365e9
movq -0x2f8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
callq 0x3160
jmp 0x365e9
leaq -0x270(%rbp), %rdi
movq %rdi, -0x300(%rbp)
callq 0x36810
movq -0x300(%rbp), %rdx
leaq -0x2b0(%rbp), %rdi
leaq -0x258(%rbp), %rsi
callq 0x36830
jmp 0x36464
leaq -0x2b0(%rbp), %rdi
callq 0x368c0
jmp 0x36472
movq 0x22b47(%rip), %rdi     # 0x58fc0
leaq 0x20ec(%rip), %rsi      # 0x3856c
callq 0x31b0
movq %rax, -0x308(%rbp)
jmp 0x3648e
leaq -0x270(%rbp), %rdi
callq 0x35cd0
movq -0x308(%rbp), %rdi
movq %rax, %rsi
callq 0x3040
movq %rax, -0x310(%rbp)
jmp 0x364b2
movq -0x310(%rbp), %rdi
leaq 0x20b3(%rip), %rsi      # 0x38573
callq 0x31b0
jmp 0x364c7
movq $0x0, -0x2b8(%rbp)
movq -0x2b8(%rbp), %rax
movq %rax, -0x318(%rbp)
leaq -0x270(%rbp), %rdi
callq 0x35cd0
movq %rax, %rcx
movq -0x318(%rbp), %rax
cmpq %rcx, %rax
jae 0x365a8
movq 0x22aba(%rip), %rdi     # 0x58fc0
leaq 0x2072(%rip), %rsi      # 0x3857f
callq 0x31b0
movq %rax, -0x320(%rbp)
jmp 0x3651b
movq -0x320(%rbp), %rdi
movq -0x2b8(%rbp), %rsi
callq 0x3040
movq %rax, -0x328(%rbp)
jmp 0x36537
movq -0x328(%rbp), %rdi
movl $0xa, %esi
callq 0x3200
jmp 0x3654a
movq -0x2b8(%rbp), %rsi
leaq -0x270(%rbp), %rdi
callq 0x368e0
movq %rax, %rdi
callq 0x366c0
jmp 0x36567
jmp 0x36569
movq -0x2b8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x2b8(%rbp)
jmp 0x364d2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
jmp 0x365dd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
leaq -0x2b0(%rbp), %rdi
callq 0x36900
jmp 0x365dd
leaq -0x2b0(%rbp), %rdi
callq 0x36900
leaq -0x270(%rbp), %rdi
callq 0x36930
leaq -0x258(%rbp), %rdi
callq 0x7bb0
leaq -0x228(%rbp), %rdi
callq 0x3050
jmp 0x3669b
leaq -0x270(%rbp), %rdi
callq 0x36930
leaq -0x258(%rbp), %rdi
callq 0x7bb0
leaq -0x228(%rbp), %rdi
callq 0x3050
movl -0x1c(%rbp), %eax
movl $0x1, %ecx
cmpl %ecx, %eax
jne 0x366ae
movq -0x18(%rbp), %rdi
callq 0x30b0
movq %rax, -0x2c0(%rbp)
movq 0x229c0(%rip), %rdi     # 0x58fe8
leaq 0x1f5c(%rip), %rsi      # 0x3858b
callq 0x31b0
movq %rax, -0x330(%rbp)
jmp 0x3663d
movq -0x2c0(%rbp), %rdi
movq (%rdi), %rax
movq 0x10(%rax), %rax
callq *%rax
movq -0x330(%rbp), %rdi
movq %rax, %rsi
callq 0x31b0
movq %rax, -0x338(%rbp)
jmp 0x36665
movq -0x338(%rbp), %rdi
movl $0xa, %esi
callq 0x3200
jmp 0x36678
movl $0x1, -0x4(%rbp)
callq 0x32a0
jmp 0x366a2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
callq 0x32a0
jmp 0x36699
jmp 0x366ae
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x340, %rsp            # imm = 0x340
popq %rbp
retq
movq -0x18(%rbp), %rdi
callq 0x32f0
movq %rax, %rdi
callq 0x8f50
nop