user: Please show me the C implementation that matches the assembly code listed below:

```asm
<scd>:
  endbr64
  push   %r15
  mulsd  %xmm2,%xmm2
  movapd %xmm0,%xmm3
  pxor   %xmm0,%xmm0
  push   %r14
  xor    %r14d,%r14d
  mov    %rdx,%r15
  push   %r13
  mov    %rsi,%r13
  push   %r12
  mov    %rdi,%r12
  push   %rbp
  push   %rbx
  sub    $0x28,%rsp
  comisd %xmm3,%xmm0
  jbe    L81
  andpd  D30(%rip),%xmm3
  mov    $0x1,%r14d
L81:
  movapd %xmm1,%xmm5
  movapd %xmm3,%xmm0
  movsd  %xmm2,0x18(%rsp)
  xor    %ebp,%ebp
  mulsd  D10(%rip),%xmm5
  movsd  %xmm1,0x10(%rsp)
  movsd  %xmm3,0x8(%rsp)
  divsd  %xmm5,%xmm0
  movsd  %xmm5,(%rsp)
  call   <floor@plt>
  pxor   %xmm4,%xmm4
  movsd  (%rsp),%xmm5
  movsd  0x8(%rsp),%xmm3
  cvtsi2sd %eax,%xmm4
  movsd  0x10(%rsp),%xmm1
  movsd  0x18(%rsp),%xmm2
  mulsd  %xmm5,%xmm4
  subsd  %xmm4,%xmm3
  movapd %xmm3,%xmm0
  movapd %xmm1,%xmm3
  addsd  %xmm1,%xmm3
  comisd %xmm3,%xmm0
  jbe    L35
  subsd  %xmm3,%xmm0
  mov    $0x1,%ebp
L35:
  movsd  D66(%rip),%xmm3
  movsd  D23(%rip),%xmm5
  xor    %ebx,%ebx
  mulsd  %xmm3,%xmm1
  movapd %xmm5,%xmm4
  subsd  %xmm2,%xmm4
  cvttsd2si %xmm4,%edi
  comisd %xmm1,%xmm0
  jb     L11
  xchg   %ax,%ax
L61:
  mulsd  %xmm3,%xmm0
  add    $0x1,%ebx
  comisd %xmm1,%xmm0
  jae    L61
  mov    %r15,%rcx
  mov    %r13,%rdx
  mov    %r12,%rsi
  movsd  %xmm2,(%rsp)
  call   <scd2@plt>
  movsd  (%rsp),%xmm2
  test   %rax,%rax
  mov    D23(%rip),%rax
  movq   %rax,%xmm5
  je     L60
L24:
  mov    $0x1,%r14d
L5:
  add    $0x28,%rsp
  mov    %r14d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  xchg   %ax,%ax
L60:
  movapd %xmm2,%xmm6
  movsd  (%r15),%xmm3
  addsd  %xmm2,%xmm6
  nopl   (%rax)
L47:
  movsd  (%r12),%xmm0
  movsd  0x0(%r13),%xmm4
  movapd %xmm5,%xmm7
  movapd %xmm0,%xmm1
  movapd %xmm0,%xmm9
  movapd %xmm0,%xmm8
  mulsd  %xmm2,%xmm1
  addsd  %xmm0,%xmm9
  mulsd  %xmm6,%xmm8
  mulsd  %xmm9,%xmm4
  mulsd  %xmm0,%xmm1
  mulsd  %xmm0,%xmm8
  mulsd  %xmm3,%xmm4
  movapd %xmm5,%xmm3
  mulsd  %xmm0,%xmm1
  subsd  %xmm8,%xmm3
  mulsd  %xmm0,%xmm1
  mulsd  %xmm9,%xmm0
  subsd  %xmm1,%xmm7
  addsd  %xmm1,%xmm3
  divsd  %xmm7,%xmm4
  divsd  %xmm7,%xmm3
  movsd  %xmm4,(%r12)
  movapd %xmm5,%xmm4
  subsd  %xmm0,%xmm4
  addsd  %xmm1,%xmm4
  divsd  %xmm7,%xmm4
  movsd  %xmm4,0x0(%r13)
  movsd  %xmm3,(%r15)
  sub    $0x1,%ebx
  jne    L47
L26:
  test   %ebp,%ebp
  je     L77
  movsd  (%r12),%xmm0
  movq   D51(%rip),%xmm1
  xorpd  %xmm1,%xmm0
  movsd  %xmm0,(%r12)
  movsd  0x0(%r13),%xmm0
  xorpd  %xmm1,%xmm0
  movsd  %xmm0,0x0(%r13)
L77:
  test   %r14d,%r14d
  je     L5
  movsd  (%r12),%xmm0
  xorpd  D51(%rip),%xmm0
  xor    %r14d,%r14d
  movsd  %xmm0,(%r12)
  jmp    L5
  nop
L11:
  mov    %r15,%rcx
  mov    %r13,%rdx
  mov    %r12,%rsi
  call   <scd2@plt>
  test   %rax,%rax
  je     L26
  jmp    L24
```

tool_calls: name: unpack_data
arguments: tag: D30
type_guessed: qword[2]
name: unpack_data
arguments: tag: D10
type_guessed: byte[8]
name: unpack_data
arguments: tag: D66
type_guessed: byte[8]
name: unpack_data
arguments: tag: D23
type_guessed: byte[8]
name: unpack_data
arguments: tag: D51
type_guessed: byte[16]

tool: {"D30": [0x7fffffffffffffff,0x0000000000000000]}

tool: {"D10": [0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x40]}

tool: {"D66": [0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0x3f]}

tool: {"D23": [0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x3f]}

tool: {"D51": [0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00]}

assistant: ```c
int scd(double u, double K, double k, double *s, double *c, double *d) {
  double m;
  int Ndiv2 = 0;
  int N4K = 0;
  int K2 = 0;
  int NEG = 0;
  m = k * k;
  if (u < 0) {
    NEG = 1;
    u = fabs(u);
  }
  N4K = (int)floor(u / (4 * K));
  u -= 4 * K * ((double)N4K);
  if (u > 2.0 * K) {
    u -= 2.0 * K;
    K2 = 1;
  }
  while (u >= K / 2.0) {
    u /= 2;
    Ndiv2++;
  }
  if (scd2(u, 1 - m, s, c, d))
    return 1;
  else {
    if (Ndiv2) {
      double ss, cc, dd;
      double nom;
      while (Ndiv2) {
        nom = (1 - m * (*s) * (*s) * (*s) * (*s));
        ss = 2 * (*s) * (*c) * (*d) / nom;
        cc = (1 - 2 * (*s) * (*s) + m * (*s) * (*s) * (*s) * (*s)) / nom;
        dd = (1 - 2 * m * (*s) * (*s) + m * (*s) * (*s) * (*s) * (*s)) / nom;
        (*s) = ss;
        (*c) = cc;
        (*d) = dd;
        Ndiv2--;
      }
    }
    if (K2) {
      (*s) = -(*s);
      (*c) = -(*c);
    }
    if (NEG) {
      (*s) = -(*s);
      (*c) = (*c);
    }
  }
  return 0;
}
```