#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 */
struct Stack {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ abort();
int /*<<< orphan*/ assert(int);
scalar_t__ feof(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int);
int scanf(char *, ...);
struct Stack *stack_create(int);
int /*<<< orphan*/ stack_destroy(struct Stack *);
int stack_pop(struct Stack *);
int /*<<< orphan*/ stack_push(struct Stack *, int);
int stack_size(struct Stack *);
int /*<<< orphan*/ stdin;
int main() {
  struct Stack *s = stack_create(2);
  for (;;) {
    int value;
    char op[2];
    if (feof(stdin)) {
      break;
    } else if (scanf(" %1[+-/*=] ", op) == 1) {
      if (op[0] == '=') {
        break;
      } else {
        int o1 = stack_pop(s), o2 = stack_pop(s);
        switch (op[0]) {
        case '+':
          stack_push(s, o2 + o1);
          break;
        case '-':
          stack_push(s, o2 - o1);
          break;
        case '*':
          stack_push(s, o2 * o1);
          break;
        case '/':
          stack_push(s, o2 / o1);
          break;
        default:
          abort();
        }
      }
    } else if (scanf(" %d ", &value) == 1) {
      stack_push(s, value);
    } else {
      abort();
    }
  }
  assert(stack_size(s) == 1);
  printf("%d\n", stack_pop(s));
  stack_destroy(s);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x2,%edi
call   1060 <stack_create@plt>
mov    %rax,-0x10(%rbp)
mov    0x2e24(%rip),%rax
mov    (%rax),%edi
call   1070 <feof@plt>
cmp    $0x0,%rax
je     11da <main+0x3a>
jmp    12f0 <main+0x150>
lea    -0x16(%rbp),%rsi
lea    0xe33(%rip),%rdi
mov    $0x0,%al
call   1090 <scanf@plt>
cmp    $0x1,%eax
jne    12ae <main+0x10e>
movsbl -0x16(%rbp),%eax
cmp    $0x3d,%eax
jne    1207 <main+0x67>
jmp    12f0 <main+0x150>
mov    -0x10(%rbp),%rdi
call   10c0 <stack_pop@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   10c0 <stack_pop@plt>
mov    %eax,-0x20(%rbp)
movsbl -0x16(%rbp),%eax
add    $0xffffffd6,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0x5,%eax
ja     129d <main+0xfd>
mov    -0x28(%rbp),%rax
lea    0xdc0(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%esi
add    -0x1c(%rbp),%esi
call   10a0 <stack_push@plt>
jmp    12a4 <main+0x104>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%esi
sub    -0x1c(%rbp),%esi
call   10a0 <stack_push@plt>
jmp    12a4 <main+0x104>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%esi
imul   -0x1c(%rbp),%esi
call   10a0 <stack_push@plt>
jmp    12a4 <main+0x104>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%eax
cltd
idivl  -0x1c(%rbp)
mov    %eax,%esi
call   10a0 <stack_push@plt>
jmp    12a4 <main+0x104>
mov    $0x0,%al
call   1030 <abort@plt>
jmp    12a9 <main+0x109>
jmp    12e6 <main+0x146>
lea    0xd6f(%rip),%rdi
lea    -0x14(%rbp),%rsi
mov    $0x0,%al
call   1090 <scanf@plt>
cmp    $0x1,%eax
jne    12da <main+0x13a>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   10a0 <stack_push@plt>
jmp    12e1 <main+0x141>
mov    $0x0,%al
call   1030 <abort@plt>
jmp    12e6 <main+0x146>
jmp    12eb <main+0x14b>
jmp    11bd <main+0x1d>
mov    -0x10(%rbp),%rdi
call   10b0 <stack_size@plt>
cmp    $0x1,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x10(%rbp),%rdi
call   10c0 <stack_pop@plt>
mov    %eax,%esi
lea    0xd0e(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1080 <stack_destroy@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0x2,%edi
call   1060 <stack_create@plt>
mov    %rax,%rbx
mov    0x2e29(%rip),%r12
mov    (%r12),%edi
call   1070 <feof@plt>
test   %rax,%rax
je     1212 <main+0x72>
mov    %rbx,%rdi
call   10b0 <stack_size@plt>
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
call   1050 <assert@plt>
mov    %rbx,%rdi
call   10c0 <stack_pop@plt>
lea    0xe37(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1080 <stack_destroy@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xdff(%rip),%r14
lea    0x2(%rsp),%r15
lea    0xddb(%rip),%r13
jmp    1248 <main+0xa8>
add    %ebp,%eax
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    %eax,%esi
call   10a0 <stack_push@plt>
mov    (%r12),%edi
call   1070 <feof@plt>
test   %rax,%rax
jne    11cd <main+0x2d>
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1090 <scanf@plt>
cmp    $0x1,%eax
jne    12a0 <main+0x100>
cmpb   $0x3d,0x2(%rsp)
je     11cd <main+0x2d>
mov    %rbx,%rdi
call   10c0 <stack_pop@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   10c0 <stack_pop@plt>
movsbl 0x2(%rsp),%ecx
add    $0xffffffd6,%ecx
cmp    $0x5,%ecx
ja     12d0 <main+0x130>
movslq 0x0(%r13,%rcx,4),%rcx
add    %r13,%rcx
jmp    *%rcx
imul   %ebp,%eax
jmp    1230 <main+0x90>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    0xd7d(%rip),%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1090 <scanf@plt>
cmp    $0x1,%eax
jne    12d0 <main+0x130>
mov    0x4(%rsp),%eax
jmp    1230 <main+0x90>
sub    %ebp,%eax
jmp    1230 <main+0x90>
cltd
idiv   %ebp
jmp    1230 <main+0x90>
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
%struct.Stack = type { i32 }
@stdin = global i32 0
@.str = [12 x i8] c" %1[+-/*=] \00"
@.str.1 = [5 x i8] c" %d \00"
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.Stack*
%3 = alloca i32
%4 = alloca [2 x i8]
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = call %struct.Stack* @stack_create(i32 2)
store %struct.Stack* %7, %struct.Stack** %2
br label %8
8: ; preds = %70, %0
%9 = load i32, i32* @stdin
%10 = call i64 @feof(i32 %9)
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %8
br label %71
13: ; preds = %8
%14 = getelementptr inbounds [2 x i8], [2 x i8]* %4, i64 0, i64 0
%15 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %14)
%16 = icmp eq i32 %15, 1
br i1 %16, label %17, label %59
17: ; preds = %13
%18 = getelementptr inbounds [2 x i8], [2 x i8]* %4, i64 0, i64 0
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp eq i32 %20, 61
br i1 %21, label %22, label %23
22: ; preds = %17
br label %71
23: ; preds = %17
%24 = load %struct.Stack*, %struct.Stack** %2
%25 = call i32 @stack_pop(%struct.Stack* %24)
store i32 %25, i32* %5
%26 = load %struct.Stack*, %struct.Stack** %2
%27 = call i32 @stack_pop(%struct.Stack* %26)
store i32 %27, i32* %6
%28 = getelementptr inbounds [2 x i8], [2 x i8]* %4, i64 0, i64 0
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
switch i32 %30, label %55 [
i32 43, label %31
i32 45, label %37
i32 42, label %43
i32 47, label %49
]
31: ; preds = %23
%32 = load %struct.Stack*, %struct.Stack** %2
%33 = load i32, i32* %6
%34 = load i32, i32* %5
%35 = add nsw i32 %33, %34
%36 = call i32 @stack_push(%struct.Stack* %32, i32 %35)
br label %57
37: ; preds = %23
%38 = load %struct.Stack*, %struct.Stack** %2
%39 = load i32, i32* %6
%40 = load i32, i32* %5
%41 = sub nsw i32 %39, %40
%42 = call i32 @stack_push(%struct.Stack* %38, i32 %41)
br label %57
43: ; preds = %23
%44 = load %struct.Stack*, %struct.Stack** %2
%45 = load i32, i32* %6
%46 = load i32, i32* %5
%47 = mul nsw i32 %45, %46
%48 = call i32 @stack_push(%struct.Stack* %44, i32 %47)
br label %57
49: ; preds = %23
%50 = load %struct.Stack*, %struct.Stack** %2
%51 = load i32, i32* %6
%52 = load i32, i32* %5
%53 = sdiv i32 %51, %52
%54 = call i32 @stack_push(%struct.Stack* %50, i32 %53)
br label %57
55: ; preds = %23
%56 = call i32 (...) @abort()
unreachable
57: ; preds = %49, %43, %37, %31
br label %58
58: ; preds = %57
br label %69
59: ; preds = %13
%60 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%61 = icmp eq i32 %60, 1
br i1 %61, label %62, label %66
62: ; preds = %59
%63 = load %struct.Stack*, %struct.Stack** %2
%64 = load i32, i32* %3
%65 = call i32 @stack_push(%struct.Stack* %63, i32 %64)
br label %68
66: ; preds = %59
%67 = call i32 (...) @abort()
unreachable
68: ; preds = %62
br label %69
69: ; preds = %68, %58
br label %70
70: ; preds = %69
br label %8
71: ; preds = %22, %12
%72 = load %struct.Stack*, %struct.Stack** %2
%73 = call i32 @stack_size(%struct.Stack* %72)
%74 = icmp eq i32 %73, 1
%75 = zext i1 %74 to i32
%76 = call i32 @assert(i32 %75)
%77 = load %struct.Stack*, %struct.Stack** %2
%78 = call i32 @stack_pop(%struct.Stack* %77)
%79 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %78)
%80 = load %struct.Stack*, %struct.Stack** %2
%81 = call i32 @stack_destroy(%struct.Stack* %80)
%82 = load i32, i32* %1
ret i32 %82
}

LLVM IR (-O2):
%struct.Stack = type { i32 }
@stdin = global i32 0
@.str = [12 x i8] c" %1[+-/*=] \00"
@.str.1 = [5 x i8] c" %d \00"
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [2 x i8]
%3 = tail call %struct.Stack* @stack_create(i32 2)
%4 = bitcast i32* %1 to i8*
%5 = getelementptr inbounds [2 x i8], [2 x i8]* %2, i64 0, i64 0
%6 = load i32, i32* @stdin
%7 = call i64 @feof(i32 %6)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %43
9: ; preds = %0, %37
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %5)
%11 = icmp eq i32 %10, 1
br i1 %11, label %12, label %30
12: ; preds = %9
%13 = load i8, i8* %5
%14 = icmp eq i8 %13, 61
br i1 %14, label %43, label %15
15: ; preds = %12
%16 = call i32 @stack_pop(%struct.Stack* %3)
%17 = call i32 @stack_pop(%struct.Stack* %3)
%18 = load i8, i8* %5
%19 = sext i8 %18 to i32
switch i32 %19, label %28 [
i32 43, label %20
i32 45, label %22
i32 42, label %24
i32 47, label %26
]
20: ; preds = %15
%21 = add nsw i32 %17, %16
br label %37
22: ; preds = %15
%23 = sub nsw i32 %17, %16
br label %37
24: ; preds = %15
%25 = mul nsw i32 %17, %16
br label %37
26: ; preds = %15
%27 = sdiv i32 %17, %16
br label %37
28: ; preds = %15
%29 = call i32 (...) @abort()
unreachable
30: ; preds = %9
%31 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%32 = icmp eq i32 %31, 1
br i1 %32, label %33, label %35
33: ; preds = %30
%34 = load i32, i32* %1
br label %37
35: ; preds = %30
%36 = call i32 (...) @abort()
unreachable
37: ; preds = %33, %26, %24, %22, %20
%38 = phi i32 [ %34, %33 ], [ %27, %26 ], [ %25, %24 ], [ %23, %22 ], [ %21, %20 ]
%39 = call i32 @stack_push(%struct.Stack* %3, i32 %38)
%40 = load i32, i32* @stdin
%41 = call i64 @feof(i32 %40)
%42 = icmp eq i64 %41, 0
br i1 %42, label %9, label %43
43: ; preds = %12, %37, %0
%44 = call i32 @stack_size(%struct.Stack* %3)
%45 = icmp eq i32 %44, 1
%46 = zext i1 %45 to i32
%47 = call i32 @assert(i32 %46)
%48 = call i32 @stack_pop(%struct.Stack* %3)
%49 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %48)
%50 = call i32 @stack_destroy(%struct.Stack* %3)
ret i32 0
}