void media_vector(double (*input)[3], double *output) {
  double media = 0.0;
  int i, j;
  for (j = 0; j < 3; j++) {
    media = 0.0;
    for (i = 0; i < 20; i++)
      media += input[i][j];
    media /= 20;
    output[j] = media;
  }
}


x86 assembly (clang, -O0):
<media_vector>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
movl   $0x0,-0x20(%rbp)
cmpl   $0x3,-0x20(%rbp)
jge    11a4 <media_vector+0xa4>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x14,-0x1c(%rbp)
jge    116e <media_vector+0x6e>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movslq -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1134 <media_vector+0x34>
movsd  -0x18(%rbp),%xmm0
movsd  0xe85(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    111b <media_vector+0x1b>
pop    %rbp
ret

x86 assembly (clang, -O2):
<media_vector>:
xorpd  %xmm0,%xmm0
movsd  (%rdi),%xmm2
addsd  %xmm0,%xmm2
addsd  0x18(%rdi),%xmm2
addsd  0x30(%rdi),%xmm2
addsd  0x48(%rdi),%xmm2
addsd  0x60(%rdi),%xmm2
addsd  0x78(%rdi),%xmm2
addsd  0x90(%rdi),%xmm2
addsd  0xa8(%rdi),%xmm2
addsd  0xc0(%rdi),%xmm2
addsd  0xd8(%rdi),%xmm2
addsd  0xf0(%rdi),%xmm2
addsd  0x108(%rdi),%xmm2
addsd  0x120(%rdi),%xmm2
addsd  0x138(%rdi),%xmm2
addsd  0x150(%rdi),%xmm2
addsd  0x168(%rdi),%xmm2
addsd  0x180(%rdi),%xmm2
addsd  0x198(%rdi),%xmm2
addsd  0x1b0(%rdi),%xmm2
addsd  0x1c8(%rdi),%xmm2
movsd  0xe63(%rip),%xmm1
divsd  %xmm1,%xmm2
movsd  %xmm2,(%rsi)
movsd  0x8(%rdi),%xmm2
addsd  %xmm0,%xmm2
addsd  0x20(%rdi),%xmm2
addsd  0x38(%rdi),%xmm2
addsd  0x50(%rdi),%xmm2
addsd  0x68(%rdi),%xmm2
addsd  0x80(%rdi),%xmm2
addsd  0x98(%rdi),%xmm2
addsd  0xb0(%rdi),%xmm2
addsd  0xc8(%rdi),%xmm2
addsd  0xe0(%rdi),%xmm2
addsd  0xf8(%rdi),%xmm2
addsd  0x110(%rdi),%xmm2
addsd  0x128(%rdi),%xmm2
addsd  0x140(%rdi),%xmm2
addsd  0x158(%rdi),%xmm2
addsd  0x170(%rdi),%xmm2
addsd  0x188(%rdi),%xmm2
addsd  0x1a0(%rdi),%xmm2
addsd  0x1b8(%rdi),%xmm2
addsd  0x1d0(%rdi),%xmm2
divsd  %xmm1,%xmm2
movsd  %xmm2,0x8(%rsi)
addsd  0x10(%rdi),%xmm0
addsd  0x28(%rdi),%xmm0
addsd  0x40(%rdi),%xmm0
addsd  0x58(%rdi),%xmm0
addsd  0x70(%rdi),%xmm0
addsd  0x88(%rdi),%xmm0
addsd  0xa0(%rdi),%xmm0
addsd  0xb8(%rdi),%xmm0
addsd  0xd0(%rdi),%xmm0
addsd  0xe8(%rdi),%xmm0
addsd  0x100(%rdi),%xmm0
addsd  0x118(%rdi),%xmm0
addsd  0x130(%rdi),%xmm0
addsd  0x148(%rdi),%xmm0
addsd  0x160(%rdi),%xmm0
addsd  0x178(%rdi),%xmm0
addsd  0x190(%rdi),%xmm0
addsd  0x1a8(%rdi),%xmm0
addsd  0x1c0(%rdi),%xmm0
addsd  0x1d8(%rdi),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,0x10(%rsi)
ret

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

LLVM IR (-O2):
define void @media_vector([3 x double]* nocapture %0, double* nocapture writeonly %1) {
%3 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 0, i64 0
%4 = load double, double* %3
%5 = fadd double %4, 0.000000e+00
%6 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 1, i64 0
%7 = load double, double* %6
%8 = fadd double %5, %7
%9 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 2, i64 0
%10 = load double, double* %9
%11 = fadd double %8, %10
%12 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 3, i64 0
%13 = load double, double* %12
%14 = fadd double %11, %13
%15 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 4, i64 0
%16 = load double, double* %15
%17 = fadd double %14, %16
%18 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 5, i64 0
%19 = load double, double* %18
%20 = fadd double %17, %19
%21 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 6, i64 0
%22 = load double, double* %21
%23 = fadd double %20, %22
%24 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 7, i64 0
%25 = load double, double* %24
%26 = fadd double %23, %25
%27 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 8, i64 0
%28 = load double, double* %27
%29 = fadd double %26, %28
%30 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 9, i64 0
%31 = load double, double* %30
%32 = fadd double %29, %31
%33 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 10, i64 0
%34 = load double, double* %33
%35 = fadd double %32, %34
%36 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 11, i64 0
%37 = load double, double* %36
%38 = fadd double %35, %37
%39 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 12, i64 0
%40 = load double, double* %39
%41 = fadd double %38, %40
%42 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 13, i64 0
%43 = load double, double* %42
%44 = fadd double %41, %43
%45 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 14, i64 0
%46 = load double, double* %45
%47 = fadd double %44, %46
%48 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 15, i64 0
%49 = load double, double* %48
%50 = fadd double %47, %49
%51 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 16, i64 0
%52 = load double, double* %51
%53 = fadd double %50, %52
%54 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 17, i64 0
%55 = load double, double* %54
%56 = fadd double %53, %55
%57 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 18, i64 0
%58 = load double, double* %57
%59 = fadd double %56, %58
%60 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 19, i64 0
%61 = load double, double* %60
%62 = fadd double %59, %61
%63 = fdiv double %62, 2.000000e+01
store double %63, double* %1
%64 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 0, i64 1
%65 = load double, double* %64
%66 = fadd double %65, 0.000000e+00
%67 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 1, i64 1
%68 = load double, double* %67
%69 = fadd double %66, %68
%70 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 2, i64 1
%71 = load double, double* %70
%72 = fadd double %69, %71
%73 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 3, i64 1
%74 = load double, double* %73
%75 = fadd double %72, %74
%76 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 4, i64 1
%77 = load double, double* %76
%78 = fadd double %75, %77
%79 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 5, i64 1
%80 = load double, double* %79
%81 = fadd double %78, %80
%82 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 6, i64 1
%83 = load double, double* %82
%84 = fadd double %81, %83
%85 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 7, i64 1
%86 = load double, double* %85
%87 = fadd double %84, %86
%88 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 8, i64 1
%89 = load double, double* %88
%90 = fadd double %87, %89
%91 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 9, i64 1
%92 = load double, double* %91
%93 = fadd double %90, %92
%94 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 10, i64 1
%95 = load double, double* %94
%96 = fadd double %93, %95
%97 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 11, i64 1
%98 = load double, double* %97
%99 = fadd double %96, %98
%100 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 12, i64 1
%101 = load double, double* %100
%102 = fadd double %99, %101
%103 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 13, i64 1
%104 = load double, double* %103
%105 = fadd double %102, %104
%106 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 14, i64 1
%107 = load double, double* %106
%108 = fadd double %105, %107
%109 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 15, i64 1
%110 = load double, double* %109
%111 = fadd double %108, %110
%112 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 16, i64 1
%113 = load double, double* %112
%114 = fadd double %111, %113
%115 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 17, i64 1
%116 = load double, double* %115
%117 = fadd double %114, %116
%118 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 18, i64 1
%119 = load double, double* %118
%120 = fadd double %117, %119
%121 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 19, i64 1
%122 = load double, double* %121
%123 = fadd double %120, %122
%124 = fdiv double %123, 2.000000e+01
%125 = getelementptr inbounds double, double* %1, i64 1
store double %124, double* %125
%126 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 0, i64 2
%127 = load double, double* %126
%128 = fadd double %127, 0.000000e+00
%129 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 1, i64 2
%130 = load double, double* %129
%131 = fadd double %128, %130
%132 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 2, i64 2
%133 = load double, double* %132
%134 = fadd double %131, %133
%135 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 3, i64 2
%136 = load double, double* %135
%137 = fadd double %134, %136
%138 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 4, i64 2
%139 = load double, double* %138
%140 = fadd double %137, %139
%141 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 5, i64 2
%142 = load double, double* %141
%143 = fadd double %140, %142
%144 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 6, i64 2
%145 = load double, double* %144
%146 = fadd double %143, %145
%147 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 7, i64 2
%148 = load double, double* %147
%149 = fadd double %146, %148
%150 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 8, i64 2
%151 = load double, double* %150
%152 = fadd double %149, %151
%153 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 9, i64 2
%154 = load double, double* %153
%155 = fadd double %152, %154
%156 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 10, i64 2
%157 = load double, double* %156
%158 = fadd double %155, %157
%159 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 11, i64 2
%160 = load double, double* %159
%161 = fadd double %158, %160
%162 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 12, i64 2
%163 = load double, double* %162
%164 = fadd double %161, %163
%165 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 13, i64 2
%166 = load double, double* %165
%167 = fadd double %164, %166
%168 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 14, i64 2
%169 = load double, double* %168
%170 = fadd double %167, %169
%171 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 15, i64 2
%172 = load double, double* %171
%173 = fadd double %170, %172
%174 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 16, i64 2
%175 = load double, double* %174
%176 = fadd double %173, %175
%177 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 17, i64 2
%178 = load double, double* %177
%179 = fadd double %176, %178
%180 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 18, i64 2
%181 = load double, double* %180
%182 = fadd double %179, %181
%183 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 19, i64 2
%184 = load double, double* %183
%185 = fadd double %182, %184
%186 = fdiv double %185, 2.000000e+01
%187 = getelementptr inbounds double, double* %1, i64 2
store double %186, double* %187
ret void
}