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

```asm
<d2bei_clip_array>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %rdi,-0x28(%rbp)
  mov    %rsi,-0x30(%rbp)
  mov    %edx,-0x34(%rbp)
  mov    %ecx,-0x38(%rbp)
  cmpl   $0x0,-0x38(%rbp)
  je     L54
  movsd  D39(%rip),%xmm0
  jmp    L62
L54:
  movsd  D36(%rip),%xmm0
L62:
  movsd  %xmm0,-0x10(%rbp)
  mov    -0x34(%rbp),%eax
  shl    $0x2,%eax
  movslq %eax,%rdx
  mov    -0x30(%rbp),%rax
  add    %rdx,%rax
  mov    %rax,-0x18(%rbp)
  jmp    L27
L59:
  subq   $0x4,-0x18(%rbp)
  mov    -0x34(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  movsd  -0x10(%rbp),%xmm1
  mulsd  %xmm1,%xmm0
  movsd  %xmm0,-0x8(%rbp)
  movsd  -0x8(%rbp),%xmm0
  comisd D15(%rip),%xmm0
  jb     L55
  mov    -0x18(%rbp),%rax
  add    $0x3,%rax
  movb   $0xff,(%rax)
  mov    -0x18(%rbp),%rax
  add    $0x2,%rax
  movb   $0xff,(%rax)
  mov    -0x18(%rbp),%rax
  add    $0x1,%rax
  movb   $0xff,(%rax)
  mov    -0x18(%rbp),%rax
  movb   $0x7f,(%rax)
  jmp    L27
L55:
  movsd  D28(%rip),%xmm0
  comisd -0x8(%rbp),%xmm0
  jb     L69
  mov    -0x18(%rbp),%rax
  add    $0x3,%rax
  movb   $0x0,(%rax)
  mov    -0x18(%rbp),%rax
  add    $0x2,%rax
  movb   $0x0,(%rax)
  mov    -0x18(%rbp),%rax
  add    $0x1,%rax
  movb   $0x0,(%rax)
  mov    -0x18(%rbp),%rax
  movb   $0x80,(%rax)
  jmp    L27
L69:
  mov    -0x8(%rbp),%rax
  movq   %rax,%xmm0
  call   <lrint@plt>
  mov    %eax,-0x1c(%rbp)
  mov    -0x1c(%rbp),%eax
  sar    $0x18,%eax
  mov    %eax,%edx
  mov    -0x18(%rbp),%rax
  mov    %dl,(%rax)
  mov    -0x1c(%rbp),%eax
  sar    $0x10,%eax
  mov    %eax,%edx
  mov    -0x18(%rbp),%rax
  add    $0x1,%rax
  mov    %dl,(%rax)
  mov    -0x1c(%rbp),%eax
  sar    $0x8,%eax
  mov    %eax,%edx
  mov    -0x18(%rbp),%rax
  add    $0x2,%rax
  mov    %dl,(%rax)
  mov    -0x18(%rbp),%rax
  add    $0x3,%rax
  mov    -0x1c(%rbp),%edx
  mov    %dl,(%rax)
L27:
  subl   $0x1,-0x34(%rbp)
  cmpl   $0x0,-0x34(%rbp)
  jns    L59
  nop
  nop
  leave
  ret
```

tool_calls: name: unpack_data
arguments: label: D39
data_type: byte[8]
name: unpack_data
arguments: label: D36
data_type: f64
name: unpack_data
arguments: label: D15
data_type: byte[16]
name: unpack_data
arguments: label: D28
data_type: byte[8]

tool: {"D39": [0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0x41]}

tool: D36: 1

tool: {"D15": [0x00,0x00,0xc0,0xff,0xff,0xff,0xdf,0x41,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xc1]}

tool: {"D28": [0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xc1]}

assistant: ```c
void d2bei_clip_array(const double *src, int *dest, int count, int normalize) {
  unsigned char *ucptr;
  int value;
  double normfact, scaled_value;
  normfact = normalize ? (8.0 * 0x10000000) : 1.0;
  ucptr = ((unsigned char *)dest) + 4 * count;
  while (--count >= 0) {
    ucptr -= 4;
    scaled_value = src[count] * normfact;
    if (0 == 0 && scaled_value >= (1.0 * 0x7FFFFFFF)) {
      ucptr[3] = 0xFF;
      ucptr[2] = 0xFF;
      ucptr[1] = 0xFF;
      ucptr[0] = 0x7F;
      continue;
    };
    if (0 == 0 && scaled_value <= (-8.0 * 0x10000000)) {
      ucptr[3] = 0x00;
      ucptr[2] = 0x00;
      ucptr[1] = 0x00;
      ucptr[0] = 0x80;
      continue;
    };
    value = lrint(scaled_value);
    ucptr[0] = value >> 24;
    ucptr[1] = value >> 16;
    ucptr[2] = value >> 8;
    ucptr[3] = value;
  };
}
```