#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*/ 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(int /*<<< orphan*/);
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 (ch >= '0' && (ch) <= '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    1264 <main+0xe4>
movsbl -0x5(%rbp),%eax
cmp    $0x30,%eax
jl     120c <main+0x8c>
movsbl -0x5(%rbp),%eax
cmp    $0x39,%eax
jg     120c <main+0x8c>
movsbl -0x5(%rbp),%edi
call   1050 <char_to_int@plt>
mov    %eax,%edi
call   1080 <push@plt>
jmp    125a <main+0xda>
movsbl -0x5(%rbp),%eax
cmp    $0x2b,%eax
je     1240 <main+0xc0>
movsbl -0x5(%rbp),%eax
cmp    $0x2d,%eax
je     1240 <main+0xc0>
movsbl -0x5(%rbp),%eax
cmp    $0x2a,%eax
je     1240 <main+0xc0>
movsbl -0x5(%rbp),%eax
cmp    $0x2f,%eax
jne    124e <main+0xce>
movsbl -0x5(%rbp),%edi
call   1060 <evaluate@plt>
jmp    1255 <main+0xd5>
xor    %edi,%edi
call   10a0 <exit@plt>
jmp    125a <main+0xda>
jmp    125f <main+0xdf>
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    11ff <main+0x7f>
cs nopw 0x0(%rax,%rax,1)
movsbl %al,%edi
call   1050 <char_to_int@plt>
mov    %eax,%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>
lea    -0x30(%rax),%ecx
cmp    $0x9,%cl
jbe    11f0 <main+0x70>
cmp    $0x2f,%al
ja     1232 <main+0xb2>
movzbl %al,%ecx
bt     %rcx,%r13
jae    1232 <main+0xb2>
movsbl %al,%edi
call   1060 <evaluate@plt>
jmp    11ff <main+0x7f>
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 = %50, %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 = %49, %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 %50
14: ; preds = %5
%15 = load i8, i8* %2
%16 = sext i8 %15 to i32
%17 = icmp sge i32 %16, 48
br i1 %17, label %18, label %26
18: ; preds = %14
%19 = load i8, i8* %2
%20 = sext i8 %19 to i32
%21 = icmp sle i32 %20, 57
br i1 %21, label %22, label %26
22: ; preds = %18
%23 = load i8, i8* %2
%24 = call i32 @char_to_int(i8 signext %23)
%25 = call i32 @push(i32 %24)
br label %48
26: ; preds = %18, %14
%27 = load i8, i8* %2
%28 = sext i8 %27 to i32
%29 = icmp eq i32 %28, 43
br i1 %29, label %42, label %30
30: ; preds = %26
%31 = load i8, i8* %2
%32 = sext i8 %31 to i32
%33 = icmp eq i32 %32, 45
br i1 %33, label %42, label %34
34: ; preds = %30
%35 = load i8, i8* %2
%36 = sext i8 %35 to i32
%37 = icmp eq i32 %36, 42
br i1 %37, label %42, label %38
38: ; preds = %34
%39 = load i8, i8* %2
%40 = sext i8 %39 to i32
%41 = icmp eq i32 %40, 47
br i1 %41, label %42, label %45
42: ; preds = %38, %34, %30, %26
%43 = load i8, i8* %2
%44 = call i32 @evaluate(i8 signext %43)
br label %47
45: ; preds = %38
%46 = call i32 @exit(i32 0)
unreachable
47: ; preds = %42
br label %48
48: ; preds = %47, %22
br label %49
49: ; preds = %48
br label %5
50: ; 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 = %23, %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, %23
%12 = phi i8 [ %25, %23 ], [ %5, %2 ]
%13 = add i8 %12, -48
%14 = icmp ult i8 %13, 10
br i1 %14, label %15, label %18
15: ; preds = %11
%16 = call i32 @char_to_int(i8 signext %12)
%17 = call i32 @push(i32 %16)
br label %23
18: ; preds = %11
switch i8 %12, label %21 [
i8 47, label %19
i8 45, label %19
i8 43, label %19
i8 42, label %19
]
19: ; preds = %18, %18, %18, %18
%20 = call i32 @evaluate(i8 signext %12)
br label %23
21: ; preds = %18
%22 = call i32 @exit(i32 0)
unreachable
23: ; preds = %15, %19
%24 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%25 = load i8, i8* %1
%26 = icmp eq i8 %25, 61
br i1 %26, label %7, label %11
}