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

```asm
<HTS_set_duration>:
  endbr64
  push   %r15
  pxor   %xmm5,%xmm5
  mov    %rdi,%r15
  push   %r14
  mov    %rsi,%r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  mov    %rdx,%rbx
  sub    $0x38,%rsp
  ucomisd %xmm5,%xmm0
  mov    %ecx,0x20(%rsp)
  jp     L438
  je     L362
L438:
  movsd  D104(%rip),%xmm7
  mov    0x20(%rsp),%esi
  addsd  %xmm7,%xmm0
  cvttsd2si %xmm0,%eax
  mov    %eax,0x24(%rsp)
  cmp    %esi,%eax
  jle    L462
  pxor   %xmm6,%xmm6
  cvtsi2sd %eax,%xmm6
  movsd  %xmm6,0x28(%rsp)
  test   %esi,%esi
  jle    L399
  cmp    $0x1,%esi
  je     L194
  mov    %esi,%edx
  pxor   %xmm0,%xmm0
  xor    %eax,%eax
  shr    %edx
  movapd %xmm0,%xmm1
  shl    $0x4,%rdx
L324:
  movsd  (%r14,%rax,1),%xmm2
  addsd  %xmm1,%xmm2
  movsd  0x8(%r14,%rax,1),%xmm1
  addsd  %xmm2,%xmm1
  movsd  (%rbx,%rax,1),%xmm2
  addsd  %xmm2,%xmm0
  movsd  0x8(%rbx,%rax,1),%xmm2
  add    $0x10,%rax
  addsd  %xmm2,%xmm0
  cmp    %rdx,%rax
  jne    L324
  mov    0x20(%rsp),%edi
  mov    %edi,%eax
  and    $0xfffffffe,%eax
  and    $0x1,%edi
  je     L212
L144:
  cltq
  addsd  (%r14,%rax,8),%xmm1
  addsd  (%rbx,%rax,8),%xmm0
L212:
  movsd  0x28(%rsp),%xmm2
  movslq 0x20(%rsp),%rdx
  subsd  %xmm1,%xmm2
  lea    0x0(,%rdx,8),%rax
  mov    %rdx,%rsi
  lea    (%r15,%rdx,4),%rcx
  lea    (%r14,%rax,1),%rdx
  cmp    %rdx,%r15
  divsd  %xmm0,%xmm2
  setae  %dl
  cmp    %r14,%rcx
  setbe  %dil
  add    %rbx,%rax
  or     %edi,%edx
  cmp    %rax,%r15
  setae  %al
  cmp    %rbx,%rcx
  setbe  %cl
  or     %ecx,%eax
  movsd  %xmm2,0x10(%rsp)
  test   %al,%dl
  je     L180
  lea    -0x1(%rsi),%eax
  cmp    $0x2,%eax
  jbe    L180
  mov    %esi,%edx
  movapd %xmm2,%xmm6
  movapd D104(%rip),%xmm4
  xor    %eax,%eax
  shr    $0x2,%edx
  movdqa D61(%rip),%xmm3
  unpcklpd %xmm6,%xmm6
  pxor   %xmm5,%xmm5
  shl    $0x4,%rdx
  nopl   0x0(%rax,%rax,1)
L310:
  movupd (%rbx,%rax,2),%xmm0
  movupd (%r14,%rax,2),%xmm2
  movupd 0x10(%r14,%rax,2),%xmm8
  mulpd  %xmm6,%xmm0
  addpd  %xmm2,%xmm0
  movupd 0x10(%rbx,%rax,2),%xmm2
  mulpd  %xmm6,%xmm2
  addpd  %xmm4,%xmm0
  cvttpd2dq %xmm0,%xmm0
  addpd  %xmm8,%xmm2
  addpd  %xmm4,%xmm2
  cvttpd2dq %xmm2,%xmm2
  punpcklqdq %xmm2,%xmm0
  movdqa %xmm0,%xmm2
  pcmpgtd %xmm3,%xmm2
  pand   %xmm2,%xmm0
  pandn  %xmm3,%xmm2
  por    %xmm2,%xmm0
  movups %xmm0,(%r15,%rax,1)
  add    $0x10,%rax
  paddd  %xmm0,%xmm5
  cmp    %rdx,%rax
  jne    L310
  movdqa %xmm5,%xmm0
  mov    0x20(%rsp),%esi
  psrldq $0x8,%xmm0
  paddd  %xmm5,%xmm0
  mov    %esi,%ecx
  movdqa %xmm0,%xmm2
  and    $0xfffffffc,%ecx
  psrldq $0x4,%xmm2
  paddd  %xmm2,%xmm0
  movd   %xmm0,%ebp
  test   $0x3,%sil
  je     L419
  mov    %ecx,%edx
  movsd  0x10(%rsp),%xmm5
  mov    $0x1,%r9d
  movsd  (%rbx,%rdx,8),%xmm0
  lea    0x0(,%rdx,8),%rdi
  lea    0x0(,%rdx,4),%r8
  mulsd  %xmm5,%xmm0
  addsd  (%r14,%rdx,8),%xmm0
  addsd  %xmm7,%xmm0
  cvttsd2si %xmm0,%eax
  test   %eax,%eax
  cmovle %r9d,%eax
  mov    %eax,(%r15,%rdx,4)
  add    %eax,%ebp
  lea    0x1(%rcx),%eax
  cmp    %eax,%esi
  jle    L419
  movsd  0x8(%rbx,%rdi,1),%xmm0
  mov    $0x1,%edx
  mulsd  %xmm5,%xmm0
  addsd  0x8(%r14,%rdi,1),%xmm0
  addsd  %xmm7,%xmm0
  cvttsd2si %xmm0,%eax
  test   %eax,%eax
  cmovle %edx,%eax
  add    $0x2,%ecx
  mov    %eax,0x4(%r15,%r8,1)
  add    %eax,%ebp
  cmp    %ecx,%esi
  jle    L419
  mulsd  0x10(%rbx,%rdi,1),%xmm5
  movsd  0x10(%r14,%rdi,1),%xmm0
  addsd  %xmm5,%xmm0
  addsd  %xmm7,%xmm0
  cvttsd2si %xmm0,%eax
  test   %eax,%eax
  cmovle %edx,%eax
  mov    %eax,0x8(%r15,%r8,1)
  add    %eax,%ebp
L419:
  cmp    %ebp,0x24(%rsp)
  je     L386
  nopl   0x0(%rax)
L338:
  cmp    %ebp,0x24(%rsp)
  jg     L210
  movslq 0x20(%rsp),%r12
  mov    $0x1,%r13d
  mov    $0xffffffff,%edx
  cmp    $0x1,%r12d
  jg     L335
  jmp    L195
  nopl   (%rax)
L373:
  add    $0x1,%r13
  cmp    %r13,%r12
  je     L331
L335:
  mov    (%r15,%r13,4),%eax
  cmp    $0x1,%eax
  jle    L373
  movsd  0x10(%rsp),%xmm2
  pxor   %xmm0,%xmm0
  mov    %edx,0x8(%rsp)
  cvtsi2sd %eax,%xmm0
  subsd  D60(%rip),%xmm0
  movsd  %xmm1,0x18(%rsp)
  subsd  (%r14,%r13,8),%xmm0
  divsd  (%rbx,%r13,8),%xmm0
  subsd  %xmm0,%xmm2
  movapd %xmm2,%xmm0
  call   <abs@plt>
  mov    0x8(%rsp),%edx
  cmp    $0xffffffff,%edx
  je     L263
  movsd  0x18(%rsp),%xmm1
  comisd %xmm1,%xmm0
  maxsd  %xmm1,%xmm0
  cmova  %r13d,%edx
  add    $0x1,%r13
  movapd %xmm0,%xmm1
  cmp    %r13,%r12
  jne    L335
L331:
  movslq %edx,%rdx
  shl    $0x2,%rdx
L301:
  subl   $0x1,(%r15,%rdx,1)
  sub    $0x1,%ebp
  jmp    L466
  nopl   0x0(%rax,%rax,1)
L462:
  jl     L230
L60:
  mov    0x20(%rsp),%eax
  test   %eax,%eax
  jle    L485
  mov    0x20(%rsp),%edi
  lea    -0x1(%rdi),%eax
  cmp    $0x2,%eax
  jbe    L30
  shr    $0x2,%edi
  movdqa D61(%rip),%xmm3
  mov    %r15,%rax
  mov    %edi,%edx
  sub    $0x1,%edx
  shl    $0x4,%rdx
  lea    0x10(%r15,%rdx,1),%rdx
  xchg   %ax,%ax
L341:
  movups %xmm3,(%rax)
  add    $0x10,%rax
  cmp    %rax,%rdx
  jne    L341
  mov    0x20(%rsp),%edi
  mov    %edi,%eax
  and    $0xfffffffc,%eax
  and    $0x3,%edi
  je     L485
L155:
  movslq %eax,%rdx
  mov    0x20(%rsp),%edi
  movl   $0x1,(%r15,%rdx,4)
  lea    0x0(,%rdx,4),%rcx
  lea    0x1(%rax),%edx
  cmp    %edi,%edx
  jge    L485
  movl   $0x1,0x4(%r15,%rcx,1)
  add    $0x2,%eax
  cmp    %eax,%edi
  jle    L485
  movl   $0x1,0x8(%r15,%rcx,1)
L485:
  pxor   %xmm7,%xmm7
  cvtsi2sdl 0x20(%rsp),%xmm7
  movsd  %xmm7,0x28(%rsp)
L386:
  movsd  0x28(%rsp),%xmm0
  add    $0x38,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  cs nopw 0x0(%rax,%rax,1)
L263:
  movapd %xmm0,%xmm1
  mov    %r13d,%edx
  jmp    L373
  nopl   0x0(%rax)
L210:
  movslq 0x20(%rsp),%rax
  cmp    $0x1,%eax
  jle    L500
  mov    %rax,0x18(%rsp)
  mov    $0x1,%r12d
  mov    $0xffffffff,%r13d
  jmp    L549
  nopl   0x0(%rax)
L275:
  movsd  0x8(%rsp),%xmm1
  comisd %xmm1,%xmm0
  maxsd  %xmm1,%xmm0
  cmova  %r12d,%r13d
  movapd %xmm0,%xmm1
  add    $0x1,%r12
  cmp    0x18(%rsp),%r12
  je     L489
L549:
  movsd  0x10(%rsp),%xmm2
  pxor   %xmm0,%xmm0
  movsd  %xmm1,0x8(%rsp)
  cvtsi2sdl (%r15,%r12,4),%xmm0
  addsd  D60(%rip),%xmm0
  subsd  (%r14,%r12,8),%xmm0
  divsd  (%rbx,%r12,8),%xmm0
  subsd  %xmm0,%xmm2
  movapd %xmm2,%xmm0
  call   <abs@plt>
  cmp    $0xffffffff,%r13d
  jne    L275
  mov    %r12d,%r13d
  movapd %xmm0,%xmm1
  add    $0x1,%r12
  cmp    0x18(%rsp),%r12
  jne    L549
L489:
  movslq %r13d,%rdx
  shl    $0x2,%rdx
L187:
  addl   $0x1,(%r15,%rdx,1)
  add    $0x1,%ebp
L466:
  cmp    0x24(%rsp),%ebp
  jne    L338
  jmp    L386
  cs nopw 0x0(%rax,%rax,1)
L362:
  mov    %ecx,%esi
  test   %ecx,%ecx
  jle    L277
  movslq %ecx,%rdx
  lea    (%rdi,%rdx,4),%rax
  lea    (%r14,%rdx,8),%rdx
  cmp    %rax,%r14
  setae  %al
  cmp    %rdx,%rdi
  setae  %dl
  or     %dl,%al
  je     L9
  lea    -0x1(%rcx),%eax
  cmp    $0x3,%eax
  jbe    L9
  shr    $0x2,%esi
  movapd D104(%rip),%xmm4
  xor    %eax,%eax
  pxor   %xmm2,%xmm2
  mov    %esi,%edx
  movdqa D61(%rip),%xmm3
  shl    $0x4,%rdx
  nopl   0x0(%rax)
L531:
  movupd (%r14,%rax,2),%xmm0
  movupd 0x10(%r14,%rax,2),%xmm1
  addpd  %xmm4,%xmm0
  addpd  %xmm4,%xmm1
  cvttpd2dq %xmm0,%xmm0
  cvttpd2dq %xmm1,%xmm1
  punpcklqdq %xmm1,%xmm0
  movdqa %xmm0,%xmm1
  pcmpgtd %xmm3,%xmm1
  pand   %xmm1,%xmm0
  pandn  %xmm3,%xmm1
  por    %xmm1,%xmm0
  movups %xmm0,(%r15,%rax,1)
  add    $0x10,%rax
  paddd  %xmm0,%xmm2
  cmp    %rdx,%rax
  jne    L531
  movdqa %xmm2,%xmm0
  mov    0x20(%rsp),%esi
  psrldq $0x8,%xmm0
  paddd  %xmm0,%xmm2
  mov    %esi,%edx
  movdqa %xmm2,%xmm0
  and    $0xfffffffc,%edx
  psrldq $0x4,%xmm0
  paddd  %xmm0,%xmm2
  movd   %xmm2,%eax
  test   $0x3,%sil
  je     L130
  mov    %edx,%edi
  movsd  D104(%rip),%xmm0
  mov    $0x1,%r10d
  movsd  (%r14,%rdi,8),%xmm1
  lea    0x0(,%rdi,8),%r9
  lea    0x0(,%rdi,4),%r8
  addsd  %xmm0,%xmm1
  cvttsd2si %xmm1,%ecx
  test   %ecx,%ecx
  cmovle %r10d,%ecx
  mov    %ecx,(%r15,%rdi,4)
  add    %ecx,%eax
  lea    0x1(%rdx),%ecx
  cmp    %esi,%ecx
  jge    L130
  movsd  0x8(%r14,%r9,1),%xmm1
  mov    $0x1,%edi
  addsd  %xmm0,%xmm1
  cvttsd2si %xmm1,%ecx
  test   %ecx,%ecx
  cmovle %edi,%ecx
  add    $0x2,%edx
  mov    %ecx,0x4(%r15,%r8,1)
  add    %ecx,%eax
  cmp    %edx,%esi
  jle    L130
  addsd  0x10(%r14,%r9,1),%xmm0
  mov    $0x1,%ecx
  cvttsd2si %xmm0,%edx
  test   %edx,%edx
  cmovle %ecx,%edx
  mov    %edx,0x8(%r15,%r8,1)
  add    %edx,%eax
L130:
  pxor   %xmm7,%xmm7
  cvtsi2sd %eax,%xmm7
  movsd  %xmm7,0x28(%rsp)
  jmp    L386
L230:
  lea    D28(%rip),%rsi
  mov    $0xffffffff,%edi
  call   <HTS_error@plt>
  jmp    L60
  nopl   (%rax)
L500:
  mov    $0xfffffffffffffffc,%rdx
  jmp    L187
  nopl   0x0(%rax)
L195:
  mov    $0xfffffffffffffffc,%rdx
  jmp    L301
L180:
  mov    0x20(%rsp),%edi
  xor    %eax,%eax
  xor    %ebp,%ebp
  nopl   0x0(%rax)
L243:
  movsd  0x10(%rsp),%xmm0
  mulsd  (%rbx,%rax,8),%xmm0
  mov    $0x1,%ecx
  addsd  (%r14,%rax,8),%xmm0
  addsd  %xmm7,%xmm0
  cvttsd2si %xmm0,%edx
  test   %edx,%edx
  cmovle %ecx,%edx
  mov    %edx,(%r15,%rax,4)
  add    $0x1,%rax
  add    %edx,%ebp
  cmp    %rax,%rdi
  jne    L243
  jmp    L419
L9:
  mov    0x20(%rsp),%r12d
  movsd  D104(%rip),%xmm7
  xor    %ecx,%ecx
  xor    %eax,%eax
L37:
  movsd  (%r14,%rcx,8),%xmm0
  mov    $0x1,%edi
  addsd  %xmm7,%xmm0
  cvttsd2si %xmm0,%edx
  test   %edx,%edx
  cmovle %edi,%edx
  mov    %edx,(%r15,%rcx,4)
  add    $0x1,%rcx
  add    %edx,%eax
  cmp    %r12,%rcx
  jne    L37
  jmp    L130
L399:
  movapd %xmm6,%xmm7
  pxor   %xmm6,%xmm6
  pxor   %xmm1,%xmm1
  xor    %ebp,%ebp
  divsd  %xmm6,%xmm7
  movsd  %xmm7,0x10(%rsp)
  jmp    L419
L194:
  pxor   %xmm0,%xmm0
  xor    %eax,%eax
  movapd %xmm0,%xmm1
  jmp    L144
L277:
  movq   $0x0,0x28(%rsp)
  jmp    L386
L30:
  xor    %eax,%eax
  jmp    L155
```

