// File: /workspace/github_cpp_makefile_star2_O1/Manuel123cool[P]smiley/instruction.cpp
// Function: Instruction::checkIf(int, Stack&)
int Instruction::checkIf(int whichInstr, Stack &stack)
{
    std::string code{ m_instructions.at(whichInstr) };
    if (code.length() <= 0)
        return -1;

    if (!MyRegex::testString(code, ":/ "))
        return -1;
    
    std::string identifier;
    bool start{ false };
    for(const auto &c : code) 
    {
        if (c == ' ' && start)
            break; 

        if (start)
            identifier += c;

        if (c == ' ' && !start)
            start = true;
    }     
    std::string value{ stack().getValueVar(identifier) };

    if (value == "true")
    {
        return whichInstr;
    }
    else 
    {
        int countBlockStarts{ 0 };
        for (int i{ whichInstr }; i < m_instructions.size(); ++i)  
        {
            std::string code{ m_instructions.at(i) };

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

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

            if (MyRegex::testString(code, "<>") && countBlockStarts == 0)
                return i;
            
        }
    }
    return -1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1c8, %rsp            # imm = 0x1C8
movq %rdx, %r14
movl %esi, 0x4(%rsp)
movslq %esi, %r15
movq 0x18(%rdi), %rax
movq %rdi, 0x40(%rsp)
movq 0x20(%rdi), %rdx
subq %rax, %rdx
sarq $0x5, %rdx
cmpq %r15, %rdx
jbe 0xc8ce
movq %r15, %rdx
shlq $0x5, %rdx
leaq 0x58(%rsp), %rcx
movq %rcx, -0x10(%rcx)
movq (%rax,%rdx), %rsi
movq %rdx, 0x10(%rsp)
movq 0x8(%rax,%rdx), %rdx
addq %rsi, %rdx
leaq 0x48(%rsp), %r12
movq %r12, %rdi
callq 0x2a3e
movq 0x8(%r12), %rdx
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testq %rdx, %rdx
je 0xc89e
leaq 0x198(%rsp), %r13
movq %r13, -0x10(%r13)
movq 0x48(%rsp), %rsi
addq %rsi, %rdx
leaq 0x188(%rsp), %rdi
callq 0x2a3e
leaq 0x178(%rsp), %rbx
movq %rbx, -0x10(%rbx)
leaq 0x1f7d(%rip), %rsi      # 0xe366
leaq 0x1f79(%rip), %rdx      # 0xe369
leaq 0x168(%rsp), %rdi
callq 0x7c60
leaq 0x188(%rsp), %rdi
leaq 0x168(%rsp), %rsi
callq 0x801c
movl %eax, %r12d
movq 0x168(%rsp), %rdi
cmpq %rbx, %rdi
je 0xc432
movq 0x178(%rsp), %rsi
incq %rsi
callq 0x2170
movq 0x188(%rsp), %rdi
cmpq %r13, %rdi
je 0xc44f
movq 0x198(%rsp), %rsi
incq %rsi
callq 0x2170
testb %r12b, %r12b
je 0xc89e
leaq 0xd8(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq 0x50(%rsp), %r13
testq %r13, %r13
je 0xc4d3
movq 0x48(%rsp), %rbp
decq %r13
xorl %ebx, %ebx
xorl %r12d, %r12d
movb (%rbp,%rbx), %al
cmpb $0x20, %al
jne 0xc496
movb $0x1, %cl
testb $0x1, %r12b
jne 0xc4c3
movb $0x1, %cl
testb $0x1, %r12b
je 0xc4b1
movsbl %al, %esi
leaq 0xc8(%rsp), %rdi
callq 0x2120
movl %r12d, %ecx
cmpb $0x20, (%rbp,%rbx)
movzbl %cl, %eax
movzbl %r12b, %r12d
cmovel %eax, %r12d
xorl %ecx, %ecx
testb %cl, %cl
jne 0xc4d3
leaq 0x1(%rbx), %rax
cmpq %rbx, %r13
movq %rax, %rbx
jne 0xc486
movq %r14, %rdi
callq 0xa8f4
movq %rax, %rbx
leaq 0x158(%rsp), %r12
movq %r12, -0x10(%r12)
movq 0xc8(%rsp), %rsi
movq 0xd0(%rsp), %rdx
addq %rsi, %rdx
leaq 0x148(%rsp), %rdi
callq 0x2a3e
leaq 0x1a8(%rsp), %rdi
leaq 0x148(%rsp), %rdx
movq %rbx, %rsi
callq 0x3a6a
movq 0x148(%rsp), %rdi
cmpq %r12, %rdi
je 0xc540
movq 0x158(%rsp), %rsi
incq %rsi
callq 0x2170
leaq 0x1b9e(%rip), %rsi      # 0xe0e5
leaq 0x1a8(%rsp), %rdi
callq 0x2070
testl %eax, %eax
je 0xc854
movq 0x40(%rsp), %rcx
movq 0x18(%rcx), %rax
movq 0x20(%rcx), %rcx
subq %rax, %rcx
sarq $0x5, %rcx
movl $0xffffffff, 0x4(%rsp)  # imm = 0xFFFFFFFF
cmpq %r15, %rcx
jbe 0xc854
movq %r15, 0x18(%rsp)
movq 0x10(%rsp), %rdi
orq $0x8, %rdi
movl $0x0, 0xc(%rsp)
leaq 0x128(%rsp), %rbx
leaq 0x108(%rsp), %r15
leaq 0xe8(%rsp), %r14
leaq 0x30(%rsp), %rcx
movq %rcx, 0x20(%rsp)
movq -0x8(%rax,%rdi), %rsi
movq %rdi, 0x10(%rsp)
movq (%rax,%rdi), %rdx
addq %rsi, %rdx
leaq 0x20(%rsp), %rdi
callq 0x2a3e
leaq 0xb8(%rsp), %rax
movq %rax, 0xa8(%rsp)
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rdx
addq %rsi, %rdx
leaq 0xa8(%rsp), %rdi
callq 0x2a3e
leaq 0x138(%rsp), %rax
movq %rax, 0x128(%rsp)
movq %rbx, %r12
movq %rbx, %rdi
leaq 0x1d45(%rip), %rsi      # 0xe360
leaq 0x1d40(%rip), %rdx      # 0xe362
callq 0x7c60
leaq 0xa8(%rsp), %rdi
movq %r12, %rsi
callq 0x801c
movl %eax, %r13d
movq 0x128(%rsp), %rdi
leaq 0x138(%rsp), %rax
cmpq %rax, %rdi
je 0xc65f
movq 0x138(%rsp), %rsi
incq %rsi
callq 0x2170
movq 0xa8(%rsp), %rdi
leaq 0xb8(%rsp), %rax
cmpq %rax, %rdi
je 0xc684
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x2170
leaq 0x98(%rsp), %rax
movq %rax, 0x88(%rsp)
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rdx
addq %rsi, %rdx
leaq 0x88(%rsp), %rdi
callq 0x2a3e
leaq 0x118(%rsp), %rax
movq %rax, 0x108(%rsp)
movq %r15, %r12
movq %r15, %rdi
leaq 0x1c98(%rip), %rsi      # 0xe363
leaq 0x1c93(%rip), %rdx      # 0xe365
callq 0x7c60
leaq 0x88(%rsp), %rdi
movq %r12, %rsi
callq 0x801c
movl %eax, %ebp
movq 0x108(%rsp), %rdi
leaq 0x118(%rsp), %rax
cmpq %rax, %rdi
je 0xc70e
movq 0x118(%rsp), %rsi
incq %rsi
callq 0x2170
movq 0x88(%rsp), %rdi
leaq 0x98(%rsp), %rax
cmpq %rax, %rdi
je 0xc733
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x2170
leaq 0x78(%rsp), %rax
movq %rax, 0x68(%rsp)
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rdx
addq %rsi, %rdx
leaq 0x68(%rsp), %rdi
callq 0x2a3e
leaq 0xf8(%rsp), %rax
movq %rax, 0xe8(%rsp)
movq %r14, %r12
movq %r14, %rdi
leaq 0x1bf2(%rip), %rsi      # 0xe363
leaq 0x1bed(%rip), %rdx      # 0xe365
callq 0x7c60
leaq 0x68(%rsp), %rdi
movq %r12, %rsi
callq 0x801c
movl %eax, %r12d
movzbl %r13b, %eax
movl 0xc(%rsp), %ecx
addl %eax, %ecx
movzbl %bpl, %eax
subl %eax, %ecx
movl %ecx, 0xc(%rsp)
sete %bpl
movq 0xe8(%rsp), %rdi
leaq 0xf8(%rsp), %rax
cmpq %rax, %rdi
je 0xc7ca
movq 0xf8(%rsp), %rsi
incq %rsi
callq 0x2170
movq 0x68(%rsp), %rdi
leaq 0x78(%rsp), %rax
cmpq %rax, %rdi
je 0xc7e6
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x2170
andb %bpl, %r12b
movl 0x8(%rsp), %eax
cmovnel 0x18(%rsp), %eax
movl %eax, 0x8(%rsp)
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0xc812
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x2170
testb %r12b, %r12b
jne 0xc84c
movq 0x18(%rsp), %rsi
incq %rsi
movq 0x40(%rsp), %rcx
movq 0x18(%rcx), %rax
movq 0x20(%rcx), %rcx
subq %rax, %rcx
sarq $0x5, %rcx
movq 0x10(%rsp), %rdi
addq $0x20, %rdi
movq %rsi, 0x18(%rsp)
cmpq %rsi, %rcx
ja 0xc5af
jmp 0xc854
movl 0x8(%rsp), %eax
movl %eax, 0x4(%rsp)
leaq 0x1b8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xc875
movq 0x1b8(%rsp), %rsi
incq %rsi
callq 0x2170
movq 0xc8(%rsp), %rdi
leaq 0xd8(%rsp), %rax
cmpq %rax, %rdi
je 0xc89a
movq 0xd8(%rsp), %rsi
incq %rsi
callq 0x2170
movl 0x4(%rsp), %ebp
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0xc8ba
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x2170
movl %ebp, %eax
addq $0x1c8, %rsp            # imm = 0x1C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x184c(%rip), %rdi      # 0xe121
movq %r15, %rsi
xorl %eax, %eax
callq 0x2210
movq %rax, %r14
movq 0x148(%rsp), %rdi
cmpq %r12, %rdi
je 0xca87
movq 0x158(%rsp), %rsi
jmp 0xca7f
jmp 0xca42
movq %rax, %r14
movq 0x168(%rsp), %rdi
cmpq %rbx, %rdi
je 0xc92a
movq 0x178(%rsp), %rsi
incq %rsi
callq 0x2170
jmp 0xc92a
movq %rax, %r14
movq 0x188(%rsp), %rdi
cmpq %r13, %rdi
je 0xcaac
movq 0x198(%rsp), %rsi
jmp 0xcaa4
movq %rax, %r14
jmp 0xcaac
movq %rax, %r14
jmp 0xc9e0
movq %rax, %r14
movq 0x108(%rsp), %rdi
leaq 0x118(%rsp), %rax
cmpq %rax, %rdi
je 0xc9f9
movq 0x118(%rsp), %rsi
incq %rsi
callq 0x2170
jmp 0xc9f9
movq %rax, %r14
movq 0x128(%rsp), %rdi
leaq 0x138(%rsp), %rax
cmpq %rax, %rdi
je 0xca1b
movq 0x138(%rsp), %rsi
incq %rsi
callq 0x2170
jmp 0xca1b
movq %rax, %r14
jmp 0xca66
movq %rax, %r14
movq 0xe8(%rsp), %rdi
leaq 0xf8(%rsp), %rax
cmpq %rax, %rdi
je 0xc9e0
movq 0xf8(%rsp), %rsi
incq %rsi
callq 0x2170
movq 0x68(%rsp), %rdi
leaq 0x78(%rsp), %rax
cmpq %rax, %rdi
je 0xca4a
movq 0x78(%rsp), %rsi
jmp 0xca38
movq %rax, %r14
movq 0x88(%rsp), %rdi
leaq 0x98(%rsp), %rax
cmpq %rax, %rdi
je 0xca4a
movq 0x98(%rsp), %rsi
jmp 0xca38
movq %rax, %r14
movq 0xa8(%rsp), %rdi
leaq 0xb8(%rsp), %rax
cmpq %rax, %rdi
je 0xca4a
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x2170
jmp 0xca4a
movq %rax, %r14
jmp 0xca87
movq %rax, %r14
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0xca66
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x2170
leaq 0x1b8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xca87
movq 0x1b8(%rsp), %rsi
incq %rsi
callq 0x2170
movq 0xc8(%rsp), %rdi
leaq 0xd8(%rsp), %rax
cmpq %rax, %rdi
je 0xcaac
movq 0xd8(%rsp), %rsi
incq %rsi
callq 0x2170
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0xcac8
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x2170
movq %r14, %rdi
callq 0x2250