// File: /workspace/github_cpp_makefile_star2_O2/Manuel123cool[P]smiley/instruction.cpp
// Function: Instruction::processFunctions()
void Instruction::processFunctions()
{
    struct Funct
    {
        std::string identifier;
        int start;
        int end; 
    };
    std::vector<Funct> functIdent;

    for (int i{ 0 }; i < m_instructions.size(); ++i)  
    {
        std::string code{ m_instructions.at(i) };

        std::string identifier;
        bool start{ false };
        for(const auto &c : code) 
        {
            if (c == ' ' && start)
                break; 

            if (start)
                identifier += c;

            if (c == ' ' && !start)
                start = true;
        }     
 
        bool isInString{ MyRegex::testString(code, ":D ") };    
        if (isInString)
        {
            int jmpTo{ -1 };
            int countBlockStarts{ 0 };
            for (int j{ i }; j < m_instructions.size(); ++j)  
            {
                std::string code{ m_instructions.at(j) };

                if (MyRegex::testString(code, "><"))
                    ++countBlockStarts;

                if (MyRegex::testString(code, "<>"))
                    --countBlockStarts;

                if (MyRegex::testString(code, "<>") && countBlockStarts == 0)
                    jmpTo = j;
            } 
            if (jmpTo == -1)
                std::cerr << "Smt went in functions wrong" << std::endl;

            Jump jump;
            jump.start = i;
            jump.jumpTo = jmpTo;
            m_jumps.push_back(jump); 
            
            Funct func;
            func.start = i;
            func.end = jmpTo;
            func.identifier = identifier;
            functIdent.push_back(func); 
        }     

        bool isInString1{ MyRegex::testString(code, ";) ") };    
        if (isInString1)
        {
            for (const auto &elem : functIdent)
            {
                if (elem.identifier == identifier)
                {
                    Jump jump;
                    jump.start = i;
                    jump.jumpTo = elem.start;
                    m_jumps.push_back(jump); 
                    
                    Jump jump1;
                    jump1.start = elem.end;
                    jump1.jumpTo = i;
                    m_jumps.push_back(jump1); 
 
                }
            }
        } 
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x208, %rsp            # imm = 0x208
movq %rdi, %r13
andq $0x0, 0x60(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x50(%rsp)
leaq 0x18(%rdi), %rax
movq %rax, 0x78(%rsp)
movq $0x0, 0x10(%rsp)
leaq 0x168(%rsp), %rbp
xorl %esi, %esi
movq %rdi, 0x68(%rsp)
movq 0x20(%r13), %rax
subq 0x18(%r13), %rax
sarq $0x5, %rax
cmpq %rsi, %rax
jbe 0x879f
movq 0x78(%rsp), %rdi
movq %rsi, 0x20(%rsp)
callq 0x94c4
leaq 0xa8(%rsp), %rdi
movq %rax, %rsi
callq 0x21e0
leaq 0x90(%rsp), %rax
movq %rax, 0x80(%rsp)
andq $0x0, 0x88(%rsp)
movb $0x0, 0x90(%rsp)
movq 0xa8(%rsp), %rbx
movq 0xb0(%rsp), %r14
xorl %r15d, %r15d
xorl %r12d, %r12d
cmpq %r15, %r14
je 0x8331
movb (%rbx,%r15), %al
cmpb $0x20, %al
jne 0x8316
testb $0x1, %r12b
movb $0x1, %r12b
je 0x832c
jmp 0x8331
testb $0x1, %r12b
je 0x832c
movsbl %al, %esi
leaq 0x80(%rsp), %rdi
callq 0x2140
incq %r15
jmp 0x82fe
movq %rbp, %rdi
leaq 0xa8(%rsp), %rsi
callq 0x21e0
leaq 0x1e8(%rsp), %r14
movq %r14, %rdi
leaq 0x1fb4(%rip), %rsi      # 0xa307
leaq 0x28(%rsp), %rdx
callq 0x57ec
movq %rbp, %rdi
movq %r14, %rsi
callq 0x5ddc
movq %rbp, %rbx
movl %eax, %ebp
movq %r14, %rdi
callq 0x20c0
movq %rbx, %rdi
callq 0x20c0
testb %bpl, %bpl
je 0x8512
xorl %ebp, %ebp
movq 0x20(%rsp), %rsi
pushq $-0x1
popq %r13
movl %r13d, 0x18(%rsp)
movl %ebp, 0x74(%rsp)
movq 0x68(%rsp), %rcx
movq 0x20(%rcx), %rax
subq 0x18(%rcx), %rax
sarq $0x5, %rax
cmpq %rsi, %rax
jbe 0x8527
movq 0x78(%rsp), %rdi
movq %rsi, 0xa0(%rsp)
callq 0x94c4
leaq 0x28(%rsp), %r14
movq %r14, %rdi
movq %rax, %rsi
callq 0x21e0
leaq 0x148(%rsp), %rdi
movq %r14, %rsi
callq 0x21e0
leaq 0x1c8(%rsp), %r12
movq %r12, %rdi
leaq 0x1f01(%rip), %rsi      # 0xa2f9
leaq 0x8(%rsp), %rdx
callq 0x57ec
leaq 0x148(%rsp), %r14
movq %r14, %rdi
movq %r12, %rsi
callq 0x5ddc
movl %eax, %r15d
movq %r12, %rdi
callq 0x20c0
movq %r14, %rdi
callq 0x20c0
leaq 0x128(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x21e0
leaq 0x1a8(%rsp), %r13
movq %r13, %rdi
leaq 0x1eb0(%rip), %rsi      # 0xa2fc
leaq 0x8(%rsp), %rdx
callq 0x57ec
leaq 0x128(%rsp), %r14
movq %r14, %rdi
movq %r13, %rsi
callq 0x5ddc
movl %eax, %r12d
movq %r13, %rdi
callq 0x20c0
movq %r14, %rdi
callq 0x20c0
leaq 0x108(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x21e0
leaq 0x188(%rsp), %rbx
movq %rbx, %rdi
leaq 0x1e5c(%rip), %rsi      # 0xa2fc
leaq 0x8(%rsp), %rdx
callq 0x57ec
leaq 0x108(%rsp), %r13
movq %r13, %rdi
movq %rbx, %rsi
callq 0x5ddc
movl 0x74(%rsp), %ebp
movl %eax, %r14d
movzbl %r15b, %eax
addl %eax, %ebp
movzbl %r12b, %eax
subl %eax, %ebp
movq %rbx, %rdi
callq 0x20c0
movq %r13, %rdi
callq 0x20c0
testl %ebp, %ebp
movl 0x18(%rsp), %ecx
movl %ecx, %eax
movq 0xa0(%rsp), %rbx
cmovel %ebx, %eax
testb %r14b, %r14b
cmovnel %eax, %ecx
movl %ecx, 0x18(%rsp)
leaq 0x28(%rsp), %rdi
callq 0x20c0
movq %rbx, %rsi
incq %rsi
jmp 0x8396
leaq 0xe8(%rsp), %r14
leaq 0xc8(%rsp), %rbx
jmp 0x86ca
cmpl $-0x1, 0x18(%rsp)
leaq 0xe8(%rsp), %r14
leaq 0xc8(%rsp), %rbx
movq 0x20(%rsp), %r15
jne 0x855e
movq 0x5aa6(%rip), %rdi      # 0xdff0
leaq 0x1dba(%rip), %rsi      # 0xa30b
callq 0x2180
movq %rax, %rdi
callq 0x20d0
movl %r15d, 0x8(%rsp)
movl 0x18(%rsp), %ebp
movl %ebp, 0xc(%rsp)
movq 0x68(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x94e6
leaq 0x38(%rsp), %rax
movq %rax, 0x28(%rsp)
andq $0x0, 0x30(%rsp)
movb $0x0, 0x38(%rsp)
movl %r15d, 0x48(%rsp)
movl %ebp, 0x4c(%rsp)
leaq 0x28(%rsp), %rdi
leaq 0x80(%rsp), %rsi
callq 0x20f0
movq 0x68(%rsp), %r13
movq 0x10(%rsp), %rdi
cmpq 0x60(%rsp), %rdi
je 0x85dd
leaq 0x28(%rsp), %rsi
callq 0x9436
movq 0x10(%rsp), %rcx
addq $0x28, %rcx
movq %rcx, 0x10(%rsp)
movq %rcx, 0x58(%rsp)
jmp 0x86c0
movq 0x50(%rsp), %rbp
movq %rdi, %rax
subq %rbp, %rax
movabsq $0x7ffffffffffffff8, %rcx # imm = 0x7FFFFFFFFFFFFFF8
cmpq %rcx, %rax
je 0x87bb
cqto
pushq $0x28
popq %rcx
idivq %rcx
movq %rax, %r15
cmpq %rbp, %rdi
pushq $0x1
popq %rcx
cmoveq %rcx, %rax
leaq (%rax,%r15), %rbx
movabsq $0x333333333333333, %rcx # imm = 0x333333333333333
cmpq %rcx, %rbx
cmovaeq %rcx, %rbx
addq %r15, %rax
cmovbq %rcx, %rbx
testq %rbx, %rbx
movq %rbx, 0x18(%rsp)
je 0x8644
imulq $0x28, %rbx, %rdi
callq 0x2190
movq %rax, %r12
jmp 0x8647
xorl %r12d, %r12d
imulq $0x28, %r15, %r15
addq %r12, %r15
movq %r15, %rdi
leaq 0x28(%rsp), %rsi
callq 0x9436
movq %rbp, %rdi
movq 0x10(%rsp), %rbx
movq %rbx, %rsi
movq %r12, %rdx
callq 0x9456
leaq 0x28(%rax), %rdx
movq %rbx, %rdi
movq %rbx, %rsi
callq 0x9456
movq %rax, %rbx
movq 0x60(%rsp), %rax
subq %rbp, %rax
cqto
pushq $0x28
popq %rcx
idivq %rcx
movq %rbp, %rdi
movq %rax, %rsi
callq 0x9426
movq %r12, 0x50(%rsp)
movq %rbx, 0x10(%rsp)
movq %rbx, 0x58(%rsp)
imulq $0x28, 0x18(%rsp), %rax
addq %r12, %rax
movq %rax, 0x60(%rsp)
leaq 0xc8(%rsp), %rbx
leaq 0x28(%rsp), %rdi
callq 0x20c0
movq %r14, %rdi
leaq 0xa8(%rsp), %rsi
callq 0x21e0
movq %rbx, %rdi
leaq 0x1c43(%rip), %rsi      # 0xa327
leaq 0x28(%rsp), %rdx
callq 0x57ec
movq %r14, %rdi
movq %rbx, %rsi
callq 0x5ddc
movl %eax, %ebp
movq %rbx, %rdi
callq 0x20c0
movq %r14, %rdi
callq 0x20c0
testb %bpl, %bpl
leaq 0x168(%rsp), %rbp
je 0x8778
movq 0x50(%rsp), %r15
movq 0x10(%rsp), %rax
cmpq %rax, %r15
je 0x8778
movq %r15, %rdi
leaq 0x80(%rsp), %rsi
callq 0x27e7
testb %al, %al
je 0x8772
movq 0x20(%rsp), %rbx
movl %ebx, 0x28(%rsp)
movl 0x20(%r15), %eax
movl %eax, 0x2c(%rsp)
movq %r13, %rdi
leaq 0x28(%rsp), %rsi
callq 0x94e6
movl 0x24(%r15), %eax
movl %eax, 0x8(%rsp)
movl %ebx, 0xc(%rsp)
movq %r13, %rdi
leaq 0x8(%rsp), %rsi
callq 0x94e6
addq $0x28, %r15
jmp 0x871d
leaq 0x80(%rsp), %rdi
callq 0x20c0
leaq 0xa8(%rsp), %rdi
callq 0x20c0
movq 0x20(%rsp), %rsi
incq %rsi
jmp 0x8293
leaq 0x50(%rsp), %rdi
callq 0x93d8
addq $0x208, %rsp            # imm = 0x208
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x19a9(%rip), %rdi      # 0xa16b
callq 0x20e0
movq %rax, %rdi
callq 0x2090
movq %r12, %rbx
testq %r12, %r12
jne 0x87e1
movq %r15, %rdi
callq 0x20c0
jmp 0x87ec
movq %rbx, %rdi
movq %rbx, %rsi
callq 0x9400
movq %rbx, %rdi
movq 0x18(%rsp), %rsi
callq 0x9426
callq 0x2200
movq %rax, %rbx
callq 0x2240
jmp 0x88ea
movq %rax, %rdi
callq 0x274f
jmp 0x88e7
jmp 0x88e2
jmp 0x88e2
jmp 0x88e7
movq %rax, %rbx
jmp 0x8841
jmp 0x88e2
movq %rax, %rbx
leaq 0xc8(%rsp), %rdi
callq 0x20c0
leaq 0xe8(%rsp), %rdi
jmp 0x88ef
jmp 0x88e2
movq %rax, %rbx
jmp 0x8868
movq %rax, %rbx
leaq 0x1e8(%rsp), %rdi
callq 0x20c0
leaq 0x168(%rsp), %rdi
jmp 0x88ef
movq %rax, %rbx
jmp 0x890e
jmp 0x88e2
jmp 0x88e2
jmp 0x88e2
movq %rax, %rbx
jmp 0x88d3
movq %rax, %rbx
jmp 0x889a
movq %rax, %rbx
leaq 0x1a8(%rsp), %rdi
callq 0x20c0
leaq 0x128(%rsp), %rdi
jmp 0x88db
movq %rax, %rbx
leaq 0x188(%rsp), %rdi
callq 0x20c0
jmp 0x88b9
movq %rax, %rbx
leaq 0x108(%rsp), %rdi
jmp 0x88db
movq %rax, %rbx
leaq 0x1c8(%rsp), %rdi
callq 0x20c0
leaq 0x148(%rsp), %rdi
callq 0x20c0
jmp 0x88ea
movq %rax, %rbx
jmp 0x88f4
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x20c0
leaq 0x80(%rsp), %rdi
callq 0x20c0
leaq 0xa8(%rsp), %rdi
callq 0x20c0
leaq 0x50(%rsp), %rdi
callq 0x93d8
movq %rbx, %rdi
callq 0x2250