// File: /workspace/github_cpp_makefile_star2_O1/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, -0x48(%rbp)
movl %edi, %ebx
callq 0x20f0
movq %rax, %r14
movl $0x8, %eax
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)
movups %xmm0, -0x15a0(%rbp,%rax)
movups %xmm0, -0x15b0(%rbp,%rax)
movq $0x0, -0x1540(%rbp,%rax)
subq $-0x80, %rax
cmpq $0x1088, %rax           # imm = 0x1088
jne 0xc9d2
leaq -0x15b0(%rbp), %rdi
callq 0x61fc
movl $0x8, %eax
xorps %xmm0, %xmm0
movups %xmm0, -0x500(%rbp,%rax)
movups %xmm0, -0x510(%rbp,%rax)
movups %xmm0, -0x520(%rbp,%rax)
movups %xmm0, -0x530(%rbp,%rax)
movq $0x0, -0x4f0(%rbp,%rax)
addq $0x50, %rax
cmpq $0x378, %rax            # imm = 0x378
jne 0xca36
movq %r14, -0x30(%rbp)
leaq -0x530(%rbp), %rdi
callq 0x4440
xorl %eax, %eax
movl %eax, -0x1c0(%rbp,%rax,4)
incq %rax
cmpq $0x1e, %rax
jne 0xca80
cmpl $0x2, %ebx
jl 0xcca6
movl %ebx, %eax
movq %rax, -0x38(%rbp)
movl $0x1, %r14d
leaq 0x4294(%rip), %rax      # 0x10d40
addq $0x10, %rax
movq %rax, -0x40(%rbp)
leaq -0x70(%rbp), %rbx
leaq -0x140(%rbp), %r13
leaq -0xd8(%rbp), %r15
movq %r13, %r12
movq -0x48(%rbp), %rax
movq (%rax,%r14,8), %r13
movl $0x8, %edx
movq 0x44fb(%rip), %rdi      # 0x10fd8
leaq 0xb0c(%rip), %rsi       # 0xd5f0
callq 0x2180
testq %r13, %r13
je 0xcb0a
movq %r13, %rdi
callq 0x20a0
movq 0x44db(%rip), %rdi      # 0x10fd8
movq %r13, %rsi
movq %rax, %rdx
callq 0x2180
jmp 0xcb28
movq 0x44c7(%rip), %rcx      # 0x10fd8
movq (%rcx), %rax
movq -0x18(%rax), %rax
leaq (%rcx,%rax), %rdi
movl 0x20(%rcx,%rax), %esi
orl $0x1, %esi
callq 0x21e0
movq 0x44a9(%rip), %rcx      # 0x10fd8
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x2160
movsbl %al, %esi
movq 0x448b(%rip), %rdi      # 0x10fd8
callq 0x2040
movq %rax, %rdi
callq 0x2100
movw $0x100, -0xd0(%rbp)     # imm = 0x100
movq -0x40(%rbp), %rax
movq %rax, -0xd8(%rbp)
movw $0x1, -0x90(%rbp)
movq %rbx, %rdi
movq %r13, %rsi
movq %r12, %r13
movq %r12, %rdx
callq 0x2090
leaq -0x80(%rbp), %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x3752
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
je 0xcba9
callq 0x2150
leaq -0x50(%rbp), %rdi
movq %r15, %rsi
callq 0x2570
movl $0x64, (%rsp)
movq %r13, %rdi
movq %r15, %rsi
leaq -0x15b0(%rbp), %rdx
leaq -0x530(%rbp), %rcx
leaq -0x1c0(%rbp), %r8
movl $0x1e, %r9d
callq 0xa9bc
leaq -0x50(%rbp), %rdi
callq 0x257a
movq %r15, %rdi
callq 0x36aa
movl $0x6, %edx
leaq 0x9fa(%rip), %rsi       # 0xd5f9
testb %al, %al
jne 0xcc42
movq %r13, %rdi
callq 0xad6e
movl $0xe, %edx
leaq 0x9e9(%rip), %rsi       # 0xd600
testb %al, %al
jne 0xcc42
cmpb $0x0, -0xdc(%rbp)
leaq 0xa04(%rip), %rsi       # 0xd62d
leaq 0x9df(%rip), %rax       # 0xd60f
cmovneq %rax, %rsi
movl $0xa, %edx
movl $0x1d, %eax
cmovneq %rax, %rdx
movq 0x438f(%rip), %rdi      # 0x10fd8
callq 0x2180
movq 0x4383(%rip), %rcx      # 0x10fd8
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x2160
movsbl %al, %esi
movq 0x4365(%rip), %rdi      # 0x10fd8
callq 0x2040
movq %rax, %rdi
callq 0x2100
movq -0x100(%rbp), %rdi
testq %rdi, %rdi
je 0xcc91
callq 0x2150
movq %r15, %rdi
callq 0x2980
incq %r14
cmpq %r14, -0x38(%rbp)
jne 0xcac6
callq 0x20f0
movq %rax, %rbx
movq 0x4323(%rip), %rdi      # 0x10fd8
leaq 0x97c(%rip), %rsi       # 0xd638
movl $0xc, %edx
callq 0x2180
xorps %xmm0, %xmm0
cvtsi2ss %rbx, %xmm0
cvtsi2ssq -0x30(%rbp), %xmm1
subss %xmm1, %xmm0
divss 0x90c(%rip), %xmm0      # 0xd5ec
cvtss2sd %xmm0, %xmm0
movq 0x42ed(%rip), %rdi      # 0x10fd8
callq 0x21b0
movq %rax, %rbx
leaq 0x94b(%rip), %rsi       # 0xd645
movl $0x8, %edx
movq %rax, %rdi
callq 0x2180
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2160
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2100
movl $0x328, %ebx            # imm = 0x328
movq -0x500(%rbp,%rbx), %rdi
testq %rdi, %rdi
je 0xcd45
callq 0x2150
movq -0x518(%rbp,%rbx), %rdi
testq %rdi, %rdi
je 0xcd57
callq 0x2150
movq -0x530(%rbp,%rbx), %rdi
testq %rdi, %rdi
je 0xcd69
callq 0x2150
addq $-0x50, %rbx
cmpq $-0x48, %rbx
jne 0xcd33
movl $0x1008, %ebx           # imm = 0x1008
movq -0x1550(%rbp,%rbx), %rdi
testq %rdi, %rdi
je 0xcd8a
callq 0x2150
movq -0x1568(%rbp,%rbx), %rdi
testq %rdi, %rdi
je 0xcd9c
callq 0x2150
movq -0x1580(%rbp,%rbx), %rdi
testq %rdi, %rdi
je 0xcdae
callq 0x2150
movq -0x1598(%rbp,%rbx), %rdi
testq %rdi, %rdi
je 0xcdc0
callq 0x2150
movq -0x15b0(%rbp,%rbx), %rdi
testq %rdi, %rdi
je 0xcdd2
callq 0x2150
addq $-0x80, %rbx
cmpq $-0x78, %rbx
jne 0xcd78
xorl %eax, %eax
addq $0x1598, %rsp           # imm = 0x1598
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xce14
movq %rax, %rbx
jmp 0xce59
jmp 0xce14
jmp 0xce0f
movq %rax, %rbx
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
jne 0xce28
jmp 0xce2d
jmp 0xce0f
movq %rax, %rbx
jmp 0xce2d
movq %rax, %rbx
jmp 0xce39
movq %rax, %rbx
movq -0x100(%rbp), %rdi
testq %rdi, %rdi
je 0xce2d
callq 0x2150
leaq -0xd8(%rbp), %rdi
callq 0x2980
movl $0x320, %r14d           # imm = 0x320
leaq (%r14,%rbp), %rdi
addq $-0x530, %rdi           # imm = 0xFAD0
callq 0xceda
addq $-0x50, %r14
cmpq $-0x50, %r14
jne 0xce3f
movl $0x1000, %r14d          # imm = 0x1000
leaq (%r14,%rbp), %rdi
addq $-0x15b0, %rdi          # imm = 0xEA50
callq 0xce82
addq $-0x80, %r14
cmpq $-0x80, %r14
jne 0xce5f
movq %rbx, %rdi
callq 0x21f0
nop