#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;
int atof(char *);
int getop(char *);
double pop();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ push(int);
int main() {
  int c;
  char s[100];
  double op1, op2;
  while ((c = getop(s)) != EOF && c != 's') {
    switch (c) {
    case '0':
      push(atof(s));
      break;
    case '\n':
      printf("result:%f\n", pop());
      break;
    case '+':
      push(pop() + pop());
      break;
    case '-':
      op2 = pop();
      push(pop() - op2);
      break;
    case '*':
      push(pop() * pop());
      break;
    case '/':
      op2 = pop();
      push(pop() / op2);
      break;
    case '%': {
      op2 = pop(), op1 = pop();
      if ((int)op2 == op2 && (int)op1 == op1)
        push((int)op1 % (int)op2);
      else
        printf("Error, operator %% not supported for"
               "floating-point numbers.\n");
      break;
    }
    default:
      printf("Error, operator %c not recognized\n", c);
      break;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x70(%rbp),%rdi
call   1060 <getop@plt>
mov    %eax,%ecx
mov    %ecx,-0x8(%rbp)
xor    %eax,%eax
mov    0x2e6f(%rip),%rdx
cmp    (%rdx),%ecx
mov    %al,-0x81(%rbp)
je     1194 <main+0x44>
cmpl   $0x73,-0x8(%rbp)
setne  %al
mov    %al,-0x81(%rbp)
mov    -0x81(%rbp),%al
test   $0x1,%al
jne    11a7 <main+0x57>
jmp    1345 <main+0x1f5>
mov    -0x8(%rbp),%eax
add    $0xfffffff6,%eax
mov    %eax,%ecx
mov    %rcx,-0x90(%rbp)
sub    $0x26,%eax
ja     132f <main+0x1df>
mov    -0x90(%rbp),%rax
lea    0xe33(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    -0x70(%rbp),%rdi
call   1030 <atof@plt>
mov    %eax,%edi
call   1070 <push@plt>
jmp    1340 <main+0x1f0>
mov    $0x0,%al
call   1050 <pop@plt>
lea    0xea3(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
jmp    1340 <main+0x1f0>
mov    $0x0,%al
call   1050 <pop@plt>
movsd  %xmm0,-0x98(%rbp)
ff
mov    $0x0,%al
call   1050 <pop@plt>
movaps %xmm0,%xmm1
movsd  -0x98(%rbp),%xmm0
ff
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1070 <push@plt>
jmp    1340 <main+0x1f0>
mov    $0x0,%al
call   1050 <pop@plt>
movsd  %xmm0,-0x80(%rbp)
mov    $0x0,%al
call   1050 <pop@plt>
subsd  -0x80(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1070 <push@plt>
jmp    1340 <main+0x1f0>
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
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1070 <push@plt>
jmp    1340 <main+0x1f0>
mov    $0x0,%al
call   1050 <pop@plt>
movsd  %xmm0,-0x80(%rbp)
mov    $0x0,%al
call   1050 <pop@plt>
divsd  -0x80(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1070 <push@plt>
jmp    1340 <main+0x1f0>
mov    $0x0,%al
call   1050 <pop@plt>
movsd  %xmm0,-0x80(%rbp)
mov    $0x0,%al
call   1050 <pop@plt>
movsd  %xmm0,-0x78(%rbp)
cvttsd2si -0x80(%rbp),%eax
cvtsi2sd %eax,%xmm0
ucomisd -0x80(%rbp),%xmm0
jne    131c <main+0x1cc>
jp     131c <main+0x1cc>
cvttsd2si -0x78(%rbp),%eax
cvtsi2sd %eax,%xmm0
ucomisd -0x78(%rbp),%xmm0
jne    131c <main+0x1cc>
jp     131c <main+0x1cc>
cvttsd2si -0x78(%rbp),%eax
cvttsd2si -0x80(%rbp),%ecx
cltd
idiv   %ecx
mov    %edx,%edi
call   1070 <push@plt>
jmp    132a <main+0x1da>
lea    0xd84(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1340 <main+0x1f0>
mov    -0x8(%rbp),%esi
lea    0xdab(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1162 <main+0x12>
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
lea    0x10(%rsp),%rdi
call   1060 <getop@plt>
cmp    $0x73,%eax
je     12e0 <main+0x190>
mov    0x2e70(%rip),%r13
cmp    0x0(%r13),%eax
je     12e0 <main+0x190>
lea    0xf5b(%rip),%r14
lea    0x10(%rsp),%rbx
lea    0xe6b(%rip),%rbp
lea    0xf00(%rip),%r15
lea    0xf04(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    -0xa(%rax),%ecx
cmp    $0x26,%ecx
ja     11d8 <main+0x88>
movslq 0x0(%rbp,%rcx,4),%rcx
add    %rbp,%rcx
jmp    *%rcx
xor    %eax,%eax
call   1050 <pop@plt>
mov    %r15,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
jmp    12bb <main+0x16b>
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    12bb <main+0x16b>
xor    %eax,%eax
call   1050 <pop@plt>
movapd %xmm0,(%rsp)
xor    %eax,%eax
call   1050 <pop@plt>
movapd (%rsp),%xmm2
cvttpd2dq %xmm2,%xmm1
cvtdq2pd %xmm1,%xmm1
ucomisd %xmm1,%xmm2
jne    12d4 <main+0x184>
jp     12d4 <main+0x184>
cvttpd2dq %xmm0,%xmm1
cvtdq2pd %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    12d4 <main+0x184>
jp     12d4 <main+0x184>
cvttsd2si %xmm2,%ecx
cvttsd2si %xmm0,%eax
cltd
idiv   %ecx
mov    %edx,%edi
jmp    12b6 <main+0x166>
xor    %eax,%eax
call   1050 <pop@plt>
movsd  %xmm0,(%rsp)
xor    %eax,%eax
call   1050 <pop@plt>
divsd  (%rsp),%xmm0
jmp    12b2 <main+0x162>
mov    %rbx,%rdi
call   1030 <atof@plt>
mov    %eax,%edi
jmp    12b6 <main+0x166>
xor    %eax,%eax
call   1050 <pop@plt>
movsd  %xmm0,(%rsp)
xor    %eax,%eax
call   1050 <pop@plt>
mulsd  (%rsp),%xmm0
jmp    12b2 <main+0x162>
xor    %eax,%eax
call   1050 <pop@plt>
movsd  %xmm0,(%rsp)
xor    %eax,%eax
call   1050 <pop@plt>
addsd  (%rsp),%xmm0
jmp    12b2 <main+0x162>
xor    %eax,%eax
call   1050 <pop@plt>
movsd  %xmm0,(%rsp)
xor    %eax,%eax
call   1050 <pop@plt>
subsd  (%rsp),%xmm0
cvttsd2si %xmm0,%edi
call   1070 <push@plt>
mov    %rbx,%rdi
call   1060 <getop@plt>
cmp    $0x73,%eax
je     12e0 <main+0x190>
cmp    0x0(%r13),%eax
jne    11b0 <main+0x60>
jmp    12e0 <main+0x190>
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    12bb <main+0x16b>
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 = [11 x i8] c"result:%f\0A\00"
@.str.1 = [61 x i8] c"Error, operator %% not supported forfloating-point numbers.\0A\00"
@.str.2 = [35 x i8] c"Error, operator %c not recognized\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [100 x i8]
%4 = alloca double
%5 = alloca double
store i32 0, i32* %1
br label %6
6: ; preds = %78, %0
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%8 = call i32 @getop(i8* %7)
store i32 %8, i32* %2
%9 = load i32, i32* @EOF
%10 = icmp ne i32 %8, %9
br i1 %10, label %11, label %14
11: ; preds = %6
%12 = load i32, i32* %2
%13 = icmp ne i32 %12, 115
br label %14
14: ; preds = %11, %6
%15 = phi i1 [ false, %6 ], [ %13, %11 ]
br i1 %15, label %16, label %79
16: ; preds = %14
%17 = load i32, i32* %2
switch i32 %17, label %75 [
i32 48, label %18
i32 10, label %22
i32 43, label %25
i32 45, label %31
i32 42, label %38
i32 47, label %44
i32 37, label %51
]
18: ; preds = %16
%19 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%20 = call i32 @atof(i8* %19)
%21 = call i32 @push(i32 %20)
br label %78
22: ; preds = %16
%23 = call double (...) @pop()
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), double %23)
br label %78
25: ; preds = %16
%26 = call double (...) @pop()
%27 = call double (...) @pop()
%28 = fadd double %26, %27
%29 = fptosi double %28 to i32
%30 = call i32 @push(i32 %29)
br label %78
31: ; preds = %16
%32 = call double (...) @pop()
store double %32, double* %5
%33 = call double (...) @pop()
%34 = load double, double* %5
%35 = fsub double %33, %34
%36 = fptosi double %35 to i32
%37 = call i32 @push(i32 %36)
br label %78
38: ; preds = %16
%39 = call double (...) @pop()
%40 = call double (...) @pop()
%41 = fmul double %39, %40
%42 = fptosi double %41 to i32
%43 = call i32 @push(i32 %42)
br label %78
44: ; preds = %16
%45 = call double (...) @pop()
store double %45, double* %5
%46 = call double (...) @pop()
%47 = load double, double* %5
%48 = fdiv double %46, %47
%49 = fptosi double %48 to i32
%50 = call i32 @push(i32 %49)
br label %78
51: ; preds = %16
%52 = call double (...) @pop()
store double %52, double* %5
%53 = call double (...) @pop()
store double %53, double* %4
%54 = load double, double* %5
%55 = fptosi double %54 to i32
%56 = sitofp i32 %55 to double
%57 = load double, double* %5
%58 = fcmp oeq double %56, %57
br i1 %58, label %59, label %72
59: ; preds = %51
%60 = load double, double* %4
%61 = fptosi double %60 to i32
%62 = sitofp i32 %61 to double
%63 = load double, double* %4
%64 = fcmp oeq double %62, %63
br i1 %64, label %65, label %72
65: ; preds = %59
%66 = load double, double* %4
%67 = fptosi double %66 to i32
%68 = load double, double* %5
%69 = fptosi double %68 to i32
%70 = srem i32 %67, %69
%71 = call i32 @push(i32 %70)
br label %74
72: ; preds = %59, %51
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.1, i64 0, i64 0))
br label %74
74: ; preds = %72, %65
br label %78
75: ; preds = %16
%76 = load i32, i32* %2
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i32 %76)
br label %78
78: ; preds = %75, %74, %44, %38, %31, %25, %22, %18
br label %6
79: ; preds = %14
ret i32 0
}

LLVM IR (-O2):
@EOF = global i32 0
@.str = [11 x i8] c"result:%f\0A\00"
@.str.1 = [61 x i8] c"Error, operator %% not supported forfloating-point numbers.\0A\00"
@.str.2 = [35 x i8] c"Error, operator %c not recognized\0A\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%3 = call i32 @getop(i8* %2)
%4 = load i32, i32* @EOF
%5 = icmp ne i32 %3, %4
%6 = icmp ne i32 %3, 115
%7 = and i1 %6, %5
br i1 %7, label %8, label %63
8: ; preds = %0, %57
%9 = phi i32 [ %58, %57 ], [ %3, %0 ]
switch i32 %9, label %55 [
i32 48, label %10
i32 10, label %13
i32 43, label %16
i32 45, label %22
i32 42, label %28
i32 47, label %34
i32 37, label %40
]
10: ; preds = %8
%11 = call i32 @atof(i8* %2)
%12 = call i32 @push(i32 %11)
br label %57
13: ; preds = %8
%14 = call double (...) @pop()
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), double %14)
br label %57
16: ; preds = %8
%17 = call double (...) @pop()
%18 = call double (...) @pop()
%19 = fadd double %17, %18
%20 = fptosi double %19 to i32
%21 = call i32 @push(i32 %20)
br label %57
22: ; preds = %8
%23 = call double (...) @pop()
%24 = call double (...) @pop()
%25 = fsub double %24, %23
%26 = fptosi double %25 to i32
%27 = call i32 @push(i32 %26)
br label %57
28: ; preds = %8
%29 = call double (...) @pop()
%30 = call double (...) @pop()
%31 = fmul double %29, %30
%32 = fptosi double %31 to i32
%33 = call i32 @push(i32 %32)
br label %57
34: ; preds = %8
%35 = call double (...) @pop()
%36 = call double (...) @pop()
%37 = fdiv double %36, %35
%38 = fptosi double %37 to i32
%39 = call i32 @push(i32 %38)
br label %57
40: ; preds = %8
%41 = call double (...) @pop()
%42 = call double (...) @pop()
%43 = fptosi double %41 to i32
%44 = sitofp i32 %43 to double
%45 = fcmp oeq double %41, %44
br i1 %45, label %46, label %53
46: ; preds = %40
%47 = fptosi double %42 to i32
%48 = sitofp i32 %47 to double
%49 = fcmp oeq double %42, %48
br i1 %49, label %50, label %53
50: ; preds = %46
%51 = srem i32 %47, %43
%52 = call i32 @push(i32 %51)
br label %57
53: ; preds = %46, %40
%54 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([61 x i8], [61 x i8]* @.str.1, i64 0, i64 0))
br label %57
55: ; preds = %8
%56 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i32 %9)
br label %57
57: ; preds = %50, %53, %55, %34, %28, %22, %16, %13, %10
%58 = call i32 @getop(i8* %2)
%59 = load i32, i32* @EOF
%60 = icmp ne i32 %58, %59
%61 = icmp ne i32 %58, 115
%62 = and i1 %61, %60
br i1 %62, label %8, label %63
63: ; preds = %57, %0
ret i32 0
}