// File: /workspace/github_cpp_makefile_star2_O3/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, 0x10(%rsp)
movl %esi, 0xc(%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 0xc4ef
movq %r15, %r14
shlq $0x5, %r14
leaq 0x58(%rsp), %rcx
movq %rcx, -0x10(%rcx)
movq (%rax,%r14), %rsi
movq 0x8(%rax,%r14), %rdx
addq %rsi, %rdx
leaq 0x48(%rsp), %r12
movq %r12, %rdi
callq 0x2a32
movq 0x8(%r12), %rdx
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testq %rdx, %rdx
je 0xc4bf
leaq 0x198(%rsp), %r13
movq %r13, -0x10(%r13)
movq 0x48(%rsp), %rsi
addq %rsi, %rdx
leaq 0x188(%rsp), %rdi
callq 0x2a32
leaq 0x178(%rsp), %rbx
movq %rbx, -0x10(%rbx)
leaq 0x231e(%rip), %rsi      # 0xe366
leaq 0x231a(%rip), %rdx      # 0xe369
leaq 0x168(%rsp), %rdi
callq 0x79c6
leaq 0x188(%rsp), %rdi
leaq 0x168(%rsp), %rsi
callq 0x7d88
movl %eax, %r12d
movq 0x168(%rsp), %rdi
cmpq %rbx, %rdi
je 0xc091
movq 0x178(%rsp), %rsi
incq %rsi
callq 0x2170
movq 0x188(%rsp), %rdi
cmpq %r13, %rdi
je 0xc0ae
movq 0x198(%rsp), %rsi
incq %rsi
callq 0x2170
testb %r12b, %r12b
je 0xc4bf
leaq 0xd8(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq 0x50(%rsp), %r13
testq %r13, %r13
je 0xc113
movq 0x48(%rsp), %rbp
xorl %ebx, %ebx
xorl %r12d, %r12d
movb (%rbp,%rbx), %al
cmpb $0x20, %al
jne 0xc0f5
testb $0x1, %r12b
movb $0x1, %r12b
je 0xc10b
jmp 0xc113
testb $0x1, %r12b
je 0xc10b
movsbl %al, %esi
leaq 0xc8(%rsp), %rdi
callq 0x2120
incq %rbx
cmpq %rbx, %r13
jne 0xc0e2
movq 0x10(%rsp), %rdi
callq 0xa598
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 0x2a32
leaq 0x1a8(%rsp), %rdi
leaq 0x148(%rsp), %rdx
movq %rbx, %rsi
callq 0x3908
movq 0x148(%rsp), %rdi
cmpq %r12, %rdi
je 0xc182
movq 0x158(%rsp), %rsi
incq %rsi
callq 0x2170
leaq 0x1f5c(%rip), %rsi      # 0xe0e5
leaq 0x1a8(%rsp), %rdi
callq 0x2070
testl %eax, %eax
je 0xc475
movq 0x40(%rsp), %rcx
movq 0x18(%rcx), %rax
movq 0x20(%rcx), %rcx
subq %rax, %rcx
sarq $0x5, %rcx
movl $0xffffffff, 0xc(%rsp)  # imm = 0xFFFFFFFF
cmpq %r15, %rcx
jbe 0xc475
movq %r15, 0x18(%rsp)
orq $0x8, %r14
movl $0x0, 0x10(%rsp)
leaq 0x128(%rsp), %rbx
leaq 0xe8(%rsp), %r15
leaq 0x30(%rsp), %rcx
movq %rcx, 0x20(%rsp)
movq -0x8(%rax,%r14), %rsi
movq (%rax,%r14), %rdx
addq %rsi, %rdx
leaq 0x20(%rsp), %rdi
callq 0x2a32
leaq 0xb8(%rsp), %rax
movq %rax, 0xa8(%rsp)
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rdx
addq %rsi, %rdx
leaq 0xa8(%rsp), %rdi
callq 0x2a32
leaq 0x138(%rsp), %rax
movq %rax, 0x128(%rsp)
movq %rbx, %r12
movq %rbx, %rdi
leaq 0x2115(%rip), %rsi      # 0xe360
leaq 0x2110(%rip), %rdx      # 0xe362
callq 0x79c6
leaq 0xa8(%rsp), %rdi
movq %r12, %rsi
callq 0x7d88
movl %eax, %r13d
movq 0x128(%rsp), %rdi
leaq 0x138(%rsp), %rax
cmpq %rax, %rdi
je 0xc28f
movq 0x138(%rsp), %rsi
incq %rsi
callq 0x2170
movq 0xa8(%rsp), %rdi
leaq 0xb8(%rsp), %rax
cmpq %rax, %rdi
je 0xc2b4
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 0x2a32
leaq 0x118(%rsp), %rax
movq %rax, 0x108(%rsp)
leaq 0x108(%rsp), %r12
movq %r12, %rdi
leaq 0x2063(%rip), %rsi      # 0xe363
leaq 0x205e(%rip), %rdx      # 0xe365
callq 0x79c6
leaq 0x88(%rsp), %rdi
movq %r12, %rsi
callq 0x7d88
movl %eax, %ebp
movq 0x108(%rsp), %rdi
leaq 0x118(%rsp), %rax
cmpq %rax, %rdi
je 0xc343
movq 0x118(%rsp), %rsi
incq %rsi
callq 0x2170
movq 0x88(%rsp), %rdi
leaq 0x98(%rsp), %rax
cmpq %rax, %rdi
je 0xc368
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 0x2a32
leaq 0xf8(%rsp), %rax
movq %rax, 0xe8(%rsp)
movq %r15, %r12
movq %r15, %rdi
leaq 0x1fbd(%rip), %rsi      # 0xe363
leaq 0x1fb8(%rip), %rdx      # 0xe365
callq 0x79c6
leaq 0x68(%rsp), %rdi
movq %r12, %rsi
callq 0x7d88
movl %eax, %r12d
movzbl %r13b, %eax
movl 0x10(%rsp), %ecx
addl %eax, %ecx
movzbl %bpl, %eax
subl %eax, %ecx
movl %ecx, 0x10(%rsp)
sete %bpl
movq 0xe8(%rsp), %rdi
leaq 0xf8(%rsp), %rax
cmpq %rax, %rdi
je 0xc3ff
movq 0xf8(%rsp), %rsi
incq %rsi
callq 0x2170
movq 0x68(%rsp), %rdi
leaq 0x78(%rsp), %rax
cmpq %rax, %rdi
je 0xc41b
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x2170
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0xc437
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x2170
andb %bpl, %r12b
jne 0xc46c
movq 0x18(%rsp), %rdx
incq %rdx
movq 0x40(%rsp), %rcx
movq 0x18(%rcx), %rax
movq 0x20(%rcx), %rcx
subq %rax, %rcx
sarq $0x5, %rcx
addq $0x20, %r14
movq %rdx, 0x18(%rsp)
cmpq %rdx, %rcx
ja 0xc1e4
jmp 0xc475
movq 0x18(%rsp), %rax
movl %eax, 0xc(%rsp)
leaq 0x1b8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xc496
movq 0x1b8(%rsp), %rsi
incq %rsi
callq 0x2170
movq 0xc8(%rsp), %rdi
leaq 0xd8(%rsp), %rax
cmpq %rax, %rdi
je 0xc4bb
movq 0xd8(%rsp), %rsi
incq %rsi
callq 0x2170
movl 0xc(%rsp), %ebp
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0xc4db
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 0x1c2b(%rip), %rdi      # 0xe121
movq %r15, %rsi
xorl %eax, %eax
callq 0x2210
movq %rax, %r14
movq 0x148(%rsp), %rdi
cmpq %r12, %rdi
je 0xc6a8
movq 0x158(%rsp), %rsi
jmp 0xc6a0
jmp 0xc56e
movq %rax, %r14
movq 0x168(%rsp), %rdi
cmpq %rbx, %rdi
je 0xc548
movq 0x178(%rsp), %rsi
incq %rsi
callq 0x2170
jmp 0xc548
movq %rax, %r14
movq 0x188(%rsp), %rdi
cmpq %r13, %rdi
je 0xc6cd
movq 0x198(%rsp), %rsi
jmp 0xc6c5
movq %rax, %r14
jmp 0xc6cd
movq %rax, %r14
jmp 0xc6a8
movq %rax, %r14
jmp 0xc606
movq %rax, %r14
movq 0x108(%rsp), %rdi
leaq 0x118(%rsp), %rax
cmpq %rax, %rdi
je 0xc61f
movq 0x118(%rsp), %rsi
incq %rsi
callq 0x2170
jmp 0xc61f
movq %rax, %r14
movq 0x128(%rsp), %rdi
leaq 0x138(%rsp), %rax
cmpq %rax, %rdi
je 0xc641
movq 0x138(%rsp), %rsi
incq %rsi
callq 0x2170
jmp 0xc641
movq %rax, %r14
jmp 0xc687
movq %rax, %r14
movq 0xe8(%rsp), %rdi
leaq 0xf8(%rsp), %rax
cmpq %rax, %rdi
je 0xc606
movq 0xf8(%rsp), %rsi
incq %rsi
callq 0x2170
movq 0x68(%rsp), %rdi
leaq 0x78(%rsp), %rax
cmpq %rax, %rdi
je 0xc66b
movq 0x78(%rsp), %rsi
jmp 0xc65e
movq %rax, %r14
movq 0x88(%rsp), %rdi
leaq 0x98(%rsp), %rax
cmpq %rax, %rdi
je 0xc66b
movq 0x98(%rsp), %rsi
jmp 0xc65e
movq %rax, %r14
movq 0xa8(%rsp), %rdi
leaq 0xb8(%rsp), %rax
cmpq %rax, %rdi
je 0xc66b
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x2170
jmp 0xc66b
movq %rax, %r14
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0xc687
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x2170
leaq 0x1b8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xc6a8
movq 0x1b8(%rsp), %rsi
incq %rsi
callq 0x2170
movq 0xc8(%rsp), %rdi
leaq 0xd8(%rsp), %rax
cmpq %rax, %rdi
je 0xc6cd
movq 0xd8(%rsp), %rsi
incq %rsi
callq 0x2170
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0xc6e9
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x2170
movq %r14, %rdi
callq 0x2250
nop