#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[]) {
  if (argc < 2) {
    printf("Usage: %s arguments\n", argv[0]);
    return 1;
  }
  int type, ar = 1;
  double op2;
  while (ar < argc) {
    type = getop(argv[ar]);
    switch (type) {
    case '0':
      push(atof(argv[ar]));
      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", argv[ar]);
      break;
    }
    ar++;
  }
  printf("\t%.8g\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)
cmpl   $0x2,-0x8(%rbp)
jge    1191 <main+0x41>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe9e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1306 <main+0x1b6>
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12ea <main+0x19a>
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,-0x28(%rbp)
sub    $0x6,%eax
ja     12c2 <main+0x172>
mov    -0x28(%rbp),%rax
lea    0xe28(%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    12dc <main+0x18c>
mov    $0x0,%al
call   1050 <pop@plt>
movsd  %xmm0,-0x30(%rbp)
mov    $0x0,%al
call   1050 <pop@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
addsd  %xmm1,%xmm0
call   1070 <push@plt>
jmp    12dc <main+0x18c>
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   1070 <push@plt>
jmp    12dc <main+0x18c>
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    12dc <main+0x18c>
mov    $0x0,%al
call   1050 <pop@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1299 <main+0x149>
jp     1299 <main+0x149>
jmp    12af <main+0x15f>
mov    $0x0,%al
call   1050 <pop@plt>
divsd  -0x20(%rbp),%xmm0
call   1070 <push@plt>
jmp    12bd <main+0x16d>
lea    0xd7b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12dc <main+0x18c>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xd71(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1198 <main+0x48>
mov    $0x0,%al
call   1050 <pop@plt>
lea    0xd69(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%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
mov    %rsi,%r13
cmp    $0x2,%edi
jge    118f <main+0x2f>
mov    0x0(%r13),%rsi
lea    0xea6(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%ebx
jmp    12af <main+0x14f>
mov    %edi,%r12d
mov    $0x1,%ebx
lea    0xe9b(%rip),%r14
lea    0xe63(%rip),%rbp
lea    0xeaf(%rip),%r15
jmp    11cd <main+0x6d>
mov    0x0(%r13,%rbx,8),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
nopl   (%rax)
add    $0x1,%rbx
cmp    %rbx,%r12
je     1298 <main+0x138>
mov    0x0(%r13,%rbx,8),%rdi
call   1070 <getop@plt>
add    $0xffffffd6,%eax
cmp    $0x6,%eax
ja     11ae <main+0x4e>
movslq 0x0(%rbp,%rax,4),%rax
add    %rbp,%rax
jmp    *%rax
xor    %eax,%eax
call   1060 <pop@plt>
movsd  %xmm0,(%rsp)
xor    %eax,%eax
call   1060 <pop@plt>
mulsd  (%rsp),%xmm0
call   1080 <push@plt>
jmp    11c0 <main+0x60>
xor    %eax,%eax
call   1060 <pop@plt>
movsd  %xmm0,(%rsp)
xor    %eax,%eax
call   1060 <pop@plt>
addsd  (%rsp),%xmm0
call   1080 <push@plt>
jmp    11c0 <main+0x60>
xor    %eax,%eax
call   1060 <pop@plt>
movsd  %xmm0,(%rsp)
xor    %eax,%eax
call   1060 <pop@plt>
subsd  (%rsp),%xmm0
call   1080 <push@plt>
jmp    11c0 <main+0x60>
xor    %eax,%eax
call   1060 <pop@plt>
ucomisd 0xda8(%rip),%xmm0
jne    125c <main+0xfc>
jnp    128b <main+0x12b>
xor    %eax,%eax
movsd  %xmm0,(%rsp)
call   1060 <pop@plt>
divsd  (%rsp),%xmm0
call   1080 <push@plt>
jmp    11c0 <main+0x60>
mov    0x0(%r13,%rbx,8),%rdi
call   1040 <atof@plt>
call   1080 <push@plt>
jmp    11c0 <main+0x60>
mov    %r15,%rdi
call   1030 <puts@plt>
jmp    11c0 <main+0x60>
xor    %ebx,%ebx
xor    %eax,%eax
call   1060 <pop@plt>
lea    0xdac(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [21 x i8] c"Usage: %s arguments\0A\00"
@.str.1 = [21 x i8] c"error: zero divisor\0A\00"
@.str.2 = [27 x i8] c"error: unknown command %s\0A\00"
@.str.3 = [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
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 2
br i1 %10, label %11, label %16
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %14)
store i32 1, i32* %3
br label %78
16: ; preds = %2
store i32 1, i32* %7
br label %17
17: ; preds = %72, %16
%18 = load i32, i32* %7
%19 = load i32, i32* %4
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %75
21: ; preds = %17
%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 %72
37: ; preds = %21
%38 = call double (...) @pop()
%39 = call double (...) @pop()
%40 = fadd double %38, %39
%41 = call i32 @push(double %40)
br label %72
42: ; preds = %21
%43 = call double (...) @pop()
%44 = call double (...) @pop()
%45 = fmul double %43, %44
%46 = call i32 @push(double %45)
br label %72
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 %72
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.1, i64 0, i64 0))
br label %64
64: ; preds = %62, %57
br label %72
65: ; preds = %21
%66 = load i8**, i8*** %5
%67 = load i32, i32* %7
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds i8*, i8** %66, i64 %68
%70 = load i8*, i8** %69
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i8* %70)
br label %72
72: ; preds = %65, %64, %47, %42, %37, %29
%73 = load i32, i32* %7
%74 = add nsw i32 %73, 1
store i32 %74, i32* %7
br label %17
75: ; preds = %17
%76 = call double (...) @pop()
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), double %76)
store i32 0, i32* %3
br label %78
78: ; preds = %75, %11
%79 = load i32, i32* %3
ret i32 %79
}

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