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

```asm
<__BetterVBalance>:
  endbr64
  push   %r15
  push   %r14
  mov    %rcx,%r14
  push   %r13
  push   %r12
  mov    %r8,%r12
  push   %rbp
  mov    %rdx,%rbp
  push   %rbx
  sub    $0x18,%rsp
  cmp    $0xffffffff,%esi
  je     L17
  cmp    $0x1,%esi
  je     L58
  lea    D6(%rip),%rdi
  call   <__errexit@plt>
L64:
  add    $0x18,%rsp
  pxor   %xmm0,%xmm0
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax,%rax,1)
L58:
  test   %edi,%edi
  jle    L64
  pxor   %xmm1,%xmm1
  movslq %edi,%r13
  xor    %eax,%eax
  movaps %xmm1,%xmm2
L24:
  movss  0x0(%rbp,%rax,4),%xmm0
  movss  (%r14,%rax,4),%xmm3
  addss  %xmm0,%xmm3
  addss  (%r12,%rax,4),%xmm0
  add    $0x1,%rax
  addss  %xmm3,%xmm2
  addss  %xmm0,%xmm1
  cmp    %rax,%r13
  jne    L24
  pxor   %xmm0,%xmm0
  cvtss2sd %xmm2,%xmm2
  cvtss2sd %xmm1,%xmm1
  pxor   %xmm6,%xmm6
  cvtsi2sd %edi,%xmm0
  xor    %ebx,%ebx
  divsd  %xmm0,%xmm2
  divsd  %xmm0,%xmm1
  cvtsd2ss %xmm2,%xmm6
  movd   %xmm6,%r15d
  pxor   %xmm6,%xmm6
  cvtsd2ss %xmm1,%xmm6
  pxor   %xmm1,%xmm1
  movss  %xmm6,0xc(%rsp)
  movss  %xmm1,0x4(%rsp)
  cs nopw 0x0(%rax,%rax,1)
L28:
  movss  0x0(%rbp,%rbx,4),%xmm0
  addss  (%r14,%rbx,4),%xmm0
  movd   %r15d,%xmm2
  movss  %xmm1,0x8(%rsp)
  subss  %xmm0,%xmm2
  movaps %xmm2,%xmm0
  call   <fabs@plt>
  pxor   %xmm0,%xmm0
  movss  0xc(%rsp),%xmm2
  cvtsi2ss %rax,%xmm0
  addss  0x4(%rsp),%xmm0
  movss  %xmm0,0x4(%rsp)
  movss  0x0(%rbp,%rbx,4),%xmm0
  addss  (%r12,%rbx,4),%xmm0
  add    $0x1,%rbx
  subss  %xmm0,%xmm2
  movaps %xmm2,%xmm0
  call   <fabs@plt>
  pxor   %xmm0,%xmm0
  movss  0x8(%rsp),%xmm1
  cvtsi2ss %rax,%xmm0
  addss  %xmm0,%xmm1
  cmp    %rbx,%r13
  jne    L28
  movss  0x4(%rsp),%xmm0
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  subss  %xmm1,%xmm0
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax,%rax,1)
L17:
  movss  (%rdx),%xmm3
  movss  (%rcx),%xmm0
  addss  %xmm3,%xmm0
  addss  (%r8),%xmm3
  cmp    $0x1,%edi
  jle    L61
  movslq %edi,%rdi
  movaps %xmm3,%xmm5
  movaps %xmm0,%xmm7
  mov    $0x1,%eax
  movaps %xmm3,%xmm4
  movaps %xmm0,%xmm6
  xchg   %ax,%ax
L59:
  movss  0x0(%rbp,%rax,4),%xmm1
  movss  (%r14,%rax,4),%xmm2
  addss  %xmm1,%xmm2
  addss  (%r12,%rax,4),%xmm1
  add    $0x1,%rax
  movaps %xmm2,%xmm8
  movaps %xmm2,%xmm9
  movaps %xmm1,%xmm10
  movaps %xmm1,%xmm11
  maxss  %xmm0,%xmm8
  minss  %xmm7,%xmm9
  maxss  %xmm3,%xmm10
  minss  %xmm5,%xmm11
  addss  %xmm2,%xmm6
  addss  %xmm1,%xmm4
  movaps %xmm8,%xmm0
  movaps %xmm9,%xmm7
  movaps %xmm10,%xmm3
  movaps %xmm11,%xmm5
  cmp    %rax,%rdi
  jne    L59
L52:
  subss  %xmm7,%xmm0
  subss  %xmm5,%xmm3
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  divss  %xmm6,%xmm0
  pop    %r14
  pop    %r15
  divss  %xmm4,%xmm3
  subss  %xmm3,%xmm0
  ret
L61:
  movaps %xmm3,%xmm5
  movaps %xmm0,%xmm7
  movaps %xmm3,%xmm4
  movaps %xmm0,%xmm6
  jmp    L52
```

tool_calls: name: read_data
arguments: tag: D6
type: string

tool: D6: 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;
}
```