user: 这段汇编代码用C语言表示是什么样的？

```asm
<conservativeHeadRichardsMualemVanGenuchtenHetEvaluateV2withUpwindAndHarm_sd>:
  endbr64
  push   %r15
  movapd %xmm0,%xmm7
  movslq %r8d,%rax
  movapd %xmm0,%xmm4
  push   %r14
  mulsd  %xmm0,%xmm7
  mov    %esi,%r14d
  mov    %eax,%esi
  push   %r13
  imul   %eax,%esi
  push   %r12
  mov    %edx,%r12d
  push   %rbp
  push   %rbx
  sub    $0xe8,%rsp
  mov    0x120(%rsp),%rbp
  mov    %eax,0xdc(%rsp)
  mov    %edi,0x5c(%rsp)
  mov    0x128(%rsp),%rbx
  mov    0x0(%rbp,%rax,4),%eax
  mov    %ecx,0x58(%rsp)
  mov    %r9d,0x60(%rsp)
  mov    0x148(%rsp),%r13
  mov    %esi,0xd8(%rsp)
  mov    %eax,0x34(%rsp)
  movsd  %xmm1,0x8(%rsp)
  movsd  %xmm7,0xd0(%rsp)
  test   %edi,%edi
  jle    L310
  mov    %r14d,%edi
  xor    %eax,%eax
  mov    %r10d,0x10(%rsp)
  movsd  %xmm0,0x18(%rsp)
  call   <assert@plt>
  movsd  0x18(%rsp),%xmm4
  mov    0x10(%rsp),%r10d
L310:
  test   %r12d,%r12d
  jle    L171
  mov    0x140(%rsp),%rax
  mov    0x140(%rsp),%rdi
  movl   $0x0,0xb4(%rsp)
  movl   $0x0,0xc0(%rsp)
  mov    %rax,0x98(%rsp)
  mov    0x58(%rsp),%eax
  imul   0x34(%rsp),%eax
  mov    %rdi,0x90(%rsp)
  movl   $0x0,0xb0(%rsp)
  movl   $0x0,0x64(%rsp)
  mov    %eax,0xc4(%rsp)
  lea    -0x1(%r12),%eax
  lea    0x4(%rdi,%rax,4),%rax
  mov    %rbx,0x128(%rsp)
  mov    %rax,0xb8(%rsp)
  mov    %r13,0x148(%rsp)
  movsd  %xmm4,0x38(%rsp)
L93:
  mov    0x90(%rsp),%rax
  mov    0x58(%rsp),%edi
  mov    (%rax),%esi
  test   %edi,%edi
  jle    L11
  movslq 0xc0(%rsp),%rcx
  mov    0x190(%rsp),%rax
  lea    -0x1(%rdi),%edx
  pxor   %xmm0,%xmm0
  mov    0x190(%rsp),%rbx
  add    %rcx,%rdx
  lea    (%rax,%rcx,8),%rax
  lea    0x8(%rbx,%rdx,8),%rdx
  nopl   0x0(%rax,%rax,1)
L42:
  addsd  (%rax),%xmm0
  add    $0x8,%rax
  cmp    %rax,%rdx
  jne    L42
  movsd  %xmm0,0xc8(%rsp)
  test   %r14d,%r14d
  je     L288
  movslq 0xb0(%rsp),%rax
  mov    0x1b8(%rsp),%rbx
  movq   $0x0,(%rbx,%rax,8)
  mov    0x1c0(%rsp),%rbx
  movq   $0x0,(%rbx,%rax,8)
L288:
  mov    0x158(%rsp),%rbx
  movslq %esi,%rax
  mov    0x160(%rsp),%r15
  shl    $0x3,%rax
  mov    0x168(%rsp),%r13
  mov    0x1a0(%rsp),%rdi
  add    %rax,%rbx
  add    %rax,%r15
  mov    0xb4(%rsp),%r12d
  mov    %rbx,0xa0(%rsp)
  add    %rax,%r13
  mov    0x178(%rsp),%rbx
  add    0x150(%rsp),%rax
  mov    %rax,0xa8(%rsp)
  lea    0x0(,%rcx,8),%rax
  add    %rax,%rbx
  add    %rax,%rdi
  mov    %rbx,0x50(%rsp)
  mov    0x198(%rsp),%rbx
  mov    %rdi,0x40(%rsp)
  add    %rax,%rbx
  add    0x190(%rsp),%rax
  mov    %rax,0x68(%rsp)
  xor    %eax,%eax
  mov    %rbx,0x48(%rsp)
  mov    %r12d,%ebx
  mov    %rax,%r12
  jmp    L265
  nopl   (%rax)
L264:
  mov    D138(%rip),%rax
  addsd  %xmm9,%xmm3
  movq   $0x0,0x10(%rsp)
  movq   %rax,%xmm1
  mov    D47(%rip),%rax
  movq   %rax,%xmm4
L87:
  mulsd  0x8(%rsp),%xmm2
  movsd  %xmm1,0x28(%rsp)
  movsd  %xmm4,0x20(%rsp)
  movsd  %xmm3,0x18(%rsp)
  movapd %xmm2,%xmm0
  call   <exp@plt>
  mulsd  0x38(%rsp),%xmm0
  movsd  0x18(%rsp),%xmm3
  mov    0x48(%rsp),%rax
  mov    0x0(%rbp),%r10d
  movapd %xmm3,%xmm2
  movsd  0x20(%rsp),%xmm4
  movsd  0x28(%rsp),%xmm1
  lea    (%rbx,%r10,1),%ecx
  movslq %ecx,%rcx
  mulsd  %xmm0,%xmm2
  movsd  %xmm2,(%rax,%r12,8)
  movsd  0x10(%rsp),%xmm2
  mov    0x40(%rsp),%rax
  mulsd  %xmm0,%xmm2
  mulsd  0x8(%rsp),%xmm0
  mulsd  %xmm3,%xmm0
  subsd  %xmm2,%xmm0
  movsd  %xmm0,(%rax,%r12,8)
  mov    0x1d8(%rsp),%rax
  movsd  %xmm4,(%rax,%rcx,8)
  mov    0x1e0(%rsp),%rax
  movsd  %xmm1,(%rax,%rcx,8)
  test   %r14d,%r14d
  je     L6
  mov    0x64(%rsp),%eax
  mov    0x1b8(%rsp),%rsi
  lea    (%rax,%r10,1),%ecx
  mov    0x68(%rsp),%rax
  movslq %ecx,%rcx
  mulsd  (%rax,%r12,8),%xmm4
  shl    $0x3,%rcx
  add    %rcx,%rsi
  add    0x1c0(%rsp),%rcx
  addsd  (%rsi),%xmm4
  movsd  %xmm4,(%rsi)
  mulsd  (%rax,%r12,8),%xmm1
  addsd  (%rcx),%xmm1
  movsd  %xmm1,(%rcx)
L6:
  add    $0x1,%r12
  add    0x34(%rsp),%ebx
  cmp    %r12d,0x58(%rsp)
  jle    L170
L265:
  mov    0x50(%rsp),%rax
  pxor   %xmm7,%xmm7
  movsd  (%r15),%xmm3
  movsd  0x0(%r13),%xmm9
  movsd  (%rax,%r12,8),%xmm2
  comisd %xmm2,%xmm7
  jbe    L264
  mov    0xa0(%rsp),%rax
  movapd %xmm2,%xmm5
  xorpd  D138(%rip),%xmm5
  movsd  %xmm9,0x88(%rsp)
  movsd  %xmm3,0x80(%rsp)
  movsd  (%rax),%xmm12
  mov    0xa8(%rsp),%rax
  movsd  %xmm2,0x78(%rsp)
  movsd  (%rax),%xmm4
  movapd %xmm12,%xmm1
  movsd  %xmm12,0x18(%rsp)
  subsd  D93(%rip),%xmm1
  mulsd  %xmm4,%xmm5
  movsd  %xmm4,0x70(%rsp)
  movapd %xmm5,%xmm0
  movsd  %xmm5,0x10(%rsp)
  call   <pow@plt>
  movsd  0x10(%rsp),%xmm5
  movsd  0x18(%rsp),%xmm12
  movsd  %xmm0,0x28(%rsp)
  movsd  D47(%rip),%xmm1
  movapd %xmm5,%xmm10
  mulsd  %xmm0,%xmm10
  movsd  D47(%rip),%xmm0
  divsd  %xmm12,%xmm0
  mulsd  %xmm10,%xmm5
  movsd  %xmm10,0x20(%rsp)
  addsd  D47(%rip),%xmm5
  movsd  %xmm5,0x10(%rsp)
  subsd  %xmm0,%xmm1
  xorpd  D138(%rip),%xmm1
  movapd %xmm5,%xmm0
  call   <pow@plt>
  movsd  0x10(%rsp),%xmm5
  movsd  0x18(%rsp),%xmm12
  movapd %xmm0,%xmm1
  movsd  0x70(%rsp),%xmm4
  movsd  D47(%rip),%xmm8
  divsd  %xmm5,%xmm1
  movsd  0x78(%rsp),%xmm2
  movsd  0x20(%rsp),%xmm10
  subsd  %xmm12,%xmm8
  movsd  0x28(%rsp),%xmm11
  subsd  D47(%rip),%xmm12
  movsd  0x88(%rsp),%xmm9
  movsd  D47(%rip),%xmm6
  movsd  0x80(%rsp),%xmm3
  mulsd  %xmm4,%xmm8
  xorpd  D138(%rip),%xmm4
  mulsd  %xmm12,%xmm4
  mulsd  %xmm11,%xmm4
  movapd %xmm4,%xmm5
  pxor   %xmm4,%xmm4
  mulsd  %xmm0,%xmm5
  ucomisd %xmm0,%xmm4
  mulsd  %xmm1,%xmm8
  movapd %xmm10,%xmm1
  mulsd  %xmm0,%xmm1
  mulsd  %xmm10,%xmm8
  subsd  %xmm1,%xmm6
  movapd %xmm9,%xmm1
  mulsd  %xmm0,%xmm1
  movapd %xmm6,%xmm7
  mulsd  %xmm8,%xmm10
  mulsd  %xmm8,%xmm9
  mulsd  %xmm6,%xmm7
  addsd  %xmm1,%xmm3
  subsd  %xmm10,%xmm5
  movsd  %xmm9,0x10(%rsp)
  ja     L159
  sqrtsd %xmm0,%xmm0
L84:
  movsd  D75(%rip),%xmm1
  movapd %xmm7,%xmm4
  mulsd  %xmm0,%xmm4
  divsd  %xmm0,%xmm1
  addsd  %xmm0,%xmm0
  mulsd  %xmm6,%xmm0
  mulsd  %xmm5,%xmm0
  mulsd  %xmm8,%xmm1
  mulsd  %xmm7,%xmm1
  addsd  %xmm0,%xmm1
  xorpd  D138(%rip),%xmm1
  jmp    L87
L170:
  test   %r14d,%r14d
  je     L212
L160:
  mov    0x64(%rsp),%eax
  mov    0x1b8(%rsp),%rdx
  movsd  0xc8(%rsp),%xmm7
  add    %r10d,%eax
  cltq
  shl    $0x3,%rax
  add    %rax,%rdx
  add    0x1c0(%rsp),%rax
  movsd  (%rdx),%xmm0
  divsd  %xmm7,%xmm0
  movsd  %xmm0,(%rdx)
  movsd  (%rax),%xmm0
  divsd  %xmm7,%xmm0
  movsd  %xmm0,(%rax)
L212:
  mov    0x34(%rsp),%edi
  mov    0xd8(%rsp),%ebx
  addq   $0x4,0x90(%rsp)
  mov    0x90(%rsp),%rax
  add    %edi,0x64(%rsp)
  mov    0x58(%rsp),%edi
  add    %ebx,0xb0(%rsp)
  mov    0xc4(%rsp),%ebx
  add    %edi,0xc0(%rsp)
  add    %ebx,0xb4(%rsp)
  cmp    %rax,0xb8(%rsp)
  jne    L93
  mov    0xdc(%rsp),%r11d
  mov    %edi,%eax
  movl   $0x0,0x48(%rsp)
  pxor   %xmm2,%xmm2
  movl   $0x0,0x50(%rsp)
  mov    0x128(%rsp),%rbx
  imul   %r11d,%eax
  lea    -0x1(%r11),%r12d
  movl   $0x0,0x64(%rsp)
  movsd  0x38(%rsp),%xmm4
  mov    %r12d,0x40(%rsp)
  mov    0x148(%rsp),%r13
  movsd  0xd0(%rsp),%xmm7
  mov    %eax,0x68(%rsp)
  movslq 0x34(%rsp),%rax
  shl    $0x3,%rax
  mov    %rax,0x28(%rsp)
L158:
  mov    0x98(%rsp),%rax
  mov    0x58(%rsp),%ecx
  movslq (%rax),%rax
  test   %ecx,%ecx
  jle    L7
  mov    0x170(%rsp),%rdi
  movslq 0x48(%rsp),%rdx
  mov    0x0(%rbp),%ecx
  movslq 0x50(%rsp),%rsi
  movsd  D0(%rip),%xmm8
  lea    (%rdi,%rax,8),%rax
  mov    0x1d8(%rsp),%rdi
  mov    %rax,0x18(%rsp)
  mov    0x138(%rsp),%rax
  shl    $0x3,%rsi
  mov    %ecx,0x10(%rsp)
  add    %rsi,%rdi
  add    0x1e0(%rsp),%rsi
  lea    (%rax,%rdx,4),%r10
  mov    0x58(%rsp),%eax
  sub    $0x1,%eax
  add    %rdx,%rax
  mov    0x138(%rsp),%rdx
  lea    0x4(%rdx,%rax,4),%rax
  mov    %rax,0x20(%rsp)
  mov    0x64(%rsp),%eax
  mov    %eax,0x8(%rsp)
  movslq %ecx,%rax
  mov    %rax,0x38(%rsp)
  nopl   0x0(%rax)
L122:
  mov    0x18(%rsp),%rcx
  mov    (%r10),%eax
  movsd  (%rcx),%xmm1
  lea    (%rax,%rax,1),%r15d
  mov    0x130(%rsp),%rcx
  movslq %r15d,%r15
  mov    0x4(%rcx,%r15,4),%r14d
  movapd %xmm1,%xmm0
  test   %r14d,%r14d
  js     L16
  mov    0x140(%rsp),%rcx
  movslq %r14d,%rdx
  movslq (%rcx,%rdx,4),%rdx
  mov    0x170(%rsp),%rcx
  movsd  (%rcx,%rdx,8),%xmm0
L16:
  movapd %xmm1,%xmm3
  addsd  %xmm1,%xmm3
  mulsd  %xmm0,%xmm3
  addsd  %xmm1,%xmm0
  addsd  %xmm8,%xmm0
  divsd  %xmm0,%xmm3
  test   %r11d,%r11d
  jle    L5
  imul   0x60(%rsp),%eax
  movapd %xmm4,%xmm6
  movapd %xmm7,%xmm9
  mov    0x180(%rsp),%rdx
  movslq 0x8(%rsp),%rcx
  mulsd  %xmm3,%xmm9
  movapd %xmm2,%xmm1
  mulsd  %xmm3,%xmm6
  imul   %r11d,%eax
  lea    (%rdx,%rcx,8),%r9
  mov    0x188(%rsp),%rdx
  cltq
  lea    (%rdx,%rax,8),%r8
  xor    %eax,%eax
  nopl   0x0(%rax,%rax,1)
L97:
  movsd  0x0(%r13,%rax,8),%xmm0
  movsd  (%r9,%rax,8),%xmm5
  mov    %rax,%rdx
  mulsd  %xmm9,%xmm0
  mulsd  %xmm6,%xmm5
  subsd  %xmm5,%xmm0
  mulsd  (%r8,%rax,8),%xmm0
  add    $0x1,%rax
  addsd  %xmm0,%xmm1
  cmp    %rdx,%r12
  jne    L97
  comisd %xmm2,%xmm1
  jb     L244
L5:
  mov    0x130(%rsp),%rax
  mov    0x5c(%rsp),%edx
  mov    (%rax,%r15,4),%r14d
  mov    0x38(%rsp),%rax
  movsd  (%rdi,%rax,8),%xmm5
  movsd  (%rsi,%rax,8),%xmm6
  test   %edx,%edx
  jle    L307
L232:
  imul   0x34(%rsp),%r14d
  mov    0x10(%rsp),%eax
  mov    0x1b8(%rsp),%rcx
  add    %r14d,%eax
  cltq
  movsd  (%rcx,%rax,8),%xmm5
L307:
  test   %r11d,%r11d
  jle    L286
  movslq 0x8(%rsp),%rcx
L260:
  movapd %xmm7,%xmm10
  movapd %xmm7,%xmm9
  shl    $0x3,%rcx
  xor    %edx,%edx
  mulsd  %xmm5,%xmm10
  mov    0x40(%rsp),%r14d
  mov    0x10(%rsp),%r8d
  mulsd  %xmm6,%xmm9
  mov    0x1c8(%rsp),%r15
  add    %rcx,%r15
  add    0x1d0(%rsp),%rcx
  mov    %rcx,%r9
  mulsd  %xmm3,%xmm10
  mulsd  %xmm3,%xmm9
  nopl   0x0(%rax,%rax,1)
L292:
  movsd  0x0(%r13,%rdx,8),%xmm0
  mov    0x4(%rbp,%rdx,4),%ecx
  movslq %r8d,%rax
  mulsd  %xmm10,%xmm0
  movsd  %xmm0,(%r15,%rdx,8)
  movsd  0x0(%r13,%rdx,8),%xmm0
  mulsd  %xmm9,%xmm0
  movsd  %xmm0,(%r9,%rdx,8)
  cmp    %r8d,%ecx
  jle    L183
  nopl   0x0(%rax,%rax,1)
L199:
  movapd %xmm2,%xmm1
  movapd %xmm2,%xmm0
  cmp    %edx,(%rbx,%rax,4)
  jne    L76
  movapd %xmm4,%xmm1
  movapd %xmm4,%xmm0
  mulsd  %xmm5,%xmm1
  mulsd  %xmm6,%xmm0
  mulsd  %xmm3,%xmm1
  mulsd  %xmm3,%xmm0
L76:
  movsd  %xmm1,(%rdi,%rax,8)
  movsd  %xmm0,(%rsi,%rax,8)
  add    $0x1,%rax
  cmp    %eax,%ecx
  jg     L199
L183:
  lea    0x1(%rdx),%rax
  cmp    %rdx,%r14
  je     L286
  mov    0x0(%rbp,%rax,4),%r8d
  mov    %rax,%rdx
  jmp    L292
  nopl   (%rax)
L286:
  mov    0x28(%rsp),%rax
  add    %r11d,0x8(%rsp)
  add    $0x4,%r10
  add    %rax,%rdi
  add    %rax,%rsi
  cmp    %r10,0x20(%rsp)
  jne    L122
L7:
  addq   $0x4,0x98(%rsp)
  mov    0x68(%rsp),%esi
  mov    0x98(%rsp),%rax
  add    %esi,0x64(%rsp)
  mov    0xc4(%rsp),%esi
  add    %esi,0x50(%rsp)
  mov    0x58(%rsp),%esi
  add    %esi,0x48(%rsp)
  cmp    %rax,0xb8(%rsp)
  jne    L158
L171:
  add    $0xe8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L244:
  test   %r14d,%r14d
  js     L5
  mov    0x38(%rsp),%rax
  movsd  (%rdi,%rax,8),%xmm5
  movsd  (%rsi,%rax,8),%xmm6
  mov    0x5c(%rsp),%eax
  test   %eax,%eax
  jg     L232
  jmp    L260
L11:
  test   %r14d,%r14d
  je     L212
  movslq 0xb0(%rsp),%rax
  mov    0x1b8(%rsp),%rbx
  pxor   %xmm7,%xmm7
  movsd  %xmm7,0xc8(%rsp)
  movq   $0x0,(%rbx,%rax,8)
  mov    0x1c0(%rsp),%rbx
  movq   $0x0,(%rbx,%rax,8)
  jmp    L160
L159:
  movsd  %xmm5,0x80(%rsp)
  movsd  %xmm7,0x78(%rsp)
  movsd  %xmm6,0x70(%rsp)
  movsd  %xmm8,0x28(%rsp)
  movsd  %xmm3,0x20(%rsp)
  movsd  %xmm2,0x18(%rsp)
  call   <sqrt@plt>
  movsd  0x78(%rsp),%xmm7
  movsd  0x80(%rsp),%xmm5
  movsd  0x70(%rsp),%xmm6
  movsd  0x28(%rsp),%xmm8
  movsd  0x20(%rsp),%xmm3
  movsd  0x18(%rsp),%xmm2
  jmp    L84
```

