#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*/ divide();
scalar_t__ is_empty();
int /*<<< orphan*/ make_empty();
int pop();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ push(int);
int /*<<< orphan*/ scanf(char *, char *);
int /*<<< orphan*/ subtract();
int /*<<< orphan*/ warn_incomplete();
int main(void) {
  char i;
  int value;
  for (;;) {
    printf("enter the expression: ");
    for (;;) {
      scanf(" %1c", &i);
      if (i >= '0' && i <= '9')
        push((int)i - '0');
      else if (i == '+')
        push(pop() + pop());
      else if (i == '-')
        subtract();
      else if (i == '*')
        push(pop() * pop());
      else if (i == '/')
        divide();
      else
        break;
    }
    if (i == '=') {
      value = pop();
      if (is_empty()) {
        printf("value: %d\n", value);
      } else {
        warn_incomplete();
        make_empty();
      }
    } else {
      break;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe5a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe63(%rip),%rdi
lea    -0x5(%rbp),%rsi
call   1080 <scanf@plt>
movsbl -0x5(%rbp),%eax
cmp    $0x30,%eax
jl     11e8 <main+0x58>
movsbl -0x5(%rbp),%eax
cmp    $0x39,%eax
jg     11e8 <main+0x58>
movsbl -0x5(%rbp),%edi
sub    $0x30,%edi
call   10a0 <push@plt>
jmp    128e <main+0xfe>
movsbl -0x5(%rbp),%eax
cmp    $0x2b,%eax
jne    1215 <main+0x85>
mov    $0x0,%al
call   1060 <pop@plt>
mov    %eax,-0x10(%rbp)
mov    $0x0,%al
call   1060 <pop@plt>
mov    -0x10(%rbp),%edi
add    %eax,%edi
call   10a0 <push@plt>
jmp    1289 <main+0xf9>
movsbl -0x5(%rbp),%eax
cmp    $0x2d,%eax
jne    122e <main+0x9e>
mov    $0x0,%al
call   1090 <subtract@plt>
jmp    1284 <main+0xf4>
movsbl -0x5(%rbp),%eax
cmp    $0x2a,%eax
jne    125c <main+0xcc>
mov    $0x0,%al
call   1060 <pop@plt>
mov    %eax,-0x14(%rbp)
mov    $0x0,%al
call   1060 <pop@plt>
mov    -0x14(%rbp),%edi
imul   %eax,%edi
call   10a0 <push@plt>
jmp    127f <main+0xef>
movsbl -0x5(%rbp),%eax
cmp    $0x2f,%eax
jne    1275 <main+0xe5>
mov    $0x0,%al
call   1030 <divide@plt>
jmp    127a <main+0xea>
jmp    1293 <main+0x103>
jmp    127f <main+0xef>
jmp    1284 <main+0xf4>
jmp    1289 <main+0xf9>
jmp    128e <main+0xfe>
jmp    11ad <main+0x1d>
movsbl -0x5(%rbp),%eax
cmp    $0x3d,%eax
jne    12e4 <main+0x154>
mov    $0x0,%al
call   1060 <pop@plt>
mov    %eax,-0xc(%rbp)
mov    $0x0,%al
call   1050 <is_empty@plt>
cmp    $0x0,%rax
je     12d1 <main+0x141>
mov    -0xc(%rbp),%esi
lea    0xd57(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12df <main+0x14f>
mov    $0x0,%al
call   1070 <warn_incomplete@plt>
mov    $0x0,%al
call   10b0 <make_empty@plt>
jmp    12e9 <main+0x159>
jmp    12ee <main+0x15e>
jmp    119f <main+0xf>
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
lea    0xeae(%rip),%r14
lea    0xebe(%rip),%r15
lea    0x7(%rsp),%rbx
lea    0xe4b(%rip),%r13
lea    0xeb0(%rip),%r12
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11d8 <main+0x48>
nopl   0x0(%rax,%rax,1)
add    $0xffffffd0,%edi
call   10a0 <push@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1080 <scanf@plt>
movzbl 0x7(%rsp),%edi
lea    -0x30(%rdi),%eax
cmp    $0x9,%al
jbe    11d0 <main+0x40>
add    $0xd6,%dil
cmp    $0x13,%dil
ja     1293 <main+0x103>
movzbl %dil,%eax
movslq 0x0(%r13,%rax,4),%rax
add    %r13,%rax
jmp    *%rax
xor    %eax,%eax
call   1060 <pop@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1060 <pop@plt>
imul   %eax,%ebp
jmp    1232 <main+0xa2>
xor    %eax,%eax
call   1060 <pop@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1060 <pop@plt>
add    %eax,%ebp
mov    %ebp,%edi
call   10a0 <push@plt>
jmp    11d8 <main+0x48>
xor    %eax,%eax
call   1090 <subtract@plt>
jmp    11d8 <main+0x48>
xor    %eax,%eax
call   1030 <divide@plt>
jmp    11d8 <main+0x48>
nopl   (%rax)
xor    %eax,%eax
call   1060 <pop@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1050 <is_empty@plt>
test   %rax,%rax
je     1280 <main+0xf0>
mov    %r12,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11bc <main+0x2c>
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
call   1070 <warn_incomplete@plt>
xor    %eax,%eax
call   10b0 <make_empty@plt>
jmp    11bc <main+0x2c>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [23 x i8] c"enter the expression: \00"
@.str.1 = [5 x i8] c" %1c\00"
@.str.2 = [11 x i8] c"value: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca i32
store i32 0, i32* %1
br label %4
4: ; preds = %72, %0
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %55, %4
%7 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%8 = load i8, i8* %2
%9 = sext i8 %8 to i32
%10 = icmp sge i32 %9, 48
br i1 %10, label %11, label %20
11: ; preds = %6
%12 = load i8, i8* %2
%13 = sext i8 %12 to i32
%14 = icmp sle i32 %13, 57
br i1 %14, label %15, label %20
15: ; preds = %11
%16 = load i8, i8* %2
%17 = sext i8 %16 to i32
%18 = sub nsw i32 %17, 48
%19 = call i32 @push(i32 %18)
br label %55
20: ; preds = %11, %6
%21 = load i8, i8* %2
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 43
br i1 %23, label %24, label %29
24: ; preds = %20
%25 = call i32 (...) @pop()
%26 = call i32 (...) @pop()
%27 = add nsw i32 %25, %26
%28 = call i32 @push(i32 %27)
br label %54
29: ; preds = %20
%30 = load i8, i8* %2
%31 = sext i8 %30 to i32
%32 = icmp eq i32 %31, 45
br i1 %32, label %33, label %35
33: ; preds = %29
%34 = call i32 (...) @subtract()
br label %53
35: ; preds = %29
%36 = load i8, i8* %2
%37 = sext i8 %36 to i32
%38 = icmp eq i32 %37, 42
br i1 %38, label %39, label %44
39: ; preds = %35
%40 = call i32 (...) @pop()
%41 = call i32 (...) @pop()
%42 = mul nsw i32 %40, %41
%43 = call i32 @push(i32 %42)
br label %52
44: ; preds = %35
%45 = load i8, i8* %2
%46 = sext i8 %45 to i32
%47 = icmp eq i32 %46, 47
br i1 %47, label %48, label %50
48: ; preds = %44
%49 = call i32 (...) @divide()
br label %51
50: ; preds = %44
br label %56
51: ; preds = %48
br label %52
52: ; preds = %51, %39
br label %53
53: ; preds = %52, %33
br label %54
54: ; preds = %53, %24
br label %55
55: ; preds = %54, %15
br label %6
56: ; preds = %50
%57 = load i8, i8* %2
%58 = sext i8 %57 to i32
%59 = icmp eq i32 %58, 61
br i1 %59, label %60, label %71
60: ; preds = %56
%61 = call i32 (...) @pop()
store i32 %61, i32* %3
%62 = call i64 (...) @is_empty()
%63 = icmp ne i64 %62, 0
br i1 %63, label %64, label %67
64: ; preds = %60
%65 = load i32, i32* %3
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %65)
br label %70
67: ; preds = %60
%68 = call i32 (...) @warn_incomplete()
%69 = call i32 (...) @make_empty()
br label %70
70: ; preds = %67, %64
br label %72
71: ; preds = %56
br label %73
72: ; preds = %70
br label %4
73: ; preds = %71
ret i32 0
}

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