main(int argc, char *argv[]) {
  char s[100];
  double op2;
  while (--argc > 0) {
    ungets(" ");
    ungets(*++argv);
    switch (getop(s)) {
    case '0':
      push(atof(s));
      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: unkown command %s\n", s);
      argc = 1;
      break;
    }
  }
  printf("\t%s.8g\n", pop());
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jle    1317 <main+0x1b7>
lea    0xe8a(%rip),%rdi
xor    %eax,%eax
mov    %al,-0x91(%rbp)
call   1040 <ungets@plt>
mov    -0x91(%rbp),%al
mov    -0x10(%rbp),%rcx
mov    %rcx,%rdx
add    $0x8,%rdx
mov    %rdx,-0x10(%rbp)
mov    0x8(%rcx),%rdi
call   1040 <ungets@plt>
mov    -0x91(%rbp),%al
lea    -0x80(%rbp),%rdi
call   1070 <getop@plt>
add    $0xffffffd6,%eax
mov    %eax,%ecx
mov    %rcx,-0x90(%rbp)
sub    $0x6,%eax
ja     12f9 <main+0x199>
mov    -0x90(%rbp),%rax
lea    0xe11(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    -0x80(%rbp),%rdi
mov    $0x0,%al
call   1030 <atof@plt>
mov    %eax,%edi
mov    $0x0,%al
call   1080 <push@plt>
jmp    1312 <main+0x1b2>
mov    $0x0,%al
call   1060 <pop@plt>
mov    %eax,-0x98(%rbp)
mov    $0x0,%al
call   1060 <pop@plt>
mov    -0x98(%rbp),%edi
add    %eax,%edi
mov    $0x0,%al
call   1080 <push@plt>
jmp    1312 <main+0x1b2>
mov    $0x0,%al
call   1060 <pop@plt>
mov    %eax,-0x9c(%rbp)
mov    $0x0,%al
call   1060 <pop@plt>
mov    -0x9c(%rbp),%edi
imul   %eax,%edi
mov    $0x0,%al
call   1080 <push@plt>
jmp    1312 <main+0x1b2>
mov    $0x0,%al
call   1060 <pop@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
mov    $0x0,%al
call   1060 <pop@plt>
cvtsi2sd %eax,%xmm0
subsd  -0x88(%rbp),%xmm0
ff
mov    $0x1,%al
call   1080 <push@plt>
jmp    1312 <main+0x1b2>
mov    $0x0,%al
call   1060 <pop@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x88(%rbp),%xmm0
ff
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    12c7 <main+0x167>
jp     12c7 <main+0x167>
jmp    12e6 <main+0x186>
mov    $0x0,%al
call   1060 <pop@plt>
cvtsi2sd %eax,%xmm0
divsd  -0x88(%rbp),%xmm0
ff
mov    $0x1,%al
call   1080 <push@plt>
jmp    12f4 <main+0x194>
lea    0xd31(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1312 <main+0x1b2>
lea    -0x80(%rbp),%rsi
lea    0xd2f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x8(%rbp)
jmp    1179 <main+0x19>
mov    $0x0,%al
call   1060 <pop@plt>
mov    %eax,%esi
lea    0xd26(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
cmp    $0x2,%edi
jl     12b4 <main+0x144>
mov    %rsi,%rbx
mov    %edi,%ebp
add    $0x8,%rbx
lea    0xe85(%rip),%r14
lea    0x10(%rsp),%r15
lea    0xe5d(%rip),%r12
jmp    11d3 <main+0x63>
xor    %eax,%eax
call   1070 <pop@plt>
mov    %eax,%r13d
xor    %eax,%eax
call   1070 <pop@plt>
add    %eax,%r13d
mov    %r13d,%edi
xor    %eax,%eax
call   1090 <push@plt>
add    $0xffffffff,%ebp
add    $0x8,%rbx
cmp    $0x1,%ebp
jbe    12b4 <main+0x144>
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <ungets@plt>
mov    (%rbx),%rdi
xor    %eax,%eax
call   1050 <ungets@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1080 <getop@plt>
add    $0xffffffd6,%eax
cmp    $0x6,%eax
ja     12a1 <main+0x131>
movslq (%r12,%rax,4),%rax
add    %r12,%rax
jmp    *%rax
xor    %eax,%eax
call   1070 <pop@plt>
mov    %eax,%r13d
xor    %eax,%eax
call   1070 <pop@plt>
imul   %eax,%r13d
jmp    11b9 <main+0x49>
xor    %eax,%eax
call   1070 <pop@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1070 <pop@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
subsd  0x8(%rsp),%xmm0
jmp    1273 <main+0x103>
xor    %eax,%eax
call   1070 <pop@plt>
test   %eax,%eax
je     1290 <main+0x120>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1070 <pop@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
divsd  0x8(%rsp),%xmm0
mov    $0x1,%al
call   1090 <push@plt>
jmp    11c3 <main+0x53>
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <atof@plt>
mov    %eax,%edi
jmp    11bc <main+0x4c>
lea    0xda9(%rip),%rdi
call   1030 <puts@plt>
jmp    11c3 <main+0x53>
lea    0xd76(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
call   1070 <pop@plt>
lea    0xd76(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [2 x i8] c" \00"
@.str.2 = [26 x i8] c"error: unkown command %s\0A\00"
@.str.3 = [8 x i8] c"\09%s.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 sgt i32 %0, 1
br i1 %5, label %6, label %50
6: ; preds = %2, %48
%7 = phi i32 [ %9, %48 ], [ %0, %2 ]
%8 = phi i8** [ %11, %48 ], [ %1, %2 ]
%9 = add nsw i32 %7, -1
%10 = call i32 (i8*, ...) bitcast (i32 (...)* @ungets to i32 (i8*, ...)*)(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%11 = getelementptr inbounds i8*, i8** %8, i64 1
%12 = load i8*, i8** %11
%13 = call i32 (i8*, ...) bitcast (i32 (...)* @ungets to i32 (i8*, ...)*)(i8* %12)
%14 = call i32 (i8*, ...) bitcast (i32 (...)* @getop to i32 (i8*, ...)*)(i8* %4)
switch i32 %14, label %46 [
i32 48, label %15
i32 43, label %18
i32 42, label %23
i32 45, label %28
i32 47, label %35
]
15: ; preds = %6
%16 = call i32 (i8*, ...) bitcast (i32 (...)* @atof to i32 (i8*, ...)*)(i8* %4)
%17 = call i32 (i32, ...) bitcast (i32 (...)* @push to i32 (i32, ...)*)(i32 %16)
br label %48
18: ; preds = %6
%19 = call i32 (...) @pop()
%20 = call i32 (...) @pop()
%21 = add nsw i32 %20, %19
%22 = call i32 (i32, ...) bitcast (i32 (...)* @push to i32 (i32, ...)*)(i32 %21)
br label %48
23: ; preds = %6
%24 = call i32 (...) @pop()
%25 = call i32 (...) @pop()
%26 = mul nsw i32 %25, %24
%27 = call i32 (i32, ...) bitcast (i32 (...)* @push to i32 (i32, ...)*)(i32 %26)
br label %48
28: ; preds = %6
%29 = call i32 (...) @pop()
%30 = sitofp i32 %29 to double
%31 = call i32 (...) @pop()
%32 = sitofp i32 %31 to double
%33 = fsub double %32, %30
%34 = call i32 (double, ...) bitcast (i32 (...)* @push to i32 (double, ...)*)(double %33)
br label %48
35: ; preds = %6
%36 = call i32 (...) @pop()
%37 = icmp eq i32 %36, 0
br i1 %37, label %44, label %38
38: ; preds = %35
%39 = sitofp i32 %36 to double
%40 = call i32 (...) @pop()
%41 = sitofp i32 %40 to double
%42 = fdiv double %41, %39
%43 = call i32 (double, ...) bitcast (i32 (...)* @push to i32 (double, ...)*)(double %42)
br label %48
44: ; preds = %35
%45 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
br label %48
46: ; preds = %6
%47 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i8* %4)
br label %50
48: ; preds = %38, %44, %28, %23, %18, %15
%49 = icmp ugt i32 %9, 1
br i1 %49, label %6, label %50
50: ; preds = %48, %46, %2
%51 = call i32 (...) @pop()
%52 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %51)
ret i32 0
}