// File: /workspace/github_cpp_makefile_star2_O2/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, %rbx
movq %rdi, %r12
movq %rsi, %rdi
callq 0x261f
testb %al, %al
je 0x2a21
leaq 0x10(%r12), %rax
movq %rax, (%r12)
andq $0x0, 0x8(%r12)
movb $0x0, 0x10(%r12)
leaq 0x18(%rsp), %r15
movq %r15, %rdi
callq 0x37b4
leaq 0x68(%rsp), %rdi
callq 0x37b4
xorl %r14d, %r14d
movq %r12, 0x8(%rsp)
movq %rbx, 0x10(%rsp)
movslq 0x8(%rbx), %rax
cmpq %rax, %r14
jge 0x2920
movq (%rbx), %rbp
movsbl (%rbp,%r14), %edi
addq %r14, %rbp
callq 0x21f0
leaq 0x68(%rsp), %rdi
testl %eax, %eax
je 0x27b9
movq %rbp, %rsi
callq 0x3f72
jmp 0x287c
leaq 0x59a8(%rip), %rdi      # 0x8168
movq %rbp, %rsi
callq 0x379a
testq %rax, %rax
je 0x2884
movq 0x48(%rsp), %r13
cmpq 0x28(%rsp), %r13
je 0x2867
movq 0x50(%rsp), %r12
movq %r13, %rax
cmpq %r12, %r13
jne 0x27ff
movq 0x60(%rsp), %rax
movq -0x8(%rax), %rax
movl $0x200, %ecx            # imm = 0x200
addq %rcx, %rax
cmpb $0x28, -0x1(%rax)
je 0x2867
movq %rbp, %rdi
callq 0x26f2
movl %eax, %ebx
movq %r13, %rdi
cmpq %r12, %r13
jne 0x2828
movq 0x60(%rsp), %rax
movq -0x8(%rax), %rdi
movl $0x200, %eax            # imm = 0x200
addq %rax, %rdi
decq %rdi
callq 0x26f2
cmpl %eax, %ebx
jg 0x2867
cmpq %r12, %r13
jne 0x284a
movq 0x60(%rsp), %rax
movq -0x8(%rax), %r13
movl $0x200, %eax            # imm = 0x200
addq %rax, %r13
decq %r13
leaq 0x68(%rsp), %rdi
movq %r13, %rsi
callq 0x3f72
movq %r15, %rdi
callq 0x4196
jmp 0x27d1
movq %r15, %rdi
movq %rbp, %rsi
movq 0x8(%rsp), %r12
callq 0x3f72
movq 0x10(%rsp), %rbx
incq %r14
jmp 0x2785
movzbl (%rbp), %eax
movq %r15, %rdi
cmpl $0x28, %eax
je 0x27ac
cmpl $0x29, %eax
jne 0x29f1
movq %r15, %rdi
callq 0x400a
movq 0x48(%rsp), %rsi
movq 0x50(%rsp), %rcx
testq %rax, %rax
je 0x28f3
cmpq %rcx, %rsi
je 0x28c1
cmpb $0x28, -0x1(%rsi)
jne 0x28dc
jmp 0x28f3
movq 0x60(%rsp), %rax
movq -0x8(%rax), %rax
cmpb $0x28, 0x1ff(%rax)
je 0x28f3
addq $0x200, %rax            # imm = 0x200
movq %rax, %rsi
decq %rsi
leaq 0x68(%rsp), %rdi
callq 0x3f72
movq %r15, %rdi
callq 0x4196
jmp 0x289d
cmpq %rcx, %rsi
jne 0x2909
movq 0x60(%rsp), %rax
movq -0x8(%rax), %rsi
movl $0x200, %eax            # imm = 0x200
addq %rax, %rsi
cmpb $0x28, -0x1(%rsi)
jne 0x287c
movq %r15, %rdi
callq 0x4196
jmp 0x287c
leaq 0x18(%rsp), %r14
movl $0x200, %ebx            # imm = 0x200
leaq 0x68(%rsp), %r15
movq %r14, %rdi
callq 0x400a
testq %rax, %rax
je 0x2969
movq 0x48(%rsp), %rsi
cmpq 0x50(%rsp), %rsi
jne 0x2954
movq 0x60(%rsp), %rax
movq -0x8(%rax), %rsi
addq %rbx, %rsi
decq %rsi
movq %r15, %rdi
callq 0x3f72
movq %r14, %rdi
callq 0x4196
jmp 0x292f
leaq 0x68(%rsp), %r14
movl $0x200, %ebx            # imm = 0x200
movq %r14, %rdi
callq 0x400a
testq %rax, %rax
je 0x29b7
movq 0x98(%rsp), %rax
cmpq 0xa0(%rsp), %rax
jne 0x29a1
movq 0xb0(%rsp), %rax
movq -0x8(%rax), %rax
addq %rbx, %rax
movsbl -0x1(%rax), %esi
movq %r12, %rdi
callq 0x2110
movq %r14, %rdi
callq 0x4196
jmp 0x2973
movq (%r12), %rdi
movq 0x8(%r12), %rsi
addq %rdi, %rsi
callq 0x41e9
leaq 0x68(%rsp), %rdi
callq 0x39f2
leaq 0x18(%rsp), %rdi
callq 0x39f2
movq %r12, %rax
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x10
popq %rdi
callq 0x20a0
movq %rax, %r15
leaq 0x262f(%rip), %rsi      # 0x5032
movq %rax, %rdi
callq 0x2040
movq 0x55a6(%rip), %rsi      # 0x7fb8
movq 0x5597(%rip), %rdx      # 0x7fb0
movq %r15, %rdi
callq 0x2220
pushq $0x10
popq %rdi
callq 0x20a0
movq %rax, %rbx
leaq 0x25ff(%rip), %rsi      # 0x5032
movq %rax, %rdi
callq 0x2040
movq 0x5576(%rip), %rsi      # 0x7fb8
movq 0x5567(%rip), %rdx      # 0x7fb0
movq %rbx, %rdi
callq 0x2220
movq %rax, %r14
movq %rbx, %rdi
callq 0x20f0
jmp 0x2aaa
jmp 0x2a81
movq %rax, %r14
jmp 0x2a98
movq %rax, %r14
jmp 0x2aa2
jmp 0x2a81
movq %rax, %r14
movq %r15, %rdi
callq 0x20f0
jmp 0x2a8e
jmp 0x2a81
jmp 0x2a81
jmp 0x2a81
jmp 0x2a81
movq %rax, %r14
jmp 0x2a8e
movq %rax, %r14
movq 0x8(%rsp), %r12
leaq 0x68(%rsp), %rdi
callq 0x39f2
leaq 0x18(%rsp), %rdi
callq 0x39f2
movq %r12, %rdi
callq 0x2080
movq %r14, %rdi
callq 0x2240