// File: /workspace/github_cpp_makefile_star2_O1/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 0x3c46
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 0x412e
movq (%rbx), %rdi
callq 0x2dd8
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 0x3a19
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 0x3fde
incl %r15d
movq %rbx, %rdi
movl %r15d, %esi
movq %r13, %rdx
callq 0x3e8e
movq -0xb0(%rbp), %rdi
cmpq %r12, %rdi
je 0x3a13
callq 0x2180
cmpl -0x2c(%rbp), %r15d
jl 0x39b0
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 0x3ac8
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 0x3fde
leal 0x2(%r15), %esi
movq %rbx, %rdi
movq %r12, %rdx
callq 0x3eee
movq -0x90(%rbp), %rdi
cmpq %r13, %rdi
je 0x3abf
callq 0x2180
incl %r15d
cmpl -0x2c(%rbp), %r15d
jl 0x3a5e
cmpl $-0x1, -0x30(%rbp)
jl 0x3b05
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 0x3ad4
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 0x3b73
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 0x3b3c
cmpl $-0x1, -0x2c(%rbp)
jl 0x3bb2
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)
cmpl -0x2c(%rbp), %r15d
jle 0x3b7f
cmpl $0x0, -0x2c(%rbp)
jle 0x3c34
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 0x3fde
incl %r15d
movq %rbx, %rdi
movl %r15d, %esi
movq %r13, %rdx
callq 0x3f78
movq -0x70(%rbp), %rdi
cmpq %r14, %rdi
je 0x3c2e
callq 0x2180
cmpl -0x2c(%rbp), %r15d
jl 0x3bc7
leaq -0x2b8(%rbp), %rdi
callq 0x2050
leaq -0x40(%rbp), %r15
jmp 0x3c5e
movq 0xf38b(%rip), %rdi      # 0x12fd8
leaq 0xb532(%rip), %rsi      # 0xf186
movl $0x14, %edx
callq 0x21c0
leaq -0x2b8(%rbp), %rdi
callq 0x2070
movq -0x50(%rbp), %rdi
cmpq %r15, %rdi
je 0x3c78
callq 0x2180
addq $0x298, %rsp            # imm = 0x298
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x3ce8
movq %rax, %rbx
jmp 0x3cdc
jmp 0x3cd5
movq %rax, %rbx
movq -0x70(%rbp), %rdi
cmpq %r14, %rdi
jne 0x3cc4
jmp 0x3cd8
movq %rax, %rbx
movq -0x90(%rbp), %rdi
cmpq %r13, %rdi
jne 0x3cc4
jmp 0x3cd8
movq %rax, %rbx
movq -0xb0(%rbp), %rdi
cmpq %r12, %rdi
je 0x3cd8
callq 0x2180
jmp 0x3cd8
jmp 0x3cd5
jmp 0x3cd5
jmp 0x3cd5
jmp 0x3cd5
jmp 0x3cd5
movq %rax, %rbx
leaq -0x40(%rbp), %r15
leaq -0x2b8(%rbp), %rdi
callq 0x2070
movq -0x50(%rbp), %rdi
cmpq %r15, %rdi
je 0x3cf6
callq 0x2180
movq %rbx, %rdi
callq 0x2260