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

```asm
<detcoef2>:
  endbr64
  push   %r15
  push   %r14
  mov    %r9d,%r14d
  push   %r13
  lea    0x0(,%r14,4),%r15d
  push   %r12
  mov    %r8,%r12
  push   %rbp
  mov    %rdi,%rbp
  mov    %r15d,%edi
  push   %rbx
  mov    %rdx,%rbx
  sub    $0x28,%rsp
  mov    0x60(%rsp),%r9d
  mov    0x68(%rsp),%r13
  mov    %r9d,0x1c(%rsp)
  call   <malloc@plt>
  mov    %r15d,%edi
  mov    %rax,0x8(%rsp)
  call   <malloc@plt>
  mov    %r15d,%edi
  mov    %rax,(%rsp)
  call   <malloc@plt>
  mov    0x8(%rsp),%r15
  mov    %r14d,%edi
  mov    %r12,%rsi
  mov    (%rsp),%rcx
  mov    %rax,%r8
  mov    %rax,0x10(%rsp)
  mov    %r15,%rdx
  call   <matrix_locate@plt>
  lea    D11(%rip),%rsi
  mov    %r13,%rdi
  call   <strcmp@plt>
  mov    0x1c(%rsp),%r9d
  sub    %r9d,%r14d
  test   %rax,%rax
  jne    L16
  movslq %r14d,%rax
  mov    (%r15,%rax,4),%r9d
L26:
  lea    0x2(%r14,%r14,1),%eax
  cltq
  mov    (%r12,%rax,4),%r14d
  test   %r14d,%r14d
  jle    L44
  mov    0x4(%r12,%rax,4),%r11d
  test   %r11d,%r11d
  jle    L44
  movslq %r9d,%rax
  mov    %r11d,%edi
  movslq %r11d,%r12
  mov    %rbx,%rcx
  lea    0x0(%rbp,%rax,8),%rsi
  mov    %r11d,%eax
  and    $0xfffffffe,%edi
  shl    $0x3,%r12
  shr    %eax
  add    %edi,%r9d
  xor    %edx,%edx
  xor    %r10d,%r10d
  lea    -0x1(%rax),%r8d
  lea    -0x1(%r11),%r15d
  mov    %r11d,%r13d
  add    $0x1,%r8
  shl    $0x4,%r8
  cs nopw 0x0(%rax,%rax,1)
L123:
  lea    0x8(%rsi),%rax
  cmp    %rax,%rcx
  je     L102
  xor    %eax,%eax
  cmp    $0x2,%r15d
  jbe    L102
  nopl   0x0(%rax)
L3:
  movupd (%rsi,%rax,1),%xmm1
  movups %xmm1,(%rcx,%rax,1)
  add    $0x10,%rax
  cmp    %r8,%rax
  jne    L3
  cmp    %r11d,%edi
  je     L23
  lea    (%rdx,%r9,1),%eax
  cltq
  movsd  0x0(%rbp,%rax,8),%xmm0
  lea    (%rdx,%rdi,1),%eax
  cltq
  movsd  %xmm0,(%rbx,%rax,8)
L23:
  add    $0x1,%r10d
  add    %r12,%rsi
  add    %r12,%rcx
  add    %r11d,%edx
  cmp    %r14d,%r10d
  jne    L123
L44:
  mov    0x8(%rsp),%rdi
  call   <free@plt>
  mov    (%rsp),%rdi
  call   <free@plt>
  mov    0x10(%rsp),%rdi
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  jmp    1080 <free@plt>
  nopw   0x0(%rax,%rax,1)
L102:
  xor    %eax,%eax
  nopw   0x0(%rax,%rax,1)
L33:
  movsd  (%rsi,%rax,8),%xmm0
  movsd  %xmm0,(%rcx,%rax,8)
  add    $0x1,%rax
  cmp    %rax,%r13
  jne    L33
  jmp    L23
L16:
  lea    D2(%rip),%rsi
  mov    %r13,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  jne    L93
  mov    (%rsp),%rdi
  movslq %r14d,%rax
  mov    (%rdi,%rax,4),%r9d
  jmp    L26
L93:
  lea    D3(%rip),%rsi
  mov    %r13,%rdi
  call   <strcmp@plt>
  xor    %r9d,%r9d
  test   %rax,%rax
  jne    L26
  mov    0x10(%rsp),%rdi
  movslq %r14d,%rax
  mov    (%rdi,%rax,4),%r9d
  jmp    L26
```

tool_calls: name: parse_data
arguments: label: D11
type: string
name: parse_data
arguments: label: D2
type: string
name: parse_data
arguments: label: D3
type: string

tool: D11: h

tool: D2: v

tool: D3: d

assistant: ```c
void detcoef2(double *coef, int sigInLength, double *coefOut, int sigOutLength, int *pLen, int stride, int level, char *coefType) {
  int row, col, sta = 0;
  int *pH, *pV, *pD;
  pH = malloc(stride * sizeof(int));
  pV = malloc(stride * sizeof(int));
  pD = malloc(stride * sizeof(int));
  matrix_locate(stride, pLen, pH, pV, pD);
  if (strcmp(coefType, "h") == 0) {
    sta = pH[stride - level];
  } else if (strcmp(coefType, "v") == 0) {
    sta = pV[stride - level];
  } else if (strcmp(coefType, "d") == 0) {
    sta = pD[stride - level];
  }
  for (row = 0; row < pLen[(stride - level + 1) * 2]; row++) {
    for (col = 0; col < pLen[(stride - level + 1) * 2 + 1]; col++)
      coefOut[col + row * (pLen[(stride - level + 1) * 2 + 1])] = coef[sta + col + row * (pLen[(stride - level + 1) * 2 + 1])];
  }
  free(pH);
  free(pV);
  free(pD);
  return;
}
```