#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 *, ...);
void average(double a[][5], int n) {
  int i, j;
  double sum = 0;
  for (i = 0; i < 10; i++) {
    for (j = 0; j < 5; j++) {
      sum += a[i][j];
    }
    printf("%.2lf ", sum / 5.0);
    sum = 0;
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<average>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0xa,-0x10(%rbp)
jge    11ae <average+0x9e>
movl   $0x0,-0x14(%rbp)
cmpl   $0x5,-0x14(%rbp)
jge    1179 <average+0x69>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
imul   $0x28,%rcx,%rcx
add    %rcx,%rax
movslq -0x14(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    113f <average+0x2f>
movsd  -0x20(%rbp),%xmm0
movsd  0xe7a(%rip),%xmm1
divsd  %xmm1,%xmm0
lea    0xe77(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    112e <average+0x1e>
lea    0xe5a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<average>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r15
mov    $0x20,%ebx
lea    0xedc(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsd  -0x20(%r15,%rbx,1),%xmm0
addsd  0xeb9(%rip),%xmm0
addsd  -0x18(%r15,%rbx,1),%xmm0
addsd  -0x10(%r15,%rbx,1),%xmm0
addsd  -0x8(%r15,%rbx,1),%xmm0
addsd  (%r15,%rbx,1),%xmm0
divsd  0xe8e(%rip),%xmm0
mov    %r14,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
add    $0x28,%rbx
cmp    $0x1b0,%rbx
jne    1140 <average+0x20>
mov    $0xa,%edi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"%.2lf \00"
@.str.1 = [2 x i8] c"\0A\00"
define void @average([5 x double]* %0, i32 %1) {
%3 = alloca [5 x double]*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca double
store [5 x double]* %0, [5 x double]** %3
store i32 %1, i32* %4
store double 0.000000e+00, double* %7
store i32 0, i32* %5
br label %8
8: ; preds = %33, %2
%9 = load i32, i32* %5
%10 = icmp slt i32 %9, 10
br i1 %10, label %11, label %36
11: ; preds = %8
store i32 0, i32* %6
br label %12
12: ; preds = %26, %11
%13 = load i32, i32* %6
%14 = icmp slt i32 %13, 5
br i1 %14, label %15, label %29
15: ; preds = %12
%16 = load [5 x double]*, [5 x double]** %3
%17 = load i32, i32* %5
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [5 x double], [5 x double]* %16, i64 %18
%20 = load i32, i32* %6
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [5 x double], [5 x double]* %19, i64 0, i64 %21
%23 = load double, double* %22
%24 = load double, double* %7
%25 = fadd double %24, %23
store double %25, double* %7
br label %26
26: ; preds = %15
%27 = load i32, i32* %6
%28 = add nsw i32 %27, 1
store i32 %28, i32* %6
br label %12
29: ; preds = %12
%30 = load double, double* %7
%31 = fdiv double %30, 5.000000e+00
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), double %31)
store double 0.000000e+00, double* %7
br label %33
33: ; preds = %29
%34 = load i32, i32* %5
%35 = add nsw i32 %34, 1
store i32 %35, i32* %5
br label %8
36: ; preds = %8
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"%.2lf \00"
define void @average([5 x double]* nocapture %0, i32 %1) {
br label %3
3: ; preds = %2, %3
%4 = phi i64 [ 0, %2 ], [ %22, %3 ]
%5 = getelementptr inbounds [5 x double], [5 x double]* %0, i64 %4, i64 0
%6 = load double, double* %5
%7 = fadd double %6, 0.000000e+00
%8 = getelementptr inbounds [5 x double], [5 x double]* %0, i64 %4, i64 1
%9 = load double, double* %8
%10 = fadd double %7, %9
%11 = getelementptr inbounds [5 x double], [5 x double]* %0, i64 %4, i64 2
%12 = load double, double* %11
%13 = fadd double %10, %12
%14 = getelementptr inbounds [5 x double], [5 x double]* %0, i64 %4, i64 3
%15 = load double, double* %14
%16 = fadd double %13, %15
%17 = getelementptr inbounds [5 x double], [5 x double]* %0, i64 %4, i64 4
%18 = load double, double* %17
%19 = fadd double %16, %18
%20 = fdiv double %19, 5.000000e+00
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), double %20)
%22 = add nuw nsw i64 %4, 1
%23 = icmp eq i64 %22, 10
br i1 %23, label %24, label %3
24: ; preds = %3
%25 = tail call i32 @putchar(i32 10)
ret void
}