#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 */
double EOF;
int /*<<< orphan*/ clear_stack();
double getop(double *, char *);
double pop();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ push(double);
int main() {
  double value, type, denominator, subtractor;
  char operation;
  while ((type = getop(&value, &operation)) != EOF) {
    if (type == '0')
      push(value);
    else {
      switch (operation) {
      case 'q':
        return 0;
      case ';':
        printf("%f\n", pop());
        clear_stack();
        break;
      case '+':
        push(pop() + pop());
        break;
      case '*':
        push(pop() * pop());
        break;
      case '/':
        denominator = pop();
        if (denominator == 0)
          printf("Warning: division by zero\n");
        else
          push(pop() / denominator);
        break;
      case '-':
        subtractor = pop();
        push(pop() - subtractor);
        break;
      default:
        printf("Unknown operation: %c\n", operation);
        break;
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x10(%rbp),%rdi
lea    -0x29(%rbp),%rsi
call   1050 <getop@plt>
movsd  %xmm0,-0x18(%rbp)
mov    0x2e70(%rip),%rax
ucomisd (%rax),%xmm0
jne    118d <main+0x3d>
jp     118d <main+0x3d>
jmp    132d <main+0x1dd>
movsd  -0x18(%rbp),%xmm0
movsd  0xe66(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    11b9 <main+0x69>
jp     11b9 <main+0x69>
movsd  -0x10(%rbp),%xmm0
call   1070 <push@plt>
jmp    1328 <main+0x1d8>
movsbl -0x29(%rbp),%eax
mov    %eax,-0x30(%rbp)
sub    $0x2a,%eax
je     1279 <main+0x129>
jmp    11ce <main+0x7e>
mov    -0x30(%rbp),%eax
sub    $0x2b,%eax
je     1250 <main+0x100>
jmp    11df <main+0x8f>
mov    -0x30(%rbp),%eax
sub    $0x2d,%eax
je     12ef <main+0x19f>
jmp    11f0 <main+0xa0>
mov    -0x30(%rbp),%eax
sub    $0x2f,%eax
je     12a2 <main+0x152>
jmp    1201 <main+0xb1>
mov    -0x30(%rbp),%eax
sub    $0x3b,%eax
je     122f <main+0xdf>
jmp    1212 <main+0xc2>
mov    -0x30(%rbp),%eax
sub    $0x71,%eax
jne    1311 <main+0x1c1>
jmp    1223 <main+0xd3>
movl   $0x0,-0x4(%rbp)
jmp    1334 <main+0x1e4>
mov    $0x0,%al
call   1040 <pop@plt>
lea    0xdcb(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1060 <clear_stack@plt>
jmp    1323 <main+0x1d3>
mov    $0x0,%al
call   1040 <pop@plt>
movsd  %xmm0,-0x38(%rbp)
mov    $0x0,%al
call   1040 <pop@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
addsd  %xmm1,%xmm0
call   1070 <push@plt>
jmp    1323 <main+0x1d3>
mov    $0x0,%al
call   1040 <pop@plt>
movsd  %xmm0,-0x40(%rbp)
mov    $0x0,%al
call   1040 <pop@plt>
movaps %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
mulsd  %xmm1,%xmm0
call   1070 <push@plt>
jmp    1323 <main+0x1d3>
mov    $0x0,%al
call   1040 <pop@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    12d9 <main+0x189>
jp     12d9 <main+0x189>
lea    0xd3f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12ea <main+0x19a>
mov    $0x0,%al
call   1040 <pop@plt>
divsd  -0x20(%rbp),%xmm0
call   1070 <push@plt>
jmp    1323 <main+0x1d3>
mov    $0x0,%al
call   1040 <pop@plt>
movsd  %xmm0,-0x28(%rbp)
mov    $0x0,%al
call   1040 <pop@plt>
subsd  -0x28(%rbp),%xmm0
call   1070 <push@plt>
jmp    1323 <main+0x1d3>
movsbl -0x29(%rbp),%esi
lea    0xd0b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1328 <main+0x1d8>
jmp    115f <main+0xf>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0x10(%rsp),%rdi
lea    0x7(%rsp),%rsi
call   1060 <getop@plt>
mov    0x2e64(%rip),%rbp
ucomisd 0x0(%rbp),%xmm0
jne    1191 <main+0x31>
jnp    12cd <main+0x16d>
lea    0x10(%rsp),%r14
lea    0x7(%rsp),%rbx
lea    0xeba(%rip),%r15
lea    0xe67(%rip),%r12
lea    0xea8(%rip),%r13
jmp    11e3 <main+0x83>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsd  0x10(%rsp),%xmm0
call   1080 <push@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <getop@plt>
ucomisd 0x0(%rbp),%xmm0
jne    11e3 <main+0x83>
jnp    12cd <main+0x16d>
ucomisd 0xe15(%rip),%xmm0
jne    11ef <main+0x8f>
jnp    11c0 <main+0x60>
movsbl 0x7(%rsp),%esi
lea    -0x2a(%rsi),%eax
cmp    $0x11,%eax
ja     12a1 <main+0x141>
movslq (%r12,%rax,4),%rax
add    %r12,%rax
jmp    *%rax
xor    %eax,%eax
call   1050 <pop@plt>
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1050 <pop@plt>
mulsd  0x8(%rsp),%xmm0
jmp    11c6 <main+0x66>
xor    %eax,%eax
call   1050 <pop@plt>
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1050 <pop@plt>
addsd  0x8(%rsp),%xmm0
jmp    11c6 <main+0x66>
xor    %eax,%eax
call   1050 <pop@plt>
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1050 <pop@plt>
subsd  0x8(%rsp),%xmm0
jmp    11c6 <main+0x66>
xor    %eax,%eax
call   1050 <pop@plt>
ucomisd 0xd99(%rip),%xmm0
jne    12b5 <main+0x155>
jp     12b5 <main+0x155>
lea    0xdf9(%rip),%rdi
call   1030 <puts@plt>
jmp    11cb <main+0x6b>
xor    %eax,%eax
call   1050 <pop@plt>
mov    %r13,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
call   1070 <clear_stack@plt>
jmp    11cb <main+0x6b>
cmp    $0x71,%esi
je     12cd <main+0x16d>
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11cb <main+0x6b>
xor    %eax,%eax
movsd  %xmm0,0x8(%rsp)
call   1050 <pop@plt>
divsd  0x8(%rsp),%xmm0
jmp    11c6 <main+0x66>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@EOF = global double 0.000000e+00
@.str = [4 x i8] c"%f\0A\00"
@.str.1 = [27 x i8] c"Warning: division by zero\0A\00"
@.str.2 = [23 x i8] c"Unknown operation: %c\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca i8
store i32 0, i32* %1
br label %7
7: ; preds = %58, %0
%8 = call double @getop(double* %2, i8* %6)
store double %8, double* %3
%9 = load double, double* @EOF
%10 = fcmp une double %8, %9
br i1 %10, label %11, label %59
11: ; preds = %7
%12 = load double, double* %3
%13 = fcmp oeq double %12, 4.800000e+01
br i1 %13, label %14, label %17
14: ; preds = %11
%15 = load double, double* %2
%16 = call i32 @push(double %15)
br label %58
17: ; preds = %11
%18 = load i8, i8* %6
%19 = sext i8 %18 to i32
switch i32 %19, label %53 [
i32 113, label %20
i32 59, label %21
i32 43, label %25
i32 42, label %30
i32 47, label %35
i32 45, label %47
]
20: ; preds = %17
store i32 0, i32* %1
br label %60
21: ; preds = %17
%22 = call double (...) @pop()
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double %22)
%24 = call i32 (...) @clear_stack()
br label %57
25: ; preds = %17
%26 = call double (...) @pop()
%27 = call double (...) @pop()
%28 = fadd double %26, %27
%29 = call i32 @push(double %28)
br label %57
30: ; preds = %17
%31 = call double (...) @pop()
%32 = call double (...) @pop()
%33 = fmul double %31, %32
%34 = call i32 @push(double %33)
br label %57
35: ; preds = %17
%36 = call double (...) @pop()
store double %36, double* %4
%37 = load double, double* %4
%38 = fcmp oeq double %37, 0.000000e+00
br i1 %38, label %39, label %41
39: ; preds = %35
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
br label %46
41: ; preds = %35
%42 = call double (...) @pop()
%43 = load double, double* %4
%44 = fdiv double %42, %43
%45 = call i32 @push(double %44)
br label %46
46: ; preds = %41, %39
br label %57
47: ; preds = %17
%48 = call double (...) @pop()
store double %48, double* %5
%49 = call double (...) @pop()
%50 = load double, double* %5
%51 = fsub double %49, %50
%52 = call i32 @push(double %51)
br label %57
53: ; preds = %17
%54 = load i8, i8* %6
%55 = sext i8 %54 to i32
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32 %55)
br label %57
57: ; preds = %53, %47, %46, %30, %25, %21
br label %58
58: ; preds = %57, %14
br label %7
59: ; preds = %7
store i32 0, i32* %1
br label %60
60: ; preds = %59, %20
%61 = load i32, i32* %1
ret i32 %61
}

LLVM IR (-O2):
@EOF = global double 0.000000e+00
@.str = [4 x i8] c"%f\0A\00"
@.str.2 = [23 x i8] c"Unknown operation: %c\0A\00"
@str = [26 x i8] c"Warning: division by zero\00"
define i32 @main() {
%1 = alloca double
%2 = alloca i8
%3 = bitcast double* %1 to i8*
%4 = call double @getop(double* %1, i8* %2)
%5 = load double, double* @EOF
%6 = fcmp une double %4, %5
br i1 %6, label %7, label %50
7: ; preds = %0, %46
%8 = phi double [ %47, %46 ], [ %4, %0 ]
%9 = fcmp oeq double %8, 4.800000e+01
br i1 %9, label %10, label %13
10: ; preds = %7
%11 = load double, double* %1
%12 = call i32 @push(double %11)
br label %46
13: ; preds = %7
%14 = load i8, i8* %2
%15 = sext i8 %14 to i32
switch i32 %15, label %44 [
i32 113, label %50
i32 59, label %16
i32 43, label %20
i32 42, label %25
i32 47, label %30
i32 45, label %39
]
16: ; preds = %13
%17 = call double (...) @pop()
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double %17)
%19 = call i32 (...) @clear_stack()
br label %46
20: ; preds = %13
%21 = call double (...) @pop()
%22 = call double (...) @pop()
%23 = fadd double %21, %22
%24 = call i32 @push(double %23)
br label %46
25: ; preds = %13
%26 = call double (...) @pop()
%27 = call double (...) @pop()
%28 = fmul double %26, %27
%29 = call i32 @push(double %28)
br label %46
30: ; preds = %13
%31 = call double (...) @pop()
%32 = fcmp oeq double %31, 0.000000e+00
br i1 %32, label %33, label %35
33: ; preds = %30
%34 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
br label %46
35: ; preds = %30
%36 = call double (...) @pop()
%37 = fdiv double %36, %31
%38 = call i32 @push(double %37)
br label %46
39: ; preds = %13
%40 = call double (...) @pop()
%41 = call double (...) @pop()
%42 = fsub double %41, %40
%43 = call i32 @push(double %42)
br label %46
44: ; preds = %13
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32 %15)
br label %46
46: ; preds = %16, %20, %25, %39, %44, %35, %33, %10
%47 = call double @getop(double* %1, i8* %2)
%48 = load double, double* @EOF
%49 = fcmp une double %47, %48
br i1 %49, label %7, label %50
50: ; preds = %13, %46, %0
ret i32 0
}