double Normalize(double vecY[20], int counter) {
  int i;
  double unitY[20], *p;
  double maxVal = vecY[0];
  for (i = 1; i < 20; i++) {
    if (vecY[i] > maxVal) {
      maxVal = vecY[i];
    }
  }
  for (i = 0; i < 20; i++) {
    unitY[i] = vecY[i] / maxVal;
  }
  p = &unitY[counter];
  return p[0];
}


x86 assembly (clang, -O0):
<Normalize>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0xc0(%rbp)
ff
movl   $0x1,-0x10(%rbp)
cmpl   $0x14,-0x10(%rbp)
jge    1173 <Normalize+0x73>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
ucomisd -0xc0(%rbp),%xmm0
ff
jbe    1160 <Normalize+0x60>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0xc0(%rbp)
ff
jmp    1165 <Normalize+0x65>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1126 <Normalize+0x26>
movl   $0x0,-0x10(%rbp)
cmpl   $0x14,-0x10(%rbp)
jge    11b4 <Normalize+0xb4>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
divsd  -0xc0(%rbp),%xmm0
ff
movslq -0x10(%rbp),%rax
movsd  %xmm0,-0xb0(%rbp,%rax,8)
ff ff
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    117a <Normalize+0x7a>
movslq -0xc(%rbp),%rcx
lea    -0xb0(%rbp),%rax
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0xb8(%rbp)
mov    -0xb8(%rbp),%rax
movsd  (%rax),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Normalize>:
sub    $0x28,%rsp
movsd  (%rdi),%xmm0
movsd  0x8(%rdi),%xmm1
maxsd  %xmm0,%xmm1
movsd  0x10(%rdi),%xmm2
maxsd  %xmm1,%xmm2
movsd  0x18(%rdi),%xmm1
maxsd  %xmm2,%xmm1
movsd  0x20(%rdi),%xmm2
maxsd  %xmm1,%xmm2
movsd  0x28(%rdi),%xmm1
maxsd  %xmm2,%xmm1
movsd  0x30(%rdi),%xmm2
maxsd  %xmm1,%xmm2
movsd  0x38(%rdi),%xmm1
maxsd  %xmm2,%xmm1
movsd  0x40(%rdi),%xmm2
maxsd  %xmm1,%xmm2
movsd  0x48(%rdi),%xmm1
maxsd  %xmm2,%xmm1
movsd  0x50(%rdi),%xmm2
maxsd  %xmm1,%xmm2
movsd  0x58(%rdi),%xmm1
maxsd  %xmm2,%xmm1
movsd  0x60(%rdi),%xmm2
maxsd  %xmm1,%xmm2
movsd  0x68(%rdi),%xmm1
maxsd  %xmm2,%xmm1
movsd  0x70(%rdi),%xmm2
maxsd  %xmm1,%xmm2
movsd  0x78(%rdi),%xmm1
maxsd  %xmm2,%xmm1
movsd  0x80(%rdi),%xmm2
maxsd  %xmm1,%xmm2
movsd  0x88(%rdi),%xmm1
maxsd  %xmm2,%xmm1
movsd  0x90(%rdi),%xmm2
maxsd  %xmm1,%xmm2
movsd  0x98(%rdi),%xmm1
maxsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x80(%rsp)
movapd %xmm1,%xmm0
unpcklpd %xmm1,%xmm0
movupd 0x8(%rdi),%xmm2
divpd  %xmm0,%xmm2
movupd %xmm2,-0x78(%rsp)
movupd 0x18(%rdi),%xmm2
divpd  %xmm0,%xmm2
movupd %xmm2,-0x68(%rsp)
movupd 0x28(%rdi),%xmm2
divpd  %xmm0,%xmm2
movupd %xmm2,-0x58(%rsp)
movupd 0x38(%rdi),%xmm2
divpd  %xmm0,%xmm2
movupd %xmm2,-0x48(%rsp)
movupd 0x48(%rdi),%xmm2
divpd  %xmm0,%xmm2
movupd %xmm2,-0x38(%rsp)
movupd 0x58(%rdi),%xmm2
divpd  %xmm0,%xmm2
movupd %xmm2,-0x28(%rsp)
movupd 0x68(%rdi),%xmm2
divpd  %xmm0,%xmm2
movupd %xmm2,-0x18(%rsp)
movupd 0x78(%rdi),%xmm2
divpd  %xmm0,%xmm2
movupd %xmm2,-0x8(%rsp)
movupd 0x88(%rdi),%xmm2
divpd  %xmm0,%xmm2
movupd %xmm2,0x8(%rsp)
movsd  0x98(%rdi),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,0x18(%rsp)
movslq %esi,%rax
movsd  -0x80(%rsp,%rax,8),%xmm0
add    $0x28,%rsp
ret

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