tool_calls: name: unpack_data
arguments: data_tag: D104
type_infered: f64[2]
name: unpack_data
arguments: data_tag: D61
type_infered: byte[16]
name: unpack_data
arguments: data_tag: D60
type_infered: f32[2]
name: unpack_data
arguments: data_tag: D28
type_infered: string

tool: {"D104": [0.5,0.5]}

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

tool: {"D60": [0.0,1.875]}

tool: D28: HTS_set_duration: Specified frame length is too short.


assistant: ```c
double HTS_set_duration(int *duration, double *mean, double *vari, int size, double frame_length) {
  int i, j;
  double temp1, temp2;
  double rho = 0.0;
  int sum = 0;
  int target_length;
  if (frame_length == 0.0) {
    for (i = 0; i < size; i++) {
      duration[i] = (int)(mean[i] + 0.5);
      if (duration[i] < 1)
        duration[i] = 1;
      sum += duration[i];
    }
    return (double)sum;
  }
  target_length = (int)(frame_length + 0.5);
  if (target_length <= size) {
    if (target_length < size)
      HTS_error(-1, "HTS_set_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++) {
    duration[i] = (int)(mean[i] + rho * vari[i] + 0.5);
    if (duration[i] < 1)
      duration[i] = 1;
    sum += duration[i];
  }
  while (target_length != sum) {
    if (target_length > sum) {
      j = -1;
      for (i = 1; i < size; i++) {
        temp2 = abs(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 = 1; i < size; i++) {
        if (duration[i] > 1) {
          temp2 = abs(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;
}
```