#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*/ clean(double *, int);
int /*<<< orphan*/ maxCol(double **, double *, int, int);
void sigmaArray(double A[1000][1000], double sigma[1000], int n, int m) {
  double max[1000];
  int i, j;
  clean(sigma, m);
  clean(max, m);
  maxCol(A, max, n, m);
  for (i = 0; i < n; i++)
    for (j = 0; j < m; j++)
      sigma[j] += ((A[i][j] / max[j]) * (A[i][j] / max[j]));
}


x86 assembly (clang, -O0):
<sigmaArray>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1f70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%esi
call   1030 <clean@plt>
lea    -0x1f60(%rbp),%rdi
mov    -0x18(%rbp),%esi
call   1030 <clean@plt>
mov    -0x8(%rbp),%rdi
lea    -0x1f60(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
call   1040 <maxCol@plt>
movl   $0x0,-0x1f64(%rbp)
mov    -0x1f64(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1248 <sigmaArray+0x128>
movl   $0x0,-0x1f68(%rbp)
mov    -0x1f68(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    122f <sigmaArray+0x10f>
mov    -0x8(%rbp),%rax
movslq -0x1f64(%rbp),%rcx
imul   $0x1f40,%rcx,%rcx
add    %rcx,%rax
movslq -0x1f68(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movslq -0x1f68(%rbp),%rax
divsd  -0x1f60(%rbp,%rax,8),%xmm0
ff ff
mov    -0x8(%rbp),%rax
movslq -0x1f64(%rbp),%rcx
imul   $0x1f40,%rcx,%rcx
add    %rcx,%rax
movslq -0x1f68(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
movslq -0x1f68(%rbp),%rax
divsd  -0x1f60(%rbp,%rax,8),%xmm2
ff ff
mov    -0x10(%rbp),%rax
movslq -0x1f68(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x1f68(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1f68(%rbp)
jmp    118d <sigmaArray+0x6d>
jmp    1234 <sigmaArray+0x114>
mov    -0x1f64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1f64(%rbp)
jmp    1174 <sigmaArray+0x54>
add    $0x1f70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sigmaArray>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1f68,%rsp
mov    %ecx,%r12d
mov    %edx,%r15d
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsi,%rdi
mov    %ecx,%esi
call   1030 <clean@plt>
lea    0x20(%rsp),%rbp
mov    %rbp,%rdi
mov    %r12d,%esi
call   1030 <clean@plt>
mov    %r14,%rdi
mov    %rbp,%rsi
mov    %r15d,%edx
mov    %r12d,%ecx
call   1040 <maxCol@plt>
test   %r15d,%r15d
jle    1332 <sigmaArray+0x212>
mov    %r15d,%r13d
mov    %r12d,%ecx
lea    (%rbx,%rcx,8),%rax
mov    %rax,0x18(%rsp)
mov    %ecx,%r15d
and    $0xfffffffe,%r15d
lea    -0x2(%r15),%r11
mov    %r11,0x10(%rsp)
shr    %r11
add    $0x1,%r11
mov    %r11,%rax
and    $0xfffffffffffffffe,%rax
mov    %rax,0x8(%rsp)
mov    %rcx,%r8
neg    %r8
lea    0x10(%r14),%rdi
lea    0x8(%r14),%rsi
xor    %edx,%edx
jmp    11db <sigmaArray+0xbb>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%rdx
add    $0x1f40,%rdi
add    $0x1f40,%rsi
cmp    %r13,%rdx
je     1332 <sigmaArray+0x212>
test   %r12d,%r12d
jle    11c0 <sigmaArray+0xa0>
imul   $0x1f40,%rdx,%r10
add    %r14,%r10
cmp    $0x1,%r12d
je     1208 <sigmaArray+0xe8>
lea    (%r10,%rcx,8),%rax
cmp    %rbx,%rax
jbe    1283 <sigmaArray+0x163>
cmp    0x18(%rsp),%r10
jae    1283 <sigmaArray+0x163>
xor    %eax,%eax
mov    %rax,%rbp
test   $0x1,%cl
je     1233 <sigmaArray+0x113>
movsd  (%r10,%rax,8),%xmm0
divsd  0x20(%rsp,%rax,8),%xmm0
mulsd  %xmm0,%xmm0
addsd  (%rbx,%rax,8),%xmm0
movsd  %xmm0,(%rbx,%rax,8)
mov    %rax,%rbp
or     $0x1,%rbp
not    %rax
cmp    %r8,%rax
je     11c0 <sigmaArray+0xa0>
nopl   0x0(%rax,%rax,1)
movsd  -0x8(%rsi,%rbp,8),%xmm0
divsd  0x20(%rsp,%rbp,8),%xmm0
mulsd  %xmm0,%xmm0
addsd  (%rbx,%rbp,8),%xmm0
movsd  %xmm0,(%rbx,%rbp,8)
movsd  (%rsi,%rbp,8),%xmm0
divsd  0x28(%rsp,%rbp,8),%xmm0
mulsd  %xmm0,%xmm0
addsd  0x8(%rbx,%rbp,8),%xmm0
movsd  %xmm0,0x8(%rbx,%rbp,8)
add    $0x2,%rbp
cmp    %rbp,%rcx
jne    1240 <sigmaArray+0x120>
jmp    11c0 <sigmaArray+0xa0>
cmpq   $0x0,0x10(%rsp)
je     1327 <sigmaArray+0x207>
mov    0x8(%rsp),%rbp
xor    %r9d,%r9d
nopw   0x0(%rax,%rax,1)
movupd -0x10(%rdi,%r9,8),%xmm0
divpd  0x20(%rsp,%r9,8),%xmm0
mulpd  %xmm0,%xmm0
movupd (%rbx,%r9,8),%xmm1
addpd  %xmm0,%xmm1
movupd 0x10(%rbx,%r9,8),%xmm0
movupd %xmm1,(%rbx,%r9,8)
movupd (%rdi,%r9,8),%xmm1
divpd  0x30(%rsp,%r9,8),%xmm1
mulpd  %xmm1,%xmm1
addpd  %xmm0,%xmm1
movupd %xmm1,0x10(%rbx,%r9,8)
add    $0x4,%r9
add    $0xfffffffffffffffe,%rbp
jne    12a0 <sigmaArray+0x180>
test   $0x1,%r11b
je     1316 <sigmaArray+0x1f6>
movupd (%r10,%r9,8),%xmm0
divpd  0x20(%rsp,%r9,8),%xmm0
movupd (%rbx,%r9,8),%xmm1
mulpd  %xmm0,%xmm0
addpd  %xmm1,%xmm0
movupd %xmm0,(%rbx,%r9,8)
mov    %r15,%rax
cmp    %rcx,%r15
je     11c0 <sigmaArray+0xa0>
jmp    120a <sigmaArray+0xea>
xor    %r9d,%r9d
test   $0x1,%r11b
jne    12f5 <sigmaArray+0x1d5>
jmp    1316 <sigmaArray+0x1f6>
add    $0x1f68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @sigmaArray([1000 x double]* %0, double* %1, i32 %2, i32 %3) {
%5 = alloca [1000 x double]*
%6 = alloca double*
%7 = alloca i32
%8 = alloca i32
%9 = alloca [1000 x double]
%10 = alloca i32
%11 = alloca i32
store [1000 x double]* %0, [1000 x double]** %5
store double* %1, double** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%12 = load double*, double** %6
%13 = load i32, i32* %8
%14 = call i32 @clean(double* %12, i32 %13)
%15 = getelementptr inbounds [1000 x double], [1000 x double]* %9, i64 0, i64 0
%16 = load i32, i32* %8
%17 = call i32 @clean(double* %15, i32 %16)
%18 = load [1000 x double]*, [1000 x double]** %5
%19 = bitcast [1000 x double]* %18 to double**
%20 = getelementptr inbounds [1000 x double], [1000 x double]* %9, i64 0, i64 0
%21 = load i32, i32* %7
%22 = load i32, i32* %8
%23 = call i32 @maxCol(double** %19, double* %20, i32 %21, i32 %22)
store i32 0, i32* %10
br label %24
24: ; preds = %70, %4
%25 = load i32, i32* %10
%26 = load i32, i32* %7
%27 = icmp slt i32 %25, %26
br i1 %27, label %28, label %73
28: ; preds = %24
store i32 0, i32* %11
br label %29
29: ; preds = %66, %28
%30 = load i32, i32* %11
%31 = load i32, i32* %8
%32 = icmp slt i32 %30, %31
br i1 %32, label %33, label %69
33: ; preds = %29
%34 = load [1000 x double]*, [1000 x double]** %5
%35 = load i32, i32* %10
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [1000 x double], [1000 x double]* %34, i64 %36
%38 = load i32, i32* %11
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds [1000 x double], [1000 x double]* %37, i64 0, i64 %39
%41 = load double, double* %40
%42 = load i32, i32* %11
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [1000 x double], [1000 x double]* %9, i64 0, i64 %43
%45 = load double, double* %44
%46 = fdiv double %41, %45
%47 = load [1000 x double]*, [1000 x double]** %5
%48 = load i32, i32* %10
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds [1000 x double], [1000 x double]* %47, i64 %49
%51 = load i32, i32* %11
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds [1000 x double], [1000 x double]* %50, i64 0, i64 %52
%54 = load double, double* %53
%55 = load i32, i32* %11
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds [1000 x double], [1000 x double]* %9, i64 0, i64 %56
%58 = load double, double* %57
%59 = fdiv double %54, %58
%60 = load double*, double** %6
%61 = load i32, i32* %11
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds double, double* %60, i64 %62
%64 = load double, double* %63
%65 = call double @llvm.fmuladd.f64(double %46, double %59, double %64)
store double %65, double* %63
br label %66
66: ; preds = %33
%67 = load i32, i32* %11
%68 = add nsw i32 %67, 1
store i32 %68, i32* %11
br label %29
69: ; preds = %29
br label %70
70: ; preds = %69
%71 = load i32, i32* %10
%72 = add nsw i32 %71, 1
store i32 %72, i32* %10
br label %24
73: ; preds = %24
ret void
}

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