// File: /workspace/github_cpp_makefile_star2_O3/davidjosepha[P]slitherlink/src/shared/import.cpp
// Function: Import::buildLattice(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void Import::buildLattice(std::string filename) {
    std::string buffer;
    std::ifstream slkfile(filename);

    if (slkfile.is_open()) {

        /* source info */
        std::getline(slkfile, buffer);

        /* get dimensions */
        int m, n;
        slkfile >> m;
        slkfile >> n;
        lattice_->initArrays(m+2, n+2);
        lattice_->initUpdateMatrix();

        /* blank lines */
        std::getline(slkfile, buffer);
        std::getline(slkfile, buffer);

        /* numbers */
        for (int i = 0; i < m; i++) {
            std::getline(slkfile, buffer);
            importNumberRow(i+1, buffer);
        }

        /* blank line */
        std::getline(slkfile, buffer);

        /* horizontal lines */
        for (int i = 0; i < m+1; i++) {
            std::getline(slkfile, buffer);
            importHLineRow(i+1, buffer);
        }
        for (int j = 0; j < n+2; j++) {
            lattice_->setHLine(0, j, NLINE);
            lattice_->setHLine(m+2, j, NLINE);
        }

        /* blank line */
        std::getline(slkfile, buffer);

        /* vertical lines */
        for (int j = 0; j < n+3; j++) {
            lattice_->setVLine(0, j, NLINE);
            lattice_->setVLine(m+1, j, NLINE);
        }
        for (int i = 0; i < m+2; i++) {
            lattice_->setVLine(i, 0, NLINE);
            lattice_->setVLine(i, n+2, NLINE);
        }

        for (int i = 0; i < m; i++) {
            std::getline(slkfile, buffer);
            importVLineRow(i+1, buffer);
        }
        slkfile.close();
    } else {
        std::cout << "Unable to open file\n";
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x298, %rsp            # imm = 0x298
movq %rdi, %rbx
leaq -0x40(%rbp), %r15
movq %r15, -0x10(%r15)
movq $0x0, -0x8(%r15)
movb $0x0, (%r15)
leaq -0x2b8(%rbp), %r14
movq %r14, %rdi
movl $0x8, %edx
callq 0x2230
leaq -0x240(%rbp), %rdi
callq 0x2060
testb %al, %al
je 0x3c5e
movq -0x2b8(%rbp), %rax
addq -0x18(%rax), %r14
movq %r14, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %edx
leaq -0x2b8(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x2280
leaq -0x2b8(%rbp), %rdi
leaq -0x2c(%rbp), %rsi
callq 0x20f0
leaq -0x2b8(%rbp), %r14
leaq -0x30(%rbp), %rsi
movq %r14, %rdi
callq 0x20f0
movq (%rbx), %rdi
movl -0x2c(%rbp), %esi
addl $0x2, %esi
movl -0x30(%rbp), %edx
addl $0x2, %edx
callq 0x414a
movq (%rbx), %rdi
callq 0x2e0c
movq -0x2b8(%rbp), %rax
addq -0x18(%rax), %r14
movq %r14, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %edx
leaq -0x2b8(%rbp), %r14
leaq -0x50(%rbp), %rsi
movq %r14, %rdi
callq 0x2280
movq -0x2b8(%rbp), %rax
addq -0x18(%rax), %r14
movq %r14, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %edx
leaq -0x2b8(%rbp), %r14
leaq -0x50(%rbp), %rsi
movq %r14, %rdi
callq 0x2280
cmpl $0x0, -0x2c(%rbp)
jle 0x3a2d
xorl %r15d, %r15d
leaq -0xa0(%rbp), %r12
leaq -0xb0(%rbp), %r13
movq -0x2b8(%rbp), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %edx
movq %r14, %rdi
leaq -0x50(%rbp), %rsi
callq 0x2280
movq %r12, -0xb0(%rbp)
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rdx
addq %rsi, %rdx
movq %r13, %rdi
callq 0x3ff6
incl %r15d
movq %rbx, %rdi
movl %r15d, %esi
movq %r13, %rdx
callq 0x3ea2
movq -0xb0(%rbp), %rdi
cmpq %r12, %rdi
je 0x3a27
callq 0x2180
cmpl -0x2c(%rbp), %r15d
jl 0x39c4
movq -0x2b8(%rbp), %rax
addq -0x18(%rax), %r14
movq %r14, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %edx
leaq -0x2b8(%rbp), %r14
leaq -0x50(%rbp), %rsi
movq %r14, %rdi
callq 0x2280
cmpl $0x0, -0x2c(%rbp)
js 0x3adc
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
leaq -0x80(%rbp), %r13
leaq -0x90(%rbp), %r12
movq -0x2b8(%rbp), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %edx
movq %r14, %rdi
leaq -0x50(%rbp), %rsi
callq 0x2280
movq %r13, -0x90(%rbp)
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rdx
addq %rsi, %rdx
movq %r12, %rdi
callq 0x3ff6
leal 0x2(%r15), %esi
movq %rbx, %rdi
movq %r12, %rdx
callq 0x3f02
movq -0x90(%rbp), %rdi
cmpq %r13, %rdi
je 0x3ad3
callq 0x2180
incl %r15d
cmpl -0x2c(%rbp), %r15d
jl 0x3a72
cmpl $-0x1, -0x30(%rbp)
jl 0x3b19
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
incl %r15d
movq (%rbx), %rdi
movq (%rdi), %rax
xorl %esi, %esi
movl %r15d, %edx
movl $0x2, %ecx
callq *(%rax)
movq (%rbx), %rdi
movl -0x2c(%rbp), %esi
addl $0x2, %esi
movq (%rdi), %rax
movl %r15d, %edx
movl $0x2, %ecx
callq *(%rax)
cmpl -0x30(%rbp), %r15d
jle 0x3ae8
movq -0x2b8(%rbp), %rax
addq -0x18(%rax), %r14
movq %r14, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %edx
leaq -0x2b8(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x2280
cmpl $-0x2, -0x30(%rbp)
jl 0x3b87
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
incl %r15d
movq (%rbx), %rdi
movq (%rdi), %rax
xorl %esi, %esi
movl %r15d, %edx
movl $0x2, %ecx
callq *0x8(%rax)
movq (%rbx), %rdi
movl -0x2c(%rbp), %esi
incl %esi
movq (%rdi), %rax
movl %r15d, %edx
movl $0x2, %ecx
callq *0x8(%rax)
movl -0x30(%rbp), %eax
addl $0x2, %eax
cmpl %eax, %r15d
jl 0x3b50
cmpl $-0x1, -0x2c(%rbp)
jl 0x3c4c
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
incl %r15d
movq (%rbx), %rdi
movq (%rdi), %rax
movl %r15d, %esi
xorl %edx, %edx
movl $0x2, %ecx
callq *0x8(%rax)
movq (%rbx), %rdi
movl -0x30(%rbp), %edx
addl $0x2, %edx
movq (%rdi), %rax
movl %r15d, %esi
movl $0x2, %ecx
callq *0x8(%rax)
movl -0x2c(%rbp), %eax
cmpl %eax, %r15d
jle 0x3b97
testl %eax, %eax
jle 0x3c4c
xorl %r15d, %r15d
leaq -0x60(%rbp), %r14
leaq -0x50(%rbp), %r12
leaq -0x70(%rbp), %r13
movq -0x2b8(%rbp), %rax
movq -0x18(%rax), %rdi
leaq -0x2b8(%rbp), %rax
addq %rax, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %edx
leaq -0x2b8(%rbp), %rdi
movq %r12, %rsi
callq 0x2280
movq %r14, -0x70(%rbp)
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rdx
addq %rsi, %rdx
movq %r13, %rdi
callq 0x3ff6
incl %r15d
movq %rbx, %rdi
movl %r15d, %esi
movq %r13, %rdx
callq 0x3f90
movq -0x70(%rbp), %rdi
cmpq %r14, %rdi
je 0x3c46
callq 0x2180
cmpl -0x2c(%rbp), %r15d
jl 0x3bdf
leaq -0x2b8(%rbp), %rdi
callq 0x2050
leaq -0x40(%rbp), %r15
jmp 0x3c76
movq 0xf373(%rip), %rdi      # 0x12fd8
leaq 0xb51a(%rip), %rsi      # 0xf186
movl $0x14, %edx
callq 0x21c0
leaq -0x2b8(%rbp), %rdi
callq 0x2070
movq -0x50(%rbp), %rdi
cmpq %r15, %rdi
je 0x3c90
callq 0x2180
addq $0x298, %rsp            # imm = 0x298
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x3d00
movq %rax, %rbx
jmp 0x3cf4
movq %rax, %rbx
movq -0x70(%rbp), %rdi
cmpq %r14, %rdi
jne 0x3cdc
jmp 0x3cf0
jmp 0x3ced
movq %rax, %rbx
movq -0x90(%rbp), %rdi
cmpq %r13, %rdi
jne 0x3cdc
jmp 0x3cf0
movq %rax, %rbx
movq -0xb0(%rbp), %rdi
cmpq %r12, %rdi
je 0x3cf0
callq 0x2180
jmp 0x3cf0
jmp 0x3ced
jmp 0x3ced
jmp 0x3ced
jmp 0x3ced
jmp 0x3ced
movq %rax, %rbx
leaq -0x40(%rbp), %r15
leaq -0x2b8(%rbp), %rdi
callq 0x2070
movq -0x50(%rbp), %rdi
cmpq %r15, %rdi
je 0x3d0e
callq 0x2180
movq %rbx, %rdi
callq 0x2260