float lvq_map(map, a, coords, data, wt, dim, ivars, total_units, samples)
float **map, **data, **a, wt;
int **coords;
int dim, ivars, total_units, samples;
{
  int i, j, k, winner, dist, diff, time_count;
  float c, distf, sum, ypred, d, weight_sumx;
  int *win_list, *lose_list, d_count, *win_count;
  float weightx, lose_weightx, *coef, tot_error, rms_error, rms_data_weights();
  win_list = ivector(1, samples);
  lose_list = ivector(1, samples);
  for (i = 1; i <= total_units; i++)
    win_count[i] = 0;
  d_count = 0;
  tot_error = 0;
  for (i = 1; i <= samples; i++) {
    winner = find_winner(map, data, i, ivars, total_units);
    lose_list[i] = winner;
    win_count[winner]++;
    ypred = a[winner][0];
    for (j = 1; j <= ivars; j++)
      ypred += data[i][j] * a[winner][j];
    distf = ypred - data[i][ivars + 1];
    tot_error += (distf * distf);
    win_list[i] = find_winner_pe2(map, a, coords, data, i, ivars, winner,
                                  total_units, dim);
    if (win_list[i] != winner)
      d_count++;
  }
  tot_error = sqrt(tot_error / ((float)samples));
  printf("shifts=%d\n", d_count);
  for (j = 1; j <= total_units; j++) {
    weight_sumx = 1;
    for (i = 1; i <= samples; i++) {
      dist = 0;
      winner = lose_list[i];
      if (winner == j)
        if (win_list[i] != winner) {
          weight_sumx -= wt;
          for (k = 1; k <= ivars; k++)
            map[j][k] += -data[i][k] * wt;
        } else {
          weight_sumx += wt;
          for (k = 1; k <= ivars; k++)
            map[j][k] += data[i][k] * wt;
        }
    }
    winner = win_list[i];
    if (winner == j && lose_list[i] != winner) {
      weight_sumx += wt;
      for (k = 1; k <= ivars; k++)
        map[j][k] += data[i][k] * wt;
    }
    weight_sumx = 1.0 / weight_sumx;
    for (k = 1; k <= ivars; k++)
      map[j][k] = map[j][k] * weight_sumx;
  }
  rms_error = rms_data_weights(map, a, data, ivars, total_units, samples);
  printf("Update map error after lvq =%f ", rms_error);
  if (rms_error <= tot_error)
    printf("down %f\n", tot_error - rms_error);
  else
    printf("up %f\n", rms_error - tot_error);
  free_ivector(win_list, 1, samples);
  free_ivector(lose_list, 1, samples);
  return (rms_error);
}


