#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);
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 main() {
  struct Stack *s = stack_create(2);
  int end = 0;
  while (!end) {
    int value;
    char op[2];
    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)
movl   $0x0,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11ca <main+0x3a>
jmp    12db <main+0x14b>
lea    -0x1a(%rbp),%rsi
lea    0xe43(%rip),%rdi
mov    $0x0,%al
call   1080 <scanf@plt>
cmp    $0x1,%eax
jne    129e <main+0x10e>
movsbl -0x1a(%rbp),%eax
cmp    $0x3d,%eax
jne    11f7 <main+0x67>
jmp    12db <main+0x14b>
mov    -0x10(%rbp),%rdi
call   10b0 <stack_pop@plt>
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   10b0 <stack_pop@plt>
mov    %eax,-0x24(%rbp)
movsbl -0x1a(%rbp),%eax
add    $0xffffffd6,%eax
mov    %eax,%ecx
mov    %rcx,-0x30(%rbp)
sub    $0x5,%eax
ja     128d <main+0xfd>
mov    -0x30(%rbp),%rax
lea    0xdd0(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x10(%rbp),%rdi
mov    -0x24(%rbp),%esi
add    -0x20(%rbp),%esi
call   1090 <stack_push@plt>
jmp    1294 <main+0x104>
mov    -0x10(%rbp),%rdi
mov    -0x24(%rbp),%esi
sub    -0x20(%rbp),%esi
call   1090 <stack_push@plt>
jmp    1294 <main+0x104>
mov    -0x10(%rbp),%rdi
mov    -0x24(%rbp),%esi
imul   -0x20(%rbp),%esi
call   1090 <stack_push@plt>
jmp    1294 <main+0x104>
mov    -0x10(%rbp),%rdi
mov    -0x24(%rbp),%eax
cltd
idivl  -0x20(%rbp)
mov    %eax,%esi
call   1090 <stack_push@plt>
jmp    1294 <main+0x104>
mov    $0x0,%al
call   1030 <abort@plt>
jmp    1299 <main+0x109>
jmp    12d6 <main+0x146>
lea    0xd7f(%rip),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1080 <scanf@plt>
cmp    $0x1,%eax
jne    12ca <main+0x13a>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%esi
call   1090 <stack_push@plt>
jmp    12d1 <main+0x141>
mov    $0x0,%al
call   1030 <abort@plt>
jmp    12d6 <main+0x146>
jmp    11b4 <main+0x24>
mov    -0x10(%rbp),%rdi
call   10a0 <stack_size@plt>
cmp    $0x1,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x10(%rbp),%rdi
call   10b0 <stack_pop@plt>
mov    %eax,%esi
lea    0xd23(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1070 <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
lea    0xe69(%rip),%r14
lea    0x2(%rsp),%r15
lea    0xe45(%rip),%r12
lea    0x4(%rsp),%r13
jmp    11da <main+0x4a>
add    %ebp,%eax
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbx,%rdi
mov    %eax,%esi
call   1090 <stack_push@plt>
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1080 <scanf@plt>
cmp    $0x1,%eax
jne    1220 <main+0x90>
cmpb   $0x3d,0x2(%rsp)
je     1245 <main+0xb5>
mov    %rbx,%rdi
call   10b0 <stack_pop@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   10b0 <stack_pop@plt>
movsbl 0x2(%rsp),%ecx
add    $0xffffffd6,%ecx
cmp    $0x5,%ecx
ja     128a <main+0xfa>
movslq (%r12,%rcx,4),%rcx
add    %r12,%rcx
jmp    *%rcx
imul   %ebp,%eax
jmp    11d0 <main+0x40>
lea    0xdfd(%rip),%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1080 <scanf@plt>
cmp    $0x1,%eax
jne    128a <main+0xfa>
mov    0x4(%rsp),%eax
jmp    11d0 <main+0x40>
sub    %ebp,%eax
jmp    11d0 <main+0x40>
cltd
idiv   %ebp
jmp    11d0 <main+0x40>
mov    %rbx,%rdi
call   10a0 <stack_size@plt>
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
call   1050 <assert@plt>
mov    %rbx,%rdi
call   10b0 <stack_pop@plt>
lea    0xdbf(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1070 <stack_destroy@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
%struct.Stack = type { i32 }
@.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 i32
%5 = alloca [2 x i8]
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
%8 = call %struct.Stack* @stack_create(i32 2)
store %struct.Stack* %8, %struct.Stack** %2
store i32 0, i32* %3
br label %9
9: ; preds = %69, %0
%10 = load i32, i32* %3
%11 = icmp ne i32 %10, 0
%12 = xor i1 %11, true
br i1 %12, label %13, label %70
13: ; preds = %9
%14 = getelementptr inbounds [2 x i8], [2 x i8]* %5, 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]* %5, 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 %70
23: ; preds = %17
%24 = load %struct.Stack*, %struct.Stack** %2
%25 = call i32 @stack_pop(%struct.Stack* %24)
store i32 %25, i32* %6
%26 = load %struct.Stack*, %struct.Stack** %2
%27 = call i32 @stack_pop(%struct.Stack* %26)
store i32 %27, i32* %7
%28 = getelementptr inbounds [2 x i8], [2 x i8]* %5, 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* %7
%34 = load i32, i32* %6
%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* %7
%40 = load i32, i32* %6
%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* %7
%46 = load i32, i32* %6
%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* %7
%52 = load i32, i32* %6
%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* %4)
%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* %4
%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 %9
70: ; preds = %22, %9
%71 = load %struct.Stack*, %struct.Stack** %2
%72 = call i32 @stack_size(%struct.Stack* %71)
%73 = icmp eq i32 %72, 1
%74 = zext i1 %73 to i32
%75 = call i32 @assert(i32 %74)
%76 = load %struct.Stack*, %struct.Stack** %2
%77 = call i32 @stack_pop(%struct.Stack* %76)
%78 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %77)
%79 = load %struct.Stack*, %struct.Stack** %2
%80 = call i32 @stack_destroy(%struct.Stack* %79)
%81 = load i32, i32* %1
ret i32 %81
}

