#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 atof(char *);
int /*<<< orphan*/ panic(char *);
double pop();
int /*<<< orphan*/ printf(char *, double);
int /*<<< orphan*/ push(double);
int main(int argc, char **argv) {
  int i;
  double value;
  for (i = 1; i < argc; ++i) {
    switch (argv[i][0]) {
    case '\0':
      panic("empty command line argument");
      break;
    case '0':
    case '1':
    case '2':
    case '3':
    case '4':
    case '5':
    case '6':
    case '7':
    case '8':
    case '9':
      push(atof(argv[i]));
      break;
    case '+':
      push(pop() + pop());
      break;
    case '-':
      value = pop();
      push(pop() - value);
      break;
    case '*':
      push(pop() * pop());
      break;
    case '/':
      value = pop();
      push(pop() / value);
      break;
    default:
      panic("unknown operator");
      break;
    }
  }
  printf("%g\n", pop());
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    128c <main+0x13c>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsbl (%rax),%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0x39,%eax
ja     126d <main+0x11d>
mov    -0x28(%rbp),%rax
lea    0xe5e(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xf36(%rip),%rdi
call   1050 <panic@plt>
jmp    1279 <main+0x129>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <atof@plt>
call   1070 <push@plt>
jmp    1279 <main+0x129>
mov    $0x0,%al
call   1060 <pop@plt>
movsd  %xmm0,-0x30(%rbp)
mov    $0x0,%al
call   1060 <pop@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
addsd  %xmm1,%xmm0
call   1070 <push@plt>
jmp    1279 <main+0x129>
mov    $0x0,%al
call   1060 <pop@plt>
movsd  %xmm0,-0x20(%rbp)
mov    $0x0,%al
call   1060 <pop@plt>
subsd  -0x20(%rbp),%xmm0
call   1070 <push@plt>
jmp    1279 <main+0x129>
mov    $0x0,%al
call   1060 <pop@plt>
movsd  %xmm0,-0x38(%rbp)
mov    $0x0,%al
call   1060 <pop@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
mulsd  %xmm1,%xmm0
call   1070 <push@plt>
jmp    1279 <main+0x129>
mov    $0x0,%al
call   1060 <pop@plt>
movsd  %xmm0,-0x20(%rbp)
mov    $0x0,%al
call   1060 <pop@plt>
divsd  -0x20(%rbp),%xmm0
call   1070 <push@plt>
jmp    1279 <main+0x129>
lea    0xe90(%rip),%rdi
call   1050 <panic@plt>
jmp    127e <main+0x12e>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    116d <main+0x1d>
mov    $0x0,%al
call   1060 <pop@plt>
lea    0xe7b(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x2,%edi
jl     1247 <main+0xf7>
mov    %rsi,%r13
mov    %edi,%r12d
mov    $0x1,%ebx
lea    0xf8e(%rip),%r14
lea    0xe83(%rip),%rbp
lea    0xf64(%rip),%r15
jmp    119d <main+0x4d>
mov    %r14,%rdi
call   1050 <panic@plt>
xchg   %ax,%ax
add    $0x1,%rbx
cmp    %rbx,%r12
je     1247 <main+0xf7>
mov    0x0(%r13,%rbx,8),%rdi
movsbl (%rdi),%eax
cmp    $0x39,%eax
ja     1186 <main+0x36>
movslq 0x0(%rbp,%rax,4),%rax
add    %rbp,%rax
jmp    *%rax
call   1030 <atof@plt>
call   1070 <push@plt>
jmp    1190 <main+0x40>
xor    %eax,%eax
call   1060 <pop@plt>
movsd  %xmm0,(%rsp)
xor    %eax,%eax
call   1060 <pop@plt>
addsd  (%rsp),%xmm0
call   1070 <push@plt>
jmp    1190 <main+0x40>
mov    %r15,%rdi
jmp    1189 <main+0x39>
xor    %eax,%eax
call   1060 <pop@plt>
movsd  %xmm0,(%rsp)
xor    %eax,%eax
call   1060 <pop@plt>
mulsd  (%rsp),%xmm0
call   1070 <push@plt>
jmp    1190 <main+0x40>
xor    %eax,%eax
call   1060 <pop@plt>
movsd  %xmm0,(%rsp)
xor    %eax,%eax
call   1060 <pop@plt>
subsd  (%rsp),%xmm0
call   1070 <push@plt>
jmp    1190 <main+0x40>
xor    %eax,%eax
call   1060 <pop@plt>
movsd  %xmm0,(%rsp)
xor    %eax,%eax
call   1060 <pop@plt>
divsd  (%rsp),%xmm0
call   1070 <push@plt>
jmp    1190 <main+0x40>
xor    %eax,%eax
call   1060 <pop@plt>
lea    0xec0(%rip),%rdi
call   1040 <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 = [28 x i8] c"empty command line argument\00"
@.str.1 = [17 x i8] c"unknown operator\00"
@.str.2 = [4 x i8] c"%g\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %6
br label %8
8: ; preds = %56, %2
%9 = load i32, i32* %6
%10 = load i32, i32* %4
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %59
12: ; preds = %8
%13 = load i8**, i8*** %5
%14 = load i32, i32* %6
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8*, i8** %13, i64 %15
%17 = load i8*, i8** %16
%18 = getelementptr inbounds i8, i8* %17, i64 0
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
switch i32 %20, label %53 [
i32 0, label %21
i32 48, label %23
i32 49, label %23
i32 50, label %23
i32 51, label %23
i32 52, label %23
i32 53, label %23
i32 54, label %23
i32 55, label %23
i32 56, label %23
i32 57, label %23
i32 43, label %31
i32 45, label %36
i32 42, label %42
i32 47, label %47
]
21: ; preds = %12
%22 = call i32 @panic(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
br label %55
23: ; preds = %12, %12, %12, %12, %12, %12, %12, %12, %12, %12
%24 = load i8**, i8*** %5
%25 = load i32, i32* %6
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8*, i8** %24, i64 %26
%28 = load i8*, i8** %27
%29 = call double @atof(i8* %28)
%30 = call i32 @push(double %29)
br label %55
31: ; preds = %12
%32 = call double (...) @pop()
%33 = call double (...) @pop()
%34 = fadd double %32, %33
%35 = call i32 @push(double %34)
br label %55
36: ; preds = %12
%37 = call double (...) @pop()
store double %37, double* %7
%38 = call double (...) @pop()
%39 = load double, double* %7
%40 = fsub double %38, %39
%41 = call i32 @push(double %40)
br label %55
42: ; preds = %12
%43 = call double (...) @pop()
%44 = call double (...) @pop()
%45 = fmul double %43, %44
%46 = call i32 @push(double %45)
br label %55
47: ; preds = %12
%48 = call double (...) @pop()
store double %48, double* %7
%49 = call double (...) @pop()
%50 = load double, double* %7
%51 = fdiv double %49, %50
%52 = call i32 @push(double %51)
br label %55
53: ; preds = %12
%54 = call i32 @panic(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
br label %55
55: ; preds = %53, %47, %42, %36, %31, %23, %21
br label %56
56: ; preds = %55
%57 = load i32, i32* %6
%58 = add nsw i32 %57, 1
store i32 %58, i32* %6
br label %8
59: ; preds = %8
%60 = call double (...) @pop()
%61 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double %60)
ret i32 0
}

LLVM IR (-O2):
@.str = [28 x i8] c"empty command line argument\00"
@.str.1 = [17 x i8] c"unknown operator\00"
@.str.2 = [4 x i8] c"%g\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %42
4: ; preds = %2
%5 = zext i32 %0 to i64
br label %6
6: ; preds = %4, %39
%7 = phi i64 [ 1, %4 ], [ %40, %39 ]
%8 = getelementptr inbounds i8*, i8** %1, i64 %7
%9 = load i8*, i8** %8
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
switch i32 %11, label %37 [
i32 0, label %12
i32 48, label %14
i32 49, label %14
i32 50, label %14
i32 51, label %14
i32 52, label %14
i32 53, label %14
i32 54, label %14
i32 55, label %14
i32 56, label %14
i32 57, label %14
i32 43, label %17
i32 45, label %22
i32 42, label %27
i32 47, label %32
]
12: ; preds = %6
%13 = tail call i32 @panic(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
br label %39
14: ; preds = %6, %6, %6, %6, %6, %6, %6, %6, %6, %6
%15 = tail call double @atof(i8* %9)
%16 = tail call i32 @push(double %15)
br label %39
17: ; preds = %6
%18 = tail call double (...) @pop()
%19 = tail call double (...) @pop()
%20 = fadd double %18, %19
%21 = tail call i32 @push(double %20)
br label %39
22: ; preds = %6
%23 = tail call double (...) @pop()
%24 = tail call double (...) @pop()
%25 = fsub double %24, %23
%26 = tail call i32 @push(double %25)
br label %39
27: ; preds = %6
%28 = tail call double (...) @pop()
%29 = tail call double (...) @pop()
%30 = fmul double %28, %29
%31 = tail call i32 @push(double %30)
br label %39
32: ; preds = %6
%33 = tail call double (...) @pop()
%34 = tail call double (...) @pop()
%35 = fdiv double %34, %33
%36 = tail call i32 @push(double %35)
br label %39
37: ; preds = %6
%38 = tail call i32 @panic(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
br label %39
39: ; preds = %12, %14, %17, %22, %27, %32, %37
%40 = add nuw nsw i64 %7, 1
%41 = icmp eq i64 %40, %5
br i1 %41, label %42, label %6
42: ; preds = %39, %2
%43 = tail call double (...) @pop()
%44 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double %43)
ret i32 0
}