// File: /workspace/github_c_makefile_star2_O3/mohuangrui[P]ArtraCFD/calculator.c
// Function: RunCalculator
int RunCalculator(void)
{
    CalcVar theVar = {
        .t = 0.0,
        .x = 0.0,
        .y = 0.0,
        .z = 0.0,
        .ans = 0.0,
        .pi = PI,
    };
    ShowInfo("Session");
    ShowInfo("*                   Expression Calculator                  *\n");
    ShowInfo("*                     <By Huangrui Mo>                     *\n");
    ShowInfo("*    Copyright (C) Huangrui Mo <huangrui.mo@gmail.com>     *\n");
    ShowInfo("Session");
    ShowInfo("Enter 'help' for more information\n");
    ShowInfo("Session");
    String str = {'\0'}; /* store the input information */
    while (1) {
        ShowInfo("\nCalc << ");
        ParseCommand(fgets(str, sizeof str, stdin));
        ShowInfo("\n");
        if (0 == strncmp(str, "help", sizeof str)) {
            ShowInfo("Options:\n");
            ShowInfo("[help]       show this information\n");
            ShowInfo("[set]        set variable values\n");
            ShowInfo("[math expr]  compute math expression\n");
            ShowInfo("[manual]     show user manual\n");
            ShowInfo("[exit]       return\n");
            continue;
        }
        if (0 == strncmp(str, "set", sizeof str)) {
            SetVariable(&theVar);
            continue;
        }
        if (0 == strncmp(str, "manual", sizeof str)) {
            ShowCalcManual();
            continue;
        }
        if ('\0' == str[0]) {
            continue;
        }
        if (0 == strncmp(str, "exit", sizeof str)) {
            ShowInfo("Session");
            return 0;
        }
        /* if non of above is true, then compute the expression */
        ComputeExpression(&theVar, str);
        ShowInfo("ans = %.6g\n", theVar.ans);
    }
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xf8, %rsp
xorps %xmm0, %xmm0
leaq 0x10(%rsp), %rcx
movaps %xmm0, (%rcx)
movaps %xmm0, -0x10(%rcx)
movq $0x0, 0x10(%rcx)
leaq 0x19a3d(%rip), %rax     # 0x1c688
movsd (%rax), %xmm0
movsd %xmm0, 0x18(%rcx)
leaq 0x166ca(%rip), %rbx     # 0x19325
movq %rbx, %rdi
xorl %eax, %eax
callq 0x8e15
leaq 0x166c1(%rip), %rdi     # 0x1932d
xorl %eax, %eax
callq 0x8e15
leaq 0x166f1(%rip), %rdi     # 0x1936b
xorl %eax, %eax
callq 0x8e15
leaq 0x16721(%rip), %rdi     # 0x193a9
xorl %eax, %eax
callq 0x8e15
movq %rbx, %rdi
xorl %eax, %eax
callq 0x8e15
leaq 0x16747(%rip), %rdi     # 0x193e7
xorl %eax, %eax
callq 0x8e15
movq %rbx, %rdi
xorl %eax, %eax
callq 0x8e15
leaq 0x30(%rsp), %r14
movl $0xc8, %edx
movq %r14, %rdi
xorl %esi, %esi
callq 0x20d0
leaq 0x1673e(%rip), %r13     # 0x1940a
movq 0x21305(%rip), %r12     # 0x23fd8
leaq 0x1b31b(%rip), %rbp     # 0x1dff5
movl $0x706c6568, %ebx       # imm = 0x706C6568
movq %r13, %rdi
xorl %eax, %eax
callq 0x8e15
movq (%r12), %rdx
movq %r14, %rdi
movl $0xc8, %esi
callq 0x2120
movq %rax, %rdi
callq 0x8c2c
movq %rbp, %rdi
xorl %eax, %eax
callq 0x8e15
movl 0x30(%rsp), %eax
xorl %ebx, %eax
movzbl 0x34(%rsp), %ecx
orl %eax, %ecx
je 0x2dd8
movl 0x30(%rsp), %eax
cmpl $0x746573, %eax         # imm = 0x746573
jne 0x2e2a
leaq 0x19dc9(%rip), %rdi     # 0x1cafe
callq 0x8d7a
movq %rax, %r15
leaq 0x16b10(%rip), %rdi     # 0x19854
xorl %eax, %eax
callq 0x8e15
movq (%r12), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movq %r15, %rdx
movq %rsp, %rcx
xorl %eax, %eax
callq 0x91dc
leaq 0x16af1(%rip), %rdi     # 0x19859
xorl %eax, %eax
callq 0x8e15
movq (%r12), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movq %r15, %rdx
leaq 0x8(%rsp), %rcx
xorl %eax, %eax
callq 0x91dc
leaq 0x16ad0(%rip), %rdi     # 0x1985e
xorl %eax, %eax
callq 0x8e15
movq (%r12), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movq %r15, %rdx
leaq 0x10(%rsp), %rcx
xorl %eax, %eax
callq 0x91dc
leaq 0x16aaf(%rip), %rdi     # 0x19863
xorl %eax, %eax
callq 0x8e15
movq (%r12), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movq %r15, %rdx
leaq 0x18(%rsp), %rcx
xorl %eax, %eax
callq 0x91dc
jmp 0x2cdf
leaq 0x1663a(%rip), %rdi     # 0x19419
xorl %eax, %eax
callq 0x8e15
leaq 0x16636(%rip), %rdi     # 0x19423
xorl %eax, %eax
callq 0x8e15
leaq 0x1664c(%rip), %rdi     # 0x19447
xorl %eax, %eax
callq 0x8e15
leaq 0x16660(%rip), %rdi     # 0x19469
xorl %eax, %eax
callq 0x8e15
leaq 0x16678(%rip), %rdi     # 0x1948f
xorl %eax, %eax
callq 0x8e15
leaq 0x16689(%rip), %rdi     # 0x194ae
jmp 0x2ed1
movl 0x30(%rsp), %ecx
movl $0x756e616d, %edx       # imm = 0x756E616D
xorl %edx, %ecx
movl 0x33(%rsp), %edx
movl $0x6c6175, %esi         # imm = 0x6C6175
xorl %esi, %edx
orl %ecx, %edx
je 0x2e84
testb %al, %al
je 0x2cdf
movl 0x30(%rsp), %eax
movl $0x74697865, %ecx       # imm = 0x74697865
xorl %ecx, %eax
movzbl 0x34(%rsp), %ecx
orl %eax, %ecx
je 0x2edd
movq %rsp, %rdi
movq %r14, %rsi
callq 0x2eff
movsd 0x20(%rsp), %xmm0
leaq 0x16657(%rip), %rdi     # 0x194cf
movb $0x1, %al
callq 0x8e15
jmp 0x2cdf
leaq 0x16878(%rip), %rdi     # 0x19703
xorl %eax, %eax
callq 0x8e15
leaq 0x1688f(%rip), %rdi     # 0x19728
xorl %eax, %eax
callq 0x8e15
leaq 0x168d5(%rip), %rdi     # 0x1977c
xorl %eax, %eax
callq 0x8e15
leaq 0x1691b(%rip), %rdi     # 0x197d0
xorl %eax, %eax
callq 0x8e15
leaq 0x16930(%rip), %rdi     # 0x197f3
xorl %eax, %eax
callq 0x8e15
leaq 0x1693b(%rip), %rdi     # 0x1980c
xorl %eax, %eax
callq 0x8e15
jmp 0x2cdf
leaq 0x16441(%rip), %rdi     # 0x19325
xorl %eax, %eax
callq 0x8e15
xorl %eax, %eax
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq