#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 */
char char_to_int(char);
int /*<<< orphan*/ evaluate(char);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ make_empty();
int pop();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ push(char);
int /*<<< orphan*/ scanf(char *, char *);
int main(void) {
  char ch;
  for (;;) {
    printf("Enter an RPN exrpession: ");
    for (;;) {
      scanf(" %c", &ch);
      if (ch == '=') {
        printf("Value of expression: %d\n", pop());
        make_empty();
        break;
      } else if (char_to_int(ch) >= 0 && char_to_int(ch) - '1' <= 9)
        push(char_to_int(ch));
      else if (ch == '+' || ch == '-' || ch == '*' || ch == '/')
        evaluate(ch);
      else
        exit(0);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe6a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe76(%rip),%rdi
lea    -0x5(%rbp),%rsi
call   1070 <scanf@plt>
movsbl -0x5(%rbp),%eax
cmp    $0x3d,%eax
jne    11dd <main+0x5d>
mov    $0x0,%al
call   1040 <pop@plt>
mov    %eax,%esi
lea    0xe54(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1090 <make_empty@plt>
jmp    1278 <main+0xf8>
movsbl -0x5(%rbp),%edi
call   1050 <char_to_int@plt>
movsbl %al,%eax
cmp    $0x0,%eax
jl     1220 <main+0xa0>
movsbl -0x5(%rbp),%edi
call   1050 <char_to_int@plt>
movsbl %al,%eax
sub    $0x31,%eax
cmp    $0x9,%eax
jg     1220 <main+0xa0>
movsbl -0x5(%rbp),%edi
call   1050 <char_to_int@plt>
movsbl %al,%edi
call   1080 <push@plt>
jmp    126e <main+0xee>
movsbl -0x5(%rbp),%eax
cmp    $0x2b,%eax
je     1254 <main+0xd4>
movsbl -0x5(%rbp),%eax
cmp    $0x2d,%eax
je     1254 <main+0xd4>
movsbl -0x5(%rbp),%eax
cmp    $0x2a,%eax
je     1254 <main+0xd4>
movsbl -0x5(%rbp),%eax
cmp    $0x2f,%eax
jne    1262 <main+0xe2>
movsbl -0x5(%rbp),%edi
call   1060 <evaluate@plt>
jmp    1269 <main+0xe9>
xor    %edi,%edi
call   10a0 <exit@plt>
jmp    126e <main+0xee>
jmp    1273 <main+0xf3>
jmp    119d <main+0x1d>
jmp    118f <main+0xf>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xe6c(%rip),%r14
lea    0xe7f(%rip),%r15
lea    0xf(%rsp),%rbx
lea    0xe77(%rip),%r12
movabs $0xac0000000000,%r13
jmp    11da <main+0x5a>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %eax,%eax
call   1040 <pop@plt>
mov    %r12,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
call   1090 <make_empty@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    1202 <main+0x82>
cs nopw 0x0(%rax,%rax,1)
movsbl 0xf(%rsp),%edi
call   1050 <char_to_int@plt>
movsbl %al,%edi
call   1080 <push@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1070 <scanf@plt>
movzbl 0xf(%rsp),%eax
cmp    $0x3d,%al
je     11c0 <main+0x40>
movsbl %al,%edi
call   1050 <char_to_int@plt>
test   %al,%al
js     1230 <main+0xb0>
movsbl 0xf(%rsp),%edi
call   1050 <char_to_int@plt>
cmp    $0x3a,%al
jle    11f0 <main+0x70>
movzbl 0xf(%rsp),%eax
cmp    $0x2f,%rax
ja     124b <main+0xcb>
bt     %rax,%r13
jae    124b <main+0xcb>
movsbl %al,%edi
call   1060 <evaluate@plt>
jmp    1202 <main+0x82>
xor    %edi,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [26 x i8] c"Enter an RPN exrpession: \00"
@.str.1 = [4 x i8] c" %c\00"
@.str.2 = [25 x i8] c"Value of expression: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
store i32 0, i32* %1
br label %3
3: ; preds = %53, %0
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
br label %5
5: ; preds = %52, %3
%6 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%7 = load i8, i8* %2
%8 = sext i8 %7 to i32
%9 = icmp eq i32 %8, 61
br i1 %9, label %10, label %14
10: ; preds = %5
%11 = call i32 (...) @pop()
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %11)
%13 = call i32 (...) @make_empty()
br label %53
14: ; preds = %5
%15 = load i8, i8* %2
%16 = call signext i8 @char_to_int(i8 signext %15)
%17 = sext i8 %16 to i32
%18 = icmp sge i32 %17, 0
br i1 %18, label %19, label %29
19: ; preds = %14
%20 = load i8, i8* %2
%21 = call signext i8 @char_to_int(i8 signext %20)
%22 = sext i8 %21 to i32
%23 = sub nsw i32 %22, 49
%24 = icmp sle i32 %23, 9
br i1 %24, label %25, label %29
25: ; preds = %19
%26 = load i8, i8* %2
%27 = call signext i8 @char_to_int(i8 signext %26)
%28 = call i32 @push(i8 signext %27)
br label %51
29: ; preds = %19, %14
%30 = load i8, i8* %2
%31 = sext i8 %30 to i32
%32 = icmp eq i32 %31, 43
br i1 %32, label %45, label %33
33: ; preds = %29
%34 = load i8, i8* %2
%35 = sext i8 %34 to i32
%36 = icmp eq i32 %35, 45
br i1 %36, label %45, label %37
37: ; preds = %33
%38 = load i8, i8* %2
%39 = sext i8 %38 to i32
%40 = icmp eq i32 %39, 42
br i1 %40, label %45, label %41
41: ; preds = %37
%42 = load i8, i8* %2
%43 = sext i8 %42 to i32
%44 = icmp eq i32 %43, 47
br i1 %44, label %45, label %48
45: ; preds = %41, %37, %33, %29
%46 = load i8, i8* %2
%47 = call i32 @evaluate(i8 signext %46)
br label %50
48: ; preds = %41
%49 = call i32 @exit(i32 0)
unreachable
50: ; preds = %45
br label %51
51: ; preds = %50, %25
br label %52
52: ; preds = %51
br label %5
53: ; preds = %10
br label %3
}

LLVM IR (-O2):
@.str = [26 x i8] c"Enter an RPN exrpession: \00"
@.str.1 = [4 x i8] c" %c\00"
@.str.2 = [25 x i8] c"Value of expression: %d\0A\00"
define i32 @main() {
%1 = alloca i8
br label %2
2: ; preds = %7, %0
%3 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%5 = load i8, i8* %1
%6 = icmp eq i8 %5, 61
br i1 %6, label %7, label %11
7: ; preds = %29, %2
%8 = call i32 (...) @pop()
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %8)
%10 = call i32 (...) @make_empty()
br label %2
11: ; preds = %2, %29
%12 = phi i8 [ %31, %29 ], [ %5, %2 ]
%13 = call signext i8 @char_to_int(i8 signext %12)
%14 = icmp sgt i8 %13, -1
br i1 %14, label %15, label %23
15: ; preds = %11
%16 = load i8, i8* %1
%17 = call signext i8 @char_to_int(i8 signext %16)
%18 = icmp slt i8 %17, 59
br i1 %18, label %19, label %23
19: ; preds = %15
%20 = load i8, i8* %1
%21 = call signext i8 @char_to_int(i8 signext %20)
%22 = call i32 @push(i8 signext %21)
br label %29
23: ; preds = %15, %11
%24 = load i8, i8* %1
switch i8 %24, label %27 [
i8 47, label %25
i8 45, label %25
i8 43, label %25
i8 42, label %25
]
25: ; preds = %23, %23, %23, %23
%26 = call i32 @evaluate(i8 signext %24)
br label %29
27: ; preds = %23
%28 = call i32 @exit(i32 0)
unreachable
29: ; preds = %19, %25
%30 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%31 = load i8, i8* %1
%32 = icmp eq i8 %31, 61
br i1 %32, label %7, label %11
}