user: Translate the below assembly code into C programming language:

```asm
<cg_update_d>:
  endbr64
  mov    %rdi,%r8
  movapd %xmm0,%xmm2
  mov    %rdx,%rdi
  movabs $0x6666666666666667,%rdx
  mov    %rcx,%rax
  imul   %rdx
  sar    %rdx
  mov    %rcx,%rax
  sar    $0x3f,%rax
  sub    %rax,%rdx
  lea    (%rdx,%rdx,4),%rax
  mov    %rcx,%rdx
  sub    %rax,%rdx
  test   %rdi,%rdi
  je     L17
  pxor   %xmm3,%xmm3
  movapd %xmm3,%xmm0
  mov    $0x0,%eax
  test   %rdx,%rdx
  jle    L77
L99:
  movsd  (%rsi,%rax,8),%xmm4
  movapd %xmm4,%xmm1
  mulsd  %xmm4,%xmm1
  addsd  %xmm1,%xmm3
  movapd %xmm2,%xmm1
  mulsd  (%r8,%rax,8),%xmm1
  subsd  %xmm4,%xmm1
  movsd  %xmm1,(%r8,%rax,8)
  mulsd  %xmm1,%xmm1
  addsd  %xmm1,%xmm0
  add    $0x1,%rax
  cmp    %rax,%rdx
  jne    L99
L79:
  cmp    %rdx,%rcx
  jle    L38
  lea    (%r8,%rdx,8),%rax
L24:
  movsd  (%rsi,%rdx,8),%xmm5
  movapd %xmm5,%xmm4
  mulsd  %xmm5,%xmm4
  addsd  %xmm3,%xmm4
  movapd %xmm2,%xmm1
  mulsd  (%rax),%xmm1
  subsd  %xmm5,%xmm1
  movsd  %xmm1,(%rax)
  mulsd  %xmm1,%xmm1
  addsd  %xmm0,%xmm1
  movsd  0x8(%rsi,%rdx,8),%xmm3
  movapd %xmm3,%xmm5
  mulsd  %xmm3,%xmm5
  addsd  %xmm4,%xmm5
  movapd %xmm2,%xmm0
  mulsd  0x8(%rax),%xmm0
  subsd  %xmm3,%xmm0
  movsd  %xmm0,0x8(%rax)
  mulsd  %xmm0,%xmm0
  addsd  %xmm0,%xmm1
  movsd  0x10(%rsi,%rdx,8),%xmm3
  movapd %xmm3,%xmm4
  mulsd  %xmm3,%xmm4
  addsd  %xmm5,%xmm4
  movapd %xmm2,%xmm0
  mulsd  0x10(%rax),%xmm0
  subsd  %xmm3,%xmm0
  movsd  %xmm0,0x10(%rax)
  mulsd  %xmm0,%xmm0
  addsd  %xmm0,%xmm1
  movsd  0x18(%rsi,%rdx,8),%xmm3
  movapd %xmm3,%xmm5
  mulsd  %xmm3,%xmm5
  addsd  %xmm4,%xmm5
  movapd %xmm2,%xmm0
  mulsd  0x18(%rax),%xmm0
  subsd  %xmm3,%xmm0
  movsd  %xmm0,0x18(%rax)
  mulsd  %xmm0,%xmm0
  addsd  %xmm0,%xmm1
  movsd  0x20(%rsi,%rdx,8),%xmm4
  movapd %xmm4,%xmm3
  mulsd  %xmm4,%xmm3
  addsd  %xmm5,%xmm3
  movapd %xmm2,%xmm0
  mulsd  0x20(%rax),%xmm0
  subsd  %xmm4,%xmm0
  movsd  %xmm0,0x20(%rax)
  mulsd  %xmm0,%xmm0
  addsd  %xmm1,%xmm0
  add    $0x5,%rdx
  add    $0x28,%rax
  cmp    %rdx,%rcx
  jg     L24
L38:
  movsd  %xmm3,(%rdi)
L30:
  ret
L77:
  pxor   %xmm3,%xmm3
  movapd %xmm3,%xmm0
  mov    $0x0,%edx
  jmp    L79
L17:
  test   %rdx,%rdx
  jle    L54
  pxor   %xmm0,%xmm0
  mov    $0x0,%eax
L60:
  movapd %xmm2,%xmm1
  mulsd  (%r8,%rax,8),%xmm1
  subsd  (%rsi,%rax,8),%xmm1
  movsd  %xmm1,(%r8,%rax,8)
  mulsd  %xmm1,%xmm1
  addsd  %xmm1,%xmm0
  add    $0x1,%rax
  cmp    %rax,%rdx
  jne    L60
L104:
  cmp    %rdx,%rcx
  jle    L30
  lea    (%r8,%rdx,8),%rax
L71:
  movapd %xmm2,%xmm1
  mulsd  (%rax),%xmm1
  subsd  (%rsi,%rdx,8),%xmm1
  movsd  %xmm1,(%rax)
  mulsd  %xmm1,%xmm1
  addsd  %xmm0,%xmm1
  movapd %xmm2,%xmm0
  mulsd  0x8(%rax),%xmm0
  subsd  0x8(%rsi,%rdx,8),%xmm0
  movsd  %xmm0,0x8(%rax)
  mulsd  %xmm0,%xmm0
  addsd  %xmm0,%xmm1
  movapd %xmm2,%xmm0
  mulsd  0x10(%rax),%xmm0
  subsd  0x10(%rsi,%rdx,8),%xmm0
  movsd  %xmm0,0x10(%rax)
  mulsd  %xmm0,%xmm0
  addsd  %xmm0,%xmm1
  movapd %xmm2,%xmm0
  mulsd  0x18(%rax),%xmm0
  subsd  0x18(%rsi,%rdx,8),%xmm0
  movsd  %xmm0,0x18(%rax)
  mulsd  %xmm0,%xmm0
  addsd  %xmm0,%xmm1
  movapd %xmm2,%xmm0
  mulsd  0x20(%rax),%xmm0
  subsd  0x20(%rsi,%rdx,8),%xmm0
  movsd  %xmm0,0x20(%rax)
  mulsd  %xmm0,%xmm0
  addsd  %xmm1,%xmm0
  add    $0x5,%rdx
  add    $0x28,%rax
  cmp    %rdx,%rcx
  jg     L71
  ret
L54:
  pxor   %xmm0,%xmm0
  mov    $0x0,%edx
  jmp    L104
```

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);
}
```