#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*/ calculate(int);
int /*<<< orphan*/ display();
int getchar();
int /*<<< orphan*/ make_empty();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ push(int);
void input(void) {
  int ch;
  printf("Enter an RPN expression: ");
  while (true) {
    ch = getchar();
    if (ch == '*' || ch == '/' || ch == '+' || ch == '-') {
      calculate(ch);
    } else if (ch == '=') {
      display();
    } else if (ch == ' ') {
      continue;
    } else if (ch == 'q') {
      make_empty();
    } else if (ch == '\n') {
      break;
    } else {
      ch -= 48;
      push(ch);
    }
  }
}


x86 assembly (clang, -O0):
<input>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xe91(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1060 <getchar@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x2a,-0x4(%rbp)
je     11a6 <input+0x46>
cmpl   $0x2f,-0x4(%rbp)
je     11a6 <input+0x46>
cmpl   $0x2b,-0x4(%rbp)
je     11a6 <input+0x46>
cmpl   $0x2d,-0x4(%rbp)
jne    11b3 <input+0x53>
mov    -0x4(%rbp),%edi
call   1050 <calculate@plt>
jmp    1222 <input+0xc2>
cmpl   $0x3d,-0x4(%rbp)
jne    11c9 <input+0x69>
mov    $0x0,%al
call   1030 <display@plt>
jmp    121d <input+0xbd>
cmpl   $0x20,-0x4(%rbp)
jne    11d8 <input+0x78>
jmp    1174 <input+0x14>
cmpl   $0x71,-0x4(%rbp)
jne    11ee <input+0x8e>
mov    $0x0,%al
call   1080 <make_empty@plt>
jmp    1213 <input+0xb3>
cmpl   $0xa,-0x4(%rbp)
jne    11fd <input+0x9d>
jmp    1227 <input+0xc7>
mov    -0x4(%rbp),%eax
sub    $0x30,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%edi
call   1070 <push@plt>
jmp    1213 <input+0xb3>
jmp    1218 <input+0xb8>
jmp    121d <input+0xbd>
jmp    1222 <input+0xc2>
jmp    1174 <input+0x14>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<input>:
push   %rbx
lea    0xf68(%rip),%rdi
call   1040 <printf@plt>
lea    0xe8c(%rip),%rbx
jmp    1180 <input+0x20>
add    $0xffffffd0,%eax
mov    %eax,%edi
call   1070 <push@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
lea    -0xa(%rax),%ecx
cmp    $0x33,%ecx
ja     11a1 <input+0x41>
movslq (%rbx,%rcx,4),%rcx
add    %rbx,%rcx
jmp    *%rcx
mov    %eax,%edi
call   1050 <calculate@plt>
jmp    1180 <input+0x20>
cmp    $0x71,%eax
jne    1176 <input+0x16>
xor    %eax,%eax
call   1080 <make_empty@plt>
jmp    1180 <input+0x20>
xor    %eax,%eax
call   1030 <display@plt>
jmp    1180 <input+0x20>
pop    %rbx
ret

LLVM IR (-O0):
@.str = [26 x i8] c"Enter an RPN expression: \00"
define void @input() {
%1 = alloca i32
%2 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
br label %3
3: ; preds = %0, %27, %46
%4 = call i32 (...) @getchar()
store i32 %4, i32* %1
%5 = load i32, i32* %1
%6 = icmp eq i32 %5, 42
br i1 %6, label %16, label %7
7: ; preds = %3
%8 = load i32, i32* %1
%9 = icmp eq i32 %8, 47
br i1 %9, label %16, label %10
10: ; preds = %7
%11 = load i32, i32* %1
%12 = icmp eq i32 %11, 43
br i1 %12, label %16, label %13
13: ; preds = %10
%14 = load i32, i32* %1
%15 = icmp eq i32 %14, 45
br i1 %15, label %16, label %19
16: ; preds = %13, %10, %7, %3
%17 = load i32, i32* %1
%18 = call i32 @calculate(i32 %17)
br label %46
19: ; preds = %13
%20 = load i32, i32* %1
%21 = icmp eq i32 %20, 61
br i1 %21, label %22, label %24
22: ; preds = %19
%23 = call i32 (...) @display()
br label %45
24: ; preds = %19
%25 = load i32, i32* %1
%26 = icmp eq i32 %25, 32
br i1 %26, label %27, label %28
27: ; preds = %24
br label %3
28: ; preds = %24
%29 = load i32, i32* %1
%30 = icmp eq i32 %29, 113
br i1 %30, label %31, label %33
31: ; preds = %28
%32 = call i32 (...) @make_empty()
br label %43
33: ; preds = %28
%34 = load i32, i32* %1
%35 = icmp eq i32 %34, 10
br i1 %35, label %36, label %37
36: ; preds = %33
br label %47
37: ; preds = %33
%38 = load i32, i32* %1
%39 = sub nsw i32 %38, 48
store i32 %39, i32* %1
%40 = load i32, i32* %1
%41 = call i32 @push(i32 %40)
br label %42
42: ; preds = %37
br label %43
43: ; preds = %42, %31
br label %44
44: ; preds = %43
br label %45
45: ; preds = %44, %22
br label %46
46: ; preds = %45, %16
br label %3
47: ; preds = %36
ret void
}

LLVM IR (-O2):
@.str = [26 x i8] c"Enter an RPN expression: \00"
define void @input() {
%1 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
br label %2
2: ; preds = %6, %0
%3 = tail call i32 (...) @getchar()
switch i32 %3, label %11 [
i32 47, label %4
i32 45, label %4
i32 43, label %4
i32 42, label %4
i32 61, label %7
i32 32, label %6
i32 113, label %9
i32 10, label %14
]
4: ; preds = %2, %2, %2, %2
%5 = tail call i32 @calculate(i32 %3)
br label %6
6: ; preds = %4, %11, %9, %7, %2
br label %2
7: ; preds = %2
%8 = tail call i32 (...) @display()
br label %6
9: ; preds = %2
%10 = tail call i32 (...) @make_empty()
br label %6
11: ; preds = %2
%12 = add nsw i32 %3, -48
%13 = tail call i32 @push(i32 %12)
br label %6
14: ; preds = %2
ret void
}