#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__ isdigit(char);
int pop();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ push(int);
int /*<<< orphan*/ scanf(char *, char *);
int main() {
  char exp[20];
  char *e;
  int n1, n2, n3, num;
  printf("Enter the expression :: ");
  scanf("%s", exp);
  e = exp;
  while (*e != '\0') {
    if (isdigit(*e)) {
      num = *e - 48;
      push(num);
    } else {
      n1 = pop();
      n2 = pop();
      switch (*e) {
      case '+': {
        n3 = n1 + n2;
        break;
      }
      case '-': {
        n3 = n2 - n1;
        break;
      }
      case '*': {
        n3 = n1 * n2;
        break;
      }
      case '/': {
        n3 = n2 / n1;
        break;
      }
      }
      push(n3);
    }
    e++;
  }
  printf("\nThe result of expression %s  =  %d\n\n", exp, pop());
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeb2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x20(%rbp),%rsi
lea    0xeb9(%rip),%rdi
call   1060 <scanf@plt>
lea    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     125a <main+0x10a>
mov    -0x28(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     11c5 <main+0x75>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
sub    $0x30,%eax
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%edi
call   1070 <push@plt>
jmp    1249 <main+0xf9>
xor    %eax,%eax
mov    %al,-0x41(%rbp)
call   1050 <pop@plt>
mov    %eax,%ecx
mov    -0x41(%rbp),%al
mov    %ecx,-0x2c(%rbp)
call   1050 <pop@plt>
mov    %eax,-0x30(%rbp)
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
add    $0xffffffd6,%eax
mov    %eax,%ecx
mov    %rcx,-0x40(%rbp)
sub    $0x5,%eax
ja     1241 <main+0xf1>
mov    -0x40(%rbp),%rax
lea    0xdfd(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x2c(%rbp),%eax
add    -0x30(%rbp),%eax
mov    %eax,-0x34(%rbp)
jmp    1241 <main+0xf1>
mov    -0x30(%rbp),%eax
sub    -0x2c(%rbp),%eax
mov    %eax,-0x34(%rbp)
jmp    1241 <main+0xf1>
mov    -0x2c(%rbp),%eax
imul   -0x30(%rbp),%eax
mov    %eax,-0x34(%rbp)
jmp    1241 <main+0xf1>
mov    -0x30(%rbp),%eax
cltd
idivl  -0x2c(%rbp)
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%edi
call   1070 <push@plt>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1185 <main+0x35>
lea    -0x20(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    $0x0,%al
call   1050 <pop@plt>
mov    -0x50(%rbp),%rsi
mov    %eax,%edx
lea    0xdbe(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
lea    0xeb7(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec2(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
call   1060 <scanf@plt>
mov    (%rsp),%al
test   %al,%al
je     11f7 <main+0xa7>
lea    0xe78(%rip),%r14
jmp    11a7 <main+0x57>
nopw   0x0(%rax,%rax,1)
movsbl (%rbx),%edi
add    $0xffffffd0,%edi
call   1070 <push@plt>
movzbl 0x1(%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     11f7 <main+0xa7>
movsbl %al,%edi
call   1030 <isdigit@plt>
test   %rax,%rax
jne    1190 <main+0x40>
xor    %eax,%eax
call   1050 <pop@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1050 <pop@plt>
movsbl (%rbx),%ecx
add    $0xffffffd6,%ecx
cmp    $0x5,%ecx
ja     11f2 <main+0xa2>
movslq (%r14,%rcx,4),%rcx
add    %r14,%rcx
mov    %r15d,%edi
jmp    *%rcx
imul   %ebp,%eax
jmp    11eb <main+0x9b>
add    %ebp,%eax
jmp    11eb <main+0x9b>
sub    %ebp,%eax
jmp    11eb <main+0x9b>
cltd
idiv   %ebp
mov    %eax,%edi
mov    %eax,%r15d
jmp    1196 <main+0x46>
mov    %r15d,%edi
jmp    1196 <main+0x46>
xor    %eax,%eax
call   1050 <pop@plt>
lea    0xe2f(%rip),%rdi
mov    %rsp,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [25 x i8] c"Enter the expression :: \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [38 x i8] c"\0AThe result of expression %s = %d\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [20 x i8]
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%9 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%11 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
store i8* %11, i8** %3
br label %12
12: ; preds = %54, %0
%13 = load i8*, i8** %3
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %57
17: ; preds = %12
%18 = load i8*, i8** %3
%19 = load i8, i8* %18
%20 = call i64 @isdigit(i8 signext %19)
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %29
22: ; preds = %17
%23 = load i8*, i8** %3
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = sub nsw i32 %25, 48
store i32 %26, i32* %7
%27 = load i32, i32* %7
%28 = call i32 @push(i32 %27)
br label %54
29: ; preds = %17
%30 = call i32 (...) @pop()
store i32 %30, i32* %4
%31 = call i32 (...) @pop()
store i32 %31, i32* %5
%32 = load i8*, i8** %3
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
switch i32 %34, label %51 [
i32 43, label %35
i32 45, label %39
i32 42, label %43
i32 47, label %47
]
35: ; preds = %29
%36 = load i32, i32* %4
%37 = load i32, i32* %5
%38 = add nsw i32 %36, %37
store i32 %38, i32* %6
br label %51
39: ; preds = %29
%40 = load i32, i32* %5
%41 = load i32, i32* %4
%42 = sub nsw i32 %40, %41
store i32 %42, i32* %6
br label %51
43: ; preds = %29
%44 = load i32, i32* %4
%45 = load i32, i32* %5
%46 = mul nsw i32 %44, %45
store i32 %46, i32* %6
br label %51
47: ; preds = %29
%48 = load i32, i32* %5
%49 = load i32, i32* %4
%50 = sdiv i32 %48, %49
store i32 %50, i32* %6
br label %51
51: ; preds = %29, %47, %43, %39, %35
%52 = load i32, i32* %6
%53 = call i32 @push(i32 %52)
br label %54
54: ; preds = %51, %22
%55 = load i8*, i8** %3
%56 = getelementptr inbounds i8, i8* %55, i32 1
store i8* %56, i8** %3
br label %12
57: ; preds = %12
%58 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%59 = call i32 (...) @pop()
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), i8* %58, i32 %59)
ret i32 0
}

LLVM IR (-O2):
@.str = [25 x i8] c"Enter the expression :: \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [38 x i8] c"\0AThe result of expression %s = %d\0A\0A\00"
define i32 @main() {
%1 = alloca [20 x i8]
%2 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 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 = load i8, i8* %2
%6 = icmp eq i8 %5, 0
br i1 %6, label %37, label %7
7: ; preds = %0, %30
%8 = phi i8 [ %35, %30 ], [ %5, %0 ]
%9 = phi i8* [ %34, %30 ], [ %2, %0 ]
%10 = phi i32 [ %32, %30 ], [ undef, %0 ]
%11 = call i64 @isdigit(i8 signext %8)
%12 = icmp eq i64 %11, 0
br i1 %12, label %17, label %13
13: ; preds = %7
%14 = load i8, i8* %9
%15 = sext i8 %14 to i32
%16 = add nsw i32 %15, -48
br label %30
17: ; preds = %7
%18 = call i32 (...) @pop()
%19 = call i32 (...) @pop()
%20 = load i8, i8* %9
%21 = sext i8 %20 to i32
switch i32 %21, label %30 [
i32 43, label %22
i32 45, label %24
i32 42, label %26
i32 47, label %28
]
22: ; preds = %17
%23 = add nsw i32 %19, %18
br label %30
24: ; preds = %17
%25 = sub nsw i32 %19, %18
br label %30
26: ; preds = %17
%27 = mul nsw i32 %19, %18
br label %30
28: ; preds = %17
%29 = sdiv i32 %19, %18
br label %30
30: ; preds = %22, %24, %26, %28, %17, %13
%31 = phi i32 [ %16, %13 ], [ %10, %17 ], [ %29, %28 ], [ %27, %26 ], [ %25, %24 ], [ %23, %22 ]
%32 = phi i32 [ %10, %13 ], [ %10, %17 ], [ %29, %28 ], [ %27, %26 ], [ %25, %24 ], [ %23, %22 ]
%33 = call i32 @push(i32 %31)
%34 = getelementptr inbounds i8, i8* %9, i64 1
%35 = load i8, i8* %34
%36 = icmp eq i8 %35, 0
br i1 %36, label %37, label %7
37: ; preds = %30, %0
%38 = call i32 (...) @pop()
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), i8* %2, i32 %38)
ret i32 0
}