user: Please show me the C implementation that matches the assembly code listed below:

```asm
<__BetterVBalance>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    %rdx,%rbp
  mov    %rcx,%r12
  mov    %r8,%r13
  cmp    $0xffffffff,%esi
  je     L33
  cmp    $0x1,%esi
  je     L95
  lea    D9(%rip),%rdi
  call   <__errexit@plt>
  pxor   %xmm0,%xmm0
L101:
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L33:
  movss  (%rdx),%xmm3
  movaps %xmm3,%xmm5
  addss  (%rcx),%xmm5
  addss  (%r8),%xmm3
  cmp    $0x1,%edi
  jle    L76
  mov    %edi,%edi
  movaps %xmm3,%xmm6
  movaps %xmm5,%xmm7
  movaps %xmm3,%xmm4
  movaps %xmm5,%xmm0
  mov    $0x1,%eax
L36:
  movss  0x0(%rbp,%rax,4),%xmm1
  movaps %xmm1,%xmm2
  addss  (%r12,%rax,4),%xmm2
  movaps %xmm2,%xmm8
  maxss  %xmm0,%xmm8
  movaps %xmm8,%xmm0
  movaps %xmm2,%xmm9
  minss  %xmm7,%xmm9
  movaps %xmm9,%xmm7
  addss  0x0(%r13,%rax,4),%xmm1
  movaps %xmm1,%xmm10
  maxss  %xmm4,%xmm10
  movaps %xmm10,%xmm4
  movaps %xmm1,%xmm11
  minss  %xmm6,%xmm11
  movaps %xmm11,%xmm6
  addss  %xmm2,%xmm5
  addss  %xmm1,%xmm3
  add    $0x1,%rax
  cmp    %rdi,%rax
  jne    L36
L104:
  subss  %xmm7,%xmm0
  divss  %xmm5,%xmm0
  subss  %xmm6,%xmm4
  divss  %xmm3,%xmm4
  subss  %xmm4,%xmm0
  jmp    L101
L76:
  movaps %xmm3,%xmm6
  movaps %xmm5,%xmm7
  movaps %xmm3,%xmm4
  movaps %xmm5,%xmm0
  jmp    L104
L95:
  test   %edi,%edi
  jle    L14
  mov    %edi,%r14d
  mov    $0x0,%eax
  pxor   %xmm1,%xmm1
  movaps %xmm1,%xmm2
L53:
  movss  0x0(%rbp,%rax,4),%xmm0
  movaps %xmm0,%xmm3
  addss  (%r12,%rax,4),%xmm3
  addss  %xmm3,%xmm2
  addss  0x0(%r13,%rax,4),%xmm0
  addss  %xmm0,%xmm1
  add    $0x1,%rax
  cmp    %r14,%rax
  jne    L53
  pxor   %xmm0,%xmm0
  cvtsi2sd %edi,%xmm0
  cvtss2sd %xmm2,%xmm2
  divsd  %xmm0,%xmm2
  pxor   %xmm4,%xmm4
  cvtsd2ss %xmm2,%xmm4
  movd   %xmm4,%r15d
  cvtss2sd %xmm1,%xmm1
  divsd  %xmm0,%xmm1
  pxor   %xmm7,%xmm7
  cvtsd2ss %xmm1,%xmm7
  movss  %xmm7,0xc(%rsp)
  mov    $0x0,%ebx
  pxor   %xmm7,%xmm7
  movss  %xmm7,0x8(%rsp)
  movss  %xmm7,0x4(%rsp)
L5:
  movss  0x0(%rbp,%rbx,4),%xmm0
  addss  (%r12,%rbx,4),%xmm0
  movd   %r15d,%xmm1
  subss  %xmm0,%xmm1
  movaps %xmm1,%xmm0
  call   <fabs@plt>
  pxor   %xmm0,%xmm0
  cvtsi2ss %rax,%xmm0
  addss  0x4(%rsp),%xmm0
  movss  %xmm0,0x4(%rsp)
  movss  0x0(%rbp,%rbx,4),%xmm0
  addss  0x0(%r13,%rbx,4),%xmm0
  movss  0xc(%rsp),%xmm1
  subss  %xmm0,%xmm1
  movaps %xmm1,%xmm0
  call   <fabs@plt>
  pxor   %xmm0,%xmm0
  cvtsi2ss %rax,%xmm0
  addss  0x8(%rsp),%xmm0
  movss  %xmm0,0x8(%rsp)
  add    $0x1,%rbx
  cmp    %r14,%rbx
  jne    L5
L102:
  movss  0x4(%rsp),%xmm0
  subss  0x8(%rsp),%xmm0
  jmp    L101
L14:
  pxor   %xmm4,%xmm4
  movss  %xmm4,0x8(%rsp)
  movss  %xmm4,0x4(%rsp)
  jmp    L102
```

tool_calls: name: disassemble_data
arguments: tag: D9
datatype: string

tool: D9: Unknown norm: %d


assistant: ```c
float __BetterVBalance(int ncon, int norm, float *vwgt, float *u1wgt, float *u2wgt) {
  int i;
  float sum1, sum2, max1, max2, min1, min2, diff1, diff2;
  if (norm == -1) {
    max1 = min1 = vwgt[0] + u1wgt[0];
    max2 = min2 = vwgt[0] + u2wgt[0];
    sum1 = vwgt[0] + u1wgt[0];
    sum2 = vwgt[0] + u2wgt[0];
    for (i = 1; i < ncon; i++) {
      if (max1 < vwgt[i] + u1wgt[i])
        max1 = vwgt[i] + u1wgt[i];
      if (min1 > vwgt[i] + u1wgt[i])
        min1 = vwgt[i] + u1wgt[i];
      if (max2 < vwgt[i] + u2wgt[i])
        max2 = vwgt[i] + u2wgt[i];
      if (min2 > vwgt[i] + u2wgt[i])
        min2 = vwgt[i] + u2wgt[i];
      sum1 += vwgt[i] + u1wgt[i];
      sum2 += vwgt[i] + u2wgt[i];
    }
    return ((max1 - min1) / sum1) - ((max2 - min2) / sum2);
  } else if (norm == 1) {
    sum1 = sum2 = 0.0;
    for (i = 0; i < ncon; i++) {
      sum1 += vwgt[i] + u1wgt[i];
      sum2 += vwgt[i] + u2wgt[i];
    }
    sum1 = sum1 / (1.0 * ncon);
    sum2 = sum2 / (1.0 * ncon);
    diff1 = diff2 = 0.0;
    for (i = 0; i < ncon; i++) {
      diff1 += fabs(sum1 - (vwgt[i] + u1wgt[i]));
      diff2 += fabs(sum2 - (vwgt[i] + u2wgt[i]));
    }
    return diff1 - diff2;
  } else {
    __errexit("Unknown norm: %d\n", norm);
  }
  return 0.0;
}
```