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

```asm
<HTS_set_specified_duration>:
  endbr64
  push   %rbp
  mov    %rcx,%rbp
  push   %rbx
  mov    %rdi,%rbx
  mov    $0x1,%edi
  sub    $0x8,%rsp
  movsd  D8(%rip),%xmm4
  movsd  D65(%rip),%xmm3
  addsd  %xmm4,%xmm0
  comisd %xmm0,%xmm3
  ja     L299
  movsd  D13(%rip),%xmm1
  comisd %xmm1,%xmm0
  jb     L224
  subsd  %xmm1,%xmm0
  cvttsd2si %xmm0,%rdi
  btc    $0x3f,%rdi
L299:
  cmp    %rbp,%rdi
  jbe    L162
L152:
  test   %rdi,%rdi
  js     L347
  pxor   %xmm7,%xmm7
  cvtsi2sd %rdi,%xmm7
L98:
  test   %rbp,%rbp
  je     L374
  cmp    $0x1,%rbp
  je     L213
  mov    %rbp,%rcx
  pxor   %xmm0,%xmm0
  xor    %eax,%eax
  shr    %rcx
  movapd %xmm0,%xmm1
  shl    $0x4,%rcx
  nopl   0x0(%rax)
L261:
  movsd  (%rsi,%rax,1),%xmm2
  addsd  %xmm2,%xmm1
  movsd  0x8(%rsi,%rax,1),%xmm2
  addsd  %xmm2,%xmm1
  movsd  (%rdx,%rax,1),%xmm2
  addsd  %xmm2,%xmm0
  movsd  0x8(%rdx,%rax,1),%xmm2
  add    $0x10,%rax
  addsd  %xmm2,%xmm0
  cmp    %rcx,%rax
  jne    L261
  mov    %rbp,%rax
  and    $0xfffffffffffffffe,%rax
  test   $0x1,%bpl
  je     L166
L89:
  addsd  (%rsi,%rax,8),%xmm1
  addsd  (%rdx,%rax,8),%xmm0
L166:
  movapd %xmm7,%xmm6
  xor    %ecx,%ecx
  xor    %eax,%eax
  movabs $0x8000000000000000,%r9
  subsd  %xmm1,%xmm6
  divsd  %xmm0,%xmm6
  movsd  D13(%rip),%xmm0
L62:
  movsd  (%rdx,%rax,8),%xmm2
  mulsd  %xmm6,%xmm2
  addsd  (%rsi,%rax,8),%xmm2
  addsd  %xmm4,%xmm2
  comisd %xmm2,%xmm3
  ja     L79
  comisd %xmm0,%xmm2
  jae    L283
  cvttsd2si %xmm2,%r8
L432:
  mov    %r8,(%rbx,%rax,8)
  add    $0x1,%rax
  add    %r8,%rcx
  cmp    %rax,%rbp
  jne    L62
L84:
  cmp    %rcx,%rdi
  je     L1
  movq   D30(%rip),%xmm4
  movapd %xmm4,%xmm5
L31:
  cmp    %rcx,%rdi
  ja     L440
  mov    $0xffffffffffffffff,%r9
  xor    %eax,%eax
  test   %rbp,%rbp
  jne    L336
  jmp    L290
  nopl   0x0(%rax)
L444:
  pxor   %xmm0,%xmm0
  cvtsi2sd %r8,%xmm0
L360:
  movapd %xmm6,%xmm1
  subsd  %xmm3,%xmm0
  subsd  (%rsi,%rax,8),%xmm0
  divsd  (%rdx,%rax,8),%xmm0
  subsd  %xmm0,%xmm1
  andpd  %xmm5,%xmm1
  movapd %xmm1,%xmm0
  test   %r9d,%r9d
  js     L325
  comisd %xmm1,%xmm2
  jbe    L338
L325:
  movslq %eax,%r9
  movapd %xmm0,%xmm2
L338:
  add    $0x1,%rax
  cmp    %rax,%rbp
  je     L177
L336:
  mov    (%rbx,%rax,8),%r8
  cmp    $0x1,%r8
  jbe    L338
  test   %r8,%r8
  jns    L444
  mov    %r8,%r10
  and    $0x1,%r8d
  pxor   %xmm0,%xmm0
  shr    %r10
  or     %r8,%r10
  cvtsi2sd %r10,%xmm0
  addsd  %xmm0,%xmm0
  jmp    L360
  nopl   0x0(%rax)
L224:
  cvttsd2si %xmm0,%rdi
  cmp    %rbp,%rdi
  ja     L152
L162:
  jb     L106
L120:
  test   %rbp,%rbp
  je     L148
  cmp    $0x1,%rbp
  je     L10
  mov    %rbp,%rdx
  movdqa D33(%rip),%xmm0
  mov    %rbx,%rax
  shr    %rdx
  shl    $0x4,%rdx
  add    %rbx,%rdx
  nopl   0x0(%rax,%rax,1)
L206:
  movups %xmm0,(%rax)
  add    $0x10,%rax
  cmp    %rax,%rdx
  jne    L206
  mov    %rbp,%rax
  and    $0xfffffffffffffffe,%rax
  test   $0x1,%bpl
  je     L148
L149:
  movq   $0x1,(%rbx,%rax,8)
L148:
  pxor   %xmm7,%xmm7
  cvtsi2sd %rbp,%xmm7
L1:
  add    $0x8,%rsp
  movapd %xmm7,%xmm0
  pop    %rbx
  pop    %rbp
  ret
  nopl   (%rax)
L347:
  mov    %rdi,%rax
  mov    %rdi,%rcx
  pxor   %xmm7,%xmm7
  shr    %rax
  and    $0x1,%ecx
  or     %rcx,%rax
  cvtsi2sd %rax,%xmm7
  addsd  %xmm7,%xmm7
  jmp    L98
  nopl   0x0(%rax)
L440:
  test   %rbp,%rbp
  je     L356
  mov    $0xffffffffffffffff,%r9
  xor    %eax,%eax
  jmp    L103
  nopl   0x0(%rax)
L217:
  pxor   %xmm0,%xmm0
  cvtsi2sd %r8,%xmm0
L116:
  movapd %xmm6,%xmm1
  addsd  %xmm3,%xmm0
  subsd  (%rsi,%rax,8),%xmm0
  divsd  (%rdx,%rax,8),%xmm0
  subsd  %xmm0,%xmm1
  andpd  %xmm4,%xmm1
  movapd %xmm1,%xmm0
  test   %r9d,%r9d
  js     L340
  comisd %xmm1,%xmm2
  jbe    L457
L340:
  movslq %eax,%r9
  movapd %xmm0,%xmm2
L457:
  add    $0x1,%rax
  cmp    %rax,%rbp
  je     L90
L103:
  mov    (%rbx,%rax,8),%r8
  test   %r8,%r8
  jns    L217
  mov    %r8,%r10
  and    $0x1,%r8d
  pxor   %xmm0,%xmm0
  shr    %r10
  or     %r8,%r10
  cvtsi2sd %r10,%xmm0
  addsd  %xmm0,%xmm0
  jmp    L116
  nopw   0x0(%rax,%rax,1)
L177:
  shl    $0x3,%r9
L393:
  subq   $0x1,(%rbx,%r9,1)
  sub    $0x1,%rcx
L331:
  cmp    %rdi,%rcx
  jne    L31
  add    $0x8,%rsp
  movapd %xmm7,%xmm0
  pop    %rbx
  pop    %rbp
  ret
  nopl   0x0(%rax)
L90:
  shl    $0x3,%r9
L421:
  addq   $0x1,(%rbx,%r9,1)
  add    $0x1,%rcx
  jmp    L331
  nopw   0x0(%rax,%rax,1)
L79:
  movq   $0x1,(%rbx,%rax,8)
  add    $0x1,%rax
  add    $0x1,%rcx
  cmp    %rax,%rbp
  jne    L62
  jmp    L84
  xchg   %ax,%ax
L283:
  movapd %xmm2,%xmm1
  subsd  %xmm0,%xmm1
  cvttsd2si %xmm1,%r8
  xor    %r9,%r8
  jmp    L432
  nopl   (%rax)
L356:
  mov    $0xfffffffffffffff8,%r9
  jmp    L421
  nopl   0x0(%rax)
L290:
  mov    $0xfffffffffffffff8,%r9
  jmp    L393
L106:
  lea    D19(%rip),%rsi
  mov    $0xffffffff,%edi
  call   <HTS_error@plt>
  jmp    L120
L374:
  pxor   %xmm2,%xmm2
  movapd %xmm7,%xmm6
  xor    %ecx,%ecx
  divsd  %xmm2,%xmm6
  jmp    L84
L213:
  pxor   %xmm0,%xmm0
  xor    %eax,%eax
  movapd %xmm0,%xmm1
  jmp    L89
L10:
  xor    %eax,%eax
  jmp    L149
```

