// File: /workspace/github_cpp_makefile_star2_O3/DCTewi[P]Truthtable-Calculator/functions.cpp
// Function: toReverseNotation(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
std::string toReverseNotation(const std::string &expr)
{
    if (!isLegal(expr))
    {
        throw std::overflow_error("Illegal Expression!");
    }

    // Result
    std::string res;
    // Stack of operators, Stack for cache data
    std::stack<char> soper, smid;
    // For every char in expressions
    for (int i = 0; i < static_cast<int>(expr.size()); i++)
    {
        const char &now = expr[i];
        // variables
        if (isalpha(now))
        {
            smid.push(now);
        }
        // operators
        else if (operators.count(now))
        {
            int flag = 0;
            while (!flag)
            {
                // Empty or top with (
                if (soper.empty() || soper.top() == '(')
                {
                    soper.push(now); flag = 1;
                }
                // Higher priority than top
                else if (getPriority(now) > getPriority(soper.top()))
                {
                    soper.push(now); flag = 1;
                }
                // Lower
                else
                {
                    smid.push(soper.top());
                    soper.pop();
                }
            }
        }
        // braces
        else if (now == '(')
        {
            soper.push(now);
        }
        else if (now == ')')
        {
            // pop!!!
            while (soper.size() && soper.top() != '(')
            {
                smid.push(soper.top());
                soper.pop();
            }
            if (soper.top() == '(') soper.pop();
        }
        else
        {
            throw std::overflow_error("Illegal Expression!");
        }
    }
    // Summary
    while (soper.size())
    {
        smid.push(soper.top());
        soper.pop();
    }
    while (smid.size())
    {
        res += smid.top();
        smid.pop();
    }
    std::reverse(res.begin(), res.end());

    return res;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movq %rsi, %rdi
callq 0x2828
testb %al, %al
je 0x3032
leaq 0x10(%rbx), %rax
movq %rax, 0xa8(%rsp)
movq %rax, (%rbx)
movq $0x0, 0x8(%rbx)
movb $0x0, 0x10(%rbx)
xorps %xmm0, %xmm0
movq %rsp, %rdi
movaps %xmm0, 0x40(%rdi)
movaps %xmm0, 0x30(%rdi)
movaps %xmm0, 0x20(%rdi)
movaps %xmm0, 0x10(%rdi)
movaps %xmm0, (%rdi)
xorl %esi, %esi
movq %rbx, 0xb0(%rsp)
callq 0x4ac0
leaq 0x50(%rsp), %r12
xorps %xmm0, %xmm0
movaps %xmm0, 0x40(%r12)
movaps %xmm0, 0x30(%r12)
movaps %xmm0, 0x20(%r12)
movaps %xmm0, 0x10(%r12)
movaps %xmm0, (%r12)
movq %r12, %rdi
xorl %esi, %esi
callq 0x4ac0
cmpl $0x0, 0x8(%r14)
jle 0x2d83
xorl %r13d, %r13d
movl $0x200, %r15d           # imm = 0x200
movq (%r14), %rbp
movb (%rbp,%r13), %bl
addq %r13, %rbp
movsbl %bl, %edi
callq 0x2210
testl %eax, %eax
je 0x2a29
movq 0x80(%rsp), %rax
movq 0x90(%rsp), %rcx
decq %rcx
movq %r12, %rdi
cmpq %rcx, %rax
je 0x2cf0
movb %bl, (%rax)
incq 0x80(%rsp)
jmp 0x2d73
leaq 0x6740(%rip), %rdi      # 0x9170
movq %rbp, %rsi
callq 0x43e0
testq %rax, %rax
je 0x2bd2
movq 0x30(%rsp), %rsi
cmpq 0x10(%rsp), %rsi
je 0x2bb7
movq 0x38(%rsp), %rax
movq %rsi, %rcx
cmpq %rax, %rsi
jne 0x2a6a
movq 0x48(%rsp), %rcx
movq -0x8(%rcx), %rcx
addq %r15, %rcx
cmpb $0x28, -0x1(%rcx)
je 0x2bb7
movb (%rbp), %cl
movzbl %cl, %edi
cmpl $0x2c, %edi
jle 0x2a9a
cmpl $0x7c, %edi
je 0x2aa8
movl $0xfffffffd, %edx       # imm = 0xFFFFFFFD
cmpl $0x3d, %edi
je 0x2abb
cmpl $0x2d, %edi
jne 0x2ab6
movl $0xfffffffe, %edx       # imm = 0xFFFFFFFE
jmp 0x2abb
cmpl $0x21, %edi
je 0x2aaf
cmpl $0x26, %edi
jne 0x2ab6
xorl %edx, %edx
jmp 0x2abb
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
jmp 0x2abb
movl $0x1, %edx
jmp 0x2abb
movl $0xfffffff6, %edx       # imm = 0xFFFFFFF6
movq %rsi, %rdi
cmpq %rax, %rsi
jne 0x2acf
movq 0x48(%rsp), %rdi
movq -0x8(%rdi), %rdi
addq %r15, %rdi
movzbl -0x1(%rdi), %r8d
cmpl $0x2c, %r8d
jle 0x2af8
cmpl $0x7c, %r8d
je 0x2b08
movl $0xfffffffd, %edi       # imm = 0xFFFFFFFD
cmpl $0x3d, %r8d
je 0x2b1b
cmpl $0x2d, %r8d
jne 0x2b16
movl $0xfffffffe, %edi       # imm = 0xFFFFFFFE
jmp 0x2b1b
cmpl $0x21, %r8d
je 0x2b0f
cmpl $0x26, %r8d
jne 0x2b16
xorl %edi, %edi
jmp 0x2b1b
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
jmp 0x2b1b
movl $0x1, %edi
jmp 0x2b1b
movl $0xfffffff6, %edi       # imm = 0xFFFFFFF6
cmpl %edi, %edx
jg 0x2d0a
cmpq %rax, %rsi
jne 0x2b34
movq 0x48(%rsp), %rax
movq -0x8(%rax), %rsi
addq %r15, %rsi
decq %rsi
movq 0x80(%rsp), %rax
movq 0x90(%rsp), %rcx
decq %rcx
cmpq %rcx, %rax
je 0x2b5d
movb (%rsi), %cl
movb %cl, (%rax)
incq 0x80(%rsp)
jmp 0x2b65
movq %r12, %rdi
callq 0x4c38
movq 0x30(%rsp), %rsi
movq 0x38(%rsp), %rdi
cmpq %rdi, %rsi
je 0x2b79
decq %rsi
jmp 0x2bad
movl $0x200, %esi            # imm = 0x200
callq 0x2180
movq 0x48(%rsp), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x48(%rsp)
movq -0x8(%rax), %rsi
movq %rsi, 0x38(%rsp)
leaq 0x200(%rsi), %rax
movq %rax, 0x40(%rsp)
addq $0x1ff, %rsi            # imm = 0x1FF
movq %rsi, 0x30(%rsp)
jmp 0x2a46
movq 0x40(%rsp), %rax
decq %rax
cmpq %rax, %rsi
je 0x2d20
movb (%rbp), %al
movb %al, (%rsi)
jmp 0x2d19
movzbl (%rbp), %eax
cmpl $0x28, %eax
je 0x2cd6
cmpl $0x29, %eax
jne 0x3000
movq 0x30(%rsp), %rsi
movq 0x38(%rsp), %rdi
movq 0x48(%rsp), %rax
movq %rax, %rcx
subq 0x28(%rsp), %rcx
shrq $0x3, %rcx
cmpq $0x1, %rax
adcq $-0x1, %rcx
movq %rsi, %rdx
subq %rdi, %rdx
addq 0x20(%rsp), %rdx
shlq $0x9, %rcx
addq %rcx, %rdx
cmpq 0x10(%rsp), %rdx
je 0x2cfa
cmpq %rdi, %rsi
je 0x2c38
cmpb $0x28, -0x1(%rsi)
jne 0x2c53
jmp 0x2cfa
movq -0x8(%rax), %rcx
cmpb $0x28, 0x1ff(%rcx)
je 0x2cfa
addq $0x200, %rcx            # imm = 0x200
movq %rcx, %rsi
decq %rsi
movq 0x80(%rsp), %rax
movq 0x90(%rsp), %rcx
decq %rcx
cmpq %rcx, %rax
je 0x2c7c
movb (%rsi), %cl
movb %cl, (%rax)
incq 0x80(%rsp)
jmp 0x2c84
movq %r12, %rdi
callq 0x4c38
movq 0x30(%rsp), %rsi
movq 0x38(%rsp), %rdi
cmpq %rdi, %rsi
je 0x2c98
decq %rsi
jmp 0x2ccc
movl $0x200, %esi            # imm = 0x200
callq 0x2180
movq 0x48(%rsp), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x48(%rsp)
movq -0x8(%rax), %rdi
movq %rdi, 0x38(%rsp)
leaq 0x200(%rdi), %rax
movq %rax, 0x40(%rsp)
leaq 0x1ff(%rdi), %rsi
movq %rsi, 0x30(%rsp)
jmp 0x2bf2
movq 0x30(%rsp), %rax
movq 0x40(%rsp), %rcx
decq %rcx
movq %rsp, %rdi
cmpq %rcx, %rax
je 0x2cf0
movb $0x28, (%rax)
jmp 0x2d19
movq %rbp, %rsi
callq 0x4c38
jmp 0x2d73
cmpq %rdi, %rsi
je 0x2d2d
cmpb $0x28, -0x1(%rsi)
jne 0x2d73
decq %rsi
jmp 0x2d6e
movq 0x40(%rsp), %rax
decq %rax
cmpq %rax, %rsi
je 0x2d20
movb %cl, (%rsi)
incq 0x30(%rsp)
jmp 0x2d73
movq %rsp, %rdi
movq %rbp, %rsi
callq 0x4c38
jmp 0x2d73
movq -0x8(%rax), %rax
cmpb $0x28, 0x1ff(%rax)
jne 0x2d73
movl $0x200, %esi            # imm = 0x200
callq 0x2180
movq 0x48(%rsp), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x48(%rsp)
movq -0x8(%rax), %rsi
movq %rsi, 0x38(%rsp)
leaq 0x200(%rsi), %rax
movq %rax, 0x40(%rsp)
addq $0x1ff, %rsi            # imm = 0x1FF
movq %rsi, 0x30(%rsp)
incq %r13
movslq 0x8(%r14), %rax
cmpq %rax, %r13
jl 0x29e4
movq 0x30(%rsp), %rsi
movq 0x38(%rsp), %rdi
movq 0x48(%rsp), %rax
movq %rax, %rcx
subq 0x28(%rsp), %rcx
shrq $0x3, %rcx
cmpq $0x1, %rax
adcq $-0x1, %rcx
movq %rsi, %rdx
subq %rdi, %rdx
addq 0x20(%rsp), %rdx
shlq $0x9, %rcx
addq %rcx, %rdx
cmpq 0x10(%rsp), %rdx
je 0x2e8e
movl $0x200, %r15d           # imm = 0x200
leaq 0x50(%rsp), %r14
cmpq %rdi, %rsi
jne 0x2dda
movq -0x8(%rax), %rsi
addq %r15, %rsi
decq %rsi
movq 0x80(%rsp), %rax
movq 0x90(%rsp), %rcx
decq %rcx
cmpq %rcx, %rax
je 0x2e03
movb (%rsi), %cl
movb %cl, (%rax)
incq 0x80(%rsp)
jmp 0x2e0b
movq %r14, %rdi
callq 0x4c38
movq 0x30(%rsp), %rsi
movq 0x38(%rsp), %rdi
cmpq %rdi, %rsi
je 0x2e1f
decq %rsi
jmp 0x2e53
movl $0x200, %esi            # imm = 0x200
callq 0x2180
movq 0x48(%rsp), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x48(%rsp)
movq -0x8(%rax), %rdi
movq %rdi, 0x38(%rsp)
leaq 0x200(%rdi), %rax
movq %rax, 0x40(%rsp)
leaq 0x1ff(%rdi), %rsi
movq %rsi, 0x30(%rsp)
movq 0x48(%rsp), %rax
movq %rax, %rcx
subq 0x28(%rsp), %rcx
shrq $0x3, %rcx
cmpq $0x1, %rax
adcq $-0x1, %rcx
movq %rsi, %rdx
subq %rdi, %rdx
addq 0x20(%rsp), %rdx
shlq $0x9, %rcx
addq %rcx, %rdx
cmpq 0x10(%rsp), %rdx
jne 0x2dce
movq 0x80(%rsp), %rax
movq 0x88(%rsp), %rdi
movq 0x98(%rsp), %rcx
movq %rcx, %rdx
subq 0x78(%rsp), %rdx
shrq $0x3, %rdx
cmpq $0x1, %rcx
adcq $-0x1, %rdx
movq %rax, %rsi
subq %rdi, %rsi
addq 0x70(%rsp), %rsi
shlq $0x9, %rdx
addq %rdx, %rsi
cmpq 0x60(%rsp), %rsi
movq 0xb0(%rsp), %rbx
je 0x2f98
movl $0x200, %r14d           # imm = 0x200
cmpq %rdi, %rax
jne 0x2ef1
movq -0x8(%rcx), %rax
addq %r14, %rax
movsbl -0x1(%rax), %esi
movq %rbx, %rdi
callq 0x2130
movq 0x80(%rsp), %rax
movq 0x88(%rsp), %rdi
cmpq %rdi, %rax
je 0x2f17
decq %rax
jmp 0x2f57
movl $0x200, %esi            # imm = 0x200
callq 0x2180
movq 0x98(%rsp), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x98(%rsp)
movq -0x8(%rax), %rdi
movq %rdi, 0x88(%rsp)
leaq 0x200(%rdi), %rax
movq %rax, 0x90(%rsp)
leaq 0x1ff(%rdi), %rax
movq %rax, 0x80(%rsp)
movq 0x98(%rsp), %rcx
movq %rcx, %rdx
subq 0x78(%rsp), %rdx
shrq $0x3, %rdx
cmpq $0x1, %rcx
adcq $-0x1, %rdx
movq %rax, %rsi
subq %rdi, %rsi
addq 0x70(%rsp), %rsi
shlq $0x9, %rdx
addq %rdx, %rsi
cmpq 0x60(%rsp), %rsi
jne 0x2ee5
movq (%rbx), %rax
movq 0x8(%rbx), %rcx
testq %rcx, %rcx
setne %dl
addq %rax, %rcx
decq %rcx
cmpq %rax, %rcx
seta %sil
andb %dl, %sil
cmpb $0x1, %sil
jne 0x2fd9
incq %rax
movb -0x1(%rax), %dl
movb (%rcx), %sil
movb %sil, -0x1(%rax)
movb %dl, (%rcx)
decq %rcx
leaq 0x1(%rax), %rdx
cmpq %rcx, %rax
movq %rdx, %rax
jb 0x2fbe
leaq 0x50(%rsp), %rdi
callq 0x47fc
movq %rsp, %rdi
callq 0x47fc
movq %rbx, %rax
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x10, %edi
callq 0x20b0
movq %rax, %r15
leaq 0x307a(%rip), %rsi      # 0x608e
movq %rax, %rdi
callq 0x2050
movq 0x5f95(%rip), %rsi      # 0x8fb8
movq 0x5f86(%rip), %rdx      # 0x8fb0
movq %r15, %rdi
callq 0x2240
movl $0x10, %edi
callq 0x20b0
movq %rax, %rbx
leaq 0x3048(%rip), %rsi      # 0x608e
movq %rax, %rdi
callq 0x2050
movq 0x5f63(%rip), %rsi      # 0x8fb8
movq 0x5f54(%rip), %rdx      # 0x8fb0
movq %rbx, %rdi
callq 0x2240
movq %rax, %r14
movq %rbx, %rdi
callq 0x2110
jmp 0x30d1
jmp 0x3094
movq %rax, %r14
movq %r15, %rdi
callq 0x2110
jmp 0x3097
movq %rax, %r14
jmp 0x30a1
movq %rax, %r14
jmp 0x30a9
jmp 0x3094
jmp 0x3094
jmp 0x3094
jmp 0x3094
jmp 0x3094
movq %rax, %r14
leaq 0x50(%rsp), %rdi
callq 0x47fc
movq %rsp, %rdi
callq 0x47fc
movq 0xb0(%rsp), %rax
movq (%rax), %rdi
cmpq 0xa8(%rsp), %rdi
je 0x30d1
movq 0xa8(%rsp), %rax
movq (%rax), %rsi
incq %rsi
callq 0x2180
movq %r14, %rdi
callq 0x2270