user: 请将以下的汇编代码转换成C语言代码:

```asm
<gettotalJS>:
  endbr64
  push   %r15
  push   %r14
  mov    %esi,%r14d
  mov    $0x4,%esi
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  lea    0x1(%r9),%ebx
  movslq %ebx,%rbp
  sub    $0x98,%rsp
  mov    %rdi,0x8(%rsp)
  mov    %rbp,%rdi
  mov    %edx,0x4(%rsp)
  mov    %ecx,0x58(%rsp)
  mov    %r8,0x10(%rsp)
  mov    %r9d,0x30(%rsp)
  mov    %ebx,0x5c(%rsp)
  call   <calloc@plt>
  mov    %rbp,%rdi
  mov    $0x4,%esi
  mov    %rax,0x38(%rsp)
  call   <calloc@plt>
  mov    %rbp,%rdi
  mov    $0x4,%esi
  mov    %rax,0x20(%rsp)
  call   <calloc@plt>
  mov    %rbp,%rdi
  mov    $0x4,%esi
  mov    %rax,0x40(%rsp)
  call   <calloc@plt>
  mov    %rbp,%rdi
  mov    $0x4,%esi
  mov    %rax,%r12
  call   <calloc@plt>
  mov    %rbp,%rdi
  mov    $0x4,%esi
  mov    %rax,%r13
  call   <calloc@plt>
  mov    %r14d,%esi
  mov    %ebx,%edi
  mov    %rax,%rbp
  xor    %eax,%eax
  call   <fmatrix@plt>
  mov    %r14d,%esi
  mov    %ebx,%edi
  mov    %r14d,0x28(%rsp)
  movslq %eax,%r15
  xor    %eax,%eax
  call   <fmatrix@plt>
  mov    0x28(%rsp),%esi
  mov    %ebx,%edi
  movslq %eax,%r14
  xor    %eax,%eax
  call   <imatrix@plt>
  mov    0x28(%rsp),%esi
  mov    %ebx,%edi
  movslq %eax,%r10
  xor    %eax,%eax
  mov    %r10,0x50(%rsp)
  call   <fmatrix@plt>
  mov    0x4(%rsp),%edi
  movslq %eax,%rbx
  test   %edi,%edi
  jle    L454
  movslq 0x58(%rsp),%rcx
  xor    %r10d,%r10d
  xor    %r9d,%r9d
  test   %ecx,%ecx
  jle    L454
  mov    %rbx,0x18(%rsp)
  mov    0x50(%rsp),%r11
  nopl   0x0(%rax)
L134:
  mov    0x10(%rsp),%rdi
  movslq %r10d,%r8
  xor    %eax,%eax
  add    %r8,%rdi
  add    0x8(%rsp),%r8
  nopw   0x0(%rax,%rax,1)
L307:
  movzbl (%rdi,%rax,1),%edx
  test   %dl,%dl
  je     L72
  pxor   %xmm1,%xmm1
  lea    0x0(,%rdx,4),%rsi
  cvtsi2ss %eax,%xmm1
  lea    (%r12,%rsi,1),%rbx
  addl   $0x1,0x0(%rbp,%rsi,1)
  movss  (%rbx),%xmm0
  addss  %xmm1,%xmm0
  movss  %xmm0,(%rbx)
  pxor   %xmm0,%xmm0
  lea    0x0(%r13,%rsi,1),%rbx
  movzbl (%r8,%rax,1),%esi
  cvtsi2ss %r9d,%xmm0
  movss  (%rbx),%xmm2
  shl    $0x2,%rsi
  addss  %xmm0,%xmm2
  movss  %xmm2,(%rbx)
  mov    (%r14,%rdx,8),%rbx
  add    %rsi,%rbx
  addss  (%rbx),%xmm1
  movss  %xmm1,(%rbx)
  mov    (%r15,%rdx,8),%rbx
  add    %rsi,%rbx
  add    (%r11,%rdx,8),%rsi
  addss  (%rbx),%xmm0
  movss  %xmm0,(%rbx)
  addl   $0x1,(%rsi)
L72:
  add    $0x1,%rax
  cmp    %rcx,%rax
  jne    L307
  add    0x58(%rsp),%r10d
  add    $0x1,%r9d
  cmp    %r9d,0x4(%rsp)
  jne    L134
  mov    0x18(%rsp),%rbx
L454:
  mov    0x30(%rsp),%esi
  test   %esi,%esi
  jle    L332
  mov    0x30(%rsp),%eax
  lea    -0x1(%rax),%edi
  mov    %edi,0x48(%rsp)
  cmp    $0x2,%edi
  jbe    L450
  shr    $0x2,%eax
  lea    -0x1(%rax),%edx
  mov    $0x4,%eax
  shl    $0x4,%rdx
  add    $0x14,%rdx
  nopw   0x0(%rax,%rax,1)
L343:
  movups (%r12,%rax,1),%xmm1
  movdqu 0x0(%rbp,%rax,1),%xmm5
  cvtdq2ps %xmm5,%xmm0
  divps  %xmm0,%xmm1
  movups %xmm1,(%r12,%rax,1)
  movups 0x0(%r13,%rax,1),%xmm1
  divps  %xmm0,%xmm1
  movups %xmm1,0x0(%r13,%rax,1)
  add    $0x10,%rax
  cmp    %rdx,%rax
  jne    L343
  mov    0x30(%rsp),%edi
  mov    %edi,%eax
  and    $0xfffffffc,%eax
  lea    0x1(%rax),%edx
  cmp    %edi,%eax
  je     L448
L340:
  movslq %edx,%rsi
  pxor   %xmm1,%xmm1
  mov    0x30(%rsp),%edi
  cvtsi2ssl 0x0(%rbp,%rsi,4),%xmm1
  lea    0x0(,%rsi,4),%rax
  lea    (%r12,%rax,1),%rcx
  movss  (%rcx),%xmm0
  divss  %xmm1,%xmm0
  movss  %xmm0,(%rcx)
  lea    0x0(%r13,%rax,1),%rcx
  movss  (%rcx),%xmm0
  divss  %xmm1,%xmm0
  movss  %xmm0,(%rcx)
  lea    0x1(%rdx),%ecx
  cmp    %edi,%ecx
  jg     L448
  pxor   %xmm1,%xmm1
  lea    0x4(%rax),%rcx
  add    $0x2,%edx
  cvtsi2ssl 0x4(%rbp,%rax,1),%xmm1
  lea    (%r12,%rcx,1),%rsi
  add    %r13,%rcx
  movss  (%rsi),%xmm0
  divss  %xmm1,%xmm0
  movss  %xmm0,(%rsi)
  movss  (%rcx),%xmm0
  divss  %xmm1,%xmm0
  movss  %xmm0,(%rcx)
  cmp    %edi,%edx
  jg     L448
  pxor   %xmm1,%xmm1
  lea    0x8(%rax),%rdx
  cvtsi2ssl 0x8(%rbp,%rax,1),%xmm1
  lea    (%r12,%rdx,1),%rcx
  add    %r13,%rdx
  movss  (%rcx),%xmm0
  divss  %xmm1,%xmm0
  movss  %xmm0,(%rcx)
  movss  (%rdx),%xmm0
  divss  %xmm1,%xmm0
  movss  %xmm0,(%rdx)
L448:
  mov    0x48(%rsp),%eax
  mov    0x28(%rsp),%edi
  mov    %r15,%r11
  mov    %r12,0x60(%rsp)
  mov    0x50(%rsp),%r10
  mov    %r13,0x68(%rsp)
  lea    0x8(%r14),%rsi
  sub    %r14,%r11
  lea    0x10(%r14,%rax,8),%rcx
  lea    -0x1(%rdi),%eax
  mov    %edi,%r13d
  mov    %eax,0x18(%rsp)
  lea    0x4(,%rax,4),%r8
  sub    %r14,%r10
  mov    %rcx,%r12
  nopw   0x0(%rax,%rax,1)
L462:
  test   %r13d,%r13d
  jle    L241
  mov    (%r10,%rsi,1),%rdi
  lea    (%r11,%rsi,1),%r9
  xor    %eax,%eax
  nopw   0x0(%rax,%rax,1)
L253:
  mov    (%rdi,%rax,1),%edx
  test   %edx,%edx
  jle    L366
  mov    (%rsi),%rcx
  pxor   %xmm1,%xmm1
  cvtsi2ss %edx,%xmm1
  mov    (%r9),%rdx
  add    %rax,%rcx
  movss  (%rcx),%xmm0
  add    %rax,%rdx
  divss  %xmm1,%xmm0
  movss  %xmm0,(%rcx)
  movss  (%rdx),%xmm0
  divss  %xmm1,%xmm0
  movss  %xmm0,(%rdx)
L366:
  add    $0x4,%rax
  cmp    %r8,%rax
  jne    L253
L241:
  add    $0x8,%rsi
  cmp    %r12,%rsi
  jne    L462
  mov    0x4(%rsp),%eax
  mov    0x60(%rsp),%r12
  mov    0x68(%rsp),%r13
  test   %eax,%eax
  jle    L57
L11:
  movslq 0x58(%rsp),%rcx
  xor    %r9d,%r9d
  xor    %r11d,%r11d
  test   %ecx,%ecx
  jle    L85
  mov    %rbp,0x48(%rsp)
  mov    0x38(%rsp),%rbp
  nopl   0x0(%rax,%rax,1)
L356:
  mov    0x10(%rsp),%rax
  mov    %r9d,0x18(%rsp)
  movslq %r9d,%r10
  xor    %edx,%edx
  lea    (%rax,%r10,1),%r8
  add    0x8(%rsp),%r10
  nopl   0x0(%rax,%rax,1)
L331:
  movzbl (%r8,%rdx,1),%eax
  test   %al,%al
  je     L390
  pxor   %xmm0,%xmm0
  pxor   %xmm2,%xmm2
  mov    (%rbx,%rax,8),%rdi
  mov    (%r15,%rax,8),%r9
  cvtsi2ss %r11d,%xmm0
  lea    0x0(%rbp,%rax,4),%rsi
  cvtsi2ss %edx,%xmm2
  movaps %xmm0,%xmm1
  subss  0x0(%r13,%rax,4),%xmm1
  movaps %xmm2,%xmm3
  subss  (%r12,%rax,4),%xmm3
  mov    (%r14,%rax,8),%rax
  mulss  %xmm1,%xmm1
  mulss  %xmm3,%xmm3
  addss  %xmm3,%xmm1
  addss  (%rsi),%xmm1
  movss  %xmm1,(%rsi)
  movzbl (%r10,%rdx,1),%esi
  subss  (%rax,%rsi,4),%xmm2
  subss  (%r9,%rsi,4),%xmm0
  lea    (%rdi,%rsi,4),%rdi
  mulss  %xmm0,%xmm0
  movaps %xmm2,%xmm1
  mulss  %xmm2,%xmm1
  addss  %xmm1,%xmm0
  addss  (%rdi),%xmm0
  movss  %xmm0,(%rdi)
L390:
  add    $0x1,%rdx
  cmp    %rcx,%rdx
  jne    L331
  mov    0x18(%rsp),%r9d
  add    $0x1,%r11d
  add    0x58(%rsp),%r9d
  cmp    %r11d,0x4(%rsp)
  jne    L356
  mov    0x48(%rsp),%rbp
L85:
  mov    0x30(%rsp),%eax
  lea    -0x1(%rax),%edi
  mov    %edi,0x48(%rsp)
  mov    0x28(%rsp),%edi
  sub    $0x1,%edi
  mov    %edi,0x18(%rsp)
  test   %eax,%eax
  jle    L254
L57:
  mov    0x48(%rsp),%ecx
  mov    0x40(%rsp),%rdi
  lea    0x8(%rbx),%r11
  mov    %r12,0x8(%rsp)
  mov    %r11,0x60(%rsp)
  mov    %r11,%rsi
  mov    0x18(%rsp),%r11d
  lea    0x8(%rdi,%rcx,4),%r9
  lea    0x4(%rdi),%rax
  mov    0x28(%rsp),%edi
  mov    %rcx,0x88(%rsp)
  mov    %r13,0x48(%rsp)
  mov    %edi,%edx
  mov    %edi,%ecx
  shr    $0x2,%edx
  and    $0xfffffffc,%ecx
  sub    $0x1,%edx
  mov    %ecx,0x10(%rsp)
  mov    %ecx,%r13d
  mov    %rdx,0x80(%rsp)
  add    $0x1,%rdx
  shl    $0x4,%rdx
  mov    %rdx,%r10
  cs nopw 0x0(%rax,%rax,1)
L401:
  test   %edi,%edi
  jle    L96
  movss  (%rax),%xmm0
  mov    (%rsi),%rdx
  cmp    $0x2,%r11d
  jbe    L466
  mov    %rdx,%rcx
  lea    (%r10,%rdx,1),%r8
L285:
  movups (%rcx),%xmm2
  add    $0x10,%rcx
  addss  %xmm2,%xmm0
  movaps %xmm2,%xmm1
  shufps $0x55,%xmm2,%xmm1
  addss  %xmm0,%xmm1
  movaps %xmm2,%xmm0
  unpckhps %xmm2,%xmm0
  shufps $0xff,%xmm2,%xmm2
  addss  %xmm1,%xmm0
  addss  %xmm2,%xmm0
  cmp    %r8,%rcx
  jne    L285
  mov    %r13d,%ecx
  cmp    %edi,%r13d
  je     L196
L130:
  movslq %ecx,%r8
  addss  (%rdx,%r8,4),%xmm0
  lea    0x0(,%r8,4),%r12
  lea    0x1(%rcx),%r8d
  cmp    %edi,%r8d
  jge    L196
  add    $0x2,%ecx
  addss  0x4(%rdx,%r12,1),%xmm0
  cmp    %ecx,%edi
  jle    L196
  addss  0x8(%rdx,%r12,1),%xmm0
L196:
  movss  %xmm0,(%rax)
L96:
  add    $0x4,%rax
  add    $0x8,%rsi
  cmp    %r9,%rax
  jne    L401
  mov    0x48(%rsp),%r13
  mov    0x8(%rsp),%r12
  mov    $0x1,%edx
  pxor   %xmm3,%xmm3
  mov    0x60(%rsp),%r11
  mov    %r14,0x70(%rsp)
  movaps %xmm3,%xmm0
  mov    %rbp,%r14
  mov    %r12,0x48(%rsp)
  mov    0x38(%rsp),%rbp
  lea    D11(%rip),%rcx
  mov    %r13,0x60(%rsp)
  mov    0x30(%rsp),%r12d
  mov    %rbx,0x78(%rsp)
  mov    0x40(%rsp),%r13
  mov    %r15,0x30(%rsp)
  mov    0xd0(%rsp),%rbx
  mov    %rdx,%r15
  mov    %r11,0x68(%rsp)
  jmp    L213
  nopl   0x0(%rax,%rax,1)
L244:
  movss  0x0(%rbp,%r15,4),%xmm1
  mov    0x20(%rsp),%rax
  subss  %xmm2,%xmm1
  movss  %xmm1,(%rax,%r15,4)
  divss  %xmm2,%xmm1
  pxor   %xmm2,%xmm2
  cvtsi2ssl (%r14,%r15,4),%xmm2
  movss  %xmm1,(%rbx,%r15,4)
  mulss  %xmm2,%xmm1
  add    $0x1,%r15
  addss  %xmm1,%xmm0
  cmp    %r15d,%r12d
  jl     L303
L213:
  movss  0x0(%r13,%r15,4),%xmm2
  mov    %r15d,%esi
  ucomiss %xmm3,%xmm2
  jp     L244
  jne    L244
  mov    %rcx,%rdi
  xor    %eax,%eax
  add    $0x1,%r15
  movss  %xmm0,0x8(%rsp)
  call   <printf@plt>
  movss  0x8(%rsp),%xmm0
  lea    D11(%rip),%rcx
  pxor   %xmm3,%xmm3
  cmp    %r15d,%r12d
  jge    L213
L303:
  pxor   %xmm1,%xmm1
  mov    0xe0(%rsp),%ecx
  mov    %r14,%rbp
  mov    0x48(%rsp),%r12
  cvtsi2ssl 0x4(%rsp),%xmm1
  mov    0x60(%rsp),%r13
  mov    0x68(%rsp),%r11
  mov    0x30(%rsp),%r15
  mov    0x70(%rsp),%r14
  mov    0x78(%rsp),%rbx
  divss  %xmm1,%xmm0
  pxor   %xmm1,%xmm1
  cvtsi2ssl 0x58(%rsp),%xmm1
  divss  %xmm1,%xmm0
  test   %ecx,%ecx
  jle    L446
  movslq 0x28(%rsp),%rax
  movslq 0x10(%rsp),%r9
  mov    %r12,0x30(%rsp)
  mov    0x80(%rsp),%rsi
  mov    %rbp,0x48(%rsp)
  lea    0x0(,%rax,4),%rdx
  mov    %rax,%rcx
  mov    0x38(%rsp),%rax
  mov    %r9,%rdi
  mov    %rdx,0x8(%rsp)
  mov    0x18(%rsp),%edx
  add    $0x1,%rsi
  shl    $0x2,%r9
  lea    0x4(%rax),%r8
  mov    %r14,0x60(%rsp)
  mov    0x8(%rsp),%r12
  shl    $0x4,%rsi
  mov    0x88(%rsp),%rax
  mov    %r13,0x8(%rsp)
  mov    %rdx,%rbp
  mov    %rbx,0x68(%rsp)
  lea    0x10(%rbx,%rax,8),%rax
  mov    %rax,0x28(%rsp)
  lea    0x1(%rdi),%eax
  mov    0x28(%rsp),%r13
  mov    %eax,0x4(%rsp)
  cltq
  lea    0x0(,%rax,4),%r10
  lea    0x2(%rdi),%eax
  mov    %r15,0x28(%rsp)
  mov    %eax,0x58(%rsp)
  cltq
  lea    0x0(,%rax,4),%rdi
  mov    0xd8(%rsp),%rax
  mov    %rdi,%r15
  sub    %rbx,%rax
  mov    %ecx,%ebx
  mov    %rax,%r14
  nopw   0x0(%rax,%rax,1)
L203:
  mov    (%r14,%r11,1),%rax
  test   %ebx,%ebx
  jle    L197
  mov    (%r11),%rdx
  mov    %rax,%rcx
  lea    0x4(%rdx),%rdi
  sub    %rdi,%rcx
  cmp    $0x8,%rcx
  mov    $0x0,%ecx
  jbe    L324
  cmpl   $0x2,0x18(%rsp)
  jbe    L324
  nopw   0x0(%rax,%rax,1)
L62:
  movups (%rdx,%rcx,1),%xmm4
  movups %xmm4,(%rax,%rcx,1)
  add    $0x10,%rcx
  cmp    %rsi,%rcx
  jne    L62
  cmp    %ebx,0x10(%rsp)
  je     L197
  movss  (%rdx,%r9,1),%xmm1
  movss  %xmm1,(%rax,%r9,1)
  cmp    0x4(%rsp),%ebx
  jle    L197
  movss  (%rdx,%r10,1),%xmm1
  movss  %xmm1,(%rax,%r10,1)
  cmp    %ebx,0x58(%rsp)
  jge    L197
  movss  (%rdx,%r15,1),%xmm1
  movss  %xmm1,(%rax,%r15,1)
L197:
  movss  (%r8),%xmm1
  add    $0x8,%r11
  add    $0x4,%r8
  movss  %xmm1,(%rax,%r12,1)
  cmp    %r11,%r13
  jne    L203
  mov    0x30(%rsp),%r12
  mov    0x8(%rsp),%r13
  mov    0x48(%rsp),%rbp
  mov    0x28(%rsp),%r15
  mov    0x60(%rsp),%r14
  mov    0x68(%rsp),%rbx
L446:
  mov    %r12,%rdi
  movss  %xmm0,0x4(%rsp)
  call   <free@plt>
  mov    %r13,%rdi
  call   <free@plt>
  mov    %rbp,%rdi
  call   <free@plt>
  mov    0x38(%rsp),%rdi
  call   <free@plt>
  mov    0x20(%rsp),%rdi
  call   <free@plt>
  mov    0x40(%rsp),%rdi
  call   <free@plt>
  mov    0x5c(%rsp),%ebp
  mov    %r14,%rdi
  xor    %eax,%eax
  mov    %ebp,%esi
  call   <free_fmatrix@plt>
  mov    %ebp,%esi
  mov    %r15,%rdi
  xor    %eax,%eax
  call   <free_fmatrix@plt>
  mov    0x50(%rsp),%rdi
  mov    %ebp,%esi
  xor    %eax,%eax
  call   <free_imatrix@plt>
  mov    %ebp,%esi
  mov    %rbx,%rdi
  xor    %eax,%eax
  call   <free_fmatrix@plt>
  movss  0x4(%rsp),%xmm0
  add    $0x98,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax,%rax,1)
L324:
  movss  (%rdx,%rcx,4),%xmm1
  mov    %rcx,%rdi
  movss  %xmm1,(%rax,%rcx,4)
  add    $0x1,%rcx
  cmp    %rbp,%rdi
  jne    L324
  jmp    L197
L466:
  xor    %ecx,%ecx
  jmp    L130
L332:
  mov    0x4(%rsp),%edx
  test   %edx,%edx
  jg     L11
L254:
  pxor   %xmm1,%xmm1
  pxor   %xmm0,%xmm0
  cvtsi2ssl 0x4(%rsp),%xmm1
  divss  %xmm1,%xmm0
  pxor   %xmm1,%xmm1
  cvtsi2ssl 0x58(%rsp),%xmm1
  divss  %xmm1,%xmm0
  jmp    L446
L450:
  mov    $0x1,%edx
  jmp    L340
```

