#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 getop(char *);
double pop();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ push(double);
int main(int argc, char *argv[]) {
  int type, i;
  double op2;
  char s[100];
  if (argc == 1)
    return 0;
  i = 1;
  while (argv[i] != NULL) {
    type = getop(argv[i]);
    switch (type) {
    case '0':
      push(atof(argv[i]));
      break;
    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: zero divisor\n");
      break;
    default:
      printf("error: unknown command %s\n", s);
      break;
    }
    i++;
  }
  printf("\t%.8g\n", pop());
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    117f <main+0x2f>
movl   $0x0,-0x4(%rbp)
jmp    1308 <main+0x1b8>
movl   $0x1,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     12ec <main+0x19c>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1060 <getop@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0xffffffd6,%eax
mov    %eax,%ecx
mov    %rcx,-0x98(%rbp)
sub    $0x6,%eax
ja     12c9 <main+0x179>
mov    -0x98(%rbp),%rax
lea    0xe2d(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <atof@plt>
call   1070 <push@plt>
jmp    12de <main+0x18e>
mov    $0x0,%al
call   1050 <pop@plt>
movsd  %xmm0,-0xa0(%rbp)
ff
mov    $0x0,%al
call   1050 <pop@plt>
movaps %xmm0,%xmm1
movsd  -0xa0(%rbp),%xmm0
ff
addsd  %xmm1,%xmm0
call   1070 <push@plt>
jmp    12de <main+0x18e>
mov    $0x0,%al
call   1050 <pop@plt>
movsd  %xmm0,-0xa8(%rbp)
ff
mov    $0x0,%al
call   1050 <pop@plt>
movaps %xmm0,%xmm1
movsd  -0xa8(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
call   1070 <push@plt>
jmp    12de <main+0x18e>
mov    $0x0,%al
call   1050 <pop@plt>
movsd  %xmm0,-0x20(%rbp)
mov    $0x0,%al
call   1050 <pop@plt>
subsd  -0x20(%rbp),%xmm0
call   1070 <push@plt>
jmp    12de <main+0x18e>
mov    $0x0,%al
call   1050 <pop@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    12a0 <main+0x150>
jp     12a0 <main+0x150>
jmp    12b6 <main+0x166>
mov    $0x0,%al
call   1050 <pop@plt>
divsd  -0x20(%rbp),%xmm0
call   1070 <push@plt>
jmp    12c4 <main+0x174>
lea    0xd5f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12de <main+0x18e>
lea    -0x90(%rbp),%rsi
lea    0xd5a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1186 <main+0x36>
mov    $0x0,%al
call   1050 <pop@plt>
lea    0xd52(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
cmp    $0x1,%edi
je     12c2 <main+0x162>
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x80,%rsp
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
test   %rdi,%rdi
je     129d <main+0x13d>
add    $0x10,%rbx
lea    0xe90(%rip),%r14
lea    0x10(%rsp),%r15
lea    0xe68(%rip),%r13
lea    0xe9f(%rip),%r12
jmp    11d0 <main+0x70>
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
cs nopw 0x0(%rax,%rax,1)
mov    (%rbx),%rdi
add    $0x8,%rbx
test   %rdi,%rdi
je     129d <main+0x13d>
call   1070 <getop@plt>
add    $0xffffffd6,%eax
cmp    $0x6,%eax
ja     11a9 <main+0x49>
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
call   1080 <push@plt>
jmp    11c0 <main+0x60>
xor    %eax,%eax
call   1060 <pop@plt>
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1060 <pop@plt>
addsd  0x8(%rsp),%xmm0
call   1080 <push@plt>
jmp    11c0 <main+0x60>
xor    %eax,%eax
call   1060 <pop@plt>
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1060 <pop@plt>
subsd  0x8(%rsp),%xmm0
call   1080 <push@plt>
jmp    11c0 <main+0x60>
xor    %eax,%eax
call   1060 <pop@plt>
ucomisd 0xda4(%rip),%xmm0
jne    1260 <main+0x100>
jnp    1290 <main+0x130>
xor    %eax,%eax
movsd  %xmm0,0x8(%rsp)
call   1060 <pop@plt>
divsd  0x8(%rsp),%xmm0
call   1080 <push@plt>
jmp    11c0 <main+0x60>
mov    -0x8(%rbx),%rdi
call   1040 <atof@plt>
call   1080 <push@plt>
jmp    11c0 <main+0x60>
mov    %r12,%rdi
call   1030 <puts@plt>
jmp    11c0 <main+0x60>
xor    %eax,%eax
call   1060 <pop@plt>
lea    0xd94(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
add    $0x80,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
xor    %eax,%eax
ret

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

LLVM IR (-O2):
@.str.1 = [27 x i8] c"error: unknown command %s\0A\00"
@.str.2 = [7 x i8] c"\09%.8g\0A\00"
@str = [20 x i8] c"error: zero divisor\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [100 x i8]
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%5 = icmp eq i32 %0, 1
br i1 %5, label %53, label %6
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = icmp eq i8* %8, null
br i1 %9, label %50, label %10
10: ; preds = %6, %45
%11 = phi i64 [ %46, %45 ], [ 1, %6 ]
%12 = phi i8* [ %48, %45 ], [ %8, %6 ]
%13 = phi i8** [ %47, %45 ], [ %7, %6 ]
%14 = call i32 @getop(i8* %12)
switch i32 %14, label %43 [
i32 48, label %15
i32 43, label %19
i32 42, label %24
i32 45, label %29
i32 47, label %34
]
15: ; preds = %10
%16 = load i8*, i8** %13
%17 = call double @atof(i8* %16)
%18 = call i32 @push(double %17)
br label %45
19: ; preds = %10
%20 = call double (...) @pop()
%21 = call double (...) @pop()
%22 = fadd double %20, %21
%23 = call i32 @push(double %22)
br label %45
24: ; preds = %10
%25 = call double (...) @pop()
%26 = call double (...) @pop()
%27 = fmul double %25, %26
%28 = call i32 @push(double %27)
br label %45
29: ; preds = %10
%30 = call double (...) @pop()
%31 = call double (...) @pop()
%32 = fsub double %31, %30
%33 = call i32 @push(double %32)
br label %45
34: ; preds = %10
%35 = call double (...) @pop()
%36 = fcmp une double %35, 0.000000e+00
br i1 %36, label %37, label %41
37: ; preds = %34
%38 = call double (...) @pop()
%39 = fdiv double %38, %35
%40 = call i32 @push(double %39)
br label %45
41: ; preds = %34
%42 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
br label %45
43: ; preds = %10
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %4)
br label %45
45: ; preds = %37, %41, %43, %29, %24, %19, %15
%46 = add nuw i64 %11, 1
%47 = getelementptr inbounds i8*, i8** %1, i64 %46
%48 = load i8*, i8** %47
%49 = icmp eq i8* %48, null
br i1 %49, label %50, label %10
50: ; preds = %45, %6
%51 = call double (...) @pop()
%52 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), double %51)
br label %53
53: ; preds = %2, %50
ret i32 0
}