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

```asm
<conservativeHeadRichardsJLeverettAni>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %rbx
  sub    $0x98,%rsp
  mov    %edi,-0x34(%rbp)
  mov    %esi,-0x38(%rbp)
  mov    %edx,-0x3c(%rbp)
  mov    %rcx,-0x48(%rbp)
  movsd  %xmm0,-0x50(%rbp)
  movsd  %xmm1,-0x58(%rbp)
  mov    %r8,-0x60(%rbp)
  mov    %r9,-0x68(%rbp)
  mov    -0x3c(%rbp),%eax
  imul   %eax,%eax
  mov    %eax,-0x28(%rbp)
  movsd  -0x50(%rbp),%xmm0
  mulsd  %xmm0,%xmm0
  movsd  %xmm0,-0x98(%rbp)
  movsd  D68(%rip),%xmm0
  movsd  %xmm0,-0x18(%rbp)
  movl   $0x0,-0x30(%rbp)
  jmp    L35
L50:
  mov    -0x30(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x48(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  mov    %eax,-0x24(%rbp)
  movl   $0x0,-0x2c(%rbp)
  jmp    L16
L41:
  mov    -0x30(%rbp),%eax
  imul   -0x38(%rbp),%eax
  mov    %eax,%edx
  mov    -0x2c(%rbp),%eax
  add    %edx,%eax
  mov    %eax,-0x20(%rbp)
  mov    -0x20(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    0x50(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  movq   D44(%rip),%xmm1
  movapd %xmm0,%xmm2
  xorpd  %xmm1,%xmm2
  mov    -0x24(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    0x10(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  comisd %xmm0,%xmm2
  jb     L51
  mov    -0x24(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    0x10(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  divsd  %xmm0,%xmm2
  mov    -0x24(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    0x18(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  movq   D44(%rip),%xmm1
  xorpd  %xmm1,%xmm0
  movapd %xmm0,%xmm1
  movsd  %xmm2,-0x78(%rbp)
  movapd %xmm2,%xmm0
  call   <pow@plt>
  movq   %xmm0,%rbx
  mov    -0x24(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    0x28(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm1
  movsd  D131(%rip),%xmm0
  subsd  %xmm1,%xmm0
  mov    -0x24(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    0x30(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm1
  subsd  %xmm1,%xmm0
  movq   %rbx,%xmm1
  mulsd  %xmm0,%xmm1
  mov    -0x24(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    0x28(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  addsd  %xmm0,%xmm1
  movsd  %xmm1,-0x70(%rbp)
  mov    -0x24(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    0x18(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  movq   %rbx,%xmm4
  mulsd  %xmm4,%xmm0
  mov    -0x24(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    0x10(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm1
  mulsd  -0x78(%rbp),%xmm1
  movapd %xmm0,%xmm3
  divsd  %xmm1,%xmm3
  mov    -0x24(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    0x28(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm1
  movsd  D131(%rip),%xmm0
  subsd  %xmm1,%xmm0
  mov    -0x24(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    0x30(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm1
  subsd  %xmm1,%xmm0
  movsd  %xmm3,-0x88(%rbp)
  mulsd  %xmm3,%xmm0
  movsd  %xmm0,-0x78(%rbp)
  mov    -0x24(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    0x18(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm1
  movsd  D105(%rip),%xmm0
  mulsd  %xmm0,%xmm1
  movsd  D35(%rip),%xmm0
  addsd  %xmm1,%xmm0
  mov    -0x24(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    0x18(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm1
  divsd  %xmm1,%xmm0
  movapd %xmm0,%xmm1
  movq   %rbx,%xmm0
  call   <pow@plt>
  mov    -0x24(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    0x18(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm1
  movsd  D105(%rip),%xmm0
  mulsd  %xmm0,%xmm1
  movsd  D35(%rip),%xmm0
  addsd  %xmm1,%xmm0
  mov    -0x24(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    0x18(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm1
  divsd  %xmm1,%xmm0
  movsd  %xmm0,-0x80(%rbp)
  mov    -0x24(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    0x18(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm2
  movsd  D35(%rip),%xmm0
  movapd %xmm0,%xmm1
  divsd  %xmm2,%xmm1
  mov    -0x24(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    0x18(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm2
  movsd  D131(%rip),%xmm0
  addsd  %xmm2,%xmm0
  mulsd  %xmm1,%xmm0
  movapd %xmm0,%xmm1
  movq   %rbx,%xmm0
  call   <pow@plt>
  mulsd  -0x80(%rbp),%xmm0
  mulsd  -0x88(%rbp),%xmm0
  mov    -0x24(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    0x20(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  movapd %xmm0,%xmm1
  movq   %rbx,%xmm0
  call   <pow@plt>
  movsd  %xmm0,-0x80(%rbp)
  mov    -0x24(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    0x20(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm4
  movsd  %xmm4,-0x90(%rbp)
  mov    -0x24(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    0x20(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  movsd  D131(%rip),%xmm1
  subsd  %xmm1,%xmm0
  movapd %xmm0,%xmm1
  movq   %rbx,%xmm0
  call   <pow@plt>
  mulsd  -0x90(%rbp),%xmm0
  mulsd  -0x88(%rbp),%xmm0
  movsd  %xmm0,-0x88(%rbp)
  jmp    L1
L51:
  mov    -0x24(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    0x30(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm1
  movsd  D131(%rip),%xmm0
  subsd  %xmm1,%xmm0
  movsd  %xmm0,-0x70(%rbp)
  pxor   %xmm3,%xmm3
  movsd  %xmm3,-0x78(%rbp)
  movsd  D131(%rip),%xmm3
  movsd  %xmm3,-0x80(%rbp)
  pxor   %xmm4,%xmm4
  movsd  %xmm4,-0x88(%rbp)
L1:
  mov    -0x20(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    0x50(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  mulsd  -0x58(%rbp),%xmm0
  movq   %xmm0,%rax
  movq   %rax,%xmm0
  call   <exp@plt>
  movq   %xmm0,%rax
  movq   %rax,%xmm4
  mulsd  -0x50(%rbp),%xmm4
  movapd %xmm4,%xmm3
  mulsd  -0x58(%rbp),%xmm3
  movapd %xmm4,%xmm1
  movsd  -0x70(%rbp),%xmm2
  mulsd  %xmm2,%xmm1
  mov    -0x24(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x68(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  mov    -0x20(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    0x58(%rbp),%rax
  add    %rdx,%rax
  mulsd  %xmm1,%xmm0
  movsd  %xmm0,(%rax)
  mulsd  -0x78(%rbp),%xmm4
  movapd %xmm4,%xmm1
  mov    -0x24(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x68(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  mulsd  %xmm0,%xmm1
  mulsd  %xmm2,%xmm3
  movapd %xmm3,%xmm2
  mov    -0x24(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x68(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  mulsd  %xmm2,%xmm0
  mov    -0x20(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    0x60(%rbp),%rax
  add    %rdx,%rax
  addsd  %xmm1,%xmm0
  movsd  %xmm0,(%rax)
  movl   $0x0,-0x1c(%rbp)
  mov    -0x24(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    0x38(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  movsd  -0x98(%rbp),%xmm5
  mulsd  %xmm5,%xmm0
  movapd %xmm0,%xmm1
  movsd  -0x80(%rbp),%xmm6
  mulsd  %xmm6,%xmm1
  mov    -0x1c(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x60(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  mov    -0x20(%rbp),%eax
  imul   -0x3c(%rbp),%eax
  mov    %eax,%edx
  mov    -0x1c(%rbp),%eax
  add    %edx,%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    0x68(%rbp),%rax
  add    %rdx,%rax
  mulsd  %xmm1,%xmm0
  movsd  %xmm0,(%rax)
  mov    -0x24(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    0x38(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  mulsd  %xmm5,%xmm0
  movapd %xmm0,%xmm1
  movsd  -0x88(%rbp),%xmm7
  mulsd  %xmm7,%xmm1
  mov    -0x1c(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x60(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  mov    -0x20(%rbp),%eax
  imul   -0x3c(%rbp),%eax
  mov    %eax,%edx
  mov    -0x1c(%rbp),%eax
  add    %edx,%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    0x70(%rbp),%rax
  add    %rdx,%rax
  mulsd  %xmm1,%xmm0
  movsd  %xmm0,(%rax)
  mov    -0x24(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    0x38(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  mulsd  -0x50(%rbp),%xmm0
  mov    -0x20(%rbp),%eax
  imul   -0x28(%rbp),%eax
  mov    %eax,%edx
  mov    -0x1c(%rbp),%eax
  imul   -0x3c(%rbp),%eax
  add    %eax,%edx
  mov    -0x1c(%rbp),%eax
  add    %edx,%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    0x78(%rbp),%rax
  add    %rdx,%rax
  mulsd  %xmm6,%xmm0
  movsd  %xmm0,(%rax)
  mov    -0x24(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    0x38(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  mulsd  -0x50(%rbp),%xmm0
  mov    -0x20(%rbp),%eax
  imul   -0x28(%rbp),%eax
  mov    %eax,%edx
  mov    -0x1c(%rbp),%eax
  imul   -0x3c(%rbp),%eax
  add    %eax,%edx
  mov    -0x1c(%rbp),%eax
  add    %edx,%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    0x80(%rbp),%rax
  add    %rdx,%rax
  mulsd  %xmm7,%xmm0
  movsd  %xmm0,(%rax)
  cmpl   $0x1,-0x3c(%rbp)
  jle    L54
  movl   $0x1,-0x1c(%rbp)
  mov    -0x24(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    0x40(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  mulsd  %xmm5,%xmm0
  movapd %xmm0,%xmm1
  mulsd  %xmm6,%xmm1
  mov    -0x1c(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x60(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  mov    -0x20(%rbp),%eax
  imul   -0x3c(%rbp),%eax
  mov    %eax,%edx
  mov    -0x1c(%rbp),%eax
  add    %edx,%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    0x68(%rbp),%rax
  add    %rdx,%rax
  mulsd  %xmm1,%xmm0
  movsd  %xmm0,(%rax)
  mov    -0x24(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    0x40(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  mulsd  %xmm5,%xmm0
  movapd %xmm0,%xmm1
  mulsd  %xmm7,%xmm1
  mov    -0x1c(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x60(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  mov    -0x20(%rbp),%eax
  imul   -0x3c(%rbp),%eax
  mov    %eax,%edx
  mov    -0x1c(%rbp),%eax
  add    %edx,%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    0x70(%rbp),%rax
  add    %rdx,%rax
  mulsd  %xmm1,%xmm0
  movsd  %xmm0,(%rax)
  mov    -0x24(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    0x40(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  mulsd  -0x50(%rbp),%xmm0
  mov    -0x20(%rbp),%eax
  imul   -0x28(%rbp),%eax
  mov    %eax,%edx
  mov    -0x1c(%rbp),%eax
  imul   -0x3c(%rbp),%eax
  add    %eax,%edx
  mov    -0x1c(%rbp),%eax
  add    %edx,%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    0x78(%rbp),%rax
  add    %rdx,%rax
  mulsd  %xmm6,%xmm0
  movsd  %xmm0,(%rax)
  mov    -0x24(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    0x40(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  mulsd  -0x50(%rbp),%xmm0
  mov    -0x20(%rbp),%eax
  imul   -0x28(%rbp),%eax
  mov    %eax,%edx
  mov    -0x1c(%rbp),%eax
  imul   -0x3c(%rbp),%eax
  add    %eax,%edx
  mov    -0x1c(%rbp),%eax
  add    %edx,%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    0x80(%rbp),%rax
  add    %rdx,%rax
  mulsd  %xmm7,%xmm0
  movsd  %xmm0,(%rax)
  cmpl   $0x2,-0x3c(%rbp)
  jle    L54
  movl   $0x2,-0x1c(%rbp)
  mov    -0x24(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    0x48(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  mulsd  %xmm5,%xmm0
  movapd %xmm0,%xmm1
  mulsd  %xmm6,%xmm1
  mov    -0x1c(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x60(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  mov    -0x20(%rbp),%eax
  imul   -0x3c(%rbp),%eax
  mov    %eax,%edx
  mov    -0x1c(%rbp),%eax
  add    %edx,%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    0x68(%rbp),%rax
  add    %rdx,%rax
  mulsd  %xmm1,%xmm0
  movsd  %xmm0,(%rax)
  mov    -0x24(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    0x48(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  mulsd  %xmm5,%xmm0
  movapd %xmm0,%xmm1
  mulsd  %xmm7,%xmm1
  mov    -0x1c(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x60(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  mov    -0x20(%rbp),%eax
  imul   -0x3c(%rbp),%eax
  mov    %eax,%edx
  mov    -0x1c(%rbp),%eax
  add    %edx,%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    0x70(%rbp),%rax
  add    %rdx,%rax
  mulsd  %xmm1,%xmm0
  movsd  %xmm0,(%rax)
  mov    -0x24(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    0x48(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  mulsd  -0x50(%rbp),%xmm0
  mov    -0x20(%rbp),%eax
  imul   -0x28(%rbp),%eax
  mov    %eax,%edx
  mov    -0x1c(%rbp),%eax
  imul   -0x3c(%rbp),%eax
  add    %eax,%edx
  mov    -0x1c(%rbp),%eax
  add    %edx,%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    0x78(%rbp),%rax
  add    %rdx,%rax
  mulsd  %xmm6,%xmm0
  movsd  %xmm0,(%rax)
  mov    -0x24(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    0x48(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  mulsd  -0x50(%rbp),%xmm0
  mov    -0x20(%rbp),%eax
  imul   -0x28(%rbp),%eax
  mov    %eax,%edx
  mov    -0x1c(%rbp),%eax
  imul   -0x3c(%rbp),%eax
  add    %eax,%edx
  mov    -0x1c(%rbp),%eax
  add    %edx,%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    0x80(%rbp),%rax
  add    %rdx,%rax
  mulsd  %xmm7,%xmm0
  movsd  %xmm0,(%rax)
L54:
  addl   $0x1,-0x2c(%rbp)
L16:
  mov    -0x2c(%rbp),%eax
  cmp    -0x38(%rbp),%eax
  jl     L41
  addl   $0x1,-0x30(%rbp)
L35:
  mov    -0x30(%rbp),%eax
  cmp    -0x34(%rbp),%eax
  jl     L50
  nop
  nop
  mov    -0x8(%rbp),%rbx
  leave
  ret
```

