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

```asm
<avg_dist_interval>:
  endbr64
  mov    %edi,%eax
  lea    (%rdi,%rsi,1),%r9d
  pxor   %xmm7,%xmm7
  mov    %ecx,%r10d
  lea    (%rdx,%rcx,1),%r8d
  pxor   %xmm6,%xmm6
  lea    -0x1(%r9),%edi
  movsd  D4(%rip),%xmm3
  cvtsi2sd %eax,%xmm7
  pxor   %xmm4,%xmm4
  lea    -0x1(%r8),%ecx
  cvtsi2sd %edx,%xmm6
  pxor   %xmm2,%xmm2
  cvtsi2sd %edi,%xmm4
  cvtsi2sd %ecx,%xmm2
  movapd %xmm7,%xmm0
  movapd %xmm6,%xmm1
  addsd  %xmm4,%xmm0
  addsd  %xmm2,%xmm1
  mulsd  %xmm3,%xmm0
  mulsd  %xmm3,%xmm1
  cmp    %eax,%ecx
  jl     L84
  cmp    %edx,%edi
  jge    L88
L84:
  subsd  %xmm1,%xmm0
  andpd  D48(%rip),%xmm0
  ret
  xchg   %ax,%ax
L88:
  cmp    %r8d,%r9d
  jg     L76
  jge    L83
  movapd %xmm4,%xmm5
  movapd %xmm2,%xmm0
  subsd  %xmm7,%xmm2
  movsd  D34(%rip),%xmm8
  subsd  %xmm7,%xmm5
  subsd  %xmm4,%xmm0
  addsd  %xmm8,%xmm2
  addsd  %xmm8,%xmm5
  mulsd  %xmm3,%xmm5
  mulsd  %xmm0,%xmm5
  mulsd  %xmm2,%xmm5
  movapd %xmm4,%xmm2
  addsd  D5(%rip),%xmm5
L77:
  cmp    %edx,%eax
  jge    L22
L86:
  movapd %xmm2,%xmm0
  pxor   %xmm1,%xmm1
  subsd  %xmm7,%xmm2
  sub    %eax,%edx
  subsd  %xmm6,%xmm0
  subsd  %xmm6,%xmm4
  cvtsi2sd %edx,%xmm1
  addsd  %xmm8,%xmm2
  addsd  %xmm8,%xmm0
  mulsd  %xmm3,%xmm0
  mulsd  %xmm1,%xmm0
  movapd %xmm8,%xmm1
  addsd  %xmm4,%xmm1
  mulsd  %xmm2,%xmm0
  movapd %xmm4,%xmm2
  addsd  %xmm0,%xmm5
L58:
  mulsd  %xmm2,%xmm1
  imul   %r10d,%esi
  addsd  D52(%rip),%xmm2
  mulsd  %xmm2,%xmm1
  divsd  D64(%rip),%xmm1
  movapd %xmm1,%xmm0
  pxor   %xmm1,%xmm1
  cvtsi2sd %esi,%xmm1
  addsd  %xmm5,%xmm0
  divsd  %xmm1,%xmm0
  ret
  nopl   0x0(%rax,%rax,1)
L76:
  movapd %xmm2,%xmm5
  movapd %xmm4,%xmm0
  subsd  %xmm6,%xmm4
  movsd  D34(%rip),%xmm8
  subsd  %xmm6,%xmm5
  subsd  %xmm2,%xmm0
  addsd  %xmm8,%xmm5
  mulsd  %xmm3,%xmm5
  mulsd  %xmm0,%xmm5
  movapd %xmm4,%xmm0
  movapd %xmm2,%xmm4
  addsd  %xmm8,%xmm0
  mulsd  %xmm0,%xmm5
  addsd  D5(%rip),%xmm5
  cmp    %edx,%eax
  jl     L86
L22:
  movapd %xmm4,%xmm2
  subsd  %xmm7,%xmm2
  movapd %xmm2,%xmm1
  addsd  %xmm8,%xmm1
  jle    L58
  mulsd  %xmm1,%xmm3
  pxor   %xmm7,%xmm7
  subsd  %xmm6,%xmm4
  sub    %edx,%eax
  cvtsi2sd %eax,%xmm7
  movapd %xmm4,%xmm0
  addsd  %xmm8,%xmm0
  mulsd  %xmm3,%xmm7
  mulsd  %xmm7,%xmm0
  addsd  %xmm0,%xmm5
  jmp    L58
  xchg   %ax,%ax
L83:
  movsd  D34(%rip),%xmm8
  pxor   %xmm5,%xmm5
  jmp    L77
```

tool_calls: name: parse_data
arguments: tag: D4
data_type: byte[8]
name: parse_data
arguments: tag: D48
data_type: qword[2]
name: parse_data
arguments: tag: D34
data_type: byte[8]
name: parse_data
arguments: tag: D5
data_type: byte[8]
name: parse_data
arguments: tag: D52
data_type: byte[8]
name: parse_data
arguments: tag: D64
data_type: f64

tool: {"D4": [0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0x3f]}

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

tool: {"D34": [0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x3f]}

tool: {"D5": [0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00]}

tool: {"D52": [0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40]}

tool: D64: 3

assistant: ```c
double avg_dist_interval(int set1_low, int set1_span, int set2_low, int set2_span) {
  double set1_high;
  double set1_avg;
  double set2_high;
  double set2_avg;
  double val;
  val = 0;
  set1_high = set1_low + set1_span - 1;
  set1_avg = .5 * (set1_high + set1_low);
  set2_high = set2_low + set2_span - 1;
  set2_avg = .5 * (set2_high + set2_low);
  if (set1_low > set2_high || set2_low > set1_high) {
    val = fabs(set1_avg - set2_avg);
  } else {
    if (set1_high > set2_high) {
      val += .5 * (set2_high - set2_low + 1) * (set1_high - set2_high) * (set1_high - set2_low + 1);
      set1_high = set2_high;
    } else if (set2_high > set1_high) {
      val += .5 * (set1_high - set1_low + 1) * (set2_high - set1_high) * (set2_high - set1_low + 1);
      set2_high = set1_high;
    }
    if (set1_low < set2_low) {
      val += .5 * (set2_high - set2_low + 1) * (set2_low - set1_low) * (set2_high - set1_low + 1);
      set1_low = set2_low;
    } else if (set2_low < set1_low) {
      val += .5 * (set1_high - set1_low + 1) * (set1_low - set2_low) * (set1_high - set2_low + 1);
      set2_low = set1_low;
    }
    val += (set1_high - set1_low) * (set1_high - set1_low + 1) * (set1_high - set1_low + 2) / 3.0;
    val /= set1_span * set2_span;
  }
  return (val);
}
```