// File: /workspace/github_cpp_makefile_star2_O3/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 0xca12
leaq -0x15b0(%rbp), %rdi
callq 0x6218
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 0xca76
movq %r14, -0x30(%rbp)
leaq -0x530(%rbp), %rdi
callq 0x4448
xorl %eax, %eax
movl %eax, -0x1c0(%rbp,%rax,4)
incq %rax
cmpq $0x1e, %rax
jne 0xcac0
cmpl $0x2, %ebx
jl 0xcce6
movl %ebx, %eax
movq %rax, -0x38(%rbp)
movl $0x1, %r14d
leaq 0x4254(%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 0x44bb(%rip), %rdi      # 0x10fd8
leaq 0xaec(%rip), %rsi       # 0xd610
callq 0x2180
testq %r13, %r13
je 0xcb4a
movq %r13, %rdi
callq 0x20a0
movq 0x449b(%rip), %rdi      # 0x10fd8
movq %r13, %rsi
movq %rax, %rdx
callq 0x2180
jmp 0xcb68
movq 0x4487(%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 0x4469(%rip), %rcx      # 0x10fd8
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x2160
movsbl %al, %esi
movq 0x444b(%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 0x3766
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
je 0xcbe9
callq 0x2150
leaq -0x50(%rbp), %rdi
movq %r15, %rsi
callq 0x2584
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 0xa9d8
leaq -0x50(%rbp), %rdi
callq 0x258e
movq %r15, %rdi
callq 0x36e2
movl $0x6, %edx
leaq 0x9da(%rip), %rsi       # 0xd619
testb %al, %al
jne 0xcc82
movq %r13, %rdi
callq 0xad68
movl $0xe, %edx
leaq 0x9c9(%rip), %rsi       # 0xd620
testb %al, %al
jne 0xcc82
cmpb $0x0, -0xdc(%rbp)
leaq 0x9e4(%rip), %rsi       # 0xd64d
leaq 0x9bf(%rip), %rax       # 0xd62f
cmovneq %rax, %rsi
movl $0xa, %edx
movl $0x1d, %eax
cmovneq %rax, %rdx
movq 0x434f(%rip), %rdi      # 0x10fd8
callq 0x2180
movq 0x4343(%rip), %rcx      # 0x10fd8
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x2160
movsbl %al, %esi
movq 0x4325(%rip), %rdi      # 0x10fd8
callq 0x2040
movq %rax, %rdi
callq 0x2100
movq -0x100(%rbp), %rdi
testq %rdi, %rdi
je 0xccd1
callq 0x2150
movq %r15, %rdi
callq 0x2994
incq %r14
cmpq %r14, -0x38(%rbp)
jne 0xcb06
callq 0x20f0
movq %rax, %rbx
movq 0x42e3(%rip), %rdi      # 0x10fd8
leaq 0x95c(%rip), %rsi       # 0xd658
movl $0xc, %edx
callq 0x2180
xorps %xmm0, %xmm0
cvtsi2ss %rbx, %xmm0
cvtsi2ssq -0x30(%rbp), %xmm1
subss %xmm1, %xmm0
divss 0x8ec(%rip), %xmm0      # 0xd60c
cvtss2sd %xmm0, %xmm0
movq 0x42ad(%rip), %rdi      # 0x10fd8
callq 0x21b0
movq %rax, %rbx
leaq 0x92b(%rip), %rsi       # 0xd665
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 0xcd85
callq 0x2150
movq -0x518(%rbp,%rbx), %rdi
testq %rdi, %rdi
je 0xcd97
callq 0x2150
movq -0x530(%rbp,%rbx), %rdi
testq %rdi, %rdi
je 0xcda9
callq 0x2150
addq $-0x50, %rbx
cmpq $-0x48, %rbx
jne 0xcd73
movl $0x1008, %ebx           # imm = 0x1008
movq -0x1550(%rbp,%rbx), %rdi
testq %rdi, %rdi
je 0xcdca
callq 0x2150
movq -0x1568(%rbp,%rbx), %rdi
testq %rdi, %rdi
je 0xcddc
callq 0x2150
movq -0x1580(%rbp,%rbx), %rdi
testq %rdi, %rdi
je 0xcdee
callq 0x2150
movq -0x1598(%rbp,%rbx), %rdi
testq %rdi, %rdi
je 0xce00
callq 0x2150
movq -0x15b0(%rbp,%rbx), %rdi
testq %rdi, %rdi
je 0xce12
callq 0x2150
addq $-0x80, %rbx
cmpq $-0x78, %rbx
jne 0xcdb8
xorl %eax, %eax
addq $0x1598, %rsp           # imm = 0x1598
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xce54
movq %rax, %rbx
jmp 0xce99
jmp 0xce54
jmp 0xce4f
movq %rax, %rbx
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
jne 0xce68
jmp 0xce6d
jmp 0xce4f
movq %rax, %rbx
jmp 0xce6d
movq %rax, %rbx
jmp 0xce79
movq %rax, %rbx
movq -0x100(%rbp), %rdi
testq %rdi, %rdi
je 0xce6d
callq 0x2150
leaq -0xd8(%rbp), %rdi
callq 0x2994
movl $0x320, %r14d           # imm = 0x320
leaq (%r14,%rbp), %rdi
addq $-0x530, %rdi           # imm = 0xFAD0
callq 0xcf1a
addq $-0x50, %r14
cmpq $-0x50, %r14
jne 0xce7f
movl $0x1000, %r14d          # imm = 0x1000
leaq (%r14,%rbp), %rdi
addq $-0x15b0, %rdi          # imm = 0xEA50
callq 0xcec2
addq $-0x80, %r14
cmpq $-0x80, %r14
jne 0xce9f
movq %rbx, %rdi
callq 0x21f0
nop