#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 *, ...);
float secondTask(int array[10]) {
  printf("\nI will make the average of the array master!\n");
  float average = 0;
  float sum = 0;
  for (int index = 0; index < 10; index++) {
    sum = sum + array[index];
  }
  average = (sum / 10);
  printf("The average is %.2f ", average);
  return average;
}


x86 assembly (clang, -O0):
<secondTask>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xee1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xorps  %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0xa,-0x14(%rbp)
jge    1174 <secondTask+0x64>
movss  -0x10(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
cvtsi2ssl (%rax,%rcx,4),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x10(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1141 <secondTask+0x31>
movss  -0x10(%rbp),%xmm0
movss  0xe7f(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe99(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movss  -0xc(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<secondTask>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
lea    0xeea(%rip),%rdi
call   1030 <puts@plt>
movsd  (%rbx),%xmm0
cvtdq2ps %xmm0,%xmm0
movaps %xmm0,%xmm1
shufps $0x55,%xmm0,%xmm1
addss  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtsi2ssl 0x8(%rbx),%xmm0
addss  %xmm1,%xmm0
xorps  %xmm1,%xmm1
cvtsi2ssl 0xc(%rbx),%xmm1
addss  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtsi2ssl 0x10(%rbx),%xmm0
addss  %xmm1,%xmm0
xorps  %xmm1,%xmm1
cvtsi2ssl 0x14(%rbx),%xmm1
addss  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtsi2ssl 0x18(%rbx),%xmm0
addss  %xmm1,%xmm0
xorps  %xmm1,%xmm1
cvtsi2ssl 0x1c(%rbx),%xmm1
addss  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtsi2ssl 0x20(%rbx),%xmm0
addss  %xmm1,%xmm0
xorps  %xmm1,%xmm1
cvtsi2ssl 0x24(%rbx),%xmm1
addss  %xmm0,%xmm1
divss  0xe52(%rip),%xmm1
movss  %xmm1,0xc(%rsp)
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
lea    0xe42(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movss  0xc(%rsp),%xmm0
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [47 x i8] c"\0AI will make the average of the array master!\0A\00"
@.str.1 = [21 x i8] c"The average is %.2f \00"
define float @secondTask(i32* %0) {
%2 = alloca i32*
%3 = alloca float
%4 = alloca float
%5 = alloca i32
store i32* %0, i32** %2
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0))
store float 0.000000e+00, float* %3
store float 0.000000e+00, float* %4
store i32 0, i32* %5
br label %7
7: ; preds = %19, %1
%8 = load i32, i32* %5
%9 = icmp slt i32 %8, 10
br i1 %9, label %10, label %22
10: ; preds = %7
%11 = load float, float* %4
%12 = load i32*, i32** %2
%13 = load i32, i32* %5
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i32, i32* %12, i64 %14
%16 = load i32, i32* %15
%17 = sitofp i32 %16 to float
%18 = fadd float %11, %17
store float %18, float* %4
br label %19
19: ; preds = %10
%20 = load i32, i32* %5
%21 = add nsw i32 %20, 1
store i32 %21, i32* %5
br label %7
22: ; preds = %7
%23 = load float, float* %4
%24 = fdiv float %23, 1.000000e+01
store float %24, float* %3
%25 = load float, float* %3
%26 = fpext float %25 to double
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), double %26)
%28 = load float, float* %3
ret float %28
}

LLVM IR (-O2):
@.str.1 = [21 x i8] c"The average is %.2f \00"
@str = [46 x i8] c"\0AI will make the average of the array master!\00"
define float @secondTask(i32* nocapture %0) {
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str, i64 0, i64 0))
%3 = bitcast i32* %0 to <2 x i32>*
%4 = load <2 x i32>, <2 x i32>* %3
%5 = sitofp <2 x i32> %4 to <2 x float>
%6 = shufflevector <2 x float> %5, <2 x float> poison, <2 x i32> <i32 1, i32 undef>
%7 = fadd <2 x float> %6, %5
%8 = extractelement <2 x float> %7, i64 0
%9 = getelementptr inbounds i32, i32* %0, i64 2
%10 = load i32, i32* %9
%11 = sitofp i32 %10 to float
%12 = fadd float %8, %11
%13 = getelementptr inbounds i32, i32* %0, i64 3
%14 = load i32, i32* %13
%15 = sitofp i32 %14 to float
%16 = fadd float %12, %15
%17 = getelementptr inbounds i32, i32* %0, i64 4
%18 = load i32, i32* %17
%19 = sitofp i32 %18 to float
%20 = fadd float %16, %19
%21 = getelementptr inbounds i32, i32* %0, i64 5
%22 = load i32, i32* %21
%23 = sitofp i32 %22 to float
%24 = fadd float %20, %23
%25 = getelementptr inbounds i32, i32* %0, i64 6
%26 = load i32, i32* %25
%27 = sitofp i32 %26 to float
%28 = fadd float %24, %27
%29 = getelementptr inbounds i32, i32* %0, i64 7
%30 = load i32, i32* %29
%31 = sitofp i32 %30 to float
%32 = fadd float %28, %31
%33 = getelementptr inbounds i32, i32* %0, i64 8
%34 = load i32, i32* %33
%35 = sitofp i32 %34 to float
%36 = fadd float %32, %35
%37 = getelementptr inbounds i32, i32* %0, i64 9
%38 = load i32, i32* %37
%39 = sitofp i32 %38 to float
%40 = fadd float %36, %39
%41 = fdiv float %40, 1.000000e+01
%42 = fpext float %41 to double
%43 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), double %42)
ret float %41
}