tool_calls: name: extract_symbolic_data
arguments: label: D68
data_type: byte[8]
name: extract_symbolic_data
arguments: label: D44
data_type: f32[2]
name: extract_symbolic_data
arguments: label: D131
data_type: f64
name: extract_symbolic_data
arguments: label: D105
data_type: f64
name: extract_symbolic_data
arguments: label: D35
data_type: f64

tool: {"D68": [0x7b,0x14,0xae,0x47,0xe1,0x7a,0x84,0x3f]}

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

tool: D131: 1

tool: D105: 3

tool: D35: 2

assistant: ```c
void conservativeHeadRichardsJLeverettAni(const int nSimplex, const int nPointsPerSimplex, const int nSpace, const int *materialTypes, const double rho, const double beta, const double *gravity, const double *phi, const double *psiD, const double *ns, const double *nk, const double *S_wirr, const double *S_nwr, const double *kr0x, const double *kr0y, const double *kr0z, double *u, double *mass, double *dmass, double *f, double *df, double *a, double *da) {
  int i, j, k, I, matID;
  const int nSpace2 = nSpace * nSpace;
  register double psiC, pcBar, Se, dSe, Sw, dSw, kr, dkr, rho2 = rho * rho, rhom, drhom;
  const double reg_diff = 1.0e-2;
  for (i = 0; i < nSimplex; i++) {
    matID = materialTypes[i];
    for (j = 0; j < nPointsPerSimplex; j++) {
      k = i * nPointsPerSimplex + j;
      psiC = -u[k];
      if (psiC >= psiD[matID]) {
        pcBar = psiC / psiD[matID];
        Se = pow(pcBar, -ns[matID]);
        Sw = Se * (1.0 - S_wirr[matID] - S_nwr[matID]) + S_wirr[matID];
        dSe = ns[matID] * Se / (pcBar * psiD[matID]);
        dSw = (1.0 - S_wirr[matID] - S_nwr[matID]) * dSe;
        kr = pow(Se, (2.0 + 3.0 * ns[matID]) / ns[matID]);
        dkr = ((2.0 + 3.0 * ns[matID]) / ns[matID] * pow(Se, 2.0 / ns[matID] * (1.0 + ns[matID])) * dSe);
        kr = pow(Se, nk[matID]);
        dkr = nk[matID] * pow(Se, nk[matID] - 1) * dSe;
      } else {
        Se = 1.0;
        Sw = 1.0 - S_nwr[matID];
        dSw = 0.0;
        kr = 1.0;
        dkr = 0.0;
      }
      rhom = rho * exp(beta * u[k]);
      drhom = beta * rhom;
      mass[k] = rhom * Sw * phi[matID];
      dmass[k] = rhom * dSw * phi[matID] + drhom * Sw * phi[matID];
      I = 0;
      f[k * nSpace + I] = rho2 * kr0x[matID] * kr * gravity[I];
      df[k * nSpace + I] = rho2 * kr0x[matID] * dkr * gravity[I];
      a[k * nSpace2 + I * nSpace + I] = rho * kr0x[matID] * kr;
      da[k * nSpace2 + I * nSpace + I] = rho * kr0x[matID] * dkr;
      if (nSpace > 1) {
        I = 1;
        f[k * nSpace + I] = rho2 * kr0y[matID] * kr * gravity[I];
        df[k * nSpace + I] = rho2 * kr0y[matID] * dkr * gravity[I];
        a[k * nSpace2 + I * nSpace + I] = rho * kr0y[matID] * kr;
        da[k * nSpace2 + I * nSpace + I] = rho * kr0y[matID] * dkr;
        if (nSpace > 2) {
          I = 2;
          f[k * nSpace + I] = rho2 * kr0z[matID] * kr * gravity[I];
          df[k * nSpace + I] = rho2 * kr0z[matID] * dkr * gravity[I];
          a[k * nSpace2 + I * nSpace + I] = rho * kr0z[matID] * kr;
          da[k * nSpace2 + I * nSpace + I] = rho * kr0z[matID] * dkr;
        }
      }
    }
  }
}
```