user: 请从给定的汇编指令推导出C源代码:

```asm
<cg_update_d>:
  endbr64
  mov    %rcx,%rax
  mov    %rdx,%r8
  movapd %xmm0,%xmm2
  mov    %rdi,%r9
  movabs $0x6666666666666667,%rdx
  mov    %rcx,%rdi
  imul   %rdx
  mov    %rcx,%rax
  sar    $0x3f,%rax
  sar    %rdx
  sub    %rax,%rdx
  lea    (%rdx,%rdx,4),%rax
  mov    %rcx,%rdx
  sub    %rax,%rdx
  test   %r8,%r8
  je     L7
  pxor   %xmm3,%xmm3
  xor    %eax,%eax
  movapd %xmm3,%xmm0
  test   %rdx,%rdx
  jle    L82
L50:
  movsd  (%rsi,%rax,8),%xmm4
  movapd %xmm4,%xmm1
  mulsd  %xmm4,%xmm1
  addsd  %xmm1,%xmm3
  movsd  (%r9,%rax,8),%xmm1
  mulsd  %xmm2,%xmm1
  subsd  %xmm4,%xmm1
  movsd  %xmm1,(%r9,%rax,8)
  mulsd  %xmm1,%xmm1
  add    $0x1,%rax
  addsd  %xmm1,%xmm0
  cmp    %rax,%rdx
  jne    L50
L55:
  cmp    %rdx,%rdi
  jle    L54
  lea    (%r9,%rdx,8),%rcx
  nopw   0x0(%rax,%rax,1)
L92:
  movsd  (%rcx),%xmm1
  movsd  (%rsi,%rdx,8),%xmm5
  add    $0x28,%rcx
  mulsd  %xmm2,%xmm1
  movapd %xmm5,%xmm4
  mulsd  %xmm5,%xmm4
  subsd  %xmm5,%xmm1
  addsd  %xmm3,%xmm4
  movsd  %xmm1,-0x28(%rcx)
  mulsd  %xmm1,%xmm1
  movsd  0x8(%rsi,%rdx,8),%xmm3
  movapd %xmm3,%xmm5
  mulsd  %xmm3,%xmm5
  addsd  %xmm0,%xmm1
  movsd  -0x20(%rcx),%xmm0
  mulsd  %xmm2,%xmm0
  addsd  %xmm4,%xmm5
  subsd  %xmm3,%xmm0
  movsd  %xmm0,-0x20(%rcx)
  mulsd  %xmm0,%xmm0
  movsd  0x10(%rsi,%rdx,8),%xmm3
  movapd %xmm3,%xmm4
  mulsd  %xmm3,%xmm4
  addsd  %xmm0,%xmm1
  movsd  -0x18(%rcx),%xmm0
  mulsd  %xmm2,%xmm0
  addsd  %xmm5,%xmm4
  subsd  %xmm3,%xmm0
  movsd  %xmm0,-0x18(%rcx)
  mulsd  %xmm0,%xmm0
  movsd  0x18(%rsi,%rdx,8),%xmm3
  movapd %xmm3,%xmm5
  mulsd  %xmm3,%xmm5
  addsd  %xmm0,%xmm1
  movsd  -0x10(%rcx),%xmm0
  mulsd  %xmm2,%xmm0
  addsd  %xmm4,%xmm5
  subsd  %xmm3,%xmm0
  movsd  %xmm0,-0x10(%rcx)
  mulsd  %xmm0,%xmm0
  movsd  0x20(%rsi,%rdx,8),%xmm4
  add    $0x5,%rdx
  movapd %xmm4,%xmm3
  mulsd  %xmm4,%xmm3
  addsd  %xmm0,%xmm1
  movsd  -0x8(%rcx),%xmm0
  mulsd  %xmm2,%xmm0
  addsd  %xmm5,%xmm3
  subsd  %xmm4,%xmm0
  movsd  %xmm0,-0x8(%rcx)
  mulsd  %xmm0,%xmm0
  addsd  %xmm1,%xmm0
  cmp    %rdx,%rdi
  jg     L92
L54:
  movsd  %xmm3,(%r8)
L33:
  ret
  nopl   0x0(%rax)
L7:
  pxor   %xmm0,%xmm0
  test   %rdx,%rdx
  jle    L39
  xor    %eax,%eax
L17:
  movsd  (%r9,%rax,8),%xmm1
  mulsd  %xmm2,%xmm1
  subsd  (%rsi,%rax,8),%xmm1
  movsd  %xmm1,(%r9,%rax,8)
  mulsd  %xmm1,%xmm1
  add    $0x1,%rax
  addsd  %xmm1,%xmm0
  cmp    %rax,%rdx
  jne    L17
L18:
  cmp    %rdx,%rdi
  jle    L33
  lea    (%r9,%rdx,8),%rcx
  cs nopw 0x0(%rax,%rax,1)
L90:
  movsd  (%rcx),%xmm1
  add    $0x28,%rcx
  mulsd  %xmm2,%xmm1
  subsd  (%rsi,%rdx,8),%xmm1
  movsd  %xmm1,-0x28(%rcx)
  mulsd  %xmm1,%xmm1
  addsd  %xmm0,%xmm1
  movsd  -0x20(%rcx),%xmm0
  mulsd  %xmm2,%xmm0
  subsd  0x8(%rsi,%rdx,8),%xmm0
  movsd  %xmm0,-0x20(%rcx)
  mulsd  %xmm0,%xmm0
  addsd  %xmm0,%xmm1
  movsd  -0x18(%rcx),%xmm0
  mulsd  %xmm2,%xmm0
  subsd  0x10(%rsi,%rdx,8),%xmm0
  movsd  %xmm0,-0x18(%rcx)
  mulsd  %xmm0,%xmm0
  addsd  %xmm0,%xmm1
  movsd  -0x10(%rcx),%xmm0
  mulsd  %xmm2,%xmm0
  subsd  0x18(%rsi,%rdx,8),%xmm0
  movsd  %xmm0,-0x10(%rcx)
  mulsd  %xmm0,%xmm0
  addsd  %xmm0,%xmm1
  movsd  -0x8(%rcx),%xmm0
  mulsd  %xmm2,%xmm0
  subsd  0x20(%rsi,%rdx,8),%xmm0
  add    $0x5,%rdx
  movsd  %xmm0,-0x8(%rcx)
  mulsd  %xmm0,%xmm0
  addsd  %xmm1,%xmm0
  cmp    %rdx,%rdi
  jg     L90
  ret
  nopl   0x0(%rax)
L82:
  xor    %edx,%edx
  jmp    L55
L39:
  xor    %edx,%edx
  jmp    L18
```

