// File: /workspace/github_c_makefile_star2_O2/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)
andq $0x0, 0x10(%rcx)
movaps %xmm0, -0x10(%rcx)
leaq 0x1894c(%rip), %rax     # 0x1b578
movsd (%rax), %xmm0
movsd %xmm0, 0x18(%rcx)
leaq 0x156e9(%rip), %rbx     # 0x18325
movq %rbx, %rdi
xorl %eax, %eax
callq 0x8643
leaq 0x156e0(%rip), %rdi     # 0x1832d
xorl %eax, %eax
callq 0x8643
leaq 0x15710(%rip), %rdi     # 0x1836b
xorl %eax, %eax
callq 0x8643
leaq 0x15740(%rip), %rdi     # 0x183a9
xorl %eax, %eax
callq 0x8643
movq %rbx, %rdi
xorl %eax, %eax
callq 0x8643
leaq 0x15766(%rip), %rdi     # 0x183e7
xorl %eax, %eax
callq 0x8643
movq %rbx, %rdi
xorl %eax, %eax
callq 0x8643
leaq 0x30(%rsp), %r14
movl $0xc8, %edx
movq %r14, %rdi
xorl %esi, %esi
callq 0x20d0
movq 0x2132b(%rip), %rbp     # 0x23fd8
leaq 0x15760(%rip), %rbx     # 0x18414
pushq $0x5
popq %r15
pushq $-0x1
popq %r12
leaq 0x15747(%rip), %rdi     # 0x1840a
xorl %eax, %eax
callq 0x8643
movq (%rbp), %rdx
movq %r14, %rdi
movl $0xc8, %esi
callq 0x2120
movq %rax, %rdi
callq 0x841c
leaq 0x1a1eb(%rip), %rdi     # 0x1ced5
xorl %eax, %eax
callq 0x8643
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x2190
testl %eax, %eax
je 0x2dbb
movl 0x30(%rsp), %r13d
cmpl $0x746573, %r13d        # imm = 0x746573
jne 0x2e0d
leaq 0x18cc6(%rip), %rdi     # 0x1b9e6
callq 0x8566
movq %rax, %r13
leaq 0x15b25(%rip), %rdi     # 0x18854
xorl %eax, %eax
callq 0x8643
movq (%rbp), %rdi
movl %r12d, %esi
movq %r13, %rdx
movq %rsp, %rcx
xorl %eax, %eax
callq 0x89d6
leaq 0x15b08(%rip), %rdi     # 0x18859
xorl %eax, %eax
callq 0x8643
movq (%rbp), %rdi
movl %r12d, %esi
movq %r13, %rdx
leaq 0x8(%rsp), %rcx
xorl %eax, %eax
callq 0x89d6
leaq 0x15ae9(%rip), %rdi     # 0x1885e
xorl %eax, %eax
callq 0x8643
movq (%rbp), %rdi
movl %r12d, %esi
movq %r13, %rdx
leaq 0x10(%rsp), %rcx
xorl %eax, %eax
callq 0x89d6
leaq 0x15aca(%rip), %rdi     # 0x18863
xorl %eax, %eax
callq 0x8643
movq (%rbp), %rdi
movl %r12d, %esi
movq %r13, %rdx
leaq 0x18(%rsp), %rcx
xorl %eax, %eax
callq 0x89d6
jmp 0x2cbc
leaq 0x15657(%rip), %rdi     # 0x18419
xorl %eax, %eax
callq 0x8643
leaq 0x15653(%rip), %rdi     # 0x18423
xorl %eax, %eax
callq 0x8643
leaq 0x15669(%rip), %rdi     # 0x18447
xorl %eax, %eax
callq 0x8643
leaq 0x1567d(%rip), %rdi     # 0x18469
xorl %eax, %eax
callq 0x8643
leaq 0x15695(%rip), %rdi     # 0x1848f
xorl %eax, %eax
callq 0x8643
leaq 0x156a6(%rip), %rdi     # 0x184ae
jmp 0x2eb3
movq %r14, %rdi
leaq 0x156ac(%rip), %rsi     # 0x184c3
pushq $0x7
popq %rdx
callq 0x2190
testl %eax, %eax
je 0x2e66
testb %r13b, %r13b
je 0x2cbc
movq %r14, %rdi
leaq 0x15694(%rip), %rsi     # 0x184ca
movq %r15, %rdx
callq 0x2190
testl %eax, %eax
je 0x2ebf
movq %rsp, %rdi
movq %r14, %rsi
callq 0x2ee1
movsd 0x20(%rsp), %xmm0
leaq 0x15675(%rip), %rdi     # 0x184cf
movb $0x1, %al
callq 0x8643
jmp 0x2cbc
leaq 0x15896(%rip), %rdi     # 0x18703
xorl %eax, %eax
callq 0x8643
leaq 0x158ad(%rip), %rdi     # 0x18728
xorl %eax, %eax
callq 0x8643
leaq 0x158f3(%rip), %rdi     # 0x1877c
xorl %eax, %eax
callq 0x8643
leaq 0x15939(%rip), %rdi     # 0x187d0
xorl %eax, %eax
callq 0x8643
leaq 0x1594e(%rip), %rdi     # 0x187f3
xorl %eax, %eax
callq 0x8643
leaq 0x15959(%rip), %rdi     # 0x1880c
xorl %eax, %eax
callq 0x8643
jmp 0x2cbc
leaq 0x1545f(%rip), %rdi     # 0x18325
xorl %eax, %eax
callq 0x8643
xorl %eax, %eax
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq