#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 */
int EOF;
double atof(char *);
int /*<<< orphan*/ clear();
double fmod(double, double);
int getop(char *, char *);
double pop();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ push(double);
int main(int argc, char *argv[]) {
  int type;
  double op1, op2;
  char s[100];
  while (--argc > 0 && (type = getop(*++argv, s)) != EOF) {
    printf("\n%c", type);
    switch (type) {
    case '0':
      push(atof(s));
      break;
    case '+':
      push(pop() + pop());
      break;
    case '*':
      push(pop() * pop());
      break;
    case '%':
      op2 = pop();
      push(fmod(pop(), op2));
      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;
    case '\n':
      printf("\t%.8g\n", pop());
      break;
    case 'd':
      op1 = pop();
      push(op1);
      push(op1);
      break;
    case 's':
      op1 = pop();
      op2 = pop();
      push(op1);
      push(op2);
      break;
    case 'p':
      op1 = pop();
      printf("\t%.8g\n", op1);
      push(op1);
      break;
    case 'c':
      clear();
      break;
    default:
      printf("error: unknown command %s\n", s);
      break;
    }
  }
  printf("\n\n");
  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)
mov    -0x8(%rbp),%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x8(%rbp)
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x91(%rbp)
jle    11d7 <main+0x67>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x10(%rbp)
mov    0x8(%rax),%rdi
lea    -0x90(%rbp),%rsi
call   1070 <getop@plt>
mov    %eax,-0x14(%rbp)
mov    0x2e1c(%rip),%rcx
cmp    (%rcx),%eax
setne  %al
mov    %al,-0x91(%rbp)
mov    -0x91(%rbp),%al
test   $0x1,%al
jne    11ea <main+0x7a>
jmp    13fd <main+0x28d>
mov    -0x14(%rbp),%esi
lea    0xfb4(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0xfffffff6,%eax
mov    %eax,%ecx
mov    %rcx,-0xa0(%rbp)
sub    $0x69,%eax
ja     13e3 <main+0x273>
mov    -0xa0(%rbp),%rax
lea    0xddf(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    -0x90(%rbp),%rdi
call   1030 <atof@plt>
call   1080 <push@plt>
jmp    13f8 <main+0x288>
mov    $0x0,%al
call   1060 <pop@plt>
movsd  %xmm0,-0xa8(%rbp)
ff
mov    $0x0,%al
call   1060 <pop@plt>
movaps %xmm0,%xmm1
movsd  -0xa8(%rbp),%xmm0
ff
addsd  %xmm1,%xmm0
call   1080 <push@plt>
jmp    13f8 <main+0x288>
mov    $0x0,%al
call   1060 <pop@plt>
movsd  %xmm0,-0xb0(%rbp)
ff
mov    $0x0,%al
call   1060 <pop@plt>
movaps %xmm0,%xmm1
movsd  -0xb0(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
call   1080 <push@plt>
jmp    13f8 <main+0x288>
mov    $0x0,%al
call   1060 <pop@plt>
movsd  %xmm0,-0x28(%rbp)
mov    $0x0,%al
call   1060 <pop@plt>
movsd  -0x28(%rbp),%xmm1
call   1050 <fmod@plt>
call   1080 <push@plt>
jmp    13f8 <main+0x288>
mov    $0x0,%al
call   1060 <pop@plt>
movsd  %xmm0,-0x28(%rbp)
mov    $0x0,%al
call   1060 <pop@plt>
subsd  -0x28(%rbp),%xmm0
call   1080 <push@plt>
jmp    13f8 <main+0x288>
mov    $0x0,%al
call   1060 <pop@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1310 <main+0x1a0>
jp     1310 <main+0x1a0>
jmp    1326 <main+0x1b6>
mov    $0x0,%al
call   1060 <pop@plt>
divsd  -0x28(%rbp),%xmm0
call   1080 <push@plt>
jmp    1334 <main+0x1c4>
lea    0xe7f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    13f8 <main+0x288>
mov    $0x0,%al
call   1060 <pop@plt>
lea    0xe7a(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
jmp    13f8 <main+0x288>
mov    $0x0,%al
call   1060 <pop@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1080 <push@plt>
movsd  -0x20(%rbp),%xmm0
call   1080 <push@plt>
jmp    13f8 <main+0x288>
mov    $0x0,%al
call   1060 <pop@plt>
movsd  %xmm0,-0x20(%rbp)
mov    $0x0,%al
call   1060 <pop@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1080 <push@plt>
movsd  -0x28(%rbp),%xmm0
call   1080 <push@plt>
jmp    13f8 <main+0x288>
mov    $0x0,%al
call   1060 <pop@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
lea    0xe00(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movsd  -0x20(%rbp),%xmm0
call   1080 <push@plt>
jmp    13f8 <main+0x288>
mov    $0x0,%al
call   1090 <clear@plt>
jmp    13f8 <main+0x288>
lea    -0x90(%rbp),%rsi
lea    0xdd7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1189 <main+0x19>
lea    0xddf(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xb0,%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     138f <main+0x20f>
mov    %rsi,%rbx
mov    %edi,%ebp
add    $0x1,%ebp
add    $0x8,%rbx
lea    0x10(%rsp),%r14
mov    0x2e39(%rip),%r13
lea    0xe52(%rip),%r15
jmp    11e0 <main+0x60>
lea    0xffc(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
nopl   0x0(%rax)
add    $0xffffffff,%ebp
add    $0x8,%rbx
cmp    $0x2,%ebp
jbe    138f <main+0x20f>
mov    (%rbx),%rdi
mov    %r14,%rsi
call   1080 <getop@plt>
cmp    0x0(%r13),%eax
je     138f <main+0x20f>
mov    %eax,%r12d
lea    0xfb1(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0xfffffff6,%r12d
cmp    $0x69,%r12d
ja     11b8 <main+0x38>
movslq (%r15,%r12,4),%rax
add    %r15,%rax
jmp    *%rax
xor    %eax,%eax
call   1070 <pop@plt>
lea    0xf8b(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
jmp    11d0 <main+0x50>
xor    %eax,%eax
call   1070 <pop@plt>
movsd  %xmm0,(%rsp)
xor    %eax,%eax
call   1070 <pop@plt>
movsd  (%rsp),%xmm1
call   1060 <fmod@plt>
call   1090 <push@plt>
jmp    11d0 <main+0x50>
xor    %eax,%eax
call   1070 <pop@plt>
movsd  %xmm0,(%rsp)
xor    %eax,%eax
call   1070 <pop@plt>
mulsd  (%rsp),%xmm0
call   1090 <push@plt>
jmp    11d0 <main+0x50>
xor    %eax,%eax
call   1070 <pop@plt>
movsd  %xmm0,(%rsp)
xor    %eax,%eax
call   1070 <pop@plt>
addsd  (%rsp),%xmm0
call   1090 <push@plt>
jmp    11d0 <main+0x50>
xor    %eax,%eax
call   1070 <pop@plt>
movsd  %xmm0,(%rsp)
xor    %eax,%eax
call   1070 <pop@plt>
subsd  (%rsp),%xmm0
call   1090 <push@plt>
jmp    11d0 <main+0x50>
xor    %eax,%eax
call   1070 <pop@plt>
ucomisd 0xd32(%rip),%xmm0
jne    12d6 <main+0x156>
jnp    137e <main+0x1fe>
xor    %eax,%eax
movsd  %xmm0,(%rsp)
call   1070 <pop@plt>
divsd  (%rsp),%xmm0
call   1090 <push@plt>
jmp    11d0 <main+0x50>
mov    %r14,%rdi
call   1040 <atof@plt>
call   1090 <push@plt>
jmp    11d0 <main+0x50>
xor    %eax,%eax
call   10a0 <clear@plt>
jmp    11d0 <main+0x50>
xor    %eax,%eax
call   1070 <pop@plt>
movsd  %xmm0,(%rsp)
call   1090 <push@plt>
jmp    133c <main+0x1bc>
xor    %eax,%eax
call   1070 <pop@plt>
movsd  %xmm0,(%rsp)
lea    0xe7f(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movsd  (%rsp),%xmm0
call   1090 <push@plt>
jmp    11d0 <main+0x50>
xor    %eax,%eax
call   1070 <pop@plt>
movsd  %xmm0,(%rsp)
xor    %eax,%eax
call   1070 <pop@plt>
movsd  %xmm0,0x8(%rsp)
movsd  (%rsp),%xmm0
call   1090 <push@plt>
movsd  0x8(%rsp),%xmm0
call   1090 <push@plt>
jmp    11d0 <main+0x50>
lea    0xe51(%rip),%rdi
call   1030 <puts@plt>
jmp    11d0 <main+0x50>
lea    0xe23(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@EOF = global i32 0
@.str = [4 x i8] c"\0A%c\00"
@.str.1 = [21 x i8] c"error: zero divisor\0A\00"
@.str.2 = [7 x i8] c"\09%.8g\0A\00"
@.str.3 = [27 x i8] c"error: unknown command %s\0A\00"
@.str.4 = [3 x i8] c"\0A\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 double
%9 = alloca [100 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
br label %10
10: ; preds = %93, %2
%11 = load i32, i32* %4
%12 = add nsw i32 %11, -1
store i32 %12, i32* %4
%13 = icmp sgt i32 %12, 0
br i1 %13, label %14, label %22
14: ; preds = %10
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i32 1
store i8** %16, i8*** %5
%17 = load i8*, i8** %16
%18 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%19 = call i32 @getop(i8* %17, i8* %18)
store i32 %19, i32* %6
%20 = load i32, i32* @EOF
%21 = icmp ne i32 %19, %20
br label %22
22: ; preds = %14, %10
%23 = phi i1 [ false, %10 ], [ %21, %14 ]
br i1 %23, label %24, label %94
24: ; preds = %22
%25 = load i32, i32* %6
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %25)
%27 = load i32, i32* %6
switch i32 %27, label %90 [
i32 48, label %28
i32 43, label %32
i32 42, label %37
i32 37, label %42
i32 45, label %48
i32 47, label %54
i32 10, label %66
i32 100, label %69
i32 115, label %75
i32 112, label %82
i32 99, label %88
]
28: ; preds = %24
%29 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%30 = call double @atof(i8* %29)
%31 = call i32 @push(double %30)
br label %93
32: ; preds = %24
%33 = call double (...) @pop()
%34 = call double (...) @pop()
%35 = fadd double %33, %34
%36 = call i32 @push(double %35)
br label %93
37: ; preds = %24
%38 = call double (...) @pop()
%39 = call double (...) @pop()
%40 = fmul double %38, %39
%41 = call i32 @push(double %40)
br label %93
42: ; preds = %24
%43 = call double (...) @pop()
store double %43, double* %8
%44 = call double (...) @pop()
%45 = load double, double* %8
%46 = call double @fmod(double %44, double %45)
%47 = call i32 @push(double %46)
br label %93
48: ; preds = %24
%49 = call double (...) @pop()
store double %49, double* %8
%50 = call double (...) @pop()
%51 = load double, double* %8
%52 = fsub double %50, %51
%53 = call i32 @push(double %52)
br label %93
54: ; preds = %24
%55 = call double (...) @pop()
store double %55, double* %8
%56 = load double, double* %8
%57 = fcmp une double %56, 0.000000e+00
br i1 %57, label %58, label %63
58: ; preds = %54
%59 = call double (...) @pop()
%60 = load double, double* %8
%61 = fdiv double %59, %60
%62 = call i32 @push(double %61)
br label %65
63: ; preds = %54
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
br label %65
65: ; preds = %63, %58
br label %93
66: ; preds = %24
%67 = call double (...) @pop()
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), double %67)
br label %93
69: ; preds = %24
%70 = call double (...) @pop()
store double %70, double* %7
%71 = load double, double* %7
%72 = call i32 @push(double %71)
%73 = load double, double* %7
%74 = call i32 @push(double %73)
br label %93
75: ; preds = %24
%76 = call double (...) @pop()
store double %76, double* %7
%77 = call double (...) @pop()
store double %77, double* %8
%78 = load double, double* %7
%79 = call i32 @push(double %78)
%80 = load double, double* %8
%81 = call i32 @push(double %80)
br label %93
82: ; preds = %24
%83 = call double (...) @pop()
store double %83, double* %7
%84 = load double, double* %7
%85 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), double %84)
%86 = load double, double* %7
%87 = call i32 @push(double %86)
br label %93
88: ; preds = %24
%89 = call i32 (...) @clear()
br label %93
90: ; preds = %24
%91 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%92 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i8* %91)
br label %93
93: ; preds = %90, %88, %82, %75, %69, %66, %65, %48, %42, %37, %32, %28
br label %10
94: ; preds = %22
%95 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
ret i32 0
}

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