#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*/ convertToPostfix(char *, char *);
int evaluatePostfixExpression(char *);
int /*<<< orphan*/ printf(char *, char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int main(int argc, char const *argv[]) {
  char infix[40] = "(6+2)*5-8/4";
  scanf("%s", infix);
  char postfix[40] = "";
  char c;
  int result;
  convertToPostfix(infix, postfix);
  printf("%s\n", postfix);
  result = evaluatePostfixExpression(postfix);
  printf("%s%d\n", "result=", result);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x40(%rbp),%rdi
lea    0xe7c(%rip),%rsi
mov    $0x28,%edx
call   1070 <memcpy@plt>
lea    -0x40(%rbp),%rsi
lea    0xe8f(%rip),%rdi
call   1080 <scanf@plt>
lea    -0x70(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1050 <memset@plt>
lea    -0x40(%rbp),%rdi
lea    -0x70(%rbp),%rsi
call   1060 <convertToPostfix@plt>
lea    -0x70(%rbp),%rsi
lea    0xe65(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x70(%rbp),%rdi
call   1030 <evaluatePostfixExpression@plt>
mov    %eax,-0x78(%rbp)
mov    -0x78(%rbp),%edx
lea    0xe4c(%rip),%rdi
lea    0xe4b(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x58,%rsp
movaps 0xec2(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xea6(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movq   $0x0,0x50(%rsp)
lea    0xeb9(%rip),%rdi
lea    0x30(%rsp),%r14
mov    %r14,%rsi
call   1060 <scanf@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
movq   $0x0,0x20(%rsp)
mov    %rsp,%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <convertToPostfix@plt>
lea    0xe85(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <evaluatePostfixExpression@plt>
lea    0xe70(%rip),%rdi
lea    0xe6f(%rip),%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.infix = [40 x i8] c"(6+2)*5-8/4\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str = [3 x i8] c"%s\00"
@.str.1 = [4 x i8] c"%s\0A\00"
@.str.2 = [6 x i8] c"%s%d\0A\00"
@.str.3 = [8 x i8] c"result=\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [40 x i8]
%7 = alloca [40 x i8]
%8 = alloca i8
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = bitcast [40 x i8]* %6 to i8*
%11 = getelementptr inbounds [40 x i8], [40 x i8]* %6, i64 0, i64 0
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %11)
%13 = bitcast [40 x i8]* %7 to i8*
%14 = getelementptr inbounds [40 x i8], [40 x i8]* %6, i64 0, i64 0
%15 = getelementptr inbounds [40 x i8], [40 x i8]* %7, i64 0, i64 0
%16 = call i32 @convertToPostfix(i8* %14, i8* %15)
%17 = getelementptr inbounds [40 x i8], [40 x i8]* %7, i64 0, i64 0
%18 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %17)
%19 = getelementptr inbounds [40 x i8], [40 x i8]* %7, i64 0, i64 0
%20 = call i32 @evaluatePostfixExpression(i8* %19)
store i32 %20, i32* %9
%21 = load i32, i32* %9
%22 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %21)
ret i32 0
}

LLVM IR (-O2):
@__const.main.infix = [40 x i8] c"(6+2)*5-8/4\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str = [3 x i8] c"%s\00"
@.str.1 = [4 x i8] c"%s\0A\00"
@.str.2 = [6 x i8] c"%s%d\0A\00"
@.str.3 = [8 x i8] c"result=\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [40 x i8]
%4 = alloca [40 x i8]
%5 = getelementptr inbounds [40 x i8], [40 x i8]* %3, i64 0, i64 0
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %5)
%7 = getelementptr inbounds [40 x i8], [40 x i8]* %4, i64 0, i64 0
%8 = call i32 @convertToPostfix(i8* %5, i8* %7)
%9 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %7)
%10 = call i32 @evaluatePostfixExpression(i8* %7)
%11 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %10)
ret i32 0
}