tool_calls: name: read_data
arguments: data_tag: D8
data_type: f64
name: read_data
arguments: data_tag: D65
data_type: f64
name: read_data
arguments: data_tag: D13
data_type: f32[2]
name: read_data
arguments: data_tag: D30
data_type: qword
name: read_data
arguments: data_tag: D33
data_type: byte[16]
name: read_data
arguments: data_tag: D19
data_type: string

tool: D8: 0.5

tool: D65: 1

tool: {"D13": [0.0,448.0]}

tool: D30: 9223372036854775807

tool: {"D33": [0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00]}

tool: D19: HTS_set_specified_duration: Specified frame length is too short.


assistant: ```c
double HTS_set_specified_duration(size_t *duration, double *mean, double *vari, size_t size, double frame_length) {
  size_t i;
  int j;
  double temp1, temp2;
  double rho = 0.0;
  size_t sum = 0;
  size_t target_length;
  if (frame_length + 0.5 < 1.0)
    target_length = 1;
  else
    target_length = (size_t)(frame_length + 0.5);
  if (target_length <= size) {
    if (target_length < size)
      HTS_error(-1, "HTS_set_specified_duration: Specified frame length is too short.\n");
    for (i = 0; i < size; i++)
      duration[i] = 1;
    return (double)size;
  }
  temp1 = 0.0;
  temp2 = 0.0;
  for (i = 0; i < size; i++) {
    temp1 += mean[i];
    temp2 += vari[i];
  }
  rho = ((double)target_length - temp1) / temp2;
  for (i = 0; i < size; i++) {
    temp1 = mean[i] + rho * vari[i] + 0.5;
    if (temp1 < 1.0)
      duration[i] = 1;
    else
      duration[i] = (size_t)temp1;
    sum += duration[i];
  }
  while (target_length != sum) {
    if (target_length > sum) {
      j = -1;
      for (i = 0; i < size; i++) {
        temp2 = fabs(rho - ((double)duration[i] + 1 - mean[i]) / vari[i]);
        if (j < 0 || temp1 > temp2) {
          j = i;
          temp1 = temp2;
        }
      }
      sum++;
      duration[j]++;
    } else {
      j = -1;
      for (i = 0; i < size; i++) {
        if (duration[i] > 1) {
          temp2 = fabs(rho - ((double)duration[i] - 1 - mean[i]) / vari[i]);
          if (j < 0 || temp1 > temp2) {
            j = i;
            temp1 = temp2;
          }
        }
      }
      sum--;
      duration[j]--;
    }
  }
  return (double)target_length;
}
```