#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*/ memset(double *, int /*<<< orphan*/, int);
int /*<<< orphan*/ mult(double *, double *, int, int);
void mean(double *mu, double **X, int n, int m) {
  memset(mu, 0, m * sizeof(double));
  int i, j;
  for (i = 0; i < n; i++)
    for (j = 0; j < m; j++)
      mu[j] += X[i][j];
  mult(mu, mu, 1 / (double)n, m);
}


x86 assembly (clang, -O0):
<mean>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
movslq -0x18(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edx
xor    %esi,%esi
call   1030 <memset@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11b9 <mean+0x99>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11a6 <mean+0x86>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
addsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1165 <mean+0x45>
jmp    11ab <mean+0x8b>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1152 <mean+0x32>
mov    -0x8(%rbp),%rdi
mov    -0x8(%rbp),%rsi
cvtsi2sdl -0x14(%rbp),%xmm1
movsd  0xe32(%rip),%xmm0
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edx
mov    -0x18(%rbp),%ecx
call   1040 <mult@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mean>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %ecx,%r14d
mov    %edx,%ebp
mov    %rsi,%r13
mov    %rdi,%rbx
lea    0x0(,%r14,8),%edx
xor    %esi,%esi
call   1030 <memset@plt>
mov    %ebp,0x4(%rsp)
test   %ebp,%ebp
jle    1319 <mean+0x1f9>
mov    0x4(%rsp),%r15d
mov    %r14d,%ecx
lea    (%rbx,%rcx,8),%r10
mov    %ecx,%r12d
and    $0xfffffffc,%r12d
lea    -0x4(%r12),%r11
mov    %r11,0x10(%rsp)
shr    $0x2,%r11
add    $0x1,%r11
mov    %r11,%rax
and    $0xfffffffffffffffe,%rax
mov    %rax,0x8(%rsp)
mov    %ecx,%r8d
and    $0x3,%r8d
xor    %edi,%edi
jmp    119d <mean+0x7d>
add    $0x1,%rdi
cmp    %r15,%rdi
je     1319 <mean+0x1f9>
test   %r14d,%r14d
jle    1190 <mean+0x70>
mov    0x0(%r13,%rdi,8),%rsi
cmp    $0x4,%r14d
jb     11c3 <mean+0xa3>
lea    (%rsi,%rcx,8),%rax
cmp    %rbx,%rax
jbe    1253 <mean+0x133>
cmp    %r10,%rsi
jae    1253 <mean+0x133>
xor    %ebp,%ebp
mov    %rbp,%rax
not    %rax
add    %rcx,%rax
test   %r8,%r8
je     11f9 <mean+0xd9>
mov    %r8,%rdx
cs nopw 0x0(%rax,%rax,1)
movsd  (%rsi,%rbp,8),%xmm0
addsd  (%rbx,%rbp,8),%xmm0
movsd  %xmm0,(%rbx,%rbp,8)
add    $0x1,%rbp
add    $0xffffffffffffffff,%rdx
jne    11e0 <mean+0xc0>
cmp    $0x3,%rax
jb     1190 <mean+0x70>
nop
movsd  (%rsi,%rbp,8),%xmm0
addsd  (%rbx,%rbp,8),%xmm0
movsd  %xmm0,(%rbx,%rbp,8)
movsd  0x8(%rsi,%rbp,8),%xmm0
addsd  0x8(%rbx,%rbp,8),%xmm0
movsd  %xmm0,0x8(%rbx,%rbp,8)
movsd  0x10(%rsi,%rbp,8),%xmm0
addsd  0x10(%rbx,%rbp,8),%xmm0
movsd  %xmm0,0x10(%rbx,%rbp,8)
movsd  0x18(%rsi,%rbp,8),%xmm0
addsd  0x18(%rbx,%rbp,8),%xmm0
movsd  %xmm0,0x18(%rbx,%rbp,8)
add    $0x4,%rbp
cmp    %rbp,%rcx
jne    1200 <mean+0xe0>
jmp    1190 <mean+0x70>
cmpq   $0x0,0x10(%rsp)
je     130f <mean+0x1ef>
mov    0x8(%rsp),%r9
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
movupd (%rsi,%rbp,8),%xmm0
movupd 0x10(%rsi,%rbp,8),%xmm1
movupd (%rbx,%rbp,8),%xmm2
addpd  %xmm0,%xmm2
movupd 0x10(%rbx,%rbp,8),%xmm0
addpd  %xmm1,%xmm0
movupd 0x20(%rbx,%rbp,8),%xmm1
movupd 0x30(%rbx,%rbp,8),%xmm3
movupd %xmm2,(%rbx,%rbp,8)
movupd %xmm0,0x10(%rbx,%rbp,8)
movupd 0x20(%rsi,%rbp,8),%xmm0
addpd  %xmm1,%xmm0
movupd 0x30(%rsi,%rbp,8),%xmm1
addpd  %xmm3,%xmm1
movupd %xmm0,0x20(%rbx,%rbp,8)
movupd %xmm1,0x30(%rbx,%rbp,8)
add    $0x8,%rbp
add    $0xfffffffffffffffe,%r9
jne    1270 <mean+0x150>
test   $0x1,%r11b
je     12fe <mean+0x1de>
movupd (%rsi,%rbp,8),%xmm0
movupd 0x10(%rsi,%rbp,8),%xmm1
movupd (%rbx,%rbp,8),%xmm2
addpd  %xmm0,%xmm2
movupd 0x10(%rbx,%rbp,8),%xmm0
addpd  %xmm1,%xmm0
movupd %xmm2,(%rbx,%rbp,8)
movupd %xmm0,0x10(%rbx,%rbp,8)
mov    %r12,%rbp
cmp    %rcx,%r12
je     1190 <mean+0x70>
jmp    11c5 <mean+0xa5>
xor    %ebp,%ebp
test   $0x1,%r11b
jne    12d5 <mean+0x1b5>
jmp    12fe <mean+0x1de>
xorps  %xmm0,%xmm0
cvtsi2sdl 0x4(%rsp),%xmm0
movsd  0xcd6(%rip),%xmm1
divsd  %xmm0,%xmm1
cvttsd2si %xmm1,%edx
mov    %rbx,%rdi
mov    %rbx,%rsi
mov    %r14d,%ecx
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <mult@plt>

LLVM IR (-O0):
define void @mean(double* %0, double** %1, i32 %2, i32 %3) {
%5 = alloca double*
%6 = alloca double**
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store double* %0, double** %5
store double** %1, double*** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%11 = load double*, double** %5
%12 = load i32, i32* %8
%13 = sext i32 %12 to i64
%14 = mul i64 %13, 8
%15 = trunc i64 %14 to i32
%16 = call i32 @memset(double* %11, i32 0, i32 %15)
store i32 0, i32* %9
br label %17
17: ; preds = %46, %4
%18 = load i32, i32* %9
%19 = load i32, i32* %7
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %49
21: ; preds = %17
store i32 0, i32* %10
br label %22
22: ; preds = %42, %21
%23 = load i32, i32* %10
%24 = load i32, i32* %8
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %45
26: ; preds = %22
%27 = load double**, double*** %6
%28 = load i32, i32* %9
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds double*, double** %27, i64 %29
%31 = load double*, double** %30
%32 = load i32, i32* %10
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds double, double* %31, i64 %33
%35 = load double, double* %34
%36 = load double*, double** %5
%37 = load i32, i32* %10
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds double, double* %36, i64 %38
%40 = load double, double* %39
%41 = fadd double %40, %35
store double %41, double* %39
br label %42
42: ; preds = %26
%43 = load i32, i32* %10
%44 = add nsw i32 %43, 1
store i32 %44, i32* %10
br label %22
45: ; preds = %22
br label %46
46: ; preds = %45
%47 = load i32, i32* %9
%48 = add nsw i32 %47, 1
store i32 %48, i32* %9
br label %17
49: ; preds = %17
%50 = load double*, double** %5
%51 = load double*, double** %5
%52 = load i32, i32* %7
%53 = sitofp i32 %52 to double
%54 = fdiv double 1.000000e+00, %53
%55 = fptosi double %54 to i32
%56 = load i32, i32* %8
%57 = call i32 @mult(double* %50, double* %51, i32 %55, i32 %56)
ret void
}

LLVM IR (-O2):
define void @mean(double* %0, double** nocapture %1, i32 %2, i32 %3) {
%5 = shl i32 %3, 3
%6 = tail call i32 @memset(double* %0, i32 0, i32 %5)
%7 = icmp sgt i32 %2, 0
br i1 %7, label %8, label %144
8: ; preds = %4
%9 = icmp sgt i32 %3, 0
%10 = zext i32 %2 to i64
%11 = zext i32 %3 to i64
%12 = getelementptr double, double* %0, i64 %11
%13 = and i64 %11, 4294967292
%14 = add nsw i64 %13, -4
%15 = lshr exact i64 %14, 2
%16 = add nuw nsw i64 %15, 1
%17 = icmp ult i32 %3, 4
%18 = and i64 %11, 4294967292
%19 = and i64 %16, 1
%20 = icmp eq i64 %14, 0
%21 = and i64 %16, 9223372036854775806
%22 = icmp eq i64 %19, 0
%23 = icmp eq i64 %18, %11
%24 = and i64 %11, 3
%25 = icmp eq i64 %24, 0
br label %26
26: ; preds = %8, %141
%27 = phi i64 [ 0, %8 ], [ %142, %141 ]
br i1 %9, label %28, label %141
28: ; preds = %26
%29 = getelementptr inbounds double*, double** %1, i64 %27
%30 = load double*, double** %29
br i1 %17, label %96, label %31
31: ; preds = %28
%32 = getelementptr double, double* %30, i64 %11
%33 = icmp ugt double* %32, %0
%34 = icmp ult double* %30, %12
%35 = and i1 %33, %34
br i1 %35, label %96, label %36
36: ; preds = %31
br i1 %20, label %76, label %37
37: ; preds = %36, %37
%38 = phi i64 [ %73, %37 ], [ 0, %36 ]
%39 = phi i64 [ %74, %37 ], [ 0, %36 ]
%40 = getelementptr inbounds double, double* %30, i64 %38
%41 = bitcast double* %40 to <2 x double>*
%42 = load <2 x double>, <2 x double>* %41
%43 = getelementptr inbounds double, double* %40, i64 2
%44 = bitcast double* %43 to <2 x double>*
%45 = load <2 x double>, <2 x double>* %44
%46 = getelementptr inbounds double, double* %0, i64 %38
%47 = bitcast double* %46 to <2 x double>*
%48 = load <2 x double>, <2 x double>* %47
%49 = getelementptr inbounds double, double* %46, i64 2
%50 = bitcast double* %49 to <2 x double>*
%51 = load <2 x double>, <2 x double>* %50
%52 = fadd <2 x double> %42, %48
%53 = fadd <2 x double> %45, %51
%54 = bitcast double* %46 to <2 x double>*
store <2 x double> %52, <2 x double>* %54
%55 = bitcast double* %49 to <2 x double>*
store <2 x double> %53, <2 x double>* %55
%56 = or i64 %38, 4
%57 = getelementptr inbounds double, double* %30, i64 %56
%58 = bitcast double* %57 to <2 x double>*
%59 = load <2 x double>, <2 x double>* %58
%60 = getelementptr inbounds double, double* %57, i64 2
%61 = bitcast double* %60 to <2 x double>*
%62 = load <2 x double>, <2 x double>* %61
%63 = getelementptr inbounds double, double* %0, i64 %56
%64 = bitcast double* %63 to <2 x double>*
%65 = load <2 x double>, <2 x double>* %64
%66 = getelementptr inbounds double, double* %63, i64 2
%67 = bitcast double* %66 to <2 x double>*
%68 = load <2 x double>, <2 x double>* %67
%69 = fadd <2 x double> %59, %65
%70 = fadd <2 x double> %62, %68
%71 = bitcast double* %63 to <2 x double>*
store <2 x double> %69, <2 x double>* %71
%72 = bitcast double* %66 to <2 x double>*
store <2 x double> %70, <2 x double>* %72
%73 = add nuw i64 %38, 8
%74 = add i64 %39, 2
%75 = icmp eq i64 %74, %21
br i1 %75, label %76, label %37
76: ; preds = %37, %36
%77 = phi i64 [ 0, %36 ], [ %73, %37 ]
br i1 %22, label %95, label %78
78: ; preds = %76
%79 = getelementptr inbounds double, double* %30, i64 %77
%80 = bitcast double* %79 to <2 x double>*
%81 = load <2 x double>, <2 x double>* %80
%82 = getelementptr inbounds double, double* %79, i64 2
%83 = bitcast double* %82 to <2 x double>*
%84 = load <2 x double>, <2 x double>* %83
%85 = getelementptr inbounds double, double* %0, i64 %77
%86 = bitcast double* %85 to <2 x double>*
%87 = load <2 x double>, <2 x double>* %86
%88 = getelementptr inbounds double, double* %85, i64 2
%89 = bitcast double* %88 to <2 x double>*
%90 = load <2 x double>, <2 x double>* %89
%91 = fadd <2 x double> %81, %87
%92 = fadd <2 x double> %84, %90
%93 = bitcast double* %85 to <2 x double>*
store <2 x double> %91, <2 x double>* %93
%94 = bitcast double* %88 to <2 x double>*
store <2 x double> %92, <2 x double>* %94
br label %95
95: ; preds = %76, %78
br i1 %23, label %141, label %96
96: ; preds = %31, %28, %95
%97 = phi i64 [ 0, %31 ], [ 0, %28 ], [ %18, %95 ]
%98 = xor i64 %97, -1
%99 = add nsw i64 %98, %11
br i1 %25, label %111, label %100
100: ; preds = %96, %100
%101 = phi i64 [ %108, %100 ], [ %97, %96 ]
%102 = phi i64 [ %109, %100 ], [ 0, %96 ]
%103 = getelementptr inbounds double, double* %30, i64 %101
%104 = load double, double* %103
%105 = getelementptr inbounds double, double* %0, i64 %101
%106 = load double, double* %105
%107 = fadd double %104, %106
store double %107, double* %105
%108 = add nuw nsw i64 %101, 1
%109 = add i64 %102, 1
%110 = icmp eq i64 %109, %24
br i1 %110, label %111, label %100
111: ; preds = %100, %96
%112 = phi i64 [ %97, %96 ], [ %108, %100 ]
%113 = icmp ult i64 %99, 3
br i1 %113, label %141, label %114
114: ; preds = %111, %114
%115 = phi i64 [ %139, %114 ], [ %112, %111 ]
%116 = getelementptr inbounds double, double* %30, i64 %115
%117 = load double, double* %116
%118 = getelementptr inbounds double, double* %0, i64 %115
%119 = load double, double* %118
%120 = fadd double %117, %119
store double %120, double* %118
%121 = add nuw nsw i64 %115, 1
%122 = getelementptr inbounds double, double* %30, i64 %121
%123 = load double, double* %122
%124 = getelementptr inbounds double, double* %0, i64 %121
%125 = load double, double* %124
%126 = fadd double %123, %125
store double %126, double* %124
%127 = add nuw nsw i64 %115, 2
%128 = getelementptr inbounds double, double* %30, i64 %127
%129 = load double, double* %128
%130 = getelementptr inbounds double, double* %0, i64 %127
%131 = load double, double* %130
%132 = fadd double %129, %131
store double %132, double* %130
%133 = add nuw nsw i64 %115, 3
%134 = getelementptr inbounds double, double* %30, i64 %133
%135 = load double, double* %134
%136 = getelementptr inbounds double, double* %0, i64 %133
%137 = load double, double* %136
%138 = fadd double %135, %137
store double %138, double* %136
%139 = add nuw nsw i64 %115, 4
%140 = icmp eq i64 %139, %11
br i1 %140, label %141, label %114
141: ; preds = %111, %114, %95, %26
%142 = add nuw nsw i64 %27, 1
%143 = icmp eq i64 %142, %10
br i1 %143, label %144, label %26
144: ; preds = %141, %4
%145 = sitofp i32 %2 to double
%146 = fdiv double 1.000000e+00, %145
%147 = fptosi double %146 to i32
%148 = tail call i32 @mult(double* %0, double* %0, i32 %147, i32 %3)
ret void
}