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

```asm
<computegradient>:
  endbr64
  push   %r15
  lea    -0x1(%rdx),%eax
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x38,%rsp
  mov    %esi,0x4(%rsp)
  mov    %eax,(%rsp)
  cmp    $0x1,%eax
  jle    L35
  cmp    $0x2,%esi
  jle    L35
  movslq %esi,%rax
  mov    %rdi,%r12
  mov    %rcx,%r14
  mov    $0x1,%r15d
  lea    -0x1(%rsi),%r13d
  lea    (%rsi,%rsi,1),%r11d
  pxor   %xmm1,%xmm1
  shl    $0x3,%rax
  mov    %rax,0x8(%rsp)
  lea    0x8(%rax),%r10
  mov    $0x2,%eax
  movsd  D59(%rip),%xmm3
  sub    %esi,%eax
  movq   D0(%rip),%xmm4
  mov    %eax,0x20(%rsp)
  nopl   0x0(%rax)
L66:
  mov    0x20(%rsp),%eax
  movsd  D27(%rip),%xmm2
  mov    %r10,%rbx
  lea    (%rax,%r13,1),%ebp
  jmp    L49
  nopl   (%rax)
L41:
  add    $0x1,%ebp
  add    $0x8,%rbx
  cmp    %r13d,%ebp
  je     L45
L49:
  movsd  (%r12,%rbx,1),%xmm0
  comisd %xmm1,%xmm0
  jbe    L41
  comisd %xmm0,%xmm3
  jbe    L41
  movsd  -0x8(%r12,%rbx,1),%xmm5
  movslq %ebp,%rdi
  lea    (%r11,%rbp,1),%eax
  lea    0x0(,%rdi,8),%rcx
  cltq
  mulsd  %xmm2,%xmm5
  lea    -0x8(%r12,%rcx,1),%r9
  lea    0x0(,%rax,8),%rdx
  movsd  (%r9),%xmm0
  lea    -0x8(%r12,%rdx,1),%rsi
  lea    0x8(%r12,%rcx,1),%rcx
  lea    0x8(%r12,%rdx,1),%rdx
  xorpd  %xmm4,%xmm0
  subsd  %xmm5,%xmm0
  movsd  0x8(%r12,%rbx,1),%xmm5
  subsd  (%rsi),%xmm0
  addsd  (%rcx),%xmm0
  mulsd  %xmm2,%xmm5
  addsd  %xmm5,%xmm0
  addsd  (%rdx),%xmm0
  movsd  %xmm0,(%r14,%rbx,1)
  movsd  (%r12,%rdi,8),%xmm5
  movsd  (%r9),%xmm0
  mulsd  %xmm2,%xmm5
  xorpd  %xmm4,%xmm0
  subsd  %xmm5,%xmm0
  movsd  (%r12,%rax,8),%xmm5
  subsd  (%rsi),%xmm0
  addsd  (%rcx),%xmm0
  mulsd  %xmm2,%xmm5
  addsd  %xmm5,%xmm0
  addsd  (%rdx),%xmm0
  movsd  %xmm0,(%r8,%rbx,1)
  movsd  (%r14,%rbx,1),%xmm6
  mulsd  %xmm0,%xmm0
  movapd %xmm6,%xmm5
  mulsd  %xmm6,%xmm5
  addsd  %xmm5,%xmm0
  comisd %xmm1,%xmm0
  jbe    L41
  ucomisd %xmm0,%xmm1
  ja     L108
  sqrtsd %xmm0,%xmm0
L86:
  divsd  %xmm0,%xmm6
  add    $0x1,%ebp
  movsd  %xmm6,(%r14,%rbx,1)
  movsd  (%r8,%rbx,1),%xmm5
  divsd  %xmm0,%xmm5
  movsd  %xmm5,(%r8,%rbx,1)
  add    $0x8,%rbx
  cmp    %r13d,%ebp
  jne    L49
  nopl   0x0(%rax,%rax,1)
L45:
  add    $0x1,%r15d
  add    0x4(%rsp),%r13d
  add    0x8(%rsp),%r10
  cmp    (%rsp),%r15d
  jne    L66
L35:
  add    $0x38,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L108:
  mov    %r8,0x28(%rsp)
  mov    %r11d,0x24(%rsp)
  mov    %r10,0x18(%rsp)
  movsd  %xmm6,0x10(%rsp)
  call   <sqrt@plt>
  mov    D27(%rip),%rax
  mov    0x28(%rsp),%r8
  pxor   %xmm1,%xmm1
  mov    0x24(%rsp),%r11d
  mov    0x18(%rsp),%r10
  movq   %rax,%xmm2
  mov    D59(%rip),%rax
  movq   D0(%rip),%xmm4
  movsd  0x10(%rsp),%xmm6
  movq   %rax,%xmm3
  jmp    L86
```

tool_calls: name: disassemble_data
arguments: tag: D59
data_type: f64
name: disassemble_data
arguments: tag: D0
data_type: f32[2]
name: disassemble_data
arguments: tag: D27
data_type: f64

tool: D59: 1

tool: {"D0": [0.0,-0.0]}

tool: D27: 1.4142136

assistant: ```c
void computegradient(double *img, int w, int h, double *gx, double *gy) {
  int i, j, k;
  double glength;
  for (i = 1; i < h - 1; i++) {
    for (j = 1; j < w - 1; j++) {
      k = i * w + j;
      if ((img[k] > 0.0) && (img[k] < 1.0)) {
        gx[k] = -img[k - w - 1] - 1.4142136 * img[k - 1] - img[k + w - 1] + img[k - w + 1] + 1.4142136 * img[k + 1] + img[k + w + 1];
        gy[k] = -img[k - w - 1] - 1.4142136 * img[k - w] - img[k + w - 1] + img[k - w + 1] + 1.4142136 * img[k + w] + img[k + w + 1];
        glength = gx[k] * gx[k] + gy[k] * gy[k];
        if (glength > 0.0) {
          glength = sqrt(glength);
          gx[k] = gx[k] / glength;
          gy[k] = gy[k] / glength;
        }
      }
    }
  }
}
```