#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
double Calcute(char *);
int /*<<< orphan*/ MidfixToPostfix(char *, char *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdin;
int main() {
  char midFix[100];
  char postFix[150];
  double result = 0.0;
  while (1) {
    printf("Please enter an expression: ");
    fgets(midFix, 100, stdin);
    printf("midfix is : %s \n", midFix);
    MidfixToPostfix(midFix, postFix);
    printf("postFix is : %s \n", postFix);
    result = Calcute(postFix);
    printf("calculation is : %lf \n", result);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x118(%rbp)
ff
lea    0xe9c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x70(%rbp),%rdi
mov    0x2e72(%rip),%rax
mov    (%rax),%edx
mov    $0x64,%esi
call   1050 <fgets@plt>
lea    -0x70(%rbp),%rsi
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x70(%rbp),%rdi
lea    -0x110(%rbp),%rsi
call   1060 <MidfixToPostfix@plt>
lea    -0x110(%rbp),%rsi
lea    0xe7c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x110(%rbp),%rdi
call   1030 <Calcute@plt>
movsd  %xmm0,-0x118(%rbp)
ff
movsd  -0x118(%rbp),%xmm0
ff
lea    0xe64(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
jmp    115d <main+0x1d>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x108,%rsp
mov    0x2e90(%rip),%r14
mov    %rsp,%r12
lea    0xebb(%rip),%r15
lea    0x70(%rsp),%rbx
lea    0xec0(%rip),%r13
lea    0xecb(%rip),%rbp
cs nopw 0x0(%rax,%rax,1)
nop
lea    0xe79(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%r14),%edx
mov    %r12,%rdi
mov    $0x64,%esi
call   1050 <fgets@plt>
mov    %r15,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1060 <MidfixToPostfix@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <Calcute@plt>
mov    %rbp,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
jmp    1180 <main+0x40>

LLVM IR (-O0):
@.str = [29 x i8] c"Please enter an expression: \00"
@stdin = global i32 0
@.str.1 = [17 x i8] c"midfix is : %s \0A\00"
@.str.2 = [18 x i8] c"postFix is : %s \0A\00"
@.str.3 = [23 x i8] c"calculation is : %lf \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i8]
%3 = alloca [150 x i8]
%4 = alloca double
store i32 0, i32* %1
store double 0.000000e+00, double* %4
br label %5
5: ; preds = %0, %5
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%8 = load i32, i32* @stdin
%9 = call i32 @fgets(i8* %7, i32 100, i32 %8)
%10 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %10)
%12 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%13 = getelementptr inbounds [150 x i8], [150 x i8]* %3, i64 0, i64 0
%14 = call i32 @MidfixToPostfix(i8* %12, i8* %13)
%15 = getelementptr inbounds [150 x i8], [150 x i8]* %3, i64 0, i64 0
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8* %15)
%17 = getelementptr inbounds [150 x i8], [150 x i8]* %3, i64 0, i64 0
%18 = call double @Calcute(i8* %17)
store double %18, double* %4
%19 = load double, double* %4
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), double %19)
br label %5
}

LLVM IR (-O2):
@.str = [29 x i8] c"Please enter an expression: \00"
@stdin = global i32 0
@.str.1 = [17 x i8] c"midfix is : %s \0A\00"
@.str.2 = [18 x i8] c"postFix is : %s \0A\00"
@.str.3 = [23 x i8] c"calculation is : %lf \0A\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = alloca [150 x i8]
%3 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [150 x i8], [150 x i8]* %2, i64 0, i64 0
br label %5
5: ; preds = %5, %0
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%7 = load i32, i32* @stdin
%8 = call i32 @fgets(i8* %3, i32 100, i32 %7)
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%10 = call i32 @MidfixToPostfix(i8* %3, i8* %4)
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8* %4)
%12 = call double @Calcute(i8* %4)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), double %12)
br label %5
}