#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 */
scalar_t__ EOF;
int pop();
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ push(int);
scalar_t__ scanf(char *, char *);
int /*<<< orphan*/ stackinit();
int main() {
  char c;
  int x;
  for (stackinit(); scanf("%1s", &c) != EOF;) {
    x = 0;
    if (c == '+')
      x = pop() + pop();
    if (c == '*')
      x = pop() * pop();
    while (c >= '0' && c <= '9') {
      x = 10 * x + (c - '0');
      scanf("%1c", &c);
    }
    push(x);
  }
  printf("%d\n", x);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <stackinit@plt>
lea    0xe93(%rip),%rdi
lea    -0x5(%rbp),%rsi
call   1060 <scanf@plt>
mov    0x2e6b(%rip),%rcx
cmp    (%rcx),%rax
je     1244 <main+0xf4>
movl   $0x0,-0xc(%rbp)
movsbl -0x5(%rbp),%eax
cmp    $0x2b,%eax
jne    11b5 <main+0x65>
mov    $0x0,%al
call   1050 <pop@plt>
mov    %eax,-0x10(%rbp)
mov    $0x0,%al
call   1050 <pop@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0xc(%rbp)
movsbl -0x5(%rbp),%eax
cmp    $0x2a,%eax
jne    11de <main+0x8e>
mov    $0x0,%al
call   1050 <pop@plt>
mov    %eax,-0x14(%rbp)
mov    $0x0,%al
call   1050 <pop@plt>
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
imul   %ecx,%eax
mov    %eax,-0xc(%rbp)
jmp    11e3 <main+0x93>
movsbl -0x5(%rbp),%ecx
xor    %eax,%eax
cmp    $0x30,%ecx
mov    %al,-0x15(%rbp)
jl     1202 <main+0xb2>
movsbl -0x5(%rbp),%eax
cmp    $0x39,%eax
setle  %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
test   $0x1,%al
jne    1212 <main+0xc2>
jmp    1237 <main+0xe7>
imul   $0xa,-0xc(%rbp),%eax
movsbl -0x5(%rbp),%ecx
sub    $0x30,%ecx
add    %ecx,%eax
mov    %eax,-0xc(%rbp)
lea    0xddb(%rip),%rdi
lea    -0x5(%rbp),%rsi
call   1060 <scanf@plt>
jmp    11e3 <main+0x93>
mov    -0xc(%rbp),%edi
call   1070 <push@plt>
jmp    1166 <main+0x16>
mov    -0xc(%rbp),%esi
lea    0xdba(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %eax,%eax
call   1040 <stackinit@plt>
lea    0xe97(%rip),%r14
lea    0x7(%rsp),%r12
mov    %r14,%rdi
mov    %r12,%rsi
call   1060 <scanf@plt>
lea    0xe84(%rip),%r15
mov    0x2e61(%rip),%r13
jmp    11ac <main+0x5c>
nopl   0x0(%rax)
mov    %ebx,%edi
call   1070 <push@plt>
mov    %r14,%rdi
mov    %r12,%rsi
call   1060 <scanf@plt>
cmp    0x0(%r13),%rax
je     1229 <main+0xd9>
mov    0x7(%rsp),%al
mov    $0x0,%ebx
cmp    $0x2b,%al
jne    11d1 <main+0x81>
xor    %eax,%eax
call   1050 <pop@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1050 <pop@plt>
mov    %eax,%ebx
add    %ebp,%ebx
mov    0x7(%rsp),%al
cmp    $0x2a,%al
jne    11ee <main+0x9e>
xor    %eax,%eax
call   1050 <pop@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1050 <pop@plt>
mov    %eax,%ebx
imul   %ebp,%ebx
mov    0x7(%rsp),%al
lea    -0x30(%rax),%ecx
cmp    $0x9,%cl
ja     1190 <main+0x40>
cs nopw 0x0(%rax,%rax,1)
movzbl %al,%eax
lea    (%rbx,%rbx,4),%ecx
lea    (%rax,%rcx,2),%ebx
add    $0xffffffd0,%ebx
mov    %r15,%rdi
mov    %r12,%rsi
call   1060 <scanf@plt>
movzbl 0x7(%rsp),%eax
lea    -0x30(%rax),%ecx
cmp    $0xa,%cl
jb     1200 <main+0xb0>
jmp    1190 <main+0x40>
lea    0xdd8(%rip),%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%1s\00"
@EOF = global i64 0
@.str.1 = [4 x i8] c"%1c\00"
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 (...) @stackinit()
br label %5
5: ; preds = %44, %0
%6 = call i64 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %2)
%7 = load i64, i64* @EOF
%8 = icmp ne i64 %6, %7
br i1 %8, label %9, label %47
9: ; preds = %5
store i32 0, i32* %3
%10 = load i8, i8* %2
%11 = sext i8 %10 to i32
%12 = icmp eq i32 %11, 43
br i1 %12, label %13, label %17
13: ; preds = %9
%14 = call i32 (...) @pop()
%15 = call i32 (...) @pop()
%16 = add nsw i32 %14, %15
store i32 %16, i32* %3
br label %17
17: ; preds = %13, %9
%18 = load i8, i8* %2
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 42
br i1 %20, label %21, label %25
21: ; preds = %17
%22 = call i32 (...) @pop()
%23 = call i32 (...) @pop()
%24 = mul nsw i32 %22, %23
store i32 %24, i32* %3
br label %25
25: ; preds = %21, %17
br label %26
26: ; preds = %36, %25
%27 = load i8, i8* %2
%28 = sext i8 %27 to i32
%29 = icmp sge i32 %28, 48
br i1 %29, label %30, label %34
30: ; preds = %26
%31 = load i8, i8* %2
%32 = sext i8 %31 to i32
%33 = icmp sle i32 %32, 57
br label %34
34: ; preds = %30, %26
%35 = phi i1 [ false, %26 ], [ %33, %30 ]
br i1 %35, label %36, label %44
36: ; preds = %34
%37 = load i32, i32* %3
%38 = mul nsw i32 10, %37
%39 = load i8, i8* %2
%40 = sext i8 %39 to i32
%41 = sub nsw i32 %40, 48
%42 = add nsw i32 %38, %41
store i32 %42, i32* %3
%43 = call i64 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %2)
br label %26
44: ; preds = %34
%45 = load i32, i32* %3
%46 = call i32 @push(i32 %45)
br label %5
47: ; preds = %5
%48 = load i32, i32* %3
%49 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %48)
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%1s\00"
@EOF = global i64 0
@.str.1 = [4 x i8] c"%1c\00"
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i8
%2 = tail call i32 (...) @stackinit()
%3 = call i64 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %1)
%4 = load i64, i64* @EOF
%5 = icmp ne i64 %3, %4
br label %6
6: ; preds = %0, %39
%7 = load i8, i8* %1
%8 = icmp eq i8 %7, 43
br i1 %8, label %9, label %14
9: ; preds = %6
%10 = call i32 (...) @pop()
%11 = call i32 (...) @pop()
%12 = add nsw i32 %11, %10
%13 = load i8, i8* %1
br label %14
14: ; preds = %9, %6
%15 = phi i8 [ %13, %9 ], [ %7, %6 ]
%16 = phi i32 [ %12, %9 ], [ 0, %6 ]
%17 = icmp eq i8 %15, 42
br i1 %17, label %18, label %23
18: ; preds = %14
%19 = call i32 (...) @pop()
%20 = call i32 (...) @pop()
%21 = mul nsw i32 %20, %19
%22 = load i8, i8* %1
br label %23
23: ; preds = %18, %14
%24 = phi i8 [ %22, %18 ], [ %15, %14 ]
%25 = phi i32 [ %21, %18 ], [ %16, %14 ]
%26 = add i8 %24, -48
%27 = icmp ult i8 %26, 10
br i1 %27, label %28, label %39
28: ; preds = %23, %28
%29 = phi i8 [ %36, %28 ], [ %24, %23 ]
%30 = phi i32 [ %34, %28 ], [ %25, %23 ]
%31 = zext i8 %29 to i32
%32 = mul nsw i32 %30, 10
%33 = add i32 %32, -48
%34 = add i32 %33, %31
%35 = call i64 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%36 = load i8, i8* %1
%37 = add i8 %36, -48
%38 = icmp ult i8 %37, 10
br i1 %38, label %28, label %39
39: ; preds = %28, %23
%40 = phi i32 [ %25, %23 ], [ %34, %28 ]
%41 = call i32 @push(i32 %40)
%42 = call i64 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %1)
%43 = load i64, i64* @EOF
%44 = icmp eq i64 %42, %43
br i1 %44, label %45, label %6
45: ; preds = %39
%46 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %40)
ret i32 0
}