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

```asm
<fast_expansion_sum>:
  endbr64
  mov    %rsi,%r10
  push   %rbx
  movsd  (%rcx),%xmm0
  mov    %edx,%esi
  movsd  (%r10),%xmm2
  movq   D2(%rip),%xmm5
  mov    %rcx,%r9
  comisd %xmm2,%xmm0
  movapd %xmm2,%xmm1
  xorpd  %xmm5,%xmm1
  seta   %dl
  comisd %xmm1,%xmm0
  seta   %al
  cmp    %al,%dl
  je     L64
  movsd  0x8(%rcx),%xmm1
  xor    %r11d,%r11d
  mov    $0x1,%ecx
L4:
  cmp    %edi,%r11d
  setl   %dl
  cmp    %esi,%ecx
  setl   %al
  and    %al,%dl
  je     L104
  comisd %xmm2,%xmm1
  movapd %xmm2,%xmm3
  xorpd  %xmm5,%xmm3
  seta   %bl
  comisd %xmm3,%xmm1
  movapd %xmm0,%xmm3
  seta   %al
  cmp    %al,%bl
  je     L111
  addsd  %xmm1,%xmm3
  add    $0x1,%ecx
  movslq %ecx,%rax
  cmp    %ecx,%esi
  movapd %xmm3,%xmm4
  subsd  %xmm1,%xmm4
  subsd  %xmm4,%xmm0
  movsd  %xmm0,(%r8)
  movapd %xmm3,%xmm0
  movsd  (%r9,%rax,8),%xmm1
  setg   %al
L149:
  test   %dl,%dl
  je     L90
  mov    $0x2,%edx
  test   %al,%al
  jne    L123
  jmp    L90
  xchg   %ax,%ax
L89:
  addsd  %xmm1,%xmm3
  add    $0x1,%ecx
  mov    %edx,%ebx
  movslq %ecx,%rax
  movapd %xmm3,%xmm4
  movapd %xmm3,%xmm6
  subsd  %xmm0,%xmm4
  subsd  %xmm4,%xmm6
  subsd  %xmm4,%xmm1
  subsd  %xmm6,%xmm0
  addsd  %xmm1,%xmm0
  movsd  %xmm0,-0x8(%r8,%rdx,8)
  movapd %xmm3,%xmm0
  movsd  (%r9,%rax,8),%xmm1
  add    $0x1,%rdx
  cmp    %edi,%r11d
  jge    L146
L74:
  cmp    %esi,%ecx
  jge    L146
L123:
  comisd %xmm2,%xmm1
  movapd %xmm2,%xmm3
  xorpd  %xmm5,%xmm3
  seta   %bl
  comisd %xmm3,%xmm1
  movapd %xmm0,%xmm3
  seta   %al
  cmp    %al,%bl
  jne    L89
  addsd  %xmm2,%xmm3
  add    $0x1,%r11d
  mov    %edx,%ebx
  movslq %r11d,%rax
  movapd %xmm3,%xmm4
  movapd %xmm3,%xmm6
  subsd  %xmm0,%xmm4
  subsd  %xmm4,%xmm6
  subsd  %xmm4,%xmm2
  subsd  %xmm6,%xmm0
  addsd  %xmm2,%xmm0
  movsd  %xmm0,-0x8(%r8,%rdx,8)
  movapd %xmm3,%xmm0
  movsd  (%r10,%rax,8),%xmm2
  add    $0x1,%rdx
  cmp    %edi,%r11d
  jl     L74
  nopw   0x0(%rax,%rax,1)
L146:
  movslq %ebx,%rax
  lea    (%r8,%rax,8),%rdx
  lea    0x1(%rbx),%eax
  jmp    L78
  nopl   0x0(%rax)
L104:
  mov    %r8,%rdx
  mov    $0x1,%eax
  xor    %ebx,%ebx
L78:
  cmp    %r11d,%edi
  jle    L163
  movslq %r11d,%rax
  movslq %ebx,%rdx
  sub    %rax,%rdx
  lea    (%r8,%rdx,8),%rdx
  nopl   0x0(%rax)
L50:
  movapd %xmm0,%xmm3
  addsd  %xmm2,%xmm0
  movapd %xmm0,%xmm4
  movapd %xmm0,%xmm5
  subsd  %xmm3,%xmm4
  subsd  %xmm4,%xmm5
  subsd  %xmm4,%xmm2
  subsd  %xmm5,%xmm3
  addsd  %xmm2,%xmm3
  movsd  %xmm3,(%rdx,%rax,8)
  movsd  0x8(%r10,%rax,8),%xmm2
  add    $0x1,%rax
  cmp    %eax,%edi
  jg     L50
  add    %edi,%ebx
  sub    %r11d,%ebx
  movslq %ebx,%rax
  lea    (%r8,%rax,8),%rdx
  lea    0x1(%rbx),%eax
L163:
  cmp    %ecx,%esi
  jle    L54
  movslq %ecx,%rax
  movslq %ebx,%rdx
  sub    %rax,%rdx
  lea    (%r8,%rdx,8),%rdx
  nopl   0x0(%rax,%rax,1)
L152:
  movapd %xmm0,%xmm2
  addsd  %xmm1,%xmm0
  movapd %xmm0,%xmm3
  movapd %xmm0,%xmm4
  subsd  %xmm2,%xmm3
  subsd  %xmm3,%xmm4
  subsd  %xmm3,%xmm1
  subsd  %xmm4,%xmm2
  addsd  %xmm1,%xmm2
  movsd  %xmm2,(%rdx,%rax,8)
  movsd  0x8(%r9,%rax,8),%xmm1
  add    $0x1,%rax
  cmp    %eax,%esi
  jg     L152
  mov    %esi,%eax
  sub    %ecx,%eax
  add    %ebx,%eax
  movslq %eax,%rdx
  add    $0x1,%eax
  lea    (%r8,%rdx,8),%rdx
L54:
  movsd  %xmm0,(%rdx)
  pop    %rbx
  ret
  xchg   %ax,%ax
L64:
  movapd %xmm0,%xmm1
  xor    %ecx,%ecx
  movapd %xmm2,%xmm0
  mov    $0x1,%r11d
  movsd  0x8(%r10),%xmm2
  jmp    L4
  nopl   0x0(%rax,%rax,1)
L111:
  addsd  %xmm2,%xmm3
  add    $0x1,%r11d
  movslq %r11d,%rax
  cmp    %r11d,%edi
  movapd %xmm3,%xmm4
  subsd  %xmm2,%xmm4
  subsd  %xmm4,%xmm0
  movsd  %xmm0,(%r8)
  movapd %xmm3,%xmm0
  movsd  (%r10,%rax,8),%xmm2
  mov    %edx,%eax
  setg   %dl
  jmp    L149
L90:
  lea    0x8(%r8),%rdx
  mov    $0x2,%eax
  mov    $0x1,%ebx
  jmp    L78
```

