#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 */
int /*<<< orphan*/ CalcPostfix(char *, int *);
int /*<<< orphan*/ InfixToPostfix(char *, char *, size_t *);
int /*<<< orphan*/ getchar();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int main(int argc, char *argv[]) {
  char infix[1024];
  char postfix[1024];
  size_t top = 0;
  printf("Input Infix (Ended with \\n):\n");
  scanf("%s", infix);
  if (!InfixToPostfix(infix, postfix, &top)) {
    printf("Error Syntax\n");
    return 1;
  }
  postfix[top] = 0;
  printf("Postfix: %s\n", postfix);
  int result;
  if (!CalcPostfix(postfix, &result)) {
    printf("Error Postfix\n");
    return 1;
  }
  printf("Result: %d\n", result);
  getchar();
  getchar();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x820,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x818(%rbp)
lea    0xe85(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x410(%rbp),%rsi
lea    0xe8e(%rip),%rdi
call   1070 <scanf@plt>
lea    -0x410(%rbp),%rdi
lea    -0x810(%rbp),%rsi
lea    -0x818(%rbp),%rdx
call   1050 <InfixToPostfix@plt>
cmp    $0x0,%eax
jne    11d2 <main+0x82>
lea    0xe62(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1255 <main+0x105>
mov    -0x818(%rbp),%rax
movb   $0x0,-0x810(%rbp,%rax,1)
lea    -0x810(%rbp),%rsi
lea    0xe40(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x810(%rbp),%rdi
lea    -0x81c(%rbp),%rsi
call   1060 <CalcPostfix@plt>
cmp    $0x0,%eax
jne    122c <main+0xdc>
lea    0xe23(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1255 <main+0x105>
mov    -0x81c(%rbp),%esi
lea    0xe12(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x820,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x818,%rsp
movq   $0x0,0x8(%rsp)
lea    0xea2(%rip),%rdi
call   1030 <puts@plt>
lea    0xe7a(%rip),%rdi
lea    0x410(%rsp),%rbx
mov    %rbx,%rsi
call   1080 <scanf@plt>
lea    0x10(%rsp),%rsi
lea    0x8(%rsp),%rdx
mov    %rbx,%rdi
call   1060 <InfixToPostfix@plt>
test   %eax,%eax
je     1201 <main+0xa1>
mov    0x8(%rsp),%rax
movb   $0x0,0x10(%rsp,%rax,1)
lea    0xe46(%rip),%rdi
xor    %ebx,%ebx
lea    0x10(%rsp),%r14
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x4(%rsp),%rsi
mov    %r14,%rdi
call   1070 <CalcPostfix@plt>
test   %eax,%eax
je     120a <main+0xaa>
mov    0x4(%rsp),%esi
lea    0xe26(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
jmp    121b <main+0xbb>
lea    0xe31(%rip),%rdi
jmp    1211 <main+0xb1>
lea    0xe35(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x818,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [30 x i8] c"Input Infix (Ended with \\n):\0A\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [14 x i8] c"Error Syntax\0A\00"
@.str.3 = [13 x i8] c"Postfix: %s\0A\00"
@.str.4 = [15 x i8] c"Error Postfix\0A\00"
@.str.5 = [12 x i8] c"Result: %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [1024 x i8]
%7 = alloca [1024 x i8]
%8 = alloca i64
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i64 0, i64* %8
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%11 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %11)
%13 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%14 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%15 = call i32 @InfixToPostfix(i8* %13, i8* %14, i64* %8)
%16 = icmp ne i32 %15, 0
br i1 %16, label %19, label %17
17: ; preds = %2
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %34
19: ; preds = %2
%20 = load i64, i64* %8
%21 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 %20
store i8 0, i8* %21
%22 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8* %22)
%24 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%25 = call i32 @CalcPostfix(i8* %24, i32* %9)
%26 = icmp ne i32 %25, 0
br i1 %26, label %29, label %27
27: ; preds = %19
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
store i32 1, i32* %3
br label %34
29: ; preds = %19
%30 = load i32, i32* %9
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32 %30)
%32 = call i32 (...) @getchar()
%33 = call i32 (...) @getchar()
store i32 0, i32* %3
br label %34
34: ; preds = %29, %27, %17
%35 = load i32, i32* %3
ret i32 %35
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%s\00"
@.str.3 = [13 x i8] c"Postfix: %s\0A\00"
@.str.5 = [12 x i8] c"Result: %d\0A\00"
@str = [29 x i8] c"Input Infix (Ended with \\n):\00"
@str.6 = [13 x i8] c"Error Syntax\00"
@str.7 = [14 x i8] c"Error Postfix\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [1024 x i8]
%4 = alloca [1024 x i8]
%5 = alloca i64
%6 = alloca i32
%7 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%8 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%9 = bitcast i64* %5 to i8*
store i64 0, i64* %5
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %7)
%12 = call i32 @InfixToPostfix(i8* %7, i8* %8, i64* %5)
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %2
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.6, i64 0, i64 0))
br label %32
16: ; preds = %2
%17 = load i64, i64* %5
%18 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 %17
store i8 0, i8* %18
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8* %8)
%20 = bitcast i32* %6 to i8*
%21 = call i32 @CalcPostfix(i8* %8, i32* %6)
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %16
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.7, i64 0, i64 0))
br label %30
25: ; preds = %16
%26 = load i32, i32* %6
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32 %26)
%28 = call i32 (...) @getchar()
%29 = call i32 (...) @getchar()
br label %30
30: ; preds = %25, %23
%31 = phi i32 [ 0, %25 ], [ 1, %23 ]
br label %32
32: ; preds = %30, %14
%33 = phi i32 [ %31, %30 ], [ 1, %14 ]
ret i32 %33
}