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

```asm
<conservativeHeadRichardsMualemVanGenuchtenHetEvaluateV2withUpwindAndHarm>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0xf8,%rsp
  mov    %edi,0x70(%rsp)
  mov    %esi,%r13d
  mov    %edx,%ebx
  mov    %ecx,0x4c(%rsp)
  mov    %r8d,%r15d
  mov    %r9d,0x74(%rsp)
  movsd  %xmm0,0x8(%rsp)
  movsd  %xmm1,0x20(%rsp)
  mov    0x148(%rsp),%rbp
  mov    0x1d8(%rsp),%r14
  mov    0x1e0(%rsp),%r12
  mov    %r8d,%eax
  imul   %r8d,%eax
  mov    %eax,0xc8(%rsp)
  movapd %xmm0,%xmm7
  mulsd  %xmm0,%xmm7
  movsd  %xmm7,0x40(%rsp)
  test   %edi,%edi
  jg     L60
L97:
  test   %ebx,%ebx
  jle    L244
  mov    0x140(%rsp),%rax
  mov    %rax,0xa8(%rsp)
  mov    0xc8(%rsp),%edi
  mov    %edi,%eax
  imul   0x4c(%rsp),%eax
  mov    %eax,0xd4(%rsp)
  lea    -0x1(%rbx),%eax
  mov    0x140(%rsp),%rbx
  lea    0x4(%rbx,%rax,4),%rax
  mov    %rax,0xd8(%rsp)
  movslq %edi,%rax
  shl    $0x3,%rax
  mov    %rax,0x18(%rsp)
  mov    %rbx,0xb0(%rsp)
  movl   $0x0,0xe8(%rsp)
  movl   $0x0,0xd0(%rsp)
  movl   $0x0,0xcc(%rsp)
  mov    %r15d,0xec(%rsp)
  mov    %r13d,%r15d
  mov    %rbp,0x148(%rsp)
  mov    %r14,0x1d8(%rsp)
  mov    %r12,0x1e0(%rsp)
  jmp    L127
L60:
  mov    %esi,%edi
  mov    $0x0,%eax
  call   <assert@plt>
  jmp    L97
L304:
  mov    0xb8(%rsp),%rax
  movsd  (%rax),%xmm7
  mov    0xc0(%rsp),%rax
  movsd  (%rax),%xmm3
  movsd  0x10(%rsp),%xmm0
  xorpd  D21(%rip),%xmm0
  movsd  %xmm3,0x38(%rsp)
  mulsd  %xmm3,%xmm0
  movsd  %xmm7,0x30(%rsp)
  movapd %xmm7,%xmm1
  subsd  D64(%rip),%xmm1
  movsd  %xmm0,0x90(%rsp)
  call   <pow@plt>
  movsd  0x90(%rsp),%xmm5
  movapd %xmm5,%xmm4
  movsd  %xmm0,0x90(%rsp)
  mulsd  %xmm0,%xmm4
  movapd %xmm5,%xmm0
  movsd  %xmm4,0x98(%rsp)
  mulsd  %xmm4,%xmm0
  movapd %xmm0,%xmm6
  addsd  D88(%rip),%xmm6
  movsd  D88(%rip),%xmm0
  divsd  0x30(%rsp),%xmm0
  movsd  D88(%rip),%xmm1
  subsd  %xmm0,%xmm1
  xorpd  D21(%rip),%xmm1
  movsd  %xmm6,0xa0(%rsp)
  movapd %xmm6,%xmm0
  call   <pow@plt>
  movsd  D88(%rip),%xmm1
  movsd  0x30(%rsp),%xmm7
  subsd  %xmm7,%xmm1
  movsd  0x38(%rsp),%xmm3
  mulsd  %xmm3,%xmm1
  movapd %xmm0,%xmm2
  divsd  0xa0(%rsp),%xmm2
  mulsd  %xmm2,%xmm1
  movsd  0x98(%rsp),%xmm4
  mulsd  %xmm4,%xmm1
  movapd %xmm1,%xmm8
  movsd  %xmm1,0x38(%rsp)
  movapd %xmm4,%xmm1
  mulsd  %xmm0,%xmm1
  movsd  D88(%rip),%xmm5
  subsd  %xmm1,%xmm5
  movsd  %xmm5,0x98(%rsp)
  mulsd  %xmm5,%xmm5
  movsd  %xmm5,0xa0(%rsp)
  xorpd  D21(%rip),%xmm3
  movapd %xmm3,%xmm1
  subsd  D88(%rip),%xmm7
  mulsd  %xmm7,%xmm1
  mulsd  0x90(%rsp),%xmm1
  mulsd  %xmm0,%xmm1
  mulsd  %xmm8,%xmm4
  subsd  %xmm4,%xmm1
  movsd  %xmm1,0x90(%rsp)
  movq   %r14,%xmm1
  mulsd  %xmm0,%xmm1
  addsd  0x28(%rsp),%xmm1
  movsd  %xmm1,0x28(%rsp)
  movq   %r14,%xmm7
  mulsd  %xmm8,%xmm7
  movsd  %xmm7,0x30(%rsp)
  pxor   %xmm1,%xmm1
  ucomisd %xmm0,%xmm1
  ja     L206
  sqrtsd %xmm0,%xmm0
L87:
  movsd  0xa0(%rsp),%xmm4
  movapd %xmm4,%xmm5
  mulsd  %xmm0,%xmm5
  movq   %xmm5,%r14
  movsd  D0(%rip),%xmm1
  divsd  %xmm0,%xmm1
  mulsd  0x38(%rsp),%xmm1
  mulsd  %xmm4,%xmm1
  addsd  %xmm0,%xmm0
  mulsd  0x98(%rsp),%xmm0
  mulsd  0x90(%rsp),%xmm0
  addsd  %xmm0,%xmm1
  movsd  %xmm1,0x38(%rsp)
  jmp    L101
L206:
  call   <sqrt@plt>
  jmp    L87
L334:
  add    $0x1,%rbx
  mov    0x18(%rsp),%rax
  add    %rax,%r13
  add    %rax,%rbp
  cmp    %ebx,0x4c(%rsp)
  jle    L90
L292:
  mov    0x60(%rsp),%rax
  movsd  (%rax,%rbx,8),%xmm4
  movsd  %xmm4,0x10(%rsp)
  mov    0x50(%rsp),%rax
  movsd  (%rax),%xmm5
  movsd  %xmm5,0x28(%rsp)
  mov    0x58(%rsp),%rax
  mov    (%rax),%r14
  pxor   %xmm0,%xmm0
  comisd %xmm4,%xmm0
  ja     L304
  movq   %r14,%xmm4
  addsd  %xmm5,%xmm4
  movsd  %xmm4,0x28(%rsp)
  movsd  %xmm0,0x38(%rsp)
  mov    D88(%rip),%r14
  movsd  %xmm0,0x30(%rsp)
L101:
  movsd  0x10(%rsp),%xmm0
  mulsd  0x20(%rsp),%xmm0
  call   <exp@plt>
  mulsd  0x8(%rsp),%xmm0
  movsd  0x28(%rsp),%xmm5
  movapd %xmm5,%xmm1
  mulsd  %xmm0,%xmm1
  mov    0x68(%rsp),%rax
  movsd  %xmm1,(%rax,%rbx,8)
  movsd  0x30(%rsp),%xmm1
  mulsd  %xmm0,%xmm1
  mulsd  0x20(%rsp),%xmm0
  mulsd  %xmm5,%xmm0
  subsd  %xmm1,%xmm0
  movsd  %xmm0,(%r15,%rbx,8)
  mov    %r14,0x0(%r13)
  movsd  0x38(%rsp),%xmm0
  xorpd  D21(%rip),%xmm0
  movsd  %xmm0,0x0(%rbp)
  test   %r12d,%r12d
  je     L334
  mov    0x88(%rsp),%rax
  movq   %r14,%xmm1
  mulsd  (%rax,%rbx,8),%xmm1
  mov    0x78(%rsp),%rdi
  addsd  (%rdi),%xmm1
  movsd  %xmm1,(%rdi)
  mulsd  (%rax,%rbx,8),%xmm0
  mov    0x80(%rsp),%rax
  addsd  (%rax),%xmm0
  movsd  %xmm0,(%rax)
  jmp    L334
L90:
  mov    %r12d,%r15d
L164:
  test   %r15d,%r15d
  je     L225
  movslq 0xcc(%rsp),%rax
  shl    $0x3,%rax
  mov    %rax,%rdx
  add    0x1b8(%rsp),%rdx
  movsd  (%rdx),%xmm0
  movsd  0xe0(%rsp),%xmm4
  divsd  %xmm4,%xmm0
  movsd  %xmm0,(%rdx)
  add    0x1c0(%rsp),%rax
  movsd  (%rax),%xmm0
  divsd  %xmm4,%xmm0
  movsd  %xmm0,(%rax)
L225:
  addq   $0x4,0xb0(%rsp)
  mov    0xb0(%rsp),%rax
  mov    0xc8(%rsp),%edi
  add    %edi,0xcc(%rsp)
  mov    0x4c(%rsp),%edi
  add    %edi,0xd0(%rsp)
  mov    0xd4(%rsp),%edi
  add    %edi,0xe8(%rsp)
  cmp    0xd8(%rsp),%rax
  je     L21
L127:
  mov    0xb0(%rsp),%rax
  mov    (%rax),%ecx
  mov    0x4c(%rsp),%ebx
  test   %ebx,%ebx
  jle    L279
  movslq 0xd0(%rsp),%rsi
  mov    0x190(%rsp),%rax
  lea    (%rax,%rsi,8),%rax
  lea    -0x1(%rbx),%edx
  add    %rsi,%rdx
  mov    0x190(%rsp),%rbx
  lea    0x8(%rbx,%rdx,8),%rdx
  pxor   %xmm0,%xmm0
L45:
  addsd  (%rax),%xmm0
  add    $0x8,%rax
  cmp    %rdx,%rax
  jne    L45
  movsd  %xmm0,0xe0(%rsp)
  test   %r15d,%r15d
  jne    L234
L99:
  movslq %ecx,%rax
  shl    $0x3,%rax
  mov    %rax,%rdi
  add    0x158(%rsp),%rdi
  mov    %rdi,0xb8(%rsp)
  mov    %rax,%rbx
  add    0x160(%rsp),%rbx
  mov    %rbx,0x50(%rsp)
  mov    %rax,%rdi
  add    0x168(%rsp),%rdi
  mov    %rdi,0x58(%rsp)
  add    0x150(%rsp),%rax
  mov    %rax,0xc0(%rsp)
  movslq 0xcc(%rsp),%rax
  shl    $0x3,%rax
  mov    %rax,%rbx
  add    0x1b8(%rsp),%rbx
  mov    %rbx,0x78(%rsp)
  add    0x1c0(%rsp),%rax
  mov    %rax,0x80(%rsp)
  movslq 0xe8(%rsp),%rax
  shl    $0x3,%rax
  mov    %rax,%r13
  add    0x1d8(%rsp),%r13
  add    0x1e0(%rsp),%rax
  mov    %rax,%rbp
  movslq 0xd0(%rsp),%rax
  shl    $0x3,%rax
  mov    %rax,%rdi
  add    0x178(%rsp),%rdi
  mov    %rdi,0x60(%rsp)
  mov    %rax,%rbx
  add    0x198(%rsp),%rbx
  mov    %rbx,0x68(%rsp)
  mov    %rax,%rdi
  add    0x1a0(%rsp),%rdi
  add    0x190(%rsp),%rax
  mov    %rax,0x88(%rsp)
  mov    $0x0,%ebx
  mov    %r15d,%r12d
  mov    %rdi,%r15
  jmp    L292
L21:
  mov    0xec(%rsp),%r15d
  mov    0x148(%rsp),%rbp
  mov    0x1d8(%rsp),%r14
  mov    0x1e0(%rsp),%r12
  mov    0x4c(%rsp),%ebx
  mov    %ebx,%eax
  imul   %r15d,%eax
  mov    %eax,0x50(%rsp)
  movslq %r15d,%rax
  lea    0x8(,%rax,8),%rdi
  movl   $0x0,0x38(%rsp)
  movl   $0x0,0x30(%rsp)
  movl   $0x0,0x28(%rsp)
  lea    -0x1(%rbx),%eax
  mov    %rax,0x58(%rsp)
  mov    0x138(%rsp),%rax
  add    $0x4,%rax
  mov    %rax,0x60(%rsp)
  movsd  D62(%rip),%xmm4
  mov    %r15d,%edx
  pxor   %xmm5,%xmm5
  mov    0x130(%rsp),%r13
  jmp    L150
L175:
  test   %r8d,%r8d
  js     L207
  movsd  (%r14,%r9,1),%xmm1
  movsd  (%r12,%r9,1),%xmm2
  cmpl   $0x0,0x70(%rsp)
  jle    L238
L115:
  imul   0xc8(%rsp),%r8d
  movslq %r8d,%r8
  mov    0x1b8(%rsp),%rax
  movsd  (%rax,%r8,8),%xmm1
L228:
  test   %r15d,%r15d
  jle    L170
L238:
  movsd  0x40(%rsp),%xmm3
  movapd %xmm3,%xmm6
  mulsd  %xmm1,%xmm6
  mulsd  %xmm7,%xmm6
  mulsd  %xmm2,%xmm3
  mulsd  %xmm7,%xmm3
  movsd  0x8(%rsp),%xmm0
  mulsd  %xmm0,%xmm1
  mulsd  %xmm7,%xmm1
  mulsd  %xmm0,%xmm2
  mulsd  %xmm7,%xmm2
  movslq %ebx,%rsi
  shl    $0x3,%rsi
  mov    %rsi,%r8
  add    0x1c8(%rsp),%r8
  add    0x1d0(%rsp),%rsi
  mov    %r9,%rcx
  mov    $0x0,%eax
L154:
  movapd %xmm6,%xmm0
  mulsd  0x0(%rbp,%rax,8),%xmm0
  movsd  %xmm0,(%r8,%rax,8)
  movapd %xmm3,%xmm0
  mulsd  0x0(%rbp,%rax,8),%xmm0
  movsd  %xmm0,(%rsi,%rax,8)
  movsd  %xmm1,(%r14,%rcx,1)
  movsd  %xmm2,(%r12,%rcx,1)
  add    $0x1,%rax
  add    %rdi,%rcx
  cmp    %rax,%rdx
  jne    L154
L170:
  add    $0x4,%r11
  add    %r15d,%ebx
  add    0x18(%rsp),%r9
  cmp    0x20(%rsp),%r11
  je     L77
L66:
  mov    (%r11),%eax
  mov    0x10(%rsp),%rsi
  movsd  (%rsi),%xmm1
  lea    (%rax,%rax,1),%r10d
  movslq %r10d,%r10
  mov    0x4(%r13,%r10,4),%r8d
  movapd %xmm1,%xmm0
  test   %r8d,%r8d
  js     L116
  movslq %r8d,%rcx
  mov    0x140(%rsp),%rsi
  movslq (%rsi,%rcx,4),%rcx
  mov    0x170(%rsp),%rsi
  movsd  (%rsi,%rcx,8),%xmm0
L116:
  movapd %xmm1,%xmm7
  addsd  %xmm1,%xmm7
  mulsd  %xmm0,%xmm7
  addsd  %xmm1,%xmm0
  addsd  %xmm4,%xmm0
  divsd  %xmm0,%xmm7
  test   %r15d,%r15d
  jle    L207
  movsd  0x40(%rsp),%xmm6
  mulsd  %xmm7,%xmm6
  movsd  0x8(%rsp),%xmm3
  mulsd  %xmm7,%xmm3
  movslq %ebx,%rcx
  mov    0x180(%rsp),%rsi
  lea    (%rsi,%rcx,8),%rsi
  imul   0x74(%rsp),%eax
  imul   %r15d,%eax
  cltq
  mov    0x188(%rsp),%rcx
  lea    (%rcx,%rax,8),%rcx
  mov    $0x0,%eax
  pxor   %xmm1,%xmm1
L183:
  movapd %xmm6,%xmm0
  mulsd  0x0(%rbp,%rax,8),%xmm0
  movapd %xmm3,%xmm2
  mulsd  (%rsi,%rax,8),%xmm2
  subsd  %xmm2,%xmm0
  mulsd  (%rcx,%rax,8),%xmm0
  addsd  %xmm0,%xmm1
  add    $0x1,%rax
  cmp    %rdx,%rax
  jne    L183
  comisd %xmm5,%xmm1
  jb     L175
L207:
  mov    0x0(%r13,%r10,4),%r8d
  movsd  (%r14,%r9,1),%xmm1
  movsd  (%r12,%r9,1),%xmm2
  cmpl   $0x0,0x70(%rsp)
  jg     L115
  jmp    L228
L77:
  addq   $0x4,0xa8(%rsp)
  mov    0xa8(%rsp),%rax
  mov    0x50(%rsp),%esi
  add    %esi,0x28(%rsp)
  mov    0xd4(%rsp),%esi
  add    %esi,0x30(%rsp)
  mov    0x4c(%rsp),%esi
  add    %esi,0x38(%rsp)
  cmp    0xd8(%rsp),%rax
  je     L244
L150:
  mov    0xa8(%rsp),%rax
  mov    (%rax),%eax
  cmpl   $0x0,0x4c(%rsp)
  jle    L77
  cltq
  mov    0x170(%rsp),%rbx
  lea    (%rbx,%rax,8),%rax
  mov    %rax,0x10(%rsp)
  movslq 0x38(%rsp),%rax
  mov    0x138(%rsp),%rbx
  lea    (%rbx,%rax,4),%r11
  movslq 0x30(%rsp),%r9
  shl    $0x3,%r9
  add    0x58(%rsp),%rax
  mov    0x60(%rsp),%rbx
  lea    (%rbx,%rax,4),%rax
  mov    %rax,0x20(%rsp)
  mov    0x28(%rsp),%ebx
  jmp    L66
L279:
  test   %r15d,%r15d
  je     L225
  movslq 0xcc(%rsp),%rax
  mov    0x1b8(%rsp),%rdi
  movq   $0x0,(%rdi,%rax,8)
  mov    0x1c0(%rsp),%rdi
  movq   $0x0,(%rdi,%rax,8)
  pxor   %xmm7,%xmm7
  movsd  %xmm7,0xe0(%rsp)
  jmp    L164
L234:
  movslq 0xcc(%rsp),%rax
  mov    0x1b8(%rsp),%rdi
  movq   $0x0,(%rdi,%rax,8)
  mov    0x1c0(%rsp),%rdi
  movq   $0x0,(%rdi,%rax,8)
  jmp    L99
L244:
  add    $0xf8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

tool_calls: name: parse_data
arguments: tag: D21
type: f32[4]
name: parse_data
arguments: tag: D64
type: f64
name: parse_data
arguments: tag: D88
type: f64
name: parse_data
arguments: tag: D0
type: f64
name: parse_data
arguments: tag: D62
type: byte[8]

tool: {"D21": [0.0,-0.0,0.0,0.0]}

tool: D64: 2

tool: D88: 1

tool: D0: 0.5

tool: {"D62": [0xa7,0x8e,0xa8,0x99,0xc2,0x57,0xf3,0x3a]}

assistant: ```c
void conservativeHeadRichardsMualemVanGenuchtenHetEvaluateV2withUpwindAndHarm(const int upwindFlag, const int computeAverages, const int nSimplex, const int nPointsPerSimplex, const int nSpace, const int nQuadraturePoints_elementBoundary, const int *elementBoundaryElementsArray, const int *quadraturePointToElementBoundary, const int *materialTypes, const double rho, const double beta, const double *gravity, const double *alpha, const double *n_vg, const double *thetaR, const double *thetaSR, const double *KWs, const double *u, const double *gradu, const double *n_global, const double *dV, double *mass, double *dmass, double *f_avg, double *df_avg, double *a_avg, double *da_avg, double *f, double *df, double *a, double *da) {
  int i, j, k, I, matID;
  const int nSpace2 = nSpace * nSpace;
  register double psiC, pcBar, pcBar_n, pcBar_nM1, pcBar_nM2, onePlus_pcBar_n, sBar, sqrt_sBar, DsBar_DpsiC, thetaW, DthetaW_DpsiC, vBar, vBar2, DvBar_DpsiC, KWr, DKWr_DpsiC, rho2 = rho * rho, thetaS, rhom, drhom, m;
  int eN_upwind, ebN_global;
  register double drive, KWs_harm, KWs_left, KWs_right, krw_val, dkrw_val, vol;
  if (upwindFlag > 0)
    assert(computeAverages);
  for (i = 0; i < nSimplex; i++) {
    matID = materialTypes[i];
    vol = 0.0;
    for (j = 0; j < nPointsPerSimplex; j++)
      vol += dV[i * nPointsPerSimplex + j];
    if (computeAverages) {
      a_avg[i * nSpace2 + 0 * nSpace + 0] = 0.0;
      da_avg[i * nSpace2 + 0 * nSpace + 0] = 0.0;
    }
    for (j = 0; j < nPointsPerSimplex; j++) {
      k = i * nPointsPerSimplex + j;
      psiC = -u[k];
      m = 1.0 - 1.0 / n_vg[matID];
      thetaS = thetaR[matID] + thetaSR[matID];
      if (psiC > 0.0) {
        pcBar = alpha[matID] * psiC;
        pcBar_nM2 = pow(pcBar, n_vg[matID] - 2);
        pcBar_nM1 = pcBar_nM2 * pcBar;
        pcBar_n = pcBar_nM1 * pcBar;
        onePlus_pcBar_n = 1.0 + pcBar_n;
        sBar = pow(onePlus_pcBar_n, -m);
        DsBar_DpsiC = alpha[matID] * (1.0 - n_vg[matID]) * (sBar / onePlus_pcBar_n) * pcBar_nM1;
        vBar = 1.0 - pcBar_nM1 * sBar;
        vBar2 = vBar * vBar;
        DvBar_DpsiC = -alpha[matID] * (n_vg[matID] - 1.0) * pcBar_nM2 * sBar - pcBar_nM1 * DsBar_DpsiC;
        thetaW = thetaSR[matID] * sBar + thetaR[matID];
        DthetaW_DpsiC = thetaSR[matID] * DsBar_DpsiC;
        sqrt_sBar = sqrt(sBar);
        KWr = sqrt_sBar * vBar2;
        DKWr_DpsiC = ((0.5 / sqrt_sBar) * DsBar_DpsiC * vBar2 + 2.0 * sqrt_sBar * vBar * DvBar_DpsiC);
      } else {
        thetaW = thetaS;
        DthetaW_DpsiC = 0.0;
        KWr = 1.0;
        DKWr_DpsiC = 0.0;
      }
      rhom = rho * exp(beta * u[k]);
      drhom = beta * rhom;
      mass[k] = rhom * thetaW;
      dmass[k] = -rhom * DthetaW_DpsiC + drhom * thetaW;
      a[i * nPointsPerSimplex * nSpace2 + j * nSpace2 + 0 * nSpace + 0] = KWr;
      da[i * nPointsPerSimplex * nSpace2 + j * nSpace2 + 0 * nSpace + 0] = -DKWr_DpsiC;
      if (computeAverages) {
        a_avg[i * nSpace2 + 0 * nSpace + 0] += KWr * dV[k];
        da_avg[i * nSpace2 + 0 * nSpace + 0] += -DKWr_DpsiC * dV[k];
      }
    }
    if (computeAverages) {
      a_avg[i * nSpace2 + 0 * nSpace + 0] /= vol;
      da_avg[i * nSpace2 + 0 * nSpace + 0] /= vol;
    }
  }
  for (i = 0; i < nSimplex; i++) {
    matID = materialTypes[i];
    for (j = 0; j < nPointsPerSimplex; j++) {
      k = i * nPointsPerSimplex + j;
      ebN_global = quadraturePointToElementBoundary[k];
      KWs_left = KWs[matID];
      KWs_right = KWs_left;
      if (elementBoundaryElementsArray[ebN_global * 2 + 1] >= 0)
        KWs_right = KWs[materialTypes[elementBoundaryElementsArray[ebN_global * 2 + 1]]];
      KWs_harm = 2.0 * KWs_left * KWs_right / (KWs_left + KWs_right + 1.0e-24);
      drive = 0.0;
      for (I = 0; I < nSpace; I++) {
        drive += (rho2 * KWs_harm * gravity[I] - rho * KWs_harm * gradu[k * nSpace + I]) * n_global[ebN_global * nQuadraturePoints_elementBoundary * nSpace + 0 * nSpace + I];
      }
      if (drive >= 0.0 || elementBoundaryElementsArray[ebN_global * 2 + 1] < 0)
        eN_upwind = elementBoundaryElementsArray[ebN_global * 2 + 0];
      else
        eN_upwind = elementBoundaryElementsArray[ebN_global * 2 + 1];
      krw_val = a[i * nPointsPerSimplex * nSpace2 + j * nSpace2 + 0 * nSpace + 0];
      dkrw_val = da[i * nPointsPerSimplex * nSpace2 + j * nSpace2 + 0 * nSpace + 0];
      if (upwindFlag > 0) {
        krw_val = a_avg[eN_upwind * nSpace2 + 0 * nSpace + 0];
      }
      for (I = 0; I < nSpace; I++) {
        f[k * nSpace + I] = rho2 * krw_val * KWs_harm * gravity[I];
        df[k * nSpace + I] = rho2 * dkrw_val * KWs_harm * gravity[I];
        a[i * nPointsPerSimplex * nSpace2 + j * nSpace2 + I * nSpace + I] = rho * krw_val * KWs_harm;
        da[i * nPointsPerSimplex * nSpace2 + j * nSpace2 + I * nSpace + I] = rho * dkrw_val * KWs_harm;
      }
    }
  }
}
```