#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 opt_type(char *);
double pop();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ push(double);
int main(int argc, char *argv[]) {
  int argp;
  double op2;
  for (argp = 1; argp < argc; argp++) {
    int argtype = opt_type(argv[argp]);
    switch (argtype) {
    case '*':
      push(pop() * pop());
      break;
    case '+':
      push(pop() + pop());
      break;
    case '-':
      op2 = pop();
      push(pop() - op2);
      break;
    case '/':
      op2 = pop();
      if (op2 != 0.0) {
        push(pop() / op2);
      } else {
        printf("error: divide by zero\n");
      }
      break;
    case '0':
      push(atof(argv[argp]));
      break;
    }
  }
  printf("%f\n", pop());
}


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    12a5 <main+0x155>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1070 <opt_type@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
add    $0xffffffd6,%eax
mov    %eax,%ecx
mov    %rcx,-0x30(%rbp)
sub    $0x6,%eax
ja     1292 <main+0x142>
mov    -0x30(%rbp),%rax
lea    0xe53(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x0,%al
call   1050 <pop@plt>
movsd  %xmm0,-0x38(%rbp)
mov    $0x0,%al
call   1050 <pop@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
mulsd  %xmm1,%xmm0
call   1060 <push@plt>
jmp    1292 <main+0x142>
mov    $0x0,%al
call   1050 <pop@plt>
movsd  %xmm0,-0x40(%rbp)
mov    $0x0,%al
call   1050 <pop@plt>
movaps %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
addsd  %xmm1,%xmm0
call   1060 <push@plt>
jmp    1292 <main+0x142>
mov    $0x0,%al
call   1050 <pop@plt>
movsd  %xmm0,-0x20(%rbp)
mov    $0x0,%al
call   1050 <pop@plt>
subsd  -0x20(%rbp),%xmm0
call   1060 <push@plt>
jmp    1292 <main+0x142>
mov    $0x0,%al
call   1050 <pop@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1253 <main+0x103>
jp     1253 <main+0x103>
jmp    1269 <main+0x119>
mov    $0x0,%al
call   1050 <pop@plt>
divsd  -0x20(%rbp),%xmm0
call   1060 <push@plt>
jmp    1277 <main+0x127>
lea    0xdac(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1292 <main+0x142>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <atof@plt>
call   1060 <push@plt>
jmp    1297 <main+0x147>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    116d <main+0x1d>
mov    $0x0,%al
call   1050 <pop@plt>
lea    0xd80(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
cmp    $0x2,%edi
jl     1256 <main+0xf6>
mov    %rsi,%r12
mov    %edi,%r15d
mov    $0x1,%ebx
lea    0xe80(%rip),%r13
lea    0xe99(%rip),%r14
jmp    11ac <main+0x4c>
mov    (%r12,%rbx,8),%rdi
call   1040 <atof@plt>
call   1070 <push@plt>
add    $0x1,%rbx
cmp    %rbx,%r15
je     1256 <main+0xf6>
mov    (%r12,%rbx,8),%rdi
call   1080 <opt_type@plt>
add    $0xffffffd6,%eax
cmp    $0x6,%eax
ja     119f <main+0x3f>
movslq 0x0(%r13,%rax,4),%rax
add    %r13,%rax
jmp    *%rax
xor    %eax,%eax
call   1060 <pop@plt>
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1060 <pop@plt>
mulsd  0x8(%rsp),%xmm0
jmp    119a <main+0x3a>
xor    %eax,%eax
call   1060 <pop@plt>
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1060 <pop@plt>
addsd  0x8(%rsp),%xmm0
jmp    119a <main+0x3a>
xor    %eax,%eax
call   1060 <pop@plt>
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1060 <pop@plt>
subsd  0x8(%rsp),%xmm0
jmp    119a <main+0x3a>
xor    %eax,%eax
call   1060 <pop@plt>
ucomisd 0xdd3(%rip),%xmm0
jne    1231 <main+0xd1>
jnp    1249 <main+0xe9>
xor    %eax,%eax
movsd  %xmm0,0x8(%rsp)
call   1060 <pop@plt>
divsd  0x8(%rsp),%xmm0
jmp    119a <main+0x3a>
mov    %r14,%rdi
call   1030 <puts@plt>
jmp    119f <main+0x3f>
xor    %eax,%eax
call   1060 <pop@plt>
lea    0xdc0(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str.1 = [4 x i8] c"%f\0A\00"
@str = [22 x i8] c"error: divide by zero\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 = tail call i32 @opt_type(i8* %9)
switch i32 %10, label %39 [
i32 42, label %11
i32 43, label %16
i32 45, label %21
i32 47, label %26
i32 48, label %35
]
11: ; preds = %6
%12 = tail call double (...) @pop()
%13 = tail call double (...) @pop()
%14 = fmul double %12, %13
%15 = tail call i32 @push(double %14)
br label %39
16: ; preds = %6
%17 = tail call double (...) @pop()
%18 = tail call double (...) @pop()
%19 = fadd double %17, %18
%20 = tail call i32 @push(double %19)
br label %39
21: ; preds = %6
%22 = tail call double (...) @pop()
%23 = tail call double (...) @pop()
%24 = fsub double %23, %22
%25 = tail call i32 @push(double %24)
br label %39
26: ; preds = %6
%27 = tail call double (...) @pop()
%28 = fcmp une double %27, 0.000000e+00
br i1 %28, label %29, label %33
29: ; preds = %26
%30 = tail call double (...) @pop()
%31 = fdiv double %30, %27
%32 = tail call i32 @push(double %31)
br label %39
33: ; preds = %26
%34 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
br label %39
35: ; preds = %6
%36 = load i8*, i8** %8
%37 = tail call double @atof(i8* %36)
%38 = tail call i32 @push(double %37)
br label %39
39: ; preds = %29, %33, %6, %35, %21, %16, %11
%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 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double %43)
ret i32 0
}