// File: /workspace/github_cpp_makefile_star2_O2/davidjosepha[P]slitherlink/src/solver/main.cpp
// Function: main
int main(int argc, char * argv[]) {
    clock_t startTime, endTime;
    startTime = clock();

    Rule rules[NUM_RULES];
    initRules(rules);
    Contradiction contradictions[NUM_CONTRADICTIONS];
    initContradictions(contradictions);
    int selectedRules[NUM_RULES - NUM_CONST_RULES];
    for (int i = 0; i < NUM_RULES - NUM_CONST_RULES; i++) {
        selectedRules[i] = i;
    }

    for (int i = 1; i < argc; i++) {
        char * filename = argv[i];
        std::cout << "Puzzle: " << filename << std::endl;

        Grid grid;
        Import importer = Import(grid, filename);
        Export exporter = Export(grid);

        Solver solver = Solver(grid, rules, contradictions, selectedRules, NUM_RULES - NUM_CONST_RULES, 100);

        exporter.print();

        if (grid.isSolved()) {
            std::cout << "Solved" << std::endl;
        } else {
            if (solver.testContradictions()) {
                std::cout << "Invalid puzzle" << std::endl;
            } else if (solver.hasMultipleSolutions()) {
                std::cout << "Puzzle has multiple solutions" << std::endl;
            } else {
                std::cout << "Not solved" << std::endl;
            }
        }
    }

    endTime = clock();
    float diff = ((float)endTime - (float)startTime) / CLOCKS_PER_SEC;
    std::cout << "Total time:\t" << diff << " seconds" << std::endl;

    return EXIT_SUCCESS;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1598, %rsp           # imm = 0x1598
movq %rsi, -0x40(%rbp)
movl %edi, %ebx
callq 0x2100
movq %rax, %r14
pushq $0x8
popq %rax
xorps %xmm0, %xmm0
movups %xmm0, -0x1550(%rbp,%rax)
movups %xmm0, -0x1560(%rbp,%rax)
movups %xmm0, -0x1570(%rbp,%rax)
movups %xmm0, -0x1580(%rbp,%rax)
movups %xmm0, -0x1590(%rbp,%rax)
andq $0x0, -0x1540(%rbp,%rax)
movups %xmm0, -0x15a0(%rbp,%rax)
movups %xmm0, -0x15b0(%rbp,%rax)
subq $-0x80, %rax
cmpq $0x1088, %rax           # imm = 0x1088
jne 0x7f3c
leaq -0x15b0(%rbp), %rdi
callq 0x50bc
pushq $0x8
popq %rax
xorps %xmm0, %xmm0
movups %xmm0, -0x500(%rbp,%rax)
movups %xmm0, -0x510(%rbp,%rax)
andq $0x0, -0x4f0(%rbp,%rax)
movups %xmm0, -0x520(%rbp,%rax)
movups %xmm0, -0x530(%rbp,%rax)
addq $0x50, %rax
cmpq $0x378, %rax            # imm = 0x378
jne 0x7f9b
leaq -0x530(%rbp), %rdi
callq 0x3cd4
xorl %eax, %eax
cmpq $0x1e, %rax
je 0x7ff0
movl %eax, -0x1c0(%rbp,%rax,4)
incq %rax
jmp 0x7fde
movq %r14, -0x30(%rbp)
movslq %ebx, %rax
movq %rax, -0x48(%rbp)
pushq $0x1
popq %r14
leaq 0x4d3a(%rip), %rax      # 0xcd40
addq $0x10, %rax
movq %rax, -0x38(%rbp)
leaq -0x70(%rbp), %rbx
leaq -0x140(%rbp), %r13
leaq -0x50(%rbp), %r15
cmpq -0x48(%rbp), %r14
jge 0x8150
movq -0x40(%rbp), %rax
movq (%rax,%r14,8), %r12
movq 0x4fa2(%rip), %rdi      # 0xcfd8
leaq 0x158b(%rip), %rsi      # 0x95c8
callq 0x2150
movq %rax, %rdi
movq %r12, %rsi
callq 0x2150
movq %rax, %rdi
callq 0x20b0
movw $0x100, -0x138(%rbp)    # imm = 0x100
movq -0x38(%rbp), %rax
movq %rax, -0x140(%rbp)
movw $0x1, -0xf8(%rbp)
movq %rbx, %rdi
movq %r12, %rsi
leaq -0xe8(%rbp), %rdx
callq 0x2090
leaq -0x80(%rbp), %rdi
movq %r13, %rsi
movq %rbx, %rdx
callq 0x323e
movq %rbx, %rdi
callq 0x20a0
movq %r15, %rdi
movq %r13, %rsi
callq 0x24a4
movl $0x64, (%rsp)
leaq -0xe8(%rbp), %rdi
movq %r13, %rsi
leaq -0x15b0(%rbp), %rdx
leaq -0x530(%rbp), %rcx
leaq -0x1c0(%rbp), %r8
pushq $0x1e
popq %r9
callq 0x61cc
movq %r15, %rdi
callq 0x24ae
movq %r13, %rdi
callq 0x31d0
leaq 0x14e5(%rip), %rsi      # 0x95d1
testb %al, %al
jne 0x8120
leaq -0xe8(%rbp), %rdi
callq 0x650a
leaq 0x14d5(%rip), %rsi      # 0x95d8
testb %al, %al
jne 0x8120
cmpb $0x0, -0x84(%rbp)
leaq 0x14f0(%rip), %rsi      # 0x9605
leaq 0x14cb(%rip), %rax      # 0x95e7
cmovneq %rax, %rsi
movq 0x4eb1(%rip), %rdi      # 0xcfd8
callq 0x2150
movq %rax, %rdi
callq 0x20b0
leaq -0xa8(%rbp), %rdi
callq 0x4a9a
movq %r13, %rdi
callq 0x26a0
incq %r14
jmp 0x801d
callq 0x2100
movq %rax, %rbx
movq 0x4e79(%rip), %rdi      # 0xcfd8
leaq 0x14aa(%rip), %rsi      # 0x9610
callq 0x2150
cvtsi2ss %rbx, %xmm0
cvtsi2ssq -0x30(%rbp), %xmm1
subss %xmm1, %xmm0
divss 0x1442(%rip), %xmm0     # 0x95c4
movq %rax, %rdi
callq 0x2110
leaq 0x148c(%rip), %rsi      # 0x961d
movq %rax, %rdi
callq 0x2150
movq %rax, %rdi
callq 0x20b0
movl $0x320, %ebx            # imm = 0x320
leaq (%rbx,%rbp), %rdi
addq $-0x530, %rdi           # imm = 0xFAD0
callq 0x4160
addq $-0x50, %rbx
cmpq $-0x50, %rbx
jne 0x81a6
movl $0x1000, %ebx           # imm = 0x1000
leaq (%rbx,%rbp), %rdi
addq $-0x15b0, %rdi          # imm = 0xEA50
callq 0x60ce
addq $-0x80, %rbx
cmpq $-0x80, %rbx
jne 0x81c5
xorl %eax, %eax
addq $0x1598, %rsp           # imm = 0x1598
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x8213
movq %rax, %rbx
jmp 0x8253
jmp 0x8213
jmp 0x8200
jmp 0x8200
movq %rax, %rbx
jmp 0x8227
movq %rax, %rbx
leaq -0x70(%rbp), %rdi
callq 0x20a0
jmp 0x8227
movq %rax, %rbx
jmp 0x8233
movq %rax, %rbx
leaq -0xa8(%rbp), %rdi
callq 0x4a9a
leaq -0x140(%rbp), %rdi
callq 0x26a0
movl $0x320, %r14d           # imm = 0x320
leaq (%r14,%rbp), %rdi
addq $-0x530, %rdi           # imm = 0xFAD0
callq 0x4160
addq $-0x50, %r14
cmpq $-0x50, %r14
jne 0x8239
movl $0x1000, %r14d          # imm = 0x1000
leaq (%r14,%rbp), %rdi
addq $-0x15b0, %rdi          # imm = 0xEA50
callq 0x60ce
addq $-0x80, %r14
cmpq $-0x80, %r14
jne 0x8259
movq %rbx, %rdi
callq 0x21d0