tool_calls: name: read_data
arguments: tag: D2
type_guessed: byte[8]

tool: {"D2": [0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80]}

assistant: ```c
int fast_expansion_sum(elen, e, flen, f, h)
int elen;
double *e;
int flen;
double *f;
double *h;
{
  double Q;
  double Qnew;
  double bvirt;
  double avirt, bround, around;
  int eindex, findex, hindex;
  double enow, fnow;
  enow = e[0];
  fnow = f[0];
  eindex = findex = 0;
  if ((fnow > enow) == (fnow > -enow)) {
    Q = enow;
    enow = e[++eindex];
  } else {
    Q = fnow;
    fnow = f[++findex];
  }
  hindex = 0;
  if ((eindex < elen) && (findex < flen)) {
    if ((fnow > enow) == (fnow > -enow)) {
      Qnew = (double)(enow + Q);
      bvirt = Qnew - enow;
      h[0] = Q - bvirt;
      enow = e[++eindex];
    } else {
      Qnew = (double)(fnow + Q);
      bvirt = Qnew - fnow;
      h[0] = Q - bvirt;
      fnow = f[++findex];
    }
    Q = Qnew;
    hindex = 1;
    while ((eindex < elen) && (findex < flen)) {
      if ((fnow > enow) == (fnow > -enow)) {
        Qnew = (double)(Q + enow);
        bvirt = (double)(Qnew - Q);
        avirt = Qnew - bvirt;
        bround = enow - bvirt;
        around = Q - avirt;
        h[hindex] = around + bround;
        enow = e[++eindex];
      } else {
        Qnew = (double)(Q + fnow);
        bvirt = (double)(Qnew - Q);
        avirt = Qnew - bvirt;
        bround = fnow - bvirt;
        around = Q - avirt;
        h[hindex] = around + bround;
        fnow = f[++findex];
      }
      Q = Qnew;
      hindex++;
    }
  }
  while (eindex < elen) {
    Qnew = (double)(Q + enow);
    bvirt = (double)(Qnew - Q);
    avirt = Qnew - bvirt;
    bround = enow - bvirt;
    around = Q - avirt;
    h[hindex] = around + bround;
    enow = e[++eindex];
    Q = Qnew;
    hindex++;
  }
  while (findex < flen) {
    Qnew = (double)(Q + fnow);
    bvirt = (double)(Qnew - Q);
    avirt = Qnew - bvirt;
    bround = fnow - bvirt;
    around = Q - avirt;
    h[hindex] = around + bround;
    fnow = f[++findex];
    Q = Qnew;
    hindex++;
  }
  h[hindex] = Q;
  return hindex + 1;
}
```