tool_calls: name: retrieve_data
arguments: data_label: D11
data_type: string

tool: D11: Sw[%d]=0


assistant: ```c
float gettotalJS(unsigned char *cmap, int N, int ny, int nx, unsigned char *rmap, int TR, float *totalJ, float **mapmatrix, int oldTR) {
  int iy, ix, i, j, *StN, **avgN, l;
  float *St, *Sb, *Sw, *Stmeanx, *Stmeany, **avgy, **avgx, overallJ, **var;
  int debug = 0;
  St = (float *)calloc(TR + 1, sizeof(float));
  Sb = (float *)calloc(TR + 1, sizeof(float));
  Sw = (float *)calloc(TR + 1, sizeof(float));
  Stmeanx = (float *)calloc(TR + 1, sizeof(float));
  Stmeany = (float *)calloc(TR + 1, sizeof(float));
  StN = (int *)calloc(TR + 1, sizeof(int));
  avgy = (float **)fmatrix(TR + 1, N);
  avgx = (float **)fmatrix(TR + 1, N);
  avgN = (int **)imatrix(TR + 1, N);
  var = (float **)fmatrix(TR + 1, N);
  l = 0;
  for (iy = 0; iy < ny; iy++) {
    for (ix = 0; ix < nx; ix++) {
      if (rmap[l] > 0) {
        i = rmap[l];
        j = cmap[l];
        Stmeanx[i] += ix;
        Stmeany[i] += iy;
        StN[i]++;
        avgx[i][j] += ix;
        avgy[i][j] += iy;
        avgN[i][j]++;
      }
      l++;
    }
  }
  for (i = 1; i <= TR; i++) {
    Stmeanx[i] /= StN[i];
    Stmeany[i] /= StN[i];
    for (j = 0; j < N; j++) {
      if (avgN[i][j] > 0) {
        avgx[i][j] /= avgN[i][j];
        avgy[i][j] /= avgN[i][j];
      }
    }
  }
  l = 0;
  for (iy = 0; iy < ny; iy++) {
    for (ix = 0; ix < nx; ix++) {
      if (rmap[l] > 0) {
        i = rmap[l];
        j = cmap[l];
        St[i] += ((iy - Stmeany[i]) * (iy - Stmeany[i])) + ((ix - Stmeanx[i]) * (ix - Stmeanx[i]));
        var[i][j] += ((iy - avgy[i][j]) * (iy - avgy[i][j])) + ((ix - avgx[i][j]) * (ix - avgx[i][j]));
      }
      l++;
    }
  }
  for (i = 1; i <= TR; i++) {
    for (j = 0; j < N; j++)
      Sw[i] += var[i][j];
  }
  overallJ = 0;
  for (i = 1; i <= TR; i++) {
    if (Sw[i] == 0)
      printf("Sw[%d]=0\n", i);
    else {
      Sb[i] = St[i] - Sw[i];
      totalJ[i] = Sb[i] / Sw[i];
      overallJ += StN[i] * totalJ[i];
    }
  }
  overallJ = overallJ / ny / nx;
  if (debug)
    printf("\n%5.3f\n", overallJ);
  if (oldTR > 0) {
    for (i = 1; i <= TR; i++) {
      for (j = 0; j < N; j++)
        mapmatrix[i][j] = var[i][j];
      mapmatrix[i][N] = St[i];
    }
  }
  free(Stmeanx);
  free(Stmeany);
  free(StN);
  free(St);
  free(Sb);
  free(Sw);
  free_fmatrix(avgx, TR + 1);
  free_fmatrix(avgy, TR + 1);
  free_imatrix(avgN, TR + 1);
  free_fmatrix(var, TR + 1);
  return overallJ;
}
```