user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<LengthBounds>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  mov    %edx,%r12d
  push   %rbp
  mov    %esi,%ebp
  push   %rbx
  lea    0x0(,%rbp,4),%r13d
  mov    %rdi,%rbx
  mov    %r13d,%edi
  sub    $0x38,%rsp
  movsd  %xmm0,0x8(%rsp)
  mov    %rcx,0x20(%rsp)
  mov    %r8,0x28(%rsp)
  call   <MallocOrDie@plt>
  mov    %r13d,%edi
  mov    %rax,0x18(%rsp)
  call   <MallocOrDie@plt>
  test   %ebp,%ebp
  movsd  0x8(%rsp),%xmm0
  mov    %rax,0x10(%rsp)
  jle    L16
  mov    0x18(%rsp),%rcx
  lea    0x1(%r12),%r13d
  mov    %rcx,%rax
  lea    (%rcx,%rbp,4),%rbp
  mov    %rcx,%r14
  neg    %rax
  lea    (%rbx,%rax,2),%r15
  mov    0x10(%rsp),%rbx
  sub    %rcx,%rbx
  nopl   (%rax)
L148:
  mov    (%r15,%r14,2),%rdi
  mov    %r13d,%esi
  movsd  %xmm0,0x8(%rsp)
  call   <DNorm@plt>
  mov    (%r15,%r14,2),%rdi
  test   %r12d,%r12d
  movsd  0x8(%rsp),%xmm0
  movsd  (%rdi),%xmm1
  jle    L196
  mov    %r13d,%r10d
  mov    $0x1,%edx
  xor    %eax,%eax
  nopl   0x0(%rax,%rax,1)
L55:
  movsd  (%rdi,%rdx,8),%xmm2
  comisd %xmm1,%xmm2
  maxsd  %xmm1,%xmm2
  cmova  %edx,%eax
  add    $0x1,%rdx
  movapd %xmm2,%xmm1
  cmp    %rdx,%r10
  jne    L55
  movslq %eax,%rdx
  movsd  (%rdi,%rdx,8),%xmm1
L119:
  movsd  D3(%rip),%xmm2
  subsd  %xmm1,%xmm2
  comisd %xmm0,%xmm2
  jbe    L144
  test   %eax,%eax
  jne    L31
  cmp    %eax,%r12d
  je     L84
L31:
  mov    %eax,%edx
  nopw   0x0(%rax,%rax,1)
L8:
  test   %eax,%eax
  jne    L49
  add    $0x1,%edx
  movslq %edx,%r10
  subsd  (%rdi,%r10,8),%xmm2
L125:
  comisd %xmm0,%xmm2
  jbe    L178
  test   %eax,%eax
  jne    L49
  cmp    %r12d,%edx
  jne    L8
  xor    %eax,%eax
L178:
  mov    %eax,(%r14)
  mov    %edx,(%rbx,%r14,1)
  add    $0x4,%r14
  cmp    %rbp,%r14
  jne    L148
L16:
  mov    0x20(%rsp),%rax
  mov    0x18(%rsp),%rsi
  mov    0x10(%rsp),%rcx
  mov    %rsi,(%rax)
  mov    0x28(%rsp),%rax
  mov    %rcx,(%rax)
  add    $0x38,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  cs nopw 0x0(%rax,%rax,1)
L49:
  cmp    %edx,%r12d
  je     L170
  movslq %edx,%r10
  movsd  0x8(%rdi,%r10,8),%xmm1
  movslq %eax,%r10
  movsd  -0x8(%rdi,%r10,8),%xmm3
  comisd %xmm1,%xmm3
  jbe    L142
  sub    $0x1,%eax
  movslq %eax,%r10
  subsd  (%rdi,%r10,8),%xmm2
L96:
  comisd %xmm0,%xmm2
  ja     L8
  jmp    L178
  nopw   0x0(%rax,%rax,1)
L170:
  sub    $0x1,%eax
  movslq %eax,%r10
  subsd  (%rdi,%r10,8),%xmm2
  jmp    L125
  nopl   0x0(%rax)
L142:
  subsd  %xmm1,%xmm2
  add    $0x1,%edx
  jmp    L96
  nopl   0x0(%rax)
L196:
  xor    %eax,%eax
  jmp    L119
L84:
  xor    %edx,%edx
  xor    %eax,%eax
  jmp    L178
L144:
  mov    %eax,%edx
  jmp    L178
```

tool_calls: name: read_data
arguments: data_tag: D3
data_type: f64

tool: D3: 1

assistant: ```c
void LengthBounds(double **lmx, int statenum, int N, double epsilon, int **ret_min, int **ret_max) {
  int *min, *max;
  int y, len;
  int cmin, cmax;
  double best;
  double p_remain;
  min = (int *)MallocOrDie(sizeof(int) * statenum);
  max = (int *)MallocOrDie(sizeof(int) * statenum);
  for (y = 0; y < statenum; y++) {
    DNorm(lmx[y], (N + 1));
    best = lmx[y][0];
    cmin = 0;
    for (len = 1; len <= N; len++)
      if (lmx[y][len] > best) {
        best = lmx[y][len];
        cmin = len;
      }
    cmax = cmin;
    p_remain = 1.0 - lmx[y][cmin];
    while (p_remain > epsilon) {
      if (cmin == 0 && cmax == N)
        break;
      else if (cmin == 0)
        p_remain -= lmx[y][++cmax];
      else if (cmax == N)
        p_remain -= lmx[y][--cmin];
      else {
        if (lmx[y][cmin - 1] > lmx[y][cmax + 1])
          p_remain -= lmx[y][--cmin];
        else
          p_remain -= lmx[y][++cmax];
      }
    }
    min[y] = cmin;
    max[y] = cmax;
  }
  *ret_min = min;
  *ret_max = max;
}
```