LLVM IR (-O2):
define double @Normalize(double* nocapture %0, i32 %1) {
%3 = alloca [20 x double]
%4 = bitcast [20 x double]* %3 to i8*
%5 = load double, double* %0
%6 = getelementptr inbounds double, double* %0, i64 1
%7 = load double, double* %6
%8 = fcmp ogt double %7, %5
%9 = select i1 %8, double %7, double %5
%10 = getelementptr inbounds double, double* %0, i64 2
%11 = load double, double* %10
%12 = fcmp ogt double %11, %9
%13 = select i1 %12, double %11, double %9
%14 = getelementptr inbounds double, double* %0, i64 3
%15 = load double, double* %14
%16 = fcmp ogt double %15, %13
%17 = select i1 %16, double %15, double %13
%18 = getelementptr inbounds double, double* %0, i64 4
%19 = load double, double* %18
%20 = fcmp ogt double %19, %17
%21 = select i1 %20, double %19, double %17
%22 = getelementptr inbounds double, double* %0, i64 5
%23 = load double, double* %22
%24 = fcmp ogt double %23, %21
%25 = select i1 %24, double %23, double %21
%26 = getelementptr inbounds double, double* %0, i64 6
%27 = load double, double* %26
%28 = fcmp ogt double %27, %25
%29 = select i1 %28, double %27, double %25
%30 = getelementptr inbounds double, double* %0, i64 7
%31 = load double, double* %30
%32 = fcmp ogt double %31, %29
%33 = select i1 %32, double %31, double %29
%34 = getelementptr inbounds double, double* %0, i64 8
%35 = load double, double* %34
%36 = fcmp ogt double %35, %33
%37 = select i1 %36, double %35, double %33
%38 = getelementptr inbounds double, double* %0, i64 9
%39 = load double, double* %38
%40 = fcmp ogt double %39, %37
%41 = select i1 %40, double %39, double %37
%42 = getelementptr inbounds double, double* %0, i64 10
%43 = load double, double* %42
%44 = fcmp ogt double %43, %41
%45 = select i1 %44, double %43, double %41
%46 = getelementptr inbounds double, double* %0, i64 11
%47 = load double, double* %46
%48 = fcmp ogt double %47, %45
%49 = select i1 %48, double %47, double %45
%50 = getelementptr inbounds double, double* %0, i64 12
%51 = load double, double* %50
%52 = fcmp ogt double %51, %49
%53 = select i1 %52, double %51, double %49
%54 = getelementptr inbounds double, double* %0, i64 13
%55 = load double, double* %54
%56 = fcmp ogt double %55, %53
%57 = select i1 %56, double %55, double %53
%58 = getelementptr inbounds double, double* %0, i64 14
%59 = load double, double* %58
%60 = fcmp ogt double %59, %57
%61 = select i1 %60, double %59, double %57
%62 = getelementptr inbounds double, double* %0, i64 15
%63 = load double, double* %62
%64 = fcmp ogt double %63, %61
%65 = select i1 %64, double %63, double %61
%66 = getelementptr inbounds double, double* %0, i64 16
%67 = load double, double* %66
%68 = fcmp ogt double %67, %65
%69 = select i1 %68, double %67, double %65
%70 = getelementptr inbounds double, double* %0, i64 17
%71 = load double, double* %70
%72 = fcmp ogt double %71, %69
%73 = select i1 %72, double %71, double %69
%74 = getelementptr inbounds double, double* %0, i64 18
%75 = load double, double* %74
%76 = fcmp ogt double %75, %73
%77 = select i1 %76, double %75, double %73
%78 = getelementptr inbounds double, double* %0, i64 19
%79 = load double, double* %78
%80 = fcmp ogt double %79, %77
%81 = select i1 %80, double %79, double %77
%82 = fdiv double %5, %81
%83 = getelementptr inbounds [20 x double], [20 x double]* %3, i64 0, i64 0
store double %82, double* %83
%84 = insertelement <2 x double> poison, double %81, i64 0
%85 = shufflevector <2 x double> %84, <2 x double> poison, <2 x i32> zeroinitializer
%86 = getelementptr inbounds double, double* %0, i64 1
%87 = bitcast double* %86 to <2 x double>*
%88 = load <2 x double>, <2 x double>* %87
%89 = fdiv <2 x double> %88, %85
%90 = getelementptr inbounds [20 x double], [20 x double]* %3, i64 0, i64 1
%91 = bitcast double* %90 to <2 x double>*
store <2 x double> %89, <2 x double>* %91
%92 = getelementptr inbounds double, double* %0, i64 3
%93 = bitcast double* %92 to <2 x double>*
%94 = load <2 x double>, <2 x double>* %93
%95 = fdiv <2 x double> %94, %85
%96 = getelementptr inbounds [20 x double], [20 x double]* %3, i64 0, i64 3
%97 = bitcast double* %96 to <2 x double>*
store <2 x double> %95, <2 x double>* %97
%98 = getelementptr inbounds double, double* %0, i64 5
%99 = bitcast double* %98 to <2 x double>*
%100 = load <2 x double>, <2 x double>* %99
%101 = fdiv <2 x double> %100, %85
%102 = getelementptr inbounds [20 x double], [20 x double]* %3, i64 0, i64 5
%103 = bitcast double* %102 to <2 x double>*
store <2 x double> %101, <2 x double>* %103
%104 = getelementptr inbounds double, double* %0, i64 7
%105 = bitcast double* %104 to <2 x double>*
%106 = load <2 x double>, <2 x double>* %105
%107 = fdiv <2 x double> %106, %85
%108 = getelementptr inbounds [20 x double], [20 x double]* %3, i64 0, i64 7
%109 = bitcast double* %108 to <2 x double>*
store <2 x double> %107, <2 x double>* %109
%110 = getelementptr inbounds double, double* %0, i64 9
%111 = bitcast double* %110 to <2 x double>*
%112 = load <2 x double>, <2 x double>* %111
%113 = fdiv <2 x double> %112, %85
%114 = getelementptr inbounds [20 x double], [20 x double]* %3, i64 0, i64 9
%115 = bitcast double* %114 to <2 x double>*
store <2 x double> %113, <2 x double>* %115
%116 = getelementptr inbounds double, double* %0, i64 11
%117 = bitcast double* %116 to <2 x double>*
%118 = load <2 x double>, <2 x double>* %117
%119 = fdiv <2 x double> %118, %85
%120 = getelementptr inbounds [20 x double], [20 x double]* %3, i64 0, i64 11
%121 = bitcast double* %120 to <2 x double>*
store <2 x double> %119, <2 x double>* %121
%122 = getelementptr inbounds double, double* %0, i64 13
%123 = bitcast double* %122 to <2 x double>*
%124 = load <2 x double>, <2 x double>* %123
%125 = fdiv <2 x double> %124, %85
%126 = getelementptr inbounds [20 x double], [20 x double]* %3, i64 0, i64 13
%127 = bitcast double* %126 to <2 x double>*
store <2 x double> %125, <2 x double>* %127
%128 = getelementptr inbounds double, double* %0, i64 15
%129 = bitcast double* %128 to <2 x double>*
%130 = load <2 x double>, <2 x double>* %129
%131 = fdiv <2 x double> %130, %85
%132 = getelementptr inbounds [20 x double], [20 x double]* %3, i64 0, i64 15
%133 = bitcast double* %132 to <2 x double>*
store <2 x double> %131, <2 x double>* %133
%134 = getelementptr inbounds double, double* %0, i64 17
%135 = bitcast double* %134 to <2 x double>*
%136 = load <2 x double>, <2 x double>* %135
%137 = fdiv <2 x double> %136, %85
%138 = getelementptr inbounds [20 x double], [20 x double]* %3, i64 0, i64 17
%139 = bitcast double* %138 to <2 x double>*
store <2 x double> %137, <2 x double>* %139
%140 = getelementptr inbounds double, double* %0, i64 19
%141 = load double, double* %140
%142 = fdiv double %141, %81
%143 = getelementptr inbounds [20 x double], [20 x double]* %3, i64 0, i64 19
store double %142, double* %143
%144 = sext i32 %1 to i64
%145 = getelementptr inbounds [20 x double], [20 x double]* %3, i64 0, i64 %144
%146 = load double, double* %145
ret double %146
}