assistant: ```c
double cg_update_d(double *d, double *g, double beta, double *gnorm2, long int n) {
  long int i, n5;
  double dnorm2, s, t;
  s = ((double)0);
  dnorm2 = ((double)0);
  n5 = n % 5;
  if (gnorm2 == 0) {
    for (i = 0; i < n5; i++) {
      t = g[i];
      t = -t + beta * d[i];
      d[i] = t;
      dnorm2 += t * t;
    }
    for (; i < n;) {
      t = g[i];
      t = -t + beta * d[i];
      d[i] = t;
      dnorm2 += t * t;
      i++;
      t = g[i];
      t = -t + beta * d[i];
      d[i] = t;
      dnorm2 += t * t;
      i++;
      t = g[i];
      t = -t + beta * d[i];
      d[i] = t;
      dnorm2 += t * t;
      i++;
      t = g[i];
      t = -t + beta * d[i];
      d[i] = t;
      dnorm2 += t * t;
      i++;
      t = g[i];
      t = -t + beta * d[i];
      d[i] = t;
      dnorm2 += t * t;
      i++;
    }
  } else {
    s = ((double)0);
    for (i = 0; i < n5; i++) {
      t = g[i];
      s += t * t;
      t = -t + beta * d[i];
      d[i] = t;
      dnorm2 += t * t;
    }
    for (; i < n;) {
      t = g[i];
      s += t * t;
      t = -t + beta * d[i];
      d[i] = t;
      dnorm2 += t * t;
      i++;
      t = g[i];
      s += t * t;
      t = -t + beta * d[i];
      d[i] = t;
      dnorm2 += t * t;
      i++;
      t = g[i];
      s += t * t;
      t = -t + beta * d[i];
      d[i] = t;
      dnorm2 += t * t;
      i++;
      t = g[i];
      s += t * t;
      t = -t + beta * d[i];
      d[i] = t;
      dnorm2 += t * t;
      i++;
      t = g[i];
      s += t * t;
      t = -t + beta * d[i];
      d[i] = t;
      dnorm2 += t * t;
      i++;
    }
    *gnorm2 = s;
  }
  return (dnorm2);
}
```