tool_calls: name: read_data
arguments: data_label: D138
datatype: f32[4]
name: read_data
arguments: data_label: D47
datatype: f64
name: read_data
arguments: data_label: D93
datatype: f64
name: read_data
arguments: data_label: D75
datatype: f64
name: read_data
arguments: data_label: D0
datatype: byte[8]

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

tool: D47: 1

tool: D93: 2

tool: D75: 0.5

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

assistant: ```c
void conservativeHeadRichardsMualemVanGenuchtenHetEvaluateV2withUpwindAndHarm_sd(const int upwindFlag, const int computeAverages, const int nSimplex, const int nPointsPerSimplex, const int nSpace, const int nQuadraturePoints_elementBoundary, const int *rowptr, const int *colind, 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, J, nnz;
  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;
  nnz = rowptr[nSpace];
  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;
      J = rowptr[0];
      a[i * nPointsPerSimplex * nnz + j * nnz + J] = KWr;
      da[i * nPointsPerSimplex * nnz + j * nnz + J] = -DKWr_DpsiC;
      if (computeAverages) {
        a_avg[i * nnz + J] += KWr * dV[k];
        da_avg[i * nnz + J] += -DKWr_DpsiC * dV[k];
      }
    }
    if (computeAverages) {
      a_avg[i * nnz + J] /= vol;
      da_avg[i * nnz + J] /= 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];
      J = rowptr[0];
      krw_val = a[i * nPointsPerSimplex * nnz + j * nnz + J];
      dkrw_val = da[i * nPointsPerSimplex * nnz + j * nnz + J];
      if (upwindFlag > 0) {
        krw_val = a_avg[eN_upwind * nnz + J];
      }
      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];
        for (J = rowptr[I]; J < rowptr[I + 1]; J++) {
          if (colind[J] == I) {
            a[i * nPointsPerSimplex * nnz + j * nnz + J] = rho * krw_val * KWs_harm;
            da[i * nPointsPerSimplex * nnz + j * nnz + J] = rho * dkrw_val * KWs_harm;
          } else {
            a[i * nPointsPerSimplex * nnz + j * nnz + J] = 0.0;
            da[i * nPointsPerSimplex * nnz + j * nnz + J] = 0.0;
          }
        }
      }
    }
  }
}
```