#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*/ fillz(double *, int, int const);
void vaverage(double *x, const int l, const int num, double *ave) {
  int i, j;
  fillz(ave, sizeof(*ave), l);
  for (i = 0; i < num; i++)
    for (j = 0; j < l; j++)
      ave[j] += *x++;
  for (j = 0; j < l; j++)
    ave[j] /= (double)num;
  return;
}


x86 assembly (clang, -O0):
<vaverage>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0xc(%rbp),%edx
mov    $0x8,%esi
call   1030 <fillz@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11a3 <vaverage+0x93>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1190 <vaverage+0x80>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x8(%rbp)
movsd  (%rax),%xmm0
mov    -0x18(%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    1151 <vaverage+0x41>
jmp    1195 <vaverage+0x85>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    113e <vaverage+0x2e>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11df <vaverage+0xcf>
cvtsi2sdl -0x10(%rbp),%xmm1
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11aa <vaverage+0x9a>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vaverage>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%rbx
mov    %edx,%r14d
mov    %esi,%r15d
mov    %rdi,%rbp
mov    %rcx,%rdi
mov    $0x8,%esi
mov    %r15d,%edx
call   1030 <fillz@plt>
mov    %r15d,%eax
test   %r14d,%r14d
jle    1310 <vaverage+0x200>
lea    (%rbx,%rax,8),%r10
mov    %eax,%r12d
and    $0xfffffffc,%r12d
lea    -0x4(%r12),%r9
mov    %r9,%r11
shr    $0x2,%r11
add    $0x1,%r11
mov    %r11,%r8
and    $0xfffffffffffffffe,%r8
mov    %eax,%r13d
and    $0x3,%r13d
xor    %ecx,%ecx
jmp    117c <vaverage+0x6c>
add    $0x1,%ecx
cmp    %r14d,%ecx
je     1310 <vaverage+0x200>
test   %r15d,%r15d
jle    1170 <vaverage+0x60>
cmp    $0x4,%r15d
jb     11a4 <vaverage+0x94>
lea    0x0(,%rax,8),%rdx
add    %rbp,%rdx
cmp    %rbx,%rdx
jbe    1244 <vaverage+0x134>
cmp    %r10,%rbp
jae    1244 <vaverage+0x134>
xor    %edx,%edx
mov    %rdx,%rdi
not    %rdi
add    %rax,%rdi
test   %r13,%r13
je     11dd <vaverage+0xcd>
mov    %r13,%rsi
nopw   0x0(%rax,%rax,1)
movsd  0x0(%rbp),%xmm0
addsd  (%rbx,%rdx,8),%xmm0
add    $0x8,%rbp
movsd  %xmm0,(%rbx,%rdx,8)
add    $0x1,%rdx
add    $0xffffffffffffffff,%rsi
jne    11c0 <vaverage+0xb0>
cmp    $0x3,%rdi
jb     1170 <vaverage+0x60>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsd  0x0(%rbp),%xmm0
addsd  (%rbx,%rdx,8),%xmm0
movsd  %xmm0,(%rbx,%rdx,8)
movsd  0x8(%rbp),%xmm0
addsd  0x8(%rbx,%rdx,8),%xmm0
movsd  %xmm0,0x8(%rbx,%rdx,8)
movsd  0x10(%rbp),%xmm0
addsd  0x10(%rbx,%rdx,8),%xmm0
movsd  %xmm0,0x10(%rbx,%rdx,8)
movsd  0x18(%rbp),%xmm0
addsd  0x18(%rbx,%rdx,8),%xmm0
add    $0x20,%rbp
movsd  %xmm0,0x18(%rbx,%rdx,8)
add    $0x4,%rdx
cmp    %rdx,%rax
jne    11f0 <vaverage+0xe0>
jmp    1170 <vaverage+0x60>
test   %r9,%r9
je     1306 <vaverage+0x1f6>
mov    %r8,%rdi
xor    %edx,%edx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movupd 0x0(%rbp,%rdx,8),%xmm0
movupd 0x10(%rbp,%rdx,8),%xmm1
movupd (%rbx,%rdx,8),%xmm2
addpd  %xmm0,%xmm2
movupd 0x10(%rbx,%rdx,8),%xmm0
addpd  %xmm1,%xmm0
movupd 0x20(%rbx,%rdx,8),%xmm1
movupd 0x30(%rbx,%rdx,8),%xmm3
movupd %xmm2,(%rbx,%rdx,8)
movupd %xmm0,0x10(%rbx,%rdx,8)
movupd 0x20(%rbp,%rdx,8),%xmm0
addpd  %xmm1,%xmm0
movupd 0x30(%rbp,%rdx,8),%xmm1
addpd  %xmm3,%xmm1
movupd %xmm0,0x20(%rbx,%rdx,8)
movupd %xmm1,0x30(%rbx,%rdx,8)
add    $0x8,%rdx
add    $0xfffffffffffffffe,%rdi
jne    1260 <vaverage+0x150>
test   $0x1,%r11b
je     12f0 <vaverage+0x1e0>
movupd 0x0(%rbp,%rdx,8),%xmm0
movupd 0x10(%rbp,%rdx,8),%xmm1
movupd (%rbx,%rdx,8),%xmm2
addpd  %xmm0,%xmm2
movupd 0x10(%rbx,%rdx,8),%xmm0
addpd  %xmm1,%xmm0
movupd %xmm2,(%rbx,%rdx,8)
movupd %xmm0,0x10(%rbx,%rdx,8)
lea    0x0(%rbp,%r12,8),%rbp
mov    %r12,%rdx
cmp    %rax,%r12
je     1170 <vaverage+0x60>
jmp    11a6 <vaverage+0x96>
xor    %edx,%edx
test   $0x1,%r11b
jne    12c6 <vaverage+0x1b6>
jmp    12f0 <vaverage+0x1e0>
test   %r15d,%r15d
jle    13b7 <vaverage+0x2a7>
xorps  %xmm0,%xmm0
cvtsi2sd %r14d,%xmm0
cmp    $0x1,%r15d
jne    132b <vaverage+0x21b>
xor    %ecx,%ecx
jmp    13a0 <vaverage+0x290>
mov    %eax,%ecx
and    $0xfffffffe,%ecx
movapd %xmm0,%xmm1
unpcklpd %xmm0,%xmm1
lea    -0x2(%rcx),%rsi
mov    %rsi,%rdx
shr    %rdx
add    $0x1,%rdx
test   %rsi,%rsi
je     13c6 <vaverage+0x2b6>
mov    %rdx,%rdi
and    $0xfffffffffffffffe,%rdi
xor    %esi,%esi
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movupd (%rbx,%rsi,8),%xmm2
movupd 0x10(%rbx,%rsi,8),%xmm3
divpd  %xmm1,%xmm2
movupd %xmm2,(%rbx,%rsi,8)
divpd  %xmm1,%xmm3
movupd %xmm3,0x10(%rbx,%rsi,8)
add    $0x4,%rsi
add    $0xfffffffffffffffe,%rdi
jne    1360 <vaverage+0x250>
test   $0x1,%dl
je     139b <vaverage+0x28b>
movupd (%rbx,%rsi,8),%xmm2
divpd  %xmm1,%xmm2
movupd %xmm2,(%rbx,%rsi,8)
cmp    %rax,%rcx
je     13b7 <vaverage+0x2a7>
movsd  (%rbx,%rcx,8),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,(%rbx,%rcx,8)
add    $0x1,%rcx
cmp    %rcx,%rax
jne    13a0 <vaverage+0x290>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %esi,%esi
test   $0x1,%dl
jne    138d <vaverage+0x27d>
jmp    139b <vaverage+0x28b>

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

LLVM IR (-O2):
define void @vaverage(double* nocapture %0, i32 %1, i32 %2, double* %3) {
%5 = tail call i32 @fillz(double* %3, i32 8, i32 %1)
%6 = icmp sgt i32 %2, 0
br i1 %6, label %7, label %116
7: ; preds = %4
%8 = icmp sgt i32 %1, 0
%9 = zext i32 %1 to i64
%10 = getelementptr double, double* %3, i64 %9
%11 = and i64 %9, 4294967292
%12 = add nsw i64 %11, -4
%13 = lshr exact i64 %12, 2
%14 = add nuw nsw i64 %13, 1
%15 = icmp ult i32 %1, 4
%16 = and i64 %9, 4294967292
%17 = and i64 %14, 1
%18 = icmp eq i64 %12, 0
%19 = and i64 %14, 9223372036854775806
%20 = icmp eq i64 %17, 0
%21 = icmp eq i64 %16, %9
%22 = and i64 %9, 3
%23 = icmp eq i64 %22, 0
br label %24
24: ; preds = %7, %191
%25 = phi i32 [ 0, %7 ], [ %193, %191 ]
%26 = phi double* [ %0, %7 ], [ %192, %191 ]
br i1 %8, label %27, label %191
27: ; preds = %24
br i1 %15, label %94, label %28
28: ; preds = %27
%29 = getelementptr double, double* %26, i64 %9
%30 = icmp ugt double* %29, %3
%31 = icmp ult double* %26, %10
%32 = and i1 %30, %31
br i1 %32, label %94, label %33
33: ; preds = %28
%34 = getelementptr double, double* %26, i64 %16
br i1 %18, label %74, label %35
35: ; preds = %33, %35
%36 = phi i64 [ %71, %35 ], [ 0, %33 ]
%37 = phi i64 [ %72, %35 ], [ 0, %33 ]
%38 = getelementptr double, double* %26, i64 %36
%39 = bitcast double* %38 to <2 x double>*
%40 = load <2 x double>, <2 x double>* %39
%41 = getelementptr double, double* %38, i64 2
%42 = bitcast double* %41 to <2 x double>*
%43 = load <2 x double>, <2 x double>* %42
%44 = getelementptr inbounds double, double* %3, i64 %36
%45 = bitcast double* %44 to <2 x double>*
%46 = load <2 x double>, <2 x double>* %45
%47 = getelementptr inbounds double, double* %44, i64 2
%48 = bitcast double* %47 to <2 x double>*
%49 = load <2 x double>, <2 x double>* %48
%50 = fadd <2 x double> %40, %46
%51 = fadd <2 x double> %43, %49
%52 = bitcast double* %44 to <2 x double>*
store <2 x double> %50, <2 x double>* %52
%53 = bitcast double* %47 to <2 x double>*
store <2 x double> %51, <2 x double>* %53
%54 = or i64 %36, 4
%55 = getelementptr double, double* %26, i64 %54
%56 = bitcast double* %55 to <2 x double>*
%57 = load <2 x double>, <2 x double>* %56
%58 = getelementptr double, double* %55, i64 2
%59 = bitcast double* %58 to <2 x double>*
%60 = load <2 x double>, <2 x double>* %59
%61 = getelementptr inbounds double, double* %3, i64 %54
%62 = bitcast double* %61 to <2 x double>*
%63 = load <2 x double>, <2 x double>* %62
%64 = getelementptr inbounds double, double* %61, i64 2
%65 = bitcast double* %64 to <2 x double>*
%66 = load <2 x double>, <2 x double>* %65
%67 = fadd <2 x double> %57, %63
%68 = fadd <2 x double> %60, %66
%69 = bitcast double* %61 to <2 x double>*
store <2 x double> %67, <2 x double>* %69
%70 = bitcast double* %64 to <2 x double>*
store <2 x double> %68, <2 x double>* %70
%71 = add nuw i64 %36, 8
%72 = add i64 %37, 2
%73 = icmp eq i64 %72, %19
br i1 %73, label %74, label %35
74: ; preds = %35, %33
%75 = phi i64 [ 0, %33 ], [ %71, %35 ]
br i1 %20, label %93, label %76
76: ; preds = %74
%77 = getelementptr double, double* %26, i64 %75
%78 = bitcast double* %77 to <2 x double>*
%79 = load <2 x double>, <2 x double>* %78
%80 = getelementptr double, double* %77, i64 2
%81 = bitcast double* %80 to <2 x double>*
%82 = load <2 x double>, <2 x double>* %81
%83 = getelementptr inbounds double, double* %3, i64 %75
%84 = bitcast double* %83 to <2 x double>*
%85 = load <2 x double>, <2 x double>* %84
%86 = getelementptr inbounds double, double* %83, i64 2
%87 = bitcast double* %86 to <2 x double>*
%88 = load <2 x double>, <2 x double>* %87
%89 = fadd <2 x double> %79, %85
%90 = fadd <2 x double> %82, %88
%91 = bitcast double* %83 to <2 x double>*
store <2 x double> %89, <2 x double>* %91
%92 = bitcast double* %86 to <2 x double>*
store <2 x double> %90, <2 x double>* %92
br label %93
93: ; preds = %74, %76
br i1 %21, label %191, label %94
94: ; preds = %28, %27, %93
%95 = phi i64 [ 0, %28 ], [ 0, %27 ], [ %16, %93 ]
%96 = phi double* [ %26, %28 ], [ %26, %27 ], [ %34, %93 ]
%97 = xor i64 %95, -1
%98 = add nsw i64 %97, %9
br i1 %23, label %111, label %99
99: ; preds = %94, %99
%100 = phi i64 [ %108, %99 ], [ %95, %94 ]
%101 = phi double* [ %103, %99 ], [ %96, %94 ]
%102 = phi i64 [ %109, %99 ], [ 0, %94 ]
%103 = getelementptr inbounds double, double* %101, i64 1
%104 = load double, double* %101
%105 = getelementptr inbounds double, double* %3, i64 %100
%106 = load double, double* %105
%107 = fadd double %104, %106
store double %107, double* %105
%108 = add nuw nsw i64 %100, 1
%109 = add i64 %102, 1
%110 = icmp eq i64 %109, %22
br i1 %110, label %111, label %99
111: ; preds = %99, %94
%112 = phi double* [ undef, %94 ], [ %103, %99 ]
%113 = phi i64 [ %95, %94 ], [ %108, %99 ]
%114 = phi double* [ %96, %94 ], [ %103, %99 ]
%115 = icmp ult i64 %98, 3
br i1 %115, label %191, label %163
116: ; preds = %191, %4
%117 = icmp sgt i32 %1, 0
br i1 %117, label %118, label %202
118: ; preds = %116
%119 = sitofp i32 %2 to double
%120 = zext i32 %1 to i64
%121 = icmp eq i32 %1, 1
br i1 %121, label %161, label %122
122: ; preds = %118
%123 = and i64 %120, 4294967294
%124 = insertelement <2 x double> poison, double %119, i64 0
%125 = shufflevector <2 x double> %124, <2 x double> poison, <2 x i32> zeroinitializer
%126 = add nsw i64 %123, -2
%127 = lshr exact i64 %126, 1
%128 = add nuw i64 %127, 1
%129 = and i64 %128, 1
%130 = icmp eq i64 %126, 0
br i1 %130, label %150, label %131
131: ; preds = %122
%132 = and i64 %128, -2
br label %133
133: ; preds = %133, %131
%134 = phi i64 [ 0, %131 ], [ %147, %133 ]
%135 = phi i64 [ 0, %131 ], [ %148, %133 ]
%136 = getelementptr inbounds double, double* %3, i64 %134
%137 = bitcast double* %136 to <2 x double>*
%138 = load <2 x double>, <2 x double>* %137
%139 = fdiv <2 x double> %138, %125
%140 = bitcast double* %136 to <2 x double>*
store <2 x double> %139, <2 x double>* %140
%141 = or i64 %134, 2
%142 = getelementptr inbounds double, double* %3, i64 %141
%143 = bitcast double* %142 to <2 x double>*
%144 = load <2 x double>, <2 x double>* %143
%145 = fdiv <2 x double> %144, %125
%146 = bitcast double* %142 to <2 x double>*
store <2 x double> %145, <2 x double>* %146
%147 = add nuw i64 %134, 4
%148 = add nuw i64 %135, 2
%149 = icmp eq i64 %148, %132
br i1 %149, label %150, label %133
150: ; preds = %133, %122
%151 = phi i64 [ 0, %122 ], [ %147, %133 ]
%152 = icmp eq i64 %129, 0
br i1 %152, label %159, label %153
153: ; preds = %150
%154 = getelementptr inbounds double, double* %3, i64 %151
%155 = bitcast double* %154 to <2 x double>*
%156 = load <2 x double>, <2 x double>* %155
%157 = fdiv <2 x double> %156, %125
%158 = bitcast double* %154 to <2 x double>*
store <2 x double> %157, <2 x double>* %158
br label %159
159: ; preds = %150, %153
%160 = icmp eq i64 %123, %120
br i1 %160, label %202, label %161
161: ; preds = %118, %159
%162 = phi i64 [ 0, %118 ], [ %123, %159 ]
br label %195
163: ; preds = %111, %163
%164 = phi i64 [ %189, %163 ], [ %113, %111 ]
%165 = phi double* [ %184, %163 ], [ %114, %111 ]
%166 = getelementptr inbounds double, double* %165, i64 1
%167 = load double, double* %165
%168 = getelementptr inbounds double, double* %3, i64 %164
%169 = load double, double* %168
%170 = fadd double %167, %169
store double %170, double* %168
%171 = add nuw nsw i64 %164, 1
%172 = getelementptr inbounds double, double* %165, i64 2
%173 = load double, double* %166
%174 = getelementptr inbounds double, double* %3, i64 %171
%175 = load double, double* %174
%176 = fadd double %173, %175
store double %176, double* %174
%177 = add nuw nsw i64 %164, 2
%178 = getelementptr inbounds double, double* %165, i64 3
%179 = load double, double* %172
%180 = getelementptr inbounds double, double* %3, i64 %177
%181 = load double, double* %180
%182 = fadd double %179, %181
store double %182, double* %180
%183 = add nuw nsw i64 %164, 3
%184 = getelementptr inbounds double, double* %165, i64 4
%185 = load double, double* %178
%186 = getelementptr inbounds double, double* %3, i64 %183
%187 = load double, double* %186
%188 = fadd double %185, %187
store double %188, double* %186
%189 = add nuw nsw i64 %164, 4
%190 = icmp eq i64 %189, %9
br i1 %190, label %191, label %163
191: ; preds = %111, %163, %93, %24
%192 = phi double* [ %26, %24 ], [ %34, %93 ], [ %112, %111 ], [ %184, %163 ]
%193 = add nuw nsw i32 %25, 1
%194 = icmp eq i32 %193, %2
br i1 %194, label %116, label %24
195: ; preds = %161, %195
%196 = phi i64 [ %200, %195 ], [ %162, %161 ]
%197 = getelementptr inbounds double, double* %3, i64 %196
%198 = load double, double* %197
%199 = fdiv double %198, %119
store double %199, double* %197
%200 = add nuw nsw i64 %196, 1
%201 = icmp eq i64 %200, %120
br i1 %201, label %202, label %195
202: ; preds = %195, %159, %116
ret void
}