// File: panosfoto[P]NGramGraphParallel/src/StringSplitter.cpp
// Function: StringSplitter::splitPayloadToAtoms(Payload<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>*)
vector<Atom<std::string>> StringSplitter::splitPayloadToAtoms(Payload<std::string> *payloadToSplit)
{
    if (atomSize > (*payloadToSplit).getPayload().length())
    {
        // TODO : replace with exception throwing
        cerr << "splitPayloadToAtoms(): Warning: atom size provided is greater than the length of the payload. Payload could not be split." << endl;
        //return;
    }
    vector<Atom<std::string>> atoms;
    std::string tempString;
    Atom<std::string> *tempAtom;
    //test implementation
    for(unsigned int i = 0 ; i < (*payloadToSplit).getPayload().length()-atomSize+1 ; ++i)
    {
        tempString.clear();
        for(unsigned int j = 0 ; j < atomSize ; ++j)
        {
            tempString.push_back((*payloadToSplit).getPayload()[i+j]);
        }
        tempAtom = new Atom<std::string>(tempString);
        atoms.push_back(*tempAtom);
        // added so valgrind won't count it as a memory leak
        delete tempAtom;
    }
    return atoms;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x140, %rsp            # imm = 0x140
movq %rdi, -0x110(%rbp)
movq %rdi, %rax
movq %rax, -0x108(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x100(%rbp)
movl 0x8(%rax), %eax
movq %rax, -0xf0(%rbp)
movq -0x18(%rbp), %rsi
movq (%rsi), %rax
leaq -0x38(%rbp), %rdi
callq *0x18(%rax)
leaq -0x38(%rbp), %rdi
callq 0x85c0
movq %rax, -0xf8(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x8260
movq -0xf8(%rbp), %rcx
movq -0xf0(%rbp), %rax
cmpq %rcx, %rax
jbe 0x3e7a9
movq 0x2985a(%rip), %rdi     # 0x67fe8
leaq 0x7b4c(%rip), %rsi      # 0x462e1
callq 0x83d0
movq %rax, %rdi
movq 0x297f4(%rip), %rsi     # 0x67f98
callq 0x8410
movq -0x110(%rbp), %rdi
movb $0x0, -0x39(%rbp)
callq 0x35da0
leaq -0x60(%rbp), %rdi
callq 0x8550
movl $0x0, -0x6c(%rbp)
movl -0x6c(%rbp), %eax
movq %rax, -0x118(%rbp)
movq -0x18(%rbp), %rsi
movq (%rsi), %rax
movq 0x18(%rax), %rax
leaq -0x90(%rbp), %rdi
callq *%rax
jmp 0x3e7e9
leaq -0x90(%rbp), %rdi
callq 0x85c0
movq -0x100(%rbp), %rcx
movl 0x8(%rcx), %ecx
subq %rcx, %rax
addq $0x1, %rax
movq %rax, -0x120(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x8260
movq -0x120(%rbp), %rcx
movq -0x118(%rbp), %rax
cmpq %rcx, %rax
jae 0x3e9e7
leaq -0x60(%rbp), %rdi
callq 0x8510
movl $0x0, -0xa0(%rbp)
movq -0x100(%rbp), %rcx
movl -0xa0(%rbp), %eax
cmpl 0x8(%rcx), %eax
jae 0x3e8fd
movq -0x18(%rbp), %rsi
movq (%rsi), %rax
movq 0x18(%rax), %rax
leaq -0xc0(%rbp), %rdi
callq *%rax
jmp 0x3e86f
movl -0x6c(%rbp), %eax
movl -0xa0(%rbp), %ecx
addl %ecx, %eax
movl %eax, %esi
leaq -0xc0(%rbp), %rdi
callq 0x8790
movq %rax, -0x128(%rbp)
jmp 0x3e891
movq -0x128(%rbp), %rax
movsbl (%rax), %esi
leaq -0x60(%rbp), %rdi
callq 0x8370
jmp 0x3e8a6
leaq -0xc0(%rbp), %rdi
callq 0x8260
movl -0xa0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa0(%rbp)
jmp 0x3e843
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x98(%rbp)
movl %eax, -0x9c(%rbp)
jmp 0x3e9fc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x98(%rbp)
movl %eax, -0x9c(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0x8260
jmp 0x3e9fc
movl $0x28, %edi
callq 0x83e0
movq %rax, -0x130(%rbp)
jmp 0x3e910
movb $0x1, -0xe1(%rbp)
leaq -0xe0(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x81b0
jmp 0x3e929
movq -0x130(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0x3e420
jmp 0x3e93e
movq -0x130(%rbp), %rax
movb $0x0, -0xe1(%rbp)
movq %rax, -0x68(%rbp)
leaq -0xe0(%rbp), %rdi
callq 0x8260
movq -0x110(%rbp), %rdi
movq -0x68(%rbp), %rsi
callq 0x3eaa0
jmp 0x3e96e
movq -0x68(%rbp), %rax
movq %rax, -0x138(%rbp)
cmpq $0x0, %rax
je 0x3e98c
movq -0x138(%rbp), %rdi
movq (%rdi), %rax
callq *0x8(%rax)
jmp 0x3e98e
movl -0x6c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6c(%rbp)
jmp 0x3e7c9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x98(%rbp)
movl %eax, -0x9c(%rbp)
jmp 0x3e9ce
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x98(%rbp)
movl %eax, -0x9c(%rbp)
leaq -0xe0(%rbp), %rdi
callq 0x8260
testb $0x1, -0xe1(%rbp)
jne 0x3e9d9
jmp 0x3e9e5
movq -0x130(%rbp), %rdi
callq 0x83b0
jmp 0x3e9fc
movb $0x1, -0x39(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x8260
testb $0x1, -0x39(%rbp)
jne 0x3ea1f
jmp 0x3ea13
leaq -0x60(%rbp), %rdi
callq 0x8260
movq -0x110(%rbp), %rdi
callq 0x35e10
jmp 0x3ea2f
movq -0x110(%rbp), %rdi
callq 0x35e10
movq -0x108(%rbp), %rax
addq $0x140, %rsp            # imm = 0x140
popq %rbp
retq
movq -0x98(%rbp), %rdi
callq 0x86c0
nopl (%rax,%rax)