#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*/ postfix(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  char infix[15];
  int c = 0;
  while (c < 2) {
    printf("\n MAIN MENU \n");
    printf("1.ENTER EXPRESSION \n");
    printf("2.EXIT \n");
    printf("ENTER YOUR CHOICE \n");
    scanf("%d", &c);
    switch (c) {
    case 1:
      printf("ENTER THE EXPRESSION \n");
      scanf("%s", infix);
      postfix(infix);
      break;
    case 2:
      c = 3;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x2,-0x18(%rbp)
jge    11ef <main+0xbf>
lea    0xea9(%rip),%rdi
call   1040 <printf@plt>
lea    0xeab(%rip),%rdi
call   1040 <printf@plt>
lea    0xeb4(%rip),%rdi
call   1040 <printf@plt>
lea    0xeb1(%rip),%rdi
call   1040 <printf@plt>
lea    0xeb9(%rip),%rdi
xor    %eax,%eax
lea    -0x18(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
sub    $0x1,%eax
je     11b7 <main+0x87>
jmp    11a6 <main+0x76>
mov    -0x1c(%rbp),%eax
sub    $0x2,%eax
je     11e3 <main+0xb3>
jmp    11ea <main+0xba>
lea    0xe85(%rip),%rdi
call   1040 <printf@plt>
lea    -0x13(%rbp),%rsi
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1050 <scanf@plt>
lea    -0x13(%rbp),%rdi
call   1030 <postfix@plt>
jmp    11ea <main+0xba>
movl   $0x3,-0x18(%rbp)
jmp    1146 <main+0x16>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
movl   $0x0,0x4(%rsp)
lea    0xec6(%rip),%r15
lea    0xed3(%rip),%r12
lea    0xed4(%rip),%r13
lea    0xe9e(%rip),%rbx
lea    0x4(%rsp),%rbp
lea    0x9(%rsp),%r14
jmp    119e <main+0x6e>
xchg   %ax,%ax
lea    0xecb(%rip),%rdi
call   1030 <puts@plt>
lea    0xe80(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    %r14,%rdi
call   1040 <postfix@plt>
mov    0x4(%rsp),%eax
cmp    $0x2,%eax
jge    11dd <main+0xad>
lea    0xe61(%rip),%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
call   1030 <puts@plt>
mov    %r12,%rdi
call   1030 <puts@plt>
mov    %r13,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
cmp    $0x1,%eax
je     1170 <main+0x40>
cmp    $0x2,%eax
jne    1199 <main+0x69>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [14 x i8] c"\0A MAIN MENU \0A\00"
@.str.1 = [21 x i8] c"1.ENTER EXPRESSION \0A\00"
@.str.2 = [9 x i8] c"2.EXIT \0A\00"
@.str.3 = [20 x i8] c"ENTER YOUR CHOICE \0A\00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [23 x i8] c"ENTER THE EXPRESSION \0A\00"
@.str.6 = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [15 x i8]
%3 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
br label %4
4: ; preds = %21, %0
%5 = load i32, i32* %3
%6 = icmp slt i32 %5, 2
br i1 %6, label %7, label %22
7: ; preds = %4
%8 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %3)
%13 = load i32, i32* %3
switch i32 %13, label %21 [
i32 1, label %14
i32 2, label %20
]
14: ; preds = %7
%15 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0))
%16 = getelementptr inbounds [15 x i8], [15 x i8]* %2, i64 0, i64 0
%17 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* %16)
%18 = getelementptr inbounds [15 x i8], [15 x i8]* %2, i64 0, i64 0
%19 = call i32 @postfix(i8* %18)
br label %21
20: ; preds = %7
store i32 3, i32* %3
br label %21
21: ; preds = %20, %7, %14
br label %4
22: ; preds = %4
ret i32 0
}

LLVM IR (-O2):
@.str.4 = [3 x i8] c"%d\00"
@.str.6 = [3 x i8] c"%s\00"
@str = [13 x i8] c"\0A MAIN MENU \00"
@str.7 = [20 x i8] c"1.ENTER EXPRESSION \00"
@str.8 = [8 x i8] c"2.EXIT \00"
@str.9 = [19 x i8] c"ENTER YOUR CHOICE \00"
@str.10 = [22 x i8] c"ENTER THE EXPRESSION \00"
define i32 @main() {
%1 = alloca [15 x i8]
%2 = alloca i32
%3 = getelementptr inbounds [15 x i8], [15 x i8]* %1, i64 0, i64 0
%4 = bitcast i32* %2 to i8*
store i32 0, i32* %2
br label %5
5: ; preds = %0, %17
%6 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0))
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.7, i64 0, i64 0))
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.8, i64 0, i64 0))
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.9, i64 0, i64 0))
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %2)
%11 = load i32, i32* %2
switch i32 %11, label %17 [
i32 1, label %12
i32 2, label %20
]
12: ; preds = %5
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.10, i64 0, i64 0))
%14 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* %3)
%15 = call i32 @postfix(i8* %3)
%16 = load i32, i32* %2
br label %17
17: ; preds = %5, %12
%18 = phi i32 [ %11, %5 ], [ %16, %12 ]
%19 = icmp slt i32 %18, 2
br i1 %19, label %5, label %20
20: ; preds = %17, %5
ret i32 0
}