// File: dnegovan[P]Intruder-On-Donnar-V/dansLibrary.cpp
// Function: printFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, double)
void printFile(std::string fileName, std::string color, double seconds)
{
    //open file
    std::ifstream stream(fileName, std::ios::in);

    //keep a character count, newline if we hit the line width global const
    int counter = 0;

    std::cout << color;
    std::string contents;

    //grab each line
    while(getline(stream, contents))
    {
        if (contents.empty())
        {
            counter = 0;
        }
        std::string temp;
        std::stringstream ss;

        //put each line into stream
        ss << contents;
        while (!ss.eof())
        {
            //put each word into string
            ss >> temp;
            counter += temp.size();
            if (counter < LINE_WIDTH)
            {
                std::cout << temp;
            }
            if (counter >= LINE_WIDTH)
            {
                //wait given seconds to print next line
                wait(seconds);
                std::cout << "\n" << temp;
                counter = 0;
                counter += temp.size();
            }
            //put the space back in
            std::cout << " ";
        }

        ss.clear();
        //wait a bit between lines
        wait(seconds/2);
        std::cout << "\n";
        counter = 0;
    }

    // a bit at the end for drama!
    wait(seconds);

    std::cout << RESET;
    stream.close();

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x420, %rsp            # imm = 0x420
movq %rsi, %rax
movq %rdi, %rsi
movq %rax, -0x408(%rbp)
movq %rsi, -0x8(%rbp)
movq %rax, -0x10(%rbp)
movsd %xmm0, -0x18(%rbp)
leaq -0x220(%rbp), %rdi
movl $0x8, %edx
callq 0x3370
movq -0x408(%rbp), %rsi
movl $0x0, -0x224(%rbp)
movq 0x10a2a(%rip), %rdi     # 0x28fc8
callq 0x31e0
jmp 0x185a5
leaq -0x258(%rbp), %rdi
callq 0x3300
leaq -0x220(%rbp), %rdi
leaq -0x258(%rbp), %rsi
callq 0x3050
movq %rax, -0x410(%rbp)
jmp 0x185cd
movq -0x410(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x3280
movb %al, -0x411(%rbp)
jmp 0x185eb
movb -0x411(%rbp), %al
testb $0x1, %al
jne 0x185fa
jmp 0x1883d
leaq -0x258(%rbp), %rdi
callq 0x3390
testb $0x1, %al
jne 0x1860c
jmp 0x18646
movl $0x0, -0x224(%rbp)
jmp 0x18646
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x230(%rbp)
movl %eax, -0x234(%rbp)
jmp 0x18899
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x230(%rbp)
movl %eax, -0x234(%rbp)
jmp 0x1888d
leaq -0x278(%rbp), %rdi
callq 0x3300
leaq -0x400(%rbp), %rdi
callq 0x3180
jmp 0x18660
leaq -0x3f0(%rbp), %rdi
leaq -0x258(%rbp), %rsi
callq 0x31e0
jmp 0x18675
jmp 0x18677
movq -0x400(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x400(%rbp,%rax), %rdi
callq 0x33f0
movb %al, -0x412(%rbp)
jmp 0x18697
movb -0x412(%rbp), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x186a8
jmp 0x187bf
leaq -0x400(%rbp), %rdi
leaq -0x278(%rbp), %rsi
callq 0x3290
jmp 0x186bd
leaq -0x278(%rbp), %rdi
callq 0x3170
movq %rax, %rcx
movslq -0x224(%rbp), %rax
addq %rcx, %rax
movl %eax, -0x224(%rbp)
cmpl $0x3a, -0x224(%rbp)
jge 0x18736
movq 0x108dc(%rip), %rdi     # 0x28fc8
leaq -0x278(%rbp), %rsi
callq 0x31e0
jmp 0x186fa
jmp 0x18736
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x230(%rbp)
movl %eax, -0x234(%rbp)
jmp 0x1882f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x230(%rbp)
movl %eax, -0x234(%rbp)
leaq -0x400(%rbp), %rdi
callq 0x3190
jmp 0x1882f
cmpl $0x3a, -0x224(%rbp)
jl 0x187a5
movsd -0x18(%rbp), %xmm0
callq 0x188c0
jmp 0x1874b
movq 0x10876(%rip), %rdi     # 0x28fc8
leaq 0x71eb(%rip), %rsi      # 0x1f944
callq 0x3210
movq %rax, -0x420(%rbp)
jmp 0x18767
movq -0x420(%rbp), %rdi
leaq -0x278(%rbp), %rsi
callq 0x31e0
jmp 0x1877c
movl $0x0, -0x224(%rbp)
leaq -0x278(%rbp), %rdi
callq 0x3170
movq %rax, %rcx
movslq -0x224(%rbp), %rax
addq %rcx, %rax
movl %eax, -0x224(%rbp)
movq 0x1081c(%rip), %rdi     # 0x28fc8
leaq 0x78a4(%rip), %rsi      # 0x20057
callq 0x3210
jmp 0x187ba
jmp 0x18677
movq -0x400(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x400(%rbp,%rax), %rdi
xorl %esi, %esi
callq 0x33a0
jmp 0x187db
movsd -0x18(%rbp), %xmm0
movsd 0x6ca8(%rip), %xmm1     # 0x1f490
mulsd %xmm1, %xmm0
callq 0x188c0
jmp 0x187f3
movq 0x107ce(%rip), %rdi     # 0x28fc8
leaq 0x7143(%rip), %rsi      # 0x1f944
callq 0x3210
jmp 0x18808
movl $0x0, -0x224(%rbp)
leaq -0x400(%rbp), %rdi
callq 0x3190
leaq -0x278(%rbp), %rdi
callq 0x3448
jmp 0x185b1
leaq -0x278(%rbp), %rdi
callq 0x3448
jmp 0x1888d
movsd -0x18(%rbp), %xmm0
callq 0x188c0
jmp 0x18849
movq 0x10778(%rip), %rdi     # 0x28fc8
leaq 0x687c(%rip), %rsi      # 0x1f0d3
callq 0x3210
jmp 0x1885e
leaq -0x220(%rbp), %rdi
callq 0x3060
jmp 0x1886c
leaq -0x258(%rbp), %rdi
callq 0x3448
leaq -0x220(%rbp), %rdi
callq 0x3090
addq $0x420, %rsp            # imm = 0x420
popq %rbp
retq
leaq -0x258(%rbp), %rdi
callq 0x3448
leaq -0x220(%rbp), %rdi
callq 0x3090
movq -0x230(%rbp), %rdi
callq 0x33c0
nopw %cs:(%rax,%rax)