#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 /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  float s = 0;
  int n, c = 0;
  do {
    printf("Enter number: ");
    scanf("%d", &n);
    if (n > 0 && (n % 10 == 8)) {
      s += n;
      c++;
    }
  } while (n != 0);
  if (c > 0)
    printf("The average is %f", s / c);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x8(%rbp)
movl   $0x0,-0x10(%rbp)
lea    0xebb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xebc(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0xc(%rbp)
jle    1192 <main+0x72>
mov    -0xc(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
cmp    $0x8,%edx
jne    1192 <main+0x72>
cvtsi2ssl -0xc(%rbp),%xmm0
addss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x8(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1197 <main+0x77>
cmpl   $0x0,-0xc(%rbp)
jne    113e <main+0x1e>
cmpl   $0x0,-0x10(%rbp)
jle    11cb <main+0xab>
movss  -0x8(%rbp),%xmm0
cvtsi2ssl -0x10(%rbp),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe4e(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
xorps  %xmm1,%xmm1
lea    0xed3(%rip),%r14
lea    0xedb(%rip),%r15
lea    0x4(%rsp),%rbx
xor    %ebp,%ebp
jmp    116b <main+0x4b>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movss  0xea8(%rip),%xmm0
movss  (%rsp),%xmm1
addss  %xmm0,%xmm1
movzbl %cl,%ecx
add    %ecx,%ebp
test   %rax,%rax
je     11c0 <main+0xa0>
movss  %xmm1,(%rsp)
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
movslq 0x4(%rsp),%rax
test   %rax,%rax
setg   %dl
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rsi
shr    $0x3f,%rsi
sar    $0x22,%rcx
add    %esi,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
mov    %eax,%esi
sub    %ecx,%esi
cmp    $0x8,%esi
sete   %cl
and    %dl,%cl
je     1150 <main+0x30>
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
jmp    1158 <main+0x38>
test   %ebp,%ebp
je     11e4 <main+0xc4>
xorps  %xmm0,%xmm0
cvtsi2ss %ebp,%xmm0
divss  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
lea    0xe39(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [15 x i8] c"Enter number: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [18 x i8] c"The average is %f\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store float 0.000000e+00, float* %2
store i32 0, i32* %4
br label %5
5: ; preds = %22, %0
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%8 = load i32, i32* %3
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %21
10: ; preds = %5
%11 = load i32, i32* %3
%12 = srem i32 %11, 10
%13 = icmp eq i32 %12, 8
br i1 %13, label %14, label %21
14: ; preds = %10
%15 = load i32, i32* %3
%16 = sitofp i32 %15 to float
%17 = load float, float* %2
%18 = fadd float %17, %16
store float %18, float* %2
%19 = load i32, i32* %4
%20 = add nsw i32 %19, 1
store i32 %20, i32* %4
br label %21
21: ; preds = %14, %10, %5
br label %22
22: ; preds = %21
%23 = load i32, i32* %3
%24 = icmp ne i32 %23, 0
br i1 %24, label %5, label %25
25: ; preds = %22
%26 = load i32, i32* %4
%27 = icmp sgt i32 %26, 0
br i1 %27, label %28, label %35
28: ; preds = %25
%29 = load float, float* %2
%30 = load i32, i32* %4
%31 = sitofp i32 %30 to float
%32 = fdiv float %29, %31
%33 = fpext float %32 to double
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), double %33)
br label %35
35: ; preds = %28, %25
ret i32 0
}

LLVM IR (-O2):
@.str = [15 x i8] c"Enter number: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [18 x i8] c"The average is %f\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
br label %3
3: ; preds = %3, %0
%4 = phi float [ 0.000000e+00, %0 ], [ %15, %3 ]
%5 = phi i32 [ 0, %0 ], [ %17, %3 ]
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%8 = load i32, i32* %1
%9 = icmp sgt i32 %8, 0
%10 = srem i32 %8, 10
%11 = icmp eq i32 %10, 8
%12 = and i1 %9, %11
%13 = sitofp i32 %8 to float
%14 = select i1 %12, float %13, float -0.000000e+00
%15 = fadd float %4, %14
%16 = zext i1 %12 to i32
%17 = add nuw nsw i32 %5, %16
%18 = icmp eq i32 %8, 0
br i1 %18, label %19, label %3
19: ; preds = %3
%20 = icmp eq i32 %17, 0
br i1 %20, label %26, label %21
21: ; preds = %19
%22 = sitofp i32 %17 to float
%23 = fdiv float %15, %22
%24 = fpext float %23 to double
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), double %24)
br label %26
26: ; preds = %21, %19
ret i32 0
}