x86 assembly (clang, -O0):
<lvq_map>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%eax
cvtsd2ss %xmm0,%xmm0
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movss  %xmm0,-0x24(%rbp)
mov    %r8d,-0x28(%rbp)
mov    %r9d,-0x2c(%rbp)
mov    0x18(%rbp),%esi
mov    $0x1,%edi
mov    $0x0,%al
call   1080 <ivector@plt>
cltq
mov    %rax,-0x68(%rbp)
mov    0x18(%rbp),%esi
mov    $0x1,%edi
mov    $0x0,%al
call   1080 <ivector@plt>
cltq
mov    %rax,-0x70(%rbp)
movl   $0x1,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    0x10(%rbp),%eax
jg     11fc <lvq_map+0x8c>
mov    -0x80(%rbp),%rax
movslq -0x30(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    11d3 <lvq_map+0x63>
movl   $0x0,-0x74(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x94(%rbp)
ff
movl   $0x1,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    0x18(%rbp),%eax
jg     1388 <lvq_map+0x218>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x30(%rbp),%edx
mov    -0x2c(%rbp),%ecx
mov    0x10(%rbp),%r8d
mov    $0x0,%al
call   1060 <find_winner@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%edx
mov    -0x70(%rbp),%rax
movslq -0x30(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x80(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
add    $0x1,%edx
mov    %edx,(%rax,%rcx,4)
mov    -0x10(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movss  (%rax),%xmm0
movss  %xmm0,-0x58(%rbp)
movl   $0x1,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jg     12ce <lvq_map+0x15e>
mov    -0x20(%rbp),%rax
movslq -0x30(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x34(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x34(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm2
movss  -0x58(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x58(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1278 <lvq_map+0x108>
movss  -0x58(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movslq -0x30(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    -0x2c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
subss  (%rax,%rcx,4),%xmm0
movss  %xmm0,-0x50(%rbp)
movss  -0x50(%rbp),%xmm0
movss  -0x50(%rbp),%xmm2
movss  -0x94(%rbp),%xmm1
ff
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x94(%rbp)
ff
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x30(%rbp),%r8d
mov    -0x2c(%rbp),%r9d
mov    -0x3c(%rbp),%r11d
mov    0x10(%rbp),%r10d
mov    -0x28(%rbp),%eax
mov    %r11d,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %eax,0x10(%rsp)
mov    $0x0,%al
call   1040 <find_winner_pe2@plt>
mov    %eax,%edx
mov    -0x68(%rbp),%rax
movslq -0x30(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x68(%rbp),%rax
movslq -0x30(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
cmp    -0x3c(%rbp),%eax
je     1375 <lvq_map+0x205>
mov    -0x74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x74(%rbp)
jmp    137a <lvq_map+0x20a>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1215 <lvq_map+0xa5>
movss  -0x94(%rbp),%xmm0
ff
cvtsi2ssl 0x18(%rbp),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
call   1090 <sqrt@plt>
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x94(%rbp)
ff
mov    -0x74(%rbp),%esi
lea    0xc58(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    0x10(%rbp),%eax
jg     1652 <lvq_map+0x4e2>
movss  0xc26(%rip),%xmm0
movss  %xmm0,-0x60(%rbp)
movl   $0x1,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    0x18(%rbp),%eax
jg     1532 <lvq_map+0x3c2>
movl   $0x0,-0x40(%rbp)
mov    -0x70(%rbp),%rax
movslq -0x30(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x34(%rbp),%eax
jne    151f <lvq_map+0x3af>
mov    -0x68(%rbp),%rax
movslq -0x30(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
cmp    -0x3c(%rbp),%eax
je     14a9 <lvq_map+0x339>
movss  -0x24(%rbp),%xmm1
movss  -0x60(%rbp),%xmm0
subss  %xmm1,%xmm0
movss  %xmm0,-0x60(%rbp)
movl   $0x1,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jg     14a4 <lvq_map+0x334>
mov    -0x20(%rbp),%rax
movslq -0x30(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x38(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  -0x24(%rbp),%xmm2
mov    -0x8(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x38(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,(%rax,%rcx,4)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1441 <lvq_map+0x2d1>
jmp    151a <lvq_map+0x3aa>
movss  -0x24(%rbp),%xmm0
addss  -0x60(%rbp),%xmm0
movss  %xmm0,-0x60(%rbp)
movl   $0x1,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jg     1515 <lvq_map+0x3a5>
mov    -0x20(%rbp),%rax
movslq -0x30(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x38(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
movss  -0x24(%rbp),%xmm2
mov    -0x8(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x38(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,(%rax,%rcx,4)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    14bf <lvq_map+0x34f>
jmp    151a <lvq_map+0x3aa>
jmp    151f <lvq_map+0x3af>
jmp    1524 <lvq_map+0x3b4>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    13e6 <lvq_map+0x276>
mov    -0x68(%rbp),%rax
movslq -0x30(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x34(%rbp),%eax
jne    15d1 <lvq_map+0x461>
mov    -0x70(%rbp),%rax
movslq -0x30(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
cmp    -0x3c(%rbp),%eax
je     15d1 <lvq_map+0x461>
movss  -0x24(%rbp),%xmm0
addss  -0x60(%rbp),%xmm0
movss  %xmm0,-0x60(%rbp)
movl   $0x1,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jg     15cc <lvq_map+0x45c>
mov    -0x20(%rbp),%rax
movslq -0x30(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x38(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
movss  -0x24(%rbp),%xmm2
mov    -0x8(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x38(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,(%rax,%rcx,4)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1576 <lvq_map+0x406>
jmp    15d1 <lvq_map+0x461>
movss  -0x60(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xa26(%rip),%xmm0
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x60(%rbp)
movl   $0x1,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jg     163f <lvq_map+0x4cf>
mov    -0x8(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x38(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
mulss  -0x60(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x38(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    15f6 <lvq_map+0x486>
jmp    1644 <lvq_map+0x4d4>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    13c6 <lvq_map+0x256>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x2c(%rbp),%ecx
mov    0x10(%rbp),%r8d
mov    0x18(%rbp),%r9d
mov    $0x0,%al
call   1050 <rms_data_weights@plt>
movss  %xmm0,-0x98(%rbp)
ff
movss  -0x98(%rbp),%xmm0
ff
cvtss2sd %xmm0,%xmm0
lea    0x990(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movss  -0x98(%rbp),%xmm1
ff
movss  -0x94(%rbp),%xmm0
ff
ucomiss %xmm1,%xmm0
jb     16d2 <lvq_map+0x562>
movss  -0x94(%rbp),%xmm0
ff
subss  -0x98(%rbp),%xmm0
ff
cvtss2sd %xmm0,%xmm0
lea    0x975(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    16f4 <lvq_map+0x584>
movss  -0x98(%rbp),%xmm0
ff
subss  -0x94(%rbp),%xmm0
ff
cvtss2sd %xmm0,%xmm0
lea    0x957(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x68(%rbp),%rdi
mov    0x18(%rbp),%edx
mov    $0x1,%esi
mov    $0x0,%al
call   1070 <free_ivector@plt>
mov    -0x70(%rbp),%rdi
mov    0x18(%rbp),%edx
mov    $0x1,%esi
mov    $0x0,%al
call   1070 <free_ivector@plt>
movss  -0x98(%rbp),%xmm0
ff
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lvq_map>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9d,%r13d
mov    %rcx,%rbp
mov    %rsi,%r14
mov    %rdi,%r12
mov    0x58(%rsp),%ebx
mov    $0x1,%edi
mov    %ebx,%esi
xor    %eax,%eax
call   1080 <ivector@plt>
mov    %eax,0x14(%rsp)
mov    $0x1,%edi
mov    %ebx,%esi
xor    %eax,%eax
call   1080 <ivector@plt>
test   %ebx,%ebx
jg     128b <lvq_map+0x12b>
mov    %eax,%r15d
cvtsi2ss %ebx,%xmm1
xorps  %xmm2,%xmm2
xorps  %xmm0,%xmm0
divss  %xmm1,%xmm0
ucomiss %xmm2,%xmm0
jb     11c2 <lvq_map+0x62>
sqrtss %xmm0,%xmm0
jmp    11c7 <lvq_map+0x67>
call   1050 <sqrtf@plt>
movss  %xmm0,0x10(%rsp)
lea    0xe2c(%rip),%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r12,%rdi
mov    %r14,%rsi
mov    %rbp,%rdx
mov    %r13d,%ecx
mov    0x50(%rsp),%r8d
mov    %ebx,%r9d
xor    %eax,%eax
call   1040 <rms_data_weights@plt>
movss  %xmm0,0xc(%rsp)
cvtss2sd %xmm0,%xmm0
lea    0xe02(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movss  0x10(%rsp),%xmm1
ucomiss 0xc(%rsp),%xmm1
jb     1228 <lvq_map+0xc8>
subss  0xc(%rsp),%xmm1
movaps %xmm1,%xmm0
jmp    1232 <lvq_map+0xd2>
movss  0xc(%rsp),%xmm0
subss  %xmm1,%xmm0
lea    0xdfb(%rip),%rax
lea    0xdeb(%rip),%rdi
cmovb  %rax,%rdi
cvtss2sd %xmm0,%xmm0
mov    $0x1,%al
call   1030 <printf@plt>
movslq %r15d,%rbp
movslq 0x14(%rsp),%rdi
mov    $0x1,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1070 <free_ivector@plt>
mov    %rbp,%rdi
mov    $0x1,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1070 <free_ivector@plt>
movss  0xc(%rsp),%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %r12,%rdi
mov    %rbp,%rsi
mov    $0x1,%edx
mov    %r13d,%ecx
mov    0x50(%rsp),%r8d
xor    %eax,%eax
call   1060 <find_winner@plt>

LLVM IR (-O0):
@.str = [11 x i8] c"shifts=%d\0A\00"
@.str.1 = [32 x i8] c"Update map error after lvq =%f \00"
@.str.2 = [9 x i8] c"down %f\0A\00"
@.str.3 = [7 x i8] c"up %f\0A\00"
define float @lvq_map(float** %0, float** %1, i32** %2, float** %3, double %4, i32 %5, i32 %6, i32 %7, i32 %8) {
%10 = alloca float**
%11 = alloca float**
%12 = alloca i32**
%13 = alloca float**
%14 = alloca float
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
%24 = alloca i32
%25 = alloca i32
%26 = alloca float
%27 = alloca float
%28 = alloca float
%29 = alloca float
%30 = alloca float
%31 = alloca float
%32 = alloca i32*
%33 = alloca i32*
%34 = alloca i32
%35 = alloca i32*
%36 = alloca float
%37 = alloca float
%38 = alloca float*
%39 = alloca float
%40 = alloca float
%41 = fptrunc double %4 to float
store float** %0, float*** %10
store float** %1, float*** %11
store i32** %2, i32*** %12
store float** %3, float*** %13
store float %41, float* %14
store i32 %5, i32* %15
store i32 %6, i32* %16
store i32 %7, i32* %17
store i32 %8, i32* %18
%42 = load i32, i32* %18
%43 = call i32 (i32, i32, ...) bitcast (i32 (...)* @ivector to i32 (i32, i32, ...)*)(i32 1, i32 %42)
%44 = sext i32 %43 to i64
%45 = inttoptr i64 %44 to i32*
store i32* %45, i32** %32
%46 = load i32, i32* %18
%47 = call i32 (i32, i32, ...) bitcast (i32 (...)* @ivector to i32 (i32, i32, ...)*)(i32 1, i32 %46)
%48 = sext i32 %47 to i64
%49 = inttoptr i64 %48 to i32*
store i32* %49, i32** %33
store i32 1, i32* %19
br label %50
50: ; preds = %59, %9
%51 = load i32, i32* %19
%52 = load i32, i32* %17
%53 = icmp sle i32 %51, %52
br i1 %53, label %54, label %62
54: ; preds = %50
%55 = load i32*, i32** %35
%56 = load i32, i32* %19
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds i32, i32* %55, i64 %57
store i32 0, i32* %58
br label %59
59: ; preds = %54
%60 = load i32, i32* %19
%61 = add nsw i32 %60, 1
store i32 %61, i32* %19
br label %50
62: ; preds = %50
store i32 0, i32* %34
store float 0.000000e+00, float* %39
store i32 1, i32* %19
br label %63
63: ; preds = %162, %62
%64 = load i32, i32* %19
%65 = load i32, i32* %18
%66 = icmp sle i32 %64, %65
br i1 %66, label %67, label %165
67: ; preds = %63
%68 = load float**, float*** %10
%69 = load float**, float*** %13
%70 = load i32, i32* %19
%71 = load i32, i32* %16
%72 = load i32, i32* %17
%73 = call i32 (float**, float**, i32, i32, i32, ...) bitcast (i32 (...)* @find_winner to i32 (float**, float**, i32, i32, i32, ...)*)(float** %68, float** %69, i32 %70, i32 %71, i32 %72)
store i32 %73, i32* %22
%74 = load i32, i32* %22
%75 = load i32*, i32** %33
%76 = load i32, i32* %19
%77 = sext i32 %76 to i64
%78 = getelementptr inbounds i32, i32* %75, i64 %77
store i32 %74, i32* %78
%79 = load i32*, i32** %35
%80 = load i32, i32* %22
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds i32, i32* %79, i64 %81
%83 = load i32, i32* %82
%84 = add nsw i32 %83, 1
store i32 %84, i32* %82
%85 = load float**, float*** %11
%86 = load i32, i32* %22
%87 = sext i32 %86 to i64
%88 = getelementptr inbounds float*, float** %85, i64 %87
%89 = load float*, float** %88
%90 = getelementptr inbounds float, float* %89, i64 0
%91 = load float, float* %90
store float %91, float* %29
store i32 1, i32* %20
br label %92
92: ; preds = %117, %67
%93 = load i32, i32* %20
%94 = load i32, i32* %16
%95 = icmp sle i32 %93, %94
br i1 %95, label %96, label %120
96: ; preds = %92
%97 = load float**, float*** %13
%98 = load i32, i32* %19
%99 = sext i32 %98 to i64
%100 = getelementptr inbounds float*, float** %97, i64 %99
%101 = load float*, float** %100
%102 = load i32, i32* %20
%103 = sext i32 %102 to i64
%104 = getelementptr inbounds float, float* %101, i64 %103
%105 = load float, float* %104
%106 = load float**, float*** %11
%107 = load i32, i32* %22
%108 = sext i32 %107 to i64
%109 = getelementptr inbounds float*, float** %106, i64 %108
%110 = load float*, float** %109
%111 = load i32, i32* %20
%112 = sext i32 %111 to i64
%113 = getelementptr inbounds float, float* %110, i64 %112
%114 = load float, float* %113
%115 = load float, float* %29
%116 = call float @llvm.fmuladd.f32(float %105, float %114, float %115)
store float %116, float* %29
br label %117
117: ; preds = %96
%118 = load i32, i32* %20
%119 = add nsw i32 %118, 1
store i32 %119, i32* %20
br label %92
120: ; preds = %92
%121 = load float, float* %29
%122 = load float**, float*** %13
%123 = load i32, i32* %19
%124 = sext i32 %123 to i64
%125 = getelementptr inbounds float*, float** %122, i64 %124
%126 = load float*, float** %125
%127 = load i32, i32* %16
%128 = add nsw i32 %127, 1
%129 = sext i32 %128 to i64
%130 = getelementptr inbounds float, float* %126, i64 %129
%131 = load float, float* %130
%132 = fsub float %121, %131
store float %132, float* %27
%133 = load float, float* %27
%134 = load float, float* %27
%135 = load float, float* %39
%136 = call float @llvm.fmuladd.f32(float %133, float %134, float %135)
store float %136, float* %39
%137 = load float**, float*** %10
%138 = load float**, float*** %11
%139 = load i32**, i32*** %12
%140 = load float**, float*** %13
%141 = load i32, i32* %19
%142 = load i32, i32* %16
%143 = load i32, i32* %22
%144 = load i32, i32* %17
%145 = load i32, i32* %15
%146 = call i32 (float**, float**, i32**, float**, i32, i32, i32, i32, i32, ...) bitcast (i32 (...)* @find_winner_pe2 to i32 (float**, float**, i32**, float**, i32, i32, i32, i32, i32, ...)*)(float** %137, float** %138, i32** %139, float** %140, i32 %141, i32 %142, i32 %143, i32 %144, i32 %145)
%147 = load i32*, i32** %32
%148 = load i32, i32* %19
%149 = sext i32 %148 to i64
%150 = getelementptr inbounds i32, i32* %147, i64 %149
store i32 %146, i32* %150
%151 = load i32*, i32** %32
%152 = load i32, i32* %19
%153 = sext i32 %152 to i64
%154 = getelementptr inbounds i32, i32* %151, i64 %153
%155 = load i32, i32* %154
%156 = load i32, i32* %22
%157 = icmp ne i32 %155, %156
br i1 %157, label %158, label %161
158: ; preds = %120
%159 = load i32, i32* %34
%160 = add nsw i32 %159, 1
store i32 %160, i32* %34
br label %161
161: ; preds = %158, %120
br label %162
162: ; preds = %161
%163 = load i32, i32* %19
%164 = add nsw i32 %163, 1
store i32 %164, i32* %19
br label %63
165: ; preds = %63
%166 = load float, float* %39
%167 = load i32, i32* %18
%168 = sitofp i32 %167 to float
%169 = fdiv float %166, %168
%170 = fpext float %169 to double
%171 = call double @sqrt(double %170)
%172 = fptrunc double %171 to float
store float %172, float* %39
%173 = load i32, i32* %34
%174 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %173)
store i32 1, i32* %20
br label %175
175: ; preds = %356, %165
%176 = load i32, i32* %20
%177 = load i32, i32* %17
%178 = icmp sle i32 %176, %177
br i1 %178, label %179, label %359
179: ; preds = %175
store float 1.000000e+00, float* %31
store i32 1, i32* %19
br label %180
180: ; preds = %270, %179
%181 = load i32, i32* %19
%182 = load i32, i32* %18
%183 = icmp sle i32 %181, %182
br i1 %183, label %184, label %273
184: ; preds = %180
store i32 0, i32* %23
%185 = load i32*, i32** %33
%186 = load i32, i32* %19
%187 = sext i32 %186 to i64
%188 = getelementptr inbounds i32, i32* %185, i64 %187
%189 = load i32, i32* %188
store i32 %189, i32* %22
%190 = load i32, i32* %22
%191 = load i32, i32* %20
%192 = icmp eq i32 %190, %191
br i1 %192, label %193, label %269
193: ; preds = %184
%194 = load i32*, i32** %32
%195 = load i32, i32* %19
%196 = sext i32 %195 to i64
%197 = getelementptr inbounds i32, i32* %194, i64 %196
%198 = load i32, i32* %197
%199 = load i32, i32* %22
%200 = icmp ne i32 %198, %199
br i1 %200, label %201, label %235
201: ; preds = %193
%202 = load float, float* %14
%203 = load float, float* %31
%204 = fsub float %203, %202
store float %204, float* %31
store i32 1, i32* %21
br label %205
205: ; preds = %231, %201
%206 = load i32, i32* %21
%207 = load i32, i32* %16
%208 = icmp sle i32 %206, %207
br i1 %208, label %209, label %234
209: ; preds = %205
%210 = load float**, float*** %13
%211 = load i32, i32* %19
%212 = sext i32 %211 to i64
%213 = getelementptr inbounds float*, float** %210, i64 %212
%214 = load float*, float** %213
%215 = load i32, i32* %21
%216 = sext i32 %215 to i64
%217 = getelementptr inbounds float, float* %214, i64 %216
%218 = load float, float* %217
%219 = fneg float %218
%220 = load float, float* %14
%221 = load float**, float*** %10
%222 = load i32, i32* %20
%223 = sext i32 %222 to i64
%224 = getelementptr inbounds float*, float** %221, i64 %223
%225 = load float*, float** %224
%226 = load i32, i32* %21
%227 = sext i32 %226 to i64
%228 = getelementptr inbounds float, float* %225, i64 %227
%229 = load float, float* %228
%230 = call float @llvm.fmuladd.f32(float %219, float %220, float %229)
store float %230, float* %228
br label %231
231: ; preds = %209
%232 = load i32, i32* %21
%233 = add nsw i32 %232, 1
store i32 %233, i32* %21
br label %205
234: ; preds = %205
br label %268
235: ; preds = %193
%236 = load float, float* %14
%237 = load float, float* %31
%238 = fadd float %237, %236
store float %238, float* %31
store i32 1, i32* %21
br label %239
239: ; preds = %264, %235
%240 = load i32, i32* %21
%241 = load i32, i32* %16
%242 = icmp sle i32 %240, %241
br i1 %242, label %243, label %267
243: ; preds = %239
%244 = load float**, float*** %13
%245 = load i32, i32* %19
%246 = sext i32 %245 to i64
%247 = getelementptr inbounds float*, float** %244, i64 %246
%248 = load float*, float** %247
%249 = load i32, i32* %21
%250 = sext i32 %249 to i64
%251 = getelementptr inbounds float, float* %248, i64 %250
%252 = load float, float* %251
%253 = load float, float* %14
%254 = load float**, float*** %10
%255 = load i32, i32* %20
%256 = sext i32 %255 to i64
%257 = getelementptr inbounds float*, float** %254, i64 %256
%258 = load float*, float** %257
%259 = load i32, i32* %21
%260 = sext i32 %259 to i64
%261 = getelementptr inbounds float, float* %258, i64 %260
%262 = load float, float* %261
%263 = call float @llvm.fmuladd.f32(float %252, float %253, float %262)
store float %263, float* %261
br label %264
264: ; preds = %243
%265 = load i32, i32* %21
%266 = add nsw i32 %265, 1
store i32 %266, i32* %21
br label %239
267: ; preds = %239
br label %268
268: ; preds = %267, %234
br label %269
269: ; preds = %268, %184
br label %270
270: ; preds = %269
%271 = load i32, i32* %19
%272 = add nsw i32 %271, 1
store i32 %272, i32* %19
br label %180
273: ; preds = %180
%274 = load i32*, i32** %32
%275 = load i32, i32* %19
%276 = sext i32 %275 to i64
%277 = getelementptr inbounds i32, i32* %274, i64 %276
%278 = load i32, i32* %277
store i32 %278, i32* %22
%279 = load i32, i32* %22
%280 = load i32, i32* %20
%281 = icmp eq i32 %279, %280
br i1 %281, label %282, label %323
282: ; preds = %273
%283 = load i32*, i32** %33
%284 = load i32, i32* %19
%285 = sext i32 %284 to i64
%286 = getelementptr inbounds i32, i32* %283, i64 %285
%287 = load i32, i32* %286
%288 = load i32, i32* %22
%289 = icmp ne i32 %287, %288
br i1 %289, label %290, label %323
290: ; preds = %282
%291 = load float, float* %14
%292 = load float, float* %31
%293 = fadd float %292, %291
store float %293, float* %31
store i32 1, i32* %21
br label %294
294: ; preds = %319, %290
%295 = load i32, i32* %21
%296 = load i32, i32* %16
%297 = icmp sle i32 %295, %296
br i1 %297, label %298, label %322
298: ; preds = %294
%299 = load float**, float*** %13
%300 = load i32, i32* %19
%301 = sext i32 %300 to i64
%302 = getelementptr inbounds float*, float** %299, i64 %301
%303 = load float*, float** %302
%304 = load i32, i32* %21
%305 = sext i32 %304 to i64
%306 = getelementptr inbounds float, float* %303, i64 %305
%307 = load float, float* %306
%308 = load float, float* %14
%309 = load float**, float*** %10
%310 = load i32, i32* %20
%311 = sext i32 %310 to i64
%312 = getelementptr inbounds float*, float** %309, i64 %311
%313 = load float*, float** %312
%314 = load i32, i32* %21
%315 = sext i32 %314 to i64
%316 = getelementptr inbounds float, float* %313, i64 %315
%317 = load float, float* %316
%318 = call float @llvm.fmuladd.f32(float %307, float %308, float %317)
store float %318, float* %316
br label %319
319: ; preds = %298
%320 = load i32, i32* %21
%321 = add nsw i32 %320, 1
store i32 %321, i32* %21
br label %294
322: ; preds = %294
br label %323
323: ; preds = %322, %282, %273
%324 = load float, float* %31
%325 = fpext float %324 to double
%326 = fdiv double 1.000000e+00, %325
%327 = fptrunc double %326 to float
store float %327, float* %31
store i32 1, i32* %21
br label %328
328: ; preds = %352, %323
%329 = load i32, i32* %21
%330 = load i32, i32* %16
%331 = icmp sle i32 %329, %330
br i1 %331, label %332, label %355
332: ; preds = %328
%333 = load float**, float*** %10
%334 = load i32, i32* %20
%335 = sext i32 %334 to i64
%336 = getelementptr inbounds float*, float** %333, i64 %335
%337 = load float*, float** %336
%338 = load i32, i32* %21
%339 = sext i32 %338 to i64
%340 = getelementptr inbounds float, float* %337, i64 %339
%341 = load float, float* %340
%342 = load float, float* %31
%343 = fmul float %341, %342
%344 = load float**, float*** %10
%345 = load i32, i32* %20
%346 = sext i32 %345 to i64
%347 = getelementptr inbounds float*, float** %344, i64 %346
%348 = load float*, float** %347
%349 = load i32, i32* %21
%350 = sext i32 %349 to i64
%351 = getelementptr inbounds float, float* %348, i64 %350
store float %343, float* %351
br label %352
352: ; preds = %332
%353 = load i32, i32* %21
%354 = add nsw i32 %353, 1
store i32 %354, i32* %21
br label %328
355: ; preds = %328
br label %356
356: ; preds = %355
%357 = load i32, i32* %20
%358 = add nsw i32 %357, 1
store i32 %358, i32* %20
br label %175
359: ; preds = %175
%360 = load float**, float*** %10
%361 = load float**, float*** %11
%362 = load float**, float*** %13
%363 = load i32, i32* %16
%364 = load i32, i32* %17
%365 = load i32, i32* %18
%366 = call float (float**, float**, float**, i32, i32, i32, ...) bitcast (float (...)* @rms_data_weights to float (float**, float**, float**, i32, i32, i32, ...)*)(float** %360, float** %361, float** %362, i32 %363, i32 %364, i32 %365)
store float %366, float* %40
%367 = load float, float* %40
%368 = fpext float %367 to double
%369 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), double %368)
%370 = load float, float* %40
%371 = load float, float* %39
%372 = fcmp ole float %370, %371
br i1 %372, label %373, label %379
373: ; preds = %359
%374 = load float, float* %39
%375 = load float, float* %40
%376 = fsub float %374, %375
%377 = fpext float %376 to double
%378 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), double %377)
br label %385
379: ; preds = %359
%380 = load float, float* %40
%381 = load float, float* %39
%382 = fsub float %380, %381
%383 = fpext float %382 to double
%384 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), double %383)
br label %385
385: ; preds = %379, %373
%386 = load i32*, i32** %32
%387 = load i32, i32* %18
%388 = call i32 (i32*, i32, i32, ...) bitcast (i32 (...)* @free_ivector to i32 (i32*, i32, i32, ...)*)(i32* %386, i32 1, i32 %387)
%389 = load i32*, i32** %33
%390 = load i32, i32* %18
%391 = call i32 (i32*, i32, i32, ...) bitcast (i32 (...)* @free_ivector to i32 (i32*, i32, i32, ...)*)(i32* %389, i32 1, i32 %390)
%392 = load float, float* %40
ret float %392
}

LLVM IR (-O2):
@.str = [11 x i8] c"shifts=%d\0A\00"
@.str.1 = [32 x i8] c"Update map error after lvq =%f \00"
@.str.2 = [9 x i8] c"down %f\0A\00"
@.str.3 = [7 x i8] c"up %f\0A\00"
define float @lvq_map(float** %0, float** %1, i32** nocapture readnone %2, float** %3, double %4, i32 %5, i32 %6, i32 %7, i32 %8) {
%10 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @ivector to i32 (i32, i32, ...)*)(i32 1, i32 %8)
%11 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @ivector to i32 (i32, i32, ...)*)(i32 1, i32 %8)
%12 = icmp slt i32 %7, 1
tail call void @llvm.assume(i1 %12)
%13 = icmp sgt i32 %8, 0
br i1 %13, label %14, label %16
14: ; preds = %9
%15 = tail call i32 (float**, float**, i32, i32, i32, ...) bitcast (i32 (...)* @find_winner to i32 (float**, float**, i32, i32, i32, ...)*)(float** %0, float** %3, i32 1, i32 %6, i32 %7)
unreachable
16: ; preds = %9
%17 = sitofp i32 %8 to float
%18 = fdiv float 0.000000e+00, %17
%19 = tail call float @sqrtf(float %18)
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 0)
%21 = tail call float (float**, float**, float**, i32, i32, i32, ...) bitcast (float (...)* @rms_data_weights to float (float**, float**, float**, i32, i32, i32, ...)*)(float** %0, float** %1, float** %3, i32 %6, i32 %7, i32 %8)
%22 = fpext float %21 to double
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), double %22)
%24 = fcmp ugt float %21, %19
%25 = fsub float %21, %19
%26 = fsub float %19, %21
%27 = select i1 %24, float %25, float %26
%28 = select i1 %24, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0)
%29 = fpext float %27 to double
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %28, double %29)
%31 = sext i32 %11 to i64
%32 = inttoptr i64 %31 to i32*
%33 = sext i32 %10 to i64
%34 = inttoptr i64 %33 to i32*
%35 = tail call i32 (i32*, i32, i32, ...) bitcast (i32 (...)* @free_ivector to i32 (i32*, i32, i32, ...)*)(i32* %34, i32 1, i32 %8)
%36 = tail call i32 (i32*, i32, i32, ...) bitcast (i32 (...)* @free_ivector to i32 (i32*, i32, i32, ...)*)(i32* %32, i32 1, i32 %8)
ret float %21
}