void avg_student(double student_scores[10][5], double averages_stu[5]) {
  for (int i = 0; i < 10; i++) {
    double tmp = 0;
    for (int j = 0; j < 5; j++) {
      tmp += student_scores[i][j];
    }
    averages_stu[i] = tmp / 5;
  }
}


x86 assembly (clang, -O0):
<avg_student>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0xa,-0x14(%rbp)
jge    1192 <avg_student+0x92>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0x5,-0x24(%rbp)
jge    1166 <avg_student+0x66>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
imul   $0x28,%rcx,%rcx
add    %rcx,%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    112c <avg_student+0x2c>
movsd  -0x20(%rbp),%xmm0
movsd  0xe8d(%rip),%xmm1
divsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1113 <avg_student+0x13>
pop    %rbp
ret

x86 assembly (clang, -O2):
<avg_student>:
add    $0x20,%rdi
xor    %eax,%eax
xorpd  %xmm0,%xmm0
movsd  0xeee(%rip),%xmm1
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsd  -0x20(%rdi),%xmm2
addsd  %xmm0,%xmm2
addsd  -0x18(%rdi),%xmm2
addsd  -0x10(%rdi),%xmm2
addsd  -0x8(%rdi),%xmm2
addsd  (%rdi),%xmm2
divsd  %xmm1,%xmm2
movsd  %xmm2,(%rsi,%rax,8)
add    $0x1,%rax
add    $0x28,%rdi
cmp    $0xa,%rax
jne    1120 <avg_student+0x20>
ret

LLVM IR (-O0):
define void @avg_student([5 x double]* %0, double* %1) {
%3 = alloca [5 x double]*
%4 = alloca double*
%5 = alloca i32
%6 = alloca double
%7 = alloca i32
store [5 x double]* %0, [5 x double]** %3
store double* %1, double** %4
store i32 0, i32* %5
br label %8
8: ; preds = %36, %2
%9 = load i32, i32* %5
%10 = icmp slt i32 %9, 10
br i1 %10, label %11, label %39
11: ; preds = %8
store double 0.000000e+00, double* %6
store i32 0, i32* %7
br label %12
12: ; preds = %26, %11
%13 = load i32, i32* %7
%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* %7
%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* %6
%25 = fadd double %24, %23
store double %25, double* %6
br label %26
26: ; preds = %15
%27 = load i32, i32* %7
%28 = add nsw i32 %27, 1
store i32 %28, i32* %7
br label %12
29: ; preds = %12
%30 = load double, double* %6
%31 = fdiv double %30, 5.000000e+00
%32 = load double*, double** %4
%33 = load i32, i32* %5
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds double, double* %32, i64 %34
store double %31, double* %35
br label %36
36: ; preds = %29
%37 = load i32, i32* %5
%38 = add nsw i32 %37, 1
store i32 %38, i32* %5
br label %8
39: ; preds = %8
ret void
}

LLVM IR (-O2):
define void @avg_student([5 x double]* nocapture %0, double* nocapture writeonly %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 = getelementptr inbounds double, double* %1, i64 %4
store double %20, double* %21
%22 = add nuw nsw i64 %4, 1
%23 = icmp eq i64 %22, 10
br i1 %23, label %24, label %3
24: ; preds = %3
ret void
}