#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 */
scalar_t__ isOperator(char);
int pop();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ push(char);
int /*<<< orphan*/ scanf(char *, char *);
int strlen(char *);
int main(void) {
  char postfix[100];
  int i, l, op1, op2;
  printf("\nEnter postfix expression\n");
  scanf("%s", postfix);
  l = strlen(postfix);
  for (i = 0; i < l; i++) {
    if (isOperator(postfix[i])) {
      op2 = pop();
      op1 = pop();
      if (postfix[i] == '+')
        push(op1 + op2);
      else if (postfix[i] == '-')
        push(op1 - op2);
      else if (postfix[i] == '*')
        push(op1 * op2);
      else if (postfix[i] == '/')
        push(op1 / op2);
      else if (postfix[i] == '%')
        push(op1 % op2);
    } else
      push(postfix[i] - '0');
  }
  printf("\nPostfix Expression = %s\n", postfix);
  printf("\nEvaluation = %d\n", pop());
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe87(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x70(%rbp),%rsi
lea    0xe90(%rip),%rdi
call   1070 <scanf@plt>
lea    -0x70(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x78(%rbp)
movl   $0x0,-0x74(%rbp)
mov    -0x74(%rbp),%eax
cmp    -0x78(%rbp),%eax
jge    12d4 <main+0x174>
movslq -0x74(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%edi
call   1050 <isOperator@plt>
cmp    $0x0,%rax
je     12ad <main+0x14d>
mov    $0x0,%al
call   1060 <pop@plt>
mov    %eax,-0x80(%rbp)
mov    $0x0,%al
call   1060 <pop@plt>
mov    %eax,-0x7c(%rbp)
movslq -0x74(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%eax
cmp    $0x2b,%eax
jne    1200 <main+0xa0>
mov    -0x7c(%rbp),%eax
add    -0x80(%rbp),%eax
movsbl %al,%edi
call   1080 <push@plt>
jmp    12a8 <main+0x148>
movslq -0x74(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%eax
cmp    $0x2d,%eax
jne    1225 <main+0xc5>
mov    -0x7c(%rbp),%eax
sub    -0x80(%rbp),%eax
movsbl %al,%edi
call   1080 <push@plt>
jmp    12a3 <main+0x143>
movslq -0x74(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%eax
cmp    $0x2a,%eax
jne    124b <main+0xeb>
mov    -0x7c(%rbp),%eax
imul   -0x80(%rbp),%eax
movsbl %al,%edi
call   1080 <push@plt>
jmp    129e <main+0x13e>
movslq -0x74(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%eax
cmp    $0x2f,%eax
jne    1271 <main+0x111>
mov    -0x7c(%rbp),%eax
cltd
idivl  -0x80(%rbp)
movsbl %al,%edi
call   1080 <push@plt>
jmp    1299 <main+0x139>
movslq -0x74(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%eax
cmp    $0x25,%eax
jne    1294 <main+0x134>
mov    -0x7c(%rbp),%eax
cltd
idivl  -0x80(%rbp)
mov    %dl,%al
movsbl %al,%edi
call   1080 <push@plt>
jmp    1299 <main+0x139>
jmp    129e <main+0x13e>
jmp    12a3 <main+0x143>
jmp    12a8 <main+0x148>
jmp    12c1 <main+0x161>
movslq -0x74(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%eax
sub    $0x30,%eax
movsbl %al,%edi
call   1080 <push@plt>
jmp    12c6 <main+0x166>
mov    -0x74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x74(%rbp)
jmp    11a3 <main+0x43>
lea    -0x70(%rbp),%rsi
lea    0xd3f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1060 <pop@plt>
mov    %eax,%esi
lea    0xd42(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x68,%rsp
lea    0xeda(%rip),%rdi
call   1030 <puts@plt>
lea    0xe9f(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
call   1080 <scanf@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    1226 <main+0xb6>
mov    %eax,%r14d
lea    0xe4e(%rip),%r15
xor    %ebx,%ebx
jmp    11d7 <main+0x67>
cs nopw 0x0(%rax,%rax,1)
movzbl (%rsp,%rbx,1),%eax
add    $0xd0,%al
movsbl %al,%edi
call   1090 <push@plt>
add    $0x1,%rbx
cmp    %rbx,%r14
je     1226 <main+0xb6>
movsbl (%rsp,%rbx,1),%edi
call   1060 <isOperator@plt>
test   %rax,%rax
je     11c0 <main+0x50>
xor    %eax,%eax
call   1070 <pop@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1070 <pop@plt>
movzbl (%rsp,%rbx,1),%ecx
add    $0xdb,%cl
cmp    $0xa,%cl
ja     11ce <main+0x5e>
movzbl %cl,%ecx
movslq (%r15,%rcx,4),%rcx
add    %r15,%rcx
jmp    *%rcx
cltd
idiv   %ebp
mov    %edx,%eax
jmp    11c6 <main+0x56>
imul   %ebp,%eax
jmp    11c6 <main+0x56>
add    %ebp,%eax
jmp    11c6 <main+0x56>
sub    %ebp,%eax
jmp    11c6 <main+0x56>
cltd
idiv   %ebp
jmp    11c6 <main+0x56>
lea    0xe02(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1070 <pop@plt>
lea    0xe04(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [27 x i8] c"\0AEnter postfix expression\0A\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [26 x i8] c"\0APostfix Expression = %s\0A\00"
@.str.3 = [18 x i8] c"\0AEvaluation = %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%8 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %8)
%10 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%11 = call i32 @strlen(i8* %10)
store i32 %11, i32* %4
store i32 0, i32* %3
br label %12
12: ; preds = %105, %0
%13 = load i32, i32* %3
%14 = load i32, i32* %4
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %108
16: ; preds = %12
%17 = load i32, i32* %3
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %18
%20 = load i8, i8* %19
%21 = call i64 @isOperator(i8 signext %20)
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %95
23: ; preds = %16
%24 = call i32 (...) @pop()
store i32 %24, i32* %6
%25 = call i32 (...) @pop()
store i32 %25, i32* %5
%26 = load i32, i32* %3
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %27
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = icmp eq i32 %30, 43
br i1 %31, label %32, label %38
32: ; preds = %23
%33 = load i32, i32* %5
%34 = load i32, i32* %6
%35 = add nsw i32 %33, %34
%36 = trunc i32 %35 to i8
%37 = call i32 @push(i8 signext %36)
br label %94
38: ; preds = %23
%39 = load i32, i32* %3
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %40
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = icmp eq i32 %43, 45
br i1 %44, label %45, label %51
45: ; preds = %38
%46 = load i32, i32* %5
%47 = load i32, i32* %6
%48 = sub nsw i32 %46, %47
%49 = trunc i32 %48 to i8
%50 = call i32 @push(i8 signext %49)
br label %93
51: ; preds = %38
%52 = load i32, i32* %3
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %53
%55 = load i8, i8* %54
%56 = sext i8 %55 to i32
%57 = icmp eq i32 %56, 42
br i1 %57, label %58, label %64
58: ; preds = %51
%59 = load i32, i32* %5
%60 = load i32, i32* %6
%61 = mul nsw i32 %59, %60
%62 = trunc i32 %61 to i8
%63 = call i32 @push(i8 signext %62)
br label %92
64: ; preds = %51
%65 = load i32, i32* %3
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %66
%68 = load i8, i8* %67
%69 = sext i8 %68 to i32
%70 = icmp eq i32 %69, 47
br i1 %70, label %71, label %77
71: ; preds = %64
%72 = load i32, i32* %5
%73 = load i32, i32* %6
%74 = sdiv i32 %72, %73
%75 = trunc i32 %74 to i8
%76 = call i32 @push(i8 signext %75)
br label %91
77: ; preds = %64
%78 = load i32, i32* %3
%79 = sext i32 %78 to i64
%80 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %79
%81 = load i8, i8* %80
%82 = sext i8 %81 to i32
%83 = icmp eq i32 %82, 37
br i1 %83, label %84, label %90
84: ; preds = %77
%85 = load i32, i32* %5
%86 = load i32, i32* %6
%87 = srem i32 %85, %86
%88 = trunc i32 %87 to i8
%89 = call i32 @push(i8 signext %88)
br label %90
90: ; preds = %84, %77
br label %91
91: ; preds = %90, %71
br label %92
92: ; preds = %91, %58
br label %93
93: ; preds = %92, %45
br label %94
94: ; preds = %93, %32
br label %104
95: ; preds = %16
%96 = load i32, i32* %3
%97 = sext i32 %96 to i64
%98 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %97
%99 = load i8, i8* %98
%100 = sext i8 %99 to i32
%101 = sub nsw i32 %100, 48
%102 = trunc i32 %101 to i8
%103 = call i32 @push(i8 signext %102)
br label %104
104: ; preds = %95, %94
br label %105
105: ; preds = %104
%106 = load i32, i32* %3
%107 = add nsw i32 %106, 1
store i32 %107, i32* %3
br label %12
108: ; preds = %12
%109 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%110 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i8* %109)
%111 = call i32 (...) @pop()
%112 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i32 %111)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [26 x i8] c"\0APostfix Expression = %s\0A\00"
@.str.3 = [18 x i8] c"\0AEvaluation = %d\0A\00"
@str = [26 x i8] c"\0AEnter postfix expression\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%5 = call i32 @strlen(i8* %2)
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %43
7: ; preds = %0
%8 = zext i32 %5 to i64
br label %9
9: ; preds = %7, %40
%10 = phi i64 [ 0, %7 ], [ %41, %40 ]
%11 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %10
%12 = load i8, i8* %11
%13 = call i64 @isOperator(i8 signext %12)
%14 = icmp eq i64 %13, 0
br i1 %14, label %34, label %15
15: ; preds = %9
%16 = call i32 (...) @pop()
%17 = call i32 (...) @pop()
%18 = load i8, i8* %11
switch i8 %18, label %40 [
i8 43, label %19
i8 45, label %22
i8 42, label %25
i8 47, label %28
i8 37, label %31
]
19: ; preds = %15
%20 = add nsw i32 %17, %16
%21 = trunc i32 %20 to i8
br label %37
22: ; preds = %15
%23 = sub nsw i32 %17, %16
%24 = trunc i32 %23 to i8
br label %37
25: ; preds = %15
%26 = mul nsw i32 %17, %16
%27 = trunc i32 %26 to i8
br label %37
28: ; preds = %15
%29 = sdiv i32 %17, %16
%30 = trunc i32 %29 to i8
br label %37
31: ; preds = %15
%32 = srem i32 %17, %16
%33 = trunc i32 %32 to i8
br label %37
34: ; preds = %9
%35 = load i8, i8* %11
%36 = add i8 %35, -48
br label %37
37: ; preds = %19, %25, %31, %28, %22, %34
%38 = phi i8 [ %36, %34 ], [ %24, %22 ], [ %30, %28 ], [ %33, %31 ], [ %27, %25 ], [ %21, %19 ]
%39 = call i32 @push(i8 signext %38)
br label %40
40: ; preds = %37, %15
%41 = add nuw nsw i64 %10, 1
%42 = icmp eq i64 %41, %8
br i1 %42, label %43, label %9
43: ; preds = %40, %0
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i8* %2)
%45 = call i32 (...) @pop()
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i32 %45)
ret i32 0
}