#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 *);
double dapop();
int /*<<< orphan*/ dapush(double);
int getop(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ ungets(char *);
int main(int argc, char *argv[]) {
  char operator[100] = "";
  double operand;
  while (--argc > 0) {
    ungets(" ");
    ungets(*++argv);
    switch (getop(operator)) {
    case '0':
      dapush(atof(operator));
      break;
    case '+':
      dapush(dapop() + dapop());
      break;
    case '-':
      operand = dapop();
      dapush(dapop() - operand);
      break;
    case '*':
      dapush(dapop() * dapop());
      break;
    case '/':
      operand = dapop();
      dapush(dapop() / operand);
      break;
    default:
      printf("Error: Unknown command '%s'\n", operator);
      argc = 1;
      break;
    }
  }
  printf("%.8g\n", dapop());
  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)
lea    -0x80(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1060 <memset@plt>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jle    12e3 <main+0x173>
lea    0xe6a(%rip),%rdi
call   1040 <ungets@plt>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x10(%rbp)
mov    0x8(%rax),%rdi
call   1040 <ungets@plt>
lea    -0x80(%rbp),%rdi
call   1070 <getop@plt>
add    $0xffffffd6,%eax
mov    %eax,%ecx
mov    %rcx,-0x90(%rbp)
sub    $0x6,%eax
ja     12c5 <main+0x155>
mov    -0x90(%rbp),%rax
lea    0xe05(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    -0x80(%rbp),%rdi
call   1030 <atof@plt>
call   1080 <dapush@plt>
jmp    12de <main+0x16e>
mov    $0x0,%al
call   1090 <dapop@plt>
movsd  %xmm0,-0x98(%rbp)
ff
mov    $0x0,%al
call   1090 <dapop@plt>
movaps %xmm0,%xmm1
movsd  -0x98(%rbp),%xmm0
ff
addsd  %xmm1,%xmm0
call   1080 <dapush@plt>
jmp    12de <main+0x16e>
mov    $0x0,%al
call   1090 <dapop@plt>
movsd  %xmm0,-0x88(%rbp)
ff
mov    $0x0,%al
call   1090 <dapop@plt>
subsd  -0x88(%rbp),%xmm0
ff
call   1080 <dapush@plt>
jmp    12de <main+0x16e>
mov    $0x0,%al
call   1090 <dapop@plt>
movsd  %xmm0,-0xa0(%rbp)
ff
mov    $0x0,%al
call   1090 <dapop@plt>
movaps %xmm0,%xmm1
movsd  -0xa0(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
call   1080 <dapush@plt>
jmp    12de <main+0x16e>
mov    $0x0,%al
call   1090 <dapop@plt>
movsd  %xmm0,-0x88(%rbp)
ff
mov    $0x0,%al
call   1090 <dapop@plt>
divsd  -0x88(%rbp),%xmm0
ff
call   1080 <dapush@plt>
jmp    12de <main+0x16e>
lea    -0x80(%rbp),%rsi
lea    0xd4e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x8(%rbp)
jmp    1199 <main+0x29>
mov    $0x0,%al
call   1090 <dapop@plt>
lea    0xd4a(%rip),%rdi
mov    $0x1,%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   %r12
push   %rbx
sub    $0x80,%rsp
xorpd  %xmm0,%xmm0
movapd %xmm0,0x60(%rsp)
movapd %xmm0,0x50(%rsp)
movapd %xmm0,0x40(%rsp)
movapd %xmm0,0x30(%rsp)
movapd %xmm0,0x20(%rsp)
movapd %xmm0,0x10(%rsp)
movl   $0x0,0x70(%rsp)
cmp    $0x2,%edi
jl     1297 <main+0x137>
mov    %rsi,%rbx
mov    %edi,%ebp
add    $0x8,%rbx
lea    0xe64(%rip),%r14
lea    0x10(%rsp),%r15
lea    0xe3c(%rip),%r12
jmp    11e5 <main+0x85>
mov    %r15,%rdi
call   1030 <atof@plt>
xchg   %ax,%ax
add    $0xffffffff,%ebp
call   1070 <dapush@plt>
add    $0x8,%rbx
cmp    $0x1,%ebp
jbe    1297 <main+0x137>
mov    %r14,%rdi
call   1040 <ungets@plt>
mov    (%rbx),%rdi
call   1040 <ungets@plt>
mov    %r15,%rdi
call   1060 <getop@plt>
add    $0xffffffd6,%eax
cmp    $0x6,%eax
ja     1284 <main+0x124>
movslq (%r12,%rax,4),%rax
add    %r12,%rax
jmp    *%rax
xor    %eax,%eax
call   1080 <dapop@plt>
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1080 <dapop@plt>
mulsd  0x8(%rsp),%xmm0
jmp    11d0 <main+0x70>
xor    %eax,%eax
call   1080 <dapop@plt>
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1080 <dapop@plt>
addsd  0x8(%rsp),%xmm0
jmp    11d0 <main+0x70>
xor    %eax,%eax
call   1080 <dapop@plt>
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1080 <dapop@plt>
subsd  0x8(%rsp),%xmm0
jmp    11d0 <main+0x70>
xor    %eax,%eax
call   1080 <dapop@plt>
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1080 <dapop@plt>
divsd  0x8(%rsp),%xmm0
jmp    11d0 <main+0x70>
lea    0xd93(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1080 <dapop@plt>
lea    0xd96(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [2 x i8] c" \00"
@.str.1 = [29 x i8] c"Error: Unknown command '%s'\0A\00"
@.str.2 = [6 x i8] c"%.8g\0A\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 %39
6: ; preds = %2, %35
%7 = phi i32 [ %9, %35 ], [ %0, %2 ]
%8 = phi i8** [ %11, %35 ], [ %1, %2 ]
%9 = add nsw i32 %7, -1
%10 = call i32 @ungets(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 @ungets(i8* %12)
%14 = call i32 @getop(i8* %4)
switch i32 %14, label %33 [
i32 48, label %15
i32 43, label %17
i32 45, label %21
i32 42, label %25
i32 47, label %29
]
15: ; preds = %6
%16 = call double @atof(i8* %4)
br label %35
17: ; preds = %6
%18 = call double (...) @dapop()
%19 = call double (...) @dapop()
%20 = fadd double %18, %19
br label %35
21: ; preds = %6
%22 = call double (...) @dapop()
%23 = call double (...) @dapop()
%24 = fsub double %23, %22
br label %35
25: ; preds = %6
%26 = call double (...) @dapop()
%27 = call double (...) @dapop()
%28 = fmul double %26, %27
br label %35
29: ; preds = %6
%30 = call double (...) @dapop()
%31 = call double (...) @dapop()
%32 = fdiv double %31, %30
br label %35
33: ; preds = %6
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i8* %4)
br label %39
35: ; preds = %29, %25, %21, %17, %15
%36 = phi double [ %32, %29 ], [ %28, %25 ], [ %24, %21 ], [ %20, %17 ], [ %16, %15 ]
%37 = call i32 @dapush(double %36)
%38 = icmp ugt i32 %9, 1
br i1 %38, label %6, label %39
39: ; preds = %35, %33, %2
%40 = call double (...) @dapop()
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double %40)
ret i32 0
}