#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 *);
void Task4() {
  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\n", s / c);
}


x86 assembly (clang, -O0):
<Task4>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
xorps  %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xec2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec3(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jle    118b <Task4+0x6b>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
cmp    $0x8,%edx
jne    118b <Task4+0x6b>
cvtsi2ssl -0x8(%rbp),%xmm0
addss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1190 <Task4+0x70>
cmpl   $0x0,-0x8(%rbp)
jne    1137 <Task4+0x17>
cmpl   $0x0,-0xc(%rbp)
jle    11c4 <Task4+0xa4>
movss  -0x4(%rbp),%xmm0
cvtsi2ssl -0xc(%rbp),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe55(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Task4>:
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 <Task4+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 <Task4+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 <Task4+0x30>
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
jmp    1158 <Task4+0x38>
test   %ebp,%ebp
je     11e4 <Task4+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>
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 = [19 x i8] c"The average is %f\0A\00"
define void @Task4() {
%1 = alloca float
%2 = alloca i32
%3 = alloca i32
store float 0.000000e+00, float* %1
store i32 0, i32* %3
br label %4
4: ; preds = %21, %0
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%7 = load i32, i32* %2
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %20
9: ; preds = %4
%10 = load i32, i32* %2
%11 = srem i32 %10, 10
%12 = icmp eq i32 %11, 8
br i1 %12, label %13, label %20
13: ; preds = %9
%14 = load i32, i32* %2
%15 = sitofp i32 %14 to float
%16 = load float, float* %1
%17 = fadd float %16, %15
store float %17, float* %1
%18 = load i32, i32* %3
%19 = add nsw i32 %18, 1
store i32 %19, i32* %3
br label %20
20: ; preds = %13, %9, %4
br label %21
21: ; preds = %20
%22 = load i32, i32* %2
%23 = icmp ne i32 %22, 0
br i1 %23, label %4, label %24
24: ; preds = %21
%25 = load i32, i32* %3
%26 = icmp sgt i32 %25, 0
br i1 %26, label %27, label %34
27: ; preds = %24
%28 = load float, float* %1
%29 = load i32, i32* %3
%30 = sitofp i32 %29 to float
%31 = fdiv float %28, %30
%32 = fpext float %31 to double
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), double %32)
br label %34
34: ; preds = %27, %24
ret void
}

LLVM IR (-O2):
@.str = [15 x i8] c"Enter number: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [19 x i8] c"The average is %f\0A\00"
define void @Task4() {
%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 ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), double %24)
br label %26
26: ; preds = %21, %19
ret void
}