user: Converte this assembly snippet into its equivalent C code:

```asm
<water_energy_balance>:
  endbr64
  push   %r15
  mov    %rdx,%r15
  push   %r14
  mov    %edi,%r14d
  push   %r13
  mov    %rsi,%r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x248,%rsp
  mov    0x2a8(%rsp),%rax
  mov    0x2b8(%rsp),%rbp
  mov    %ecx,0x7c(%rsp)
  movsd  %xmm5,0x20(%rsp)
  mov    0x2c0(%rsp),%rbx
  movapd %xmm6,%xmm5
  movapd %xmm7,%xmm6
  mov    %rax,0x30(%rsp)
  mov    0x2b0(%rsp),%rax
  movsd  %xmm2,0x90(%rsp)
  mov    %rax,0x38(%rsp)
  mov    0x2c8(%rsp),%rax
  mov    %r9,0x28(%rsp)
  mov    %rax,0x80(%rsp)
  mov    0x2d0(%rsp),%rax
  movsd  %xmm0,0x8(%rsp)
  mov    %rax,0x88(%rsp)
  mov    0x2e0(%rsp),%rax
  movsd  %xmm1,0x10(%rsp)
  mov    %rax,0xb8(%rsp)
  mov    0x2e8(%rsp),%rax
  movsd  %xmm3,0x70(%rsp)
  mov    %rax,0x60(%rsp)
  mov    0x2f0(%rsp),%rax
  movsd  %xmm4,0x18(%rsp)
  mov    %rax,0xc0(%rsp)
  mov    0x2f8(%rsp),%rax
  mov    %rax,0x98(%rsp)
  mov    0x300(%rsp),%rax
  movsd  0x0(%rbp),%xmm2
  mov    %rax,0xc8(%rsp)
  mov    %fs:0x28,%rax
  mov    %rax,0x238(%rsp)
  xor    %eax,%eax
  test   %edi,%edi
  jle    L55
  lea    -0x1(%rdi),%edx
  movapd %xmm2,%xmm0
  lea    0xf0(%rsp),%r12
  shl    $0x3,%rdx
  jmp    L39
  xchg   %ax,%ax
L58:
  movsd  0x8(%rbp,%rax,1),%xmm0
  add    $0x8,%rax
L39:
  movsd  %xmm0,(%r12,%rax,1)
  cmp    %rax,%rdx
  jne    L58
L55:
  movsd  0x10(%rsp),%xmm1
  mov    %rbx,%r9
  mov    %r13,%rcx
  mov    %r14d,%edx
  movsd  0x8(%rsp),%xmm0
  mov    0x60(%rsp),%r8
  mov    %rbp,%rdi
  lea    0xe0(%rsp),%rsi
  movsd  %xmm6,0x50(%rsp)
  movsd  %xmm5,0x48(%rsp)
  movsd  %xmm2,0x40(%rsp)
  call   <energycalc@plt>
  movsd  D67(%rip),%xmm0
  movsd  0x40(%rsp),%xmm2
  movsd  0x48(%rsp),%xmm5
  movsd  0x50(%rsp),%xmm6
  movapd %xmm0,%xmm1
  subsd  %xmm2,%xmm1
  andpd  D211(%rip),%xmm1
  comisd D6(%rip),%xmm1
  jbe    L72
  movsd  D59(%rip),%xmm7
  addsd  0x70(%rsp),%xmm7
  lea    0xf0(%rsp),%r12
  xor    %r10d,%r10d
  lea    0x190(%rsp),%rax
  lea    0xe8(%rsp),%rdx
  mov    %r12,0x68(%rsp)
  mov    %rdx,0xa8(%rsp)
  mov    %rax,%r12
  movsd  %xmm7,0xa0(%rsp)
  pxor   %xmm7,%xmm7
  cvtsi2sdl 0x7c(%rsp),%xmm7
  movsd  %xmm7,0xb0(%rsp)
  jmp    L6
  nopl   0x0(%rax,%rax,1)
L80:
  movsd  0xb0(%rsp),%xmm2
  mulsd  0x0(%r13),%xmm2
  mulsd  D136(%rip),%xmm2
  mov    0x80(%rsp),%rax
  movsd  0xe8(%rsp),%xmm1
  subsd  0xe0(%rsp),%xmm1
  divsd  %xmm2,%xmm1
  movsd  %xmm1,(%rax)
  mov    0x88(%rsp),%rax
  movq   $0x0,(%rax)
L18:
  addsd  0x0(%rbp),%xmm0
  mulsd  D26(%rip),%xmm0
  add    $0x1,%r10d
  movapd %xmm0,%xmm1
  subsd  %xmm8,%xmm1
  andpd  D211(%rip),%xmm1
  cmp    $0x32,%r10d
  je     L72
  comisd D6(%rip),%xmm1
  jbe    L72
L6:
  movapd %xmm0,%xmm8
  test   %r10d,%r10d
  jne    L59
  movsd  0x0(%rbp),%xmm8
L59:
  mov    %r10d,0x78(%rsp)
  sub    $0x8,%rsp
  mov    %r15,%rdi
  pxor   %xmm2,%xmm2
  movsd  D59(%rip),%xmm9
  push   0x2a8(%rsp)
  movsd  0x290(%rsp),%xmm7
  addsd  %xmm8,%xmm9
  movsd  0x30(%rsp),%xmm4
  mov    0x38(%rsp),%rsi
  movsd  0x28(%rsp),%xmm3
  movsd  %xmm6,0x68(%rsp)
  movsd  0xb0(%rsp),%xmm1
  movsd  %xmm5,0x60(%rsp)
  movapd %xmm9,%xmm0
  movsd  %xmm8,0x58(%rsp)
  movsd  %xmm9,0x50(%rsp)
  call   <latsens@plt>
  mov    0x40(%rsp),%rax
  mov    %r14d,%r8d
  mov    %rbx,%rdx
  movsd  D97(%rip),%xmm1
  mulsd  0x28(%rsp),%xmm1
  mov    %rbp,%rsi
  mov    $0x1,%edi
  movsd  D38(%rip),%xmm0
  movsd  0x50(%rsp),%xmm9
  mov    0x48(%rsp),%rcx
  movsd  0x20(%rsp),%xmm3
  movsd  0x18(%rsp),%xmm2
  subsd  %xmm1,%xmm0
  mulsd  D187(%rip),%xmm0
  movsd  (%r15),%xmm1
  xorpd  D1(%rip),%xmm1
  mulsd  %xmm1,%xmm0
  movsd  0x298(%rsp),%xmm1
  movsd  %xmm0,(%rax)
  movsd  D57(%rip),%xmm0
  mulsd  %xmm9,%xmm0
  mulsd  %xmm9,%xmm0
  mulsd  %xmm9,%xmm0
  mulsd  %xmm9,%xmm0
  subsd  %xmm0,%xmm1
  movsd  0x30(%rsp),%xmm0
  movsd  %xmm1,(%rcx)
  mov    %r12,%rcx
  movsd  0xa0(%rsp),%xmm1
  call   <eddy@plt>
  mov    0x40(%rsp),%rax
  mov    %r13,%r9
  mov    %r12,%rcx
  mov    0x38(%rsp),%rdi
  movsd  D126(%rip),%xmm0
  mov    %rbx,%rdx
  mulsd  0x2a0(%rsp),%xmm0
  movsd  (%rax),%xmm2
  movsd  D183(%rip),%xmm1
  addsd  (%rdi),%xmm2
  mov    %rbp,%rdi
  push   0xa8(%rsp)
  push   0x78(%rsp)
  push   0xc8(%rsp)
  push   %r14
  mov    0x68(%rsp),%rax
  movsd  0x40(%rsp),%xmm4
  mulsd  0x2c0(%rsp),%xmm1
  movsd  0x38(%rsp),%xmm3
  addsd  (%rax),%xmm2
  mov    0xac(%rsp),%r8d
  mov    0x98(%rsp),%rsi
  call   <temp_area@plt>
  movsd  0x120(%rsp),%xmm0
  add    $0x30,%rsp
  movsd  0x70(%rsp),%xmm4
  movsd  0x48(%rsp),%xmm8
  movsd  0x50(%rsp),%xmm5
  comisd %xmm0,%xmm4
  movsd  0x58(%rsp),%xmm6
  mov    0x78(%rsp),%r10d
  jbe    L80
  mov    %r10d,0x48(%rsp)
  mov    %r14d,%ecx
  movsd  %xmm8,0x40(%rsp)
  push   0xc8(%rsp)
  push   %rbx
  push   0xd0(%rsp)
  push   %r13
  movsd  0x328(%rsp),%xmm4
  mov    0x80(%rsp),%r9
  movsd  0x30(%rsp),%xmm3
  movsd  0x28(%rsp),%xmm2
  mov    0xd8(%rsp),%rdx
  mov    0x88(%rsp),%rsi
  mov    0x9c(%rsp),%r8d
  mov    0xa8(%rsp),%rdi
  movsd  0x2f8(%rsp),%xmm1
  movsd  0x90(%rsp),%xmm0
  call   <iceform@plt>
  add    $0x20,%rsp
  movsd  0x10(%rsp),%xmm1
  movsd  0x8(%rsp),%xmm0
  mov    0x60(%rsp),%r8
  mov    0x68(%rsp),%rdi
  mov    %rbx,%r9
  mov    %r13,%rcx
  lea    0xd8(%rsp),%rsi
  mov    %r14d,%edx
  call   <energycalc@plt>
  mov    0x48(%rsp),%r10d
  movsd  0xb0(%rsp),%xmm1
  mulsd  0x0(%r13),%xmm1
  mov    0x80(%rsp),%rax
  mulsd  D136(%rip),%xmm1
  movsd  0x40(%rsp),%xmm8
  movsd  0xd8(%rsp),%xmm0
  movsd  0x50(%rsp),%xmm5
  subsd  0xe0(%rsp),%xmm0
  movsd  0x58(%rsp),%xmm6
  divsd  %xmm1,%xmm0
  movsd  %xmm0,(%rax)
  movsd  0xf0(%rsp),%xmm0
  jmp    L18
  nopw   0x0(%rax,%rax,1)
L72:
  movsd  D6(%rip),%xmm7
  comisd %xmm1,%xmm7
  jb     L98
  test   %r14d,%r14d
  jle    L112
  movslq %r14d,%rdx
  lea    0xf0(%rsp),%rsi
  mov    %rbp,%rdi
  shl    $0x3,%rdx
  call   <memcpy@plt>
L112:
  mov    0x238(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L21
  add    $0x248,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   (%rax)
L98:
  movsd  D59(%rip),%xmm1
  movsd  0x0(%rbp),%xmm8
  sub    $0x8,%rsp
  mov    %r15,%rdi
  push   0x2a8(%rsp)
  mov    0x38(%rsp),%rsi
  pxor   %xmm2,%xmm2
  addsd  %xmm1,%xmm8
  movsd  0x30(%rsp),%xmm4
  addsd  0x80(%rsp),%xmm1
  movsd  0x28(%rsp),%xmm3
  movsd  0x290(%rsp),%xmm7
  movapd %xmm8,%xmm0
  movsd  %xmm8,0x30(%rsp)
  call   <latsens@plt>
  movsd  0x28(%rsp),%xmm0
  mov    0x40(%rsp),%rax
  mulsd  D97(%rip),%xmm0
  movsd  D38(%rip),%xmm1
  movsd  0x30(%rsp),%xmm8
  subsd  %xmm0,%xmm1
  mulsd  D187(%rip),%xmm1
  movapd %xmm1,%xmm0
  movsd  (%r15),%xmm1
  xorpd  D1(%rip),%xmm1
  mulsd  %xmm1,%xmm0
  movsd  D57(%rip),%xmm1
  mulsd  %xmm8,%xmm1
  movsd  %xmm0,(%rax)
  mov    0x48(%rsp),%rax
  movsd  0x298(%rsp),%xmm0
  mulsd  %xmm8,%xmm1
  mulsd  %xmm8,%xmm1
  mulsd  %xmm8,%xmm1
  subsd  %xmm1,%xmm0
  movsd  %xmm0,(%rax)
  pop    %rax
  pop    %rdx
  movsd  0x70(%rsp),%xmm10
  comisd 0x0(%rbp),%xmm10
  ja     L154
  mov    0x88(%rsp),%rax
  movq   $0x0,(%rax)
L34:
  mov    0x80(%rsp),%rax
  movq   $0x0,(%rax)
  jmp    L112
L154:
  push   0xc8(%rsp)
  mov    %r14d,%ecx
  mov    %rbp,%rsi
  push   %rbx
  push   0xd0(%rsp)
  push   %r13
  movsd  0x328(%rsp),%xmm4
  mov    0x80(%rsp),%r9
  movsd  0x30(%rsp),%xmm3
  movsd  0x28(%rsp),%xmm2
  mov    0x9c(%rsp),%r8d
  mov    0xd8(%rsp),%rdx
  movsd  0x2f8(%rsp),%xmm1
  mov    0xa8(%rsp),%rdi
  movsd  0x90(%rsp),%xmm0
  call   <iceform@plt>
  add    $0x20,%rsp
  jmp    L34
L21:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: parse_data
arguments: label: D67
data_type: f32[2]
name: parse_data
arguments: label: D211
data_type: qword[2]
name: parse_data
arguments: label: D6
data_type: f64[2]
name: parse_data
arguments: label: D59
data_type: f64
name: parse_data
arguments: label: D136
data_type: f32[2]
name: parse_data
arguments: label: D26
data_type: f32[2]
name: parse_data
arguments: label: D97
data_type: f64
name: parse_data
arguments: label: D38
data_type: f64
name: parse_data
arguments: label: D187
data_type: f64
name: parse_data
arguments: label: D1
data_type: f32[4]
name: parse_data
arguments: label: D57
data_type: byte[8]
name: parse_data
arguments: label: D126
data_type: f64
name: parse_data
arguments: label: D183
data_type: f64

tool: {"D67": [0.0,-4.4755859375]}

tool: {"D211": [0x7fffffffffffffff,0x0000000000000000]}

tool: {"D6": [0.0001,273.15]}

tool: D59: 273.15

tool: {"D136": [0.0,5.37890625]}

tool: {"D26": [0.0,1.75]}

tool: D97: 0.002361

tool: D38: 2.501

tool: D187: 1000000

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

tool: {"D57": [0x3b,0x5f,0x91,0xe5,0x64,0xd4,0x6d,0x3e]}

tool: D126: 0.7

tool: D183: 0.3

assistant: ```c
int water_energy_balance(int numnod, double *surface, double *evapw, int dt, int freezeflag, double dz, double surfdz, double lat, double Tcutoff, double Tair, double wind, double pressure, double vp, double air_density, double longwave, double shortwave, double sumjoulb, double wind_h, double *Qh, double *Qle, double *LWnet, double *T, double *water_density, double *deltaH, double *energy_ice_formation, double fracprv, double *new_ice_area, double *cp, double *new_ice_height, double *energy_out_bottom, double *new_ice_water_eq, double lvolume) {
  double Ts;
  double Tcutk;
  double Tskin;
  double Tnew[20];
  int k;
  double sumjouli;
  double Tmean;
  int iterations;
  double Le;
  double jouleold;
  double joulenew;
  double error;
  double Told;
  double Tupper, Tlower;
  double de[20];
  double epsilon = 0.0001;
  Tmean = -999.;
  error = -999.;
  Ts = T[0];
  iterations = 0;
  for (k = 0; k < numnod; k++)
    Tnew[k] = T[k];
  energycalc(T, &jouleold, numnod, dz, surfdz, surface, cp, water_density);
  while ((fabs(Tmean - Ts) > epsilon) && iterations < 50) {
    if (iterations == 0)
      Ts = T[0];
    else
      Ts = Tmean;
    Tskin = Ts + 273.15;
    Tcutk = Tcutoff + 273.15;
    latsens(Tskin, Tcutk, 0.0, Tair, wind, pressure, vp, air_density, evapw, Qh, wind_h);
    Le = (2.501 - 0.002361 * Tair) * 1.0e6;
    *Qle = -1. * (*evapw) * Le;
    *LWnet = longwave - .98 * 5.6696e-8 * Tskin * Tskin * Tskin * Tskin;
    eddy(1, wind, T, water_density, de, lat, numnod, dz, surfdz);
    temp_area(shortwave * 0.7, shortwave * 0.3, *Qle + *Qh + *LWnet, T, Tnew, water_density, de, dt, surface, numnod, dz, surfdz, &joulenew, cp, energy_out_bottom);
    if (Tnew[0] < Tcutoff) {
      iceform(energy_ice_formation, Tnew, Tcutoff, fracprv, new_ice_area, numnod, dt, dz, surfdz, cp, surface, new_ice_height, water_density, new_ice_water_eq, lvolume);
      energycalc(Tnew, &sumjouli, numnod, dz, surfdz, surface, cp, water_density);
      *deltaH = (sumjouli - jouleold) / (surface[0] * dt * 3600);
    } else {
      *deltaH = (joulenew - jouleold) / (surface[0] * dt * 3600);
      *energy_ice_formation = 0.0;
    }
    Tmean = (Tnew[0] + T[0]) / 2.;
    error = *LWnet + shortwave - *energy_out_bottom + *Qh + *Qle - *deltaH + *energy_ice_formation;
    iterations += 1;
  }
  if (fabs(Tmean - Ts) <= epsilon) {
    for (k = 0; k < numnod; k++)
      T[k] = Tnew[k];
    return (0);
  } else {
    Tskin = T[0] + 273.15;
    Tcutk = Tcutoff + 273.15;
    latsens(Tskin, Tcutk, 0.0, Tair, wind, pressure, vp, air_density, evapw, Qh, wind_h);
    Le = (2.501 - 0.002361 * Tair) * 1.0e6;
    *Qle = -1. * (*evapw) * Le;
    *LWnet = longwave - .98 * 5.6696e-8 * Tskin * Tskin * Tskin * Tskin;
    if (T[0] < Tcutoff) {
      iceform(energy_ice_formation, T, Tcutoff, fracprv, new_ice_area, numnod, dt, dz, surfdz, cp, surface, new_ice_height, water_density, new_ice_water_eq, lvolume);
    } else {
      *energy_ice_formation = 0.0;
    }
    *deltaH = 0.0;
    return (0);
  }
}
```