LLVM IR (-O2):
%struct.Stack = type { i32 }
@.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
br label %6
6: ; preds = %34, %0
%7 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %5)
%8 = icmp eq i32 %7, 1
br i1 %8, label %9, label %27
9: ; preds = %6
%10 = load i8, i8* %5
%11 = icmp eq i8 %10, 61
br i1 %11, label %37, label %12
12: ; preds = %9
%13 = call i32 @stack_pop(%struct.Stack* %3)
%14 = call i32 @stack_pop(%struct.Stack* %3)
%15 = load i8, i8* %5
%16 = sext i8 %15 to i32
switch i32 %16, label %25 [
i32 43, label %17
i32 45, label %19
i32 42, label %21
i32 47, label %23
]
17: ; preds = %12
%18 = add nsw i32 %14, %13
br label %34
19: ; preds = %12
%20 = sub nsw i32 %14, %13
br label %34
21: ; preds = %12
%22 = mul nsw i32 %14, %13
br label %34
23: ; preds = %12
%24 = sdiv i32 %14, %13
br label %34
25: ; preds = %12
%26 = call i32 (...) @abort()
unreachable
27: ; preds = %6
%28 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%29 = icmp eq i32 %28, 1
br i1 %29, label %30, label %32
30: ; preds = %27
%31 = load i32, i32* %1
br label %34
32: ; preds = %27
%33 = call i32 (...) @abort()
unreachable
34: ; preds = %30, %23, %21, %19, %17
%35 = phi i32 [ %31, %30 ], [ %24, %23 ], [ %22, %21 ], [ %20, %19 ], [ %18, %17 ]
%36 = call i32 @stack_push(%struct.Stack* %3, i32 %35)
br label %6
37: ; preds = %9
%38 = call i32 @stack_size(%struct.Stack* %3)
%39 = icmp eq i32 %38, 1
%40 = zext i1 %39 to i32
%41 = call i32 @assert(i32 %40)
%42 = call i32 @stack_pop(%struct.Stack* %3)
%43 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %42)
%44 = call i32 @stack_destroy(%struct.Stack* %3)
ret i32 0
}