user: What would the C source look like for the assembly code provided here?

```asm
<HTS_set_duration>:
  endbr64
  push   %r15
  pxor   %xmm4,%xmm4
  mov    %rdi,%r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  mov    %rdx,%rbp
  push   %rbx
  mov    %rsi,%rbx
  sub    $0x38,%rsp
  ucomisd %xmm4,%xmm0
  mov    %ecx,0x24(%rsp)
  jp     L248
  je     L204
L248:
  movsd  D8(%rip),%xmm2
  mov    0x24(%rsp),%edi
  addsd  %xmm2,%xmm0
  cvttsd2si %xmm0,%eax
  mov    %eax,0x20(%rsp)
  cmp    %edi,%eax
  jle    L131
  pxor   %xmm5,%xmm5
  cvtsi2sd %eax,%xmm5
  movsd  %xmm5,0x28(%rsp)
  test   %edi,%edi
  jle    L119
  pxor   %xmm0,%xmm0
  movslq 0x24(%rsp),%rcx
  xor    %eax,%eax
  movapd %xmm0,%xmm1
  nopl   0x0(%rax)
L291:
  addsd  (%rbx,%rax,8),%xmm1
  addsd  0x0(%rbp,%rax,8),%xmm0
  add    $0x1,%rax
  cmp    %rax,%rcx
  jne    L291
  movsd  0x28(%rsp),%xmm3
  xor    %eax,%eax
  xor    %r12d,%r12d
  subsd  %xmm1,%xmm3
  divsd  %xmm0,%xmm3
  movsd  %xmm3,0x8(%rsp)
  nopl   (%rax)
L69:
  movsd  0x8(%rsp),%xmm0
  mulsd  0x0(%rbp,%rax,8),%xmm0
  mov    $0x1,%esi
  addsd  (%rbx,%rax,8),%xmm0
  addsd  %xmm2,%xmm0
  cvttsd2si %xmm0,%edx
  test   %edx,%edx
  cmovle %esi,%edx
  mov    %edx,(%r15,%rax,4)
  add    $0x1,%rax
  add    %edx,%r12d
  cmp    %rax,%rcx
  jne    L69
L19:
  cmp    %r12d,0x20(%rsp)
  je     L288
  cmp    %r12d,0x20(%rsp)
  jg     L220
  nopl   0x0(%rax)
L250:
  movslq 0x24(%rsp),%rcx
  mov    $0x1,%r13d
  mov    $0xffffffff,%r14d
  mov    $0xfffffffffffffffc,%rdx
  cmp    $0x1,%ecx
  jg     L31
  jmp    L15
  nopw   0x0(%rax,%rax,1)
L327:
  add    $0x1,%r13
  cmp    %r13,%rcx
  je     L121
L31:
  mov    (%r15,%r13,4),%eax
  cmp    $0x1,%eax
  jle    L327
  movsd  0x8(%rsp),%xmm2
  pxor   %xmm0,%xmm0
  mov    %rcx,0x10(%rsp)
  cvtsi2sd %eax,%xmm0
  subsd  D38(%rip),%xmm0
  movsd  %xmm1,0x18(%rsp)
  subsd  (%rbx,%r13,8),%xmm0
  divsd  0x0(%rbp,%r13,8),%xmm0
  subsd  %xmm0,%xmm2
  movapd %xmm2,%xmm0
  call   <abs@plt>
  cmp    $0xffffffff,%r14d
  mov    0x10(%rsp),%rcx
  je     L188
  movsd  0x18(%rsp),%xmm1
  comisd %xmm1,%xmm0
  maxsd  %xmm1,%xmm0
  cmova  %r13d,%r14d
  add    $0x1,%r13
  movapd %xmm0,%xmm1
  cmp    %r13,%rcx
  jne    L31
L121:
  movslq %r14d,%rdx
  shl    $0x2,%rdx
L15:
  subl   $0x1,(%r15,%rdx,1)
  sub    $0x1,%r12d
L118:
  cmp    0x20(%rsp),%r12d
  je     L288
  cmp    %r12d,0x20(%rsp)
  jle    L250
L220:
  movslq 0x24(%rsp),%rax
  cmp    $0x1,%eax
  jle    L61
  mov    %rax,0x18(%rsp)
  mov    $0x1,%r13d
  mov    $0xffffffff,%r14d
  jmp    L187
  nopw   0x0(%rax,%rax,1)
L214:
  movsd  0x10(%rsp),%xmm1
  comisd %xmm1,%xmm0
  maxsd  %xmm1,%xmm0
  cmova  %r13d,%r14d
  movapd %xmm0,%xmm1
  add    $0x1,%r13
  cmp    %r13,0x18(%rsp)
  je     L136
L187:
  movsd  0x8(%rsp),%xmm2
  pxor   %xmm0,%xmm0
  movsd  %xmm1,0x10(%rsp)
  cvtsi2sdl (%r15,%r13,4),%xmm0
  addsd  D38(%rip),%xmm0
  subsd  (%rbx,%r13,8),%xmm0
  divsd  0x0(%rbp,%r13,8),%xmm0
  subsd  %xmm0,%xmm2
  movapd %xmm2,%xmm0
  call   <abs@plt>
  cmp    $0xffffffff,%r14d
  jne    L214
  mov    %r13d,%r14d
  movapd %xmm0,%xmm1
  add    $0x1,%r13
  cmp    %r13,0x18(%rsp)
  jne    L187
L136:
  movslq %r14d,%rdx
  shl    $0x2,%rdx
L298:
  addl   $0x1,(%r15,%rdx,1)
  add    $0x1,%r12d
  jmp    L118
  xchg   %ax,%ax
L131:
  jl     L158
L28:
  mov    0x24(%rsp),%eax
  test   %eax,%eax
  jle    L107
  mov    0x24(%rsp),%eax
  mov    %r15,%r8
  sub    $0x1,%eax
  lea    0x4(%r15,%rax,4),%rax
  nopl   (%rax)
L94:
  movl   $0x1,(%r8)
  add    $0x4,%r8
  cmp    %r8,%rax
  jne    L94
L107:
  pxor   %xmm7,%xmm7
  cvtsi2sdl 0x24(%rsp),%xmm7
  movsd  %xmm7,0x28(%rsp)
L288:
  movsd  0x28(%rsp),%xmm0
  add    $0x38,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   (%rax)
L188:
  movapd %xmm0,%xmm1
  mov    %r13d,%r14d
  jmp    L327
  nopl   0x0(%rax)
L204:
  test   %ecx,%ecx
  jle    L289
  movsd  D8(%rip),%xmm2
  movslq %ecx,%r14
  xor    %edx,%edx
  xor    %ecx,%ecx
  nop
L109:
  movsd  (%rbx,%rdx,8),%xmm0
  mov    $0x1,%esi
  addsd  %xmm2,%xmm0
  cvttsd2si %xmm0,%eax
  test   %eax,%eax
  cmovle %esi,%eax
  mov    %eax,(%r15,%rdx,4)
  add    $0x1,%rdx
  add    %eax,%ecx
  cmp    %rdx,%r14
  jne    L109
  pxor   %xmm6,%xmm6
  cvtsi2sd %ecx,%xmm6
  movsd  %xmm6,0x28(%rsp)
  jmp    L288
L158:
  lea    D0(%rip),%rsi
  mov    $0xffffffff,%edi
  call   <HTS_error@plt>
  jmp    L28
  nopl   0x0(%rax)
L61:
  mov    $0xfffffffffffffffc,%rdx
  jmp    L298
L119:
  movsd  0x28(%rsp),%xmm7
  pxor   %xmm6,%xmm6
  pxor   %xmm1,%xmm1
  xor    %r12d,%r12d
  divsd  %xmm6,%xmm7
  movsd  %xmm7,0x8(%rsp)
  jmp    L19
L289:
  movq   $0x0,0x28(%rsp)
  jmp    L288
```

tool_calls: name: retrieve_data
arguments: tag: D8
datatype: f64
name: retrieve_data
arguments: tag: D38
datatype: f32[2]
name: retrieve_data
arguments: tag: D0
datatype: string

tool: D8: 0.5

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

tool: D0: 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;
}
```