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

```asm
<_compute_viterbi>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  mov    %rcx,%rbp
  movslq %r8d,%rcx
  push   %rbx
  lea    0x0(,%rcx,8),%r12
  mov    %rcx,%r15
  mov    %rsi,%rbx
  sub    $0x68,%rsp
  mov    %rdi,0x50(%rsp)
  mov    %r12,%rdi
  mov    %rdx,0x40(%rsp)
  mov    %r9d,0x34(%rsp)
  call   <malloc@plt>
  mov    %r12,%rdi
  mov    %rax,%r13
  call   <malloc@plt>
  mov    %r12,%rdi
  mov    %rax,0x10(%rsp)
  call   <malloc@plt>
  mov    0x34(%rsp),%ecx
  mov    %rax,%r14
  imul   %r15d,%ecx
  movslq %ecx,%rdi
  mov    %ecx,0x5c(%rsp)
  shl    $0x2,%rdi
  call   <malloc@plt>
  mov    %rax,0x38(%rsp)
  test   %r13,%r13
  je     L126
  cmpq   $0x0,0x10(%rsp)
  je     L126
  test   %r14,%r14
  je     L126
  test   %rax,%rax
  je     L126
  mov    0x40(%rsp),%rcx
  mov    %r15d,%edx
  xor    %eax,%eax
  pxor   %xmm1,%xmm1
  test   %r15d,%r15d
  jle    L14
  nop
L136:
  movsd  (%rcx,%rax,8),%xmm0
  mulsd  0x0(%rbp,%rax,8),%xmm0
  movsd  %xmm0,0x0(%r13,%rax,8)
  add    $0x1,%rax
  addsd  %xmm0,%xmm1
  cmp    %rax,%rdx
  jne    L136
  mov    %r13,%rax
  lea    0x0(%r13,%rdx,8),%rdx
  nopw   0x0(%rax,%rax,1)
L20:
  movsd  (%rax),%xmm0
  add    $0x8,%rax
  divsd  %xmm1,%xmm0
  movsd  %xmm0,-0x8(%rax)
  cmp    %rax,%rdx
  jne    L20
L14:
  movslq 0x34(%rsp),%rax
  mov    0x50(%rsp),%rsi
  mov    %rax,%rcx
  lea    -0x4(%rsi,%rax,4),%rax
  mov    %rax,0x48(%rsp)
  lea    -0x2(%rcx),%eax
  mov    %eax,0x58(%rsp)
  cmp    $0x1,%ecx
  jle    L31
  lea    -0x1(%r15),%ebp
  mov    %r14,%rcx
  mov    %r15d,%eax
  mov    %r15d,0x30(%rsp)
  movl   $0x1,0x2c(%rsp)
  mov    %r12,%r14
  mov    %r13,%r15
  mov    %rcx,%r12
  mov    %rbp,%r13
  mov    %rbx,%rbp
  mov    %eax,%ebx
  nopl   (%rax)
L107:
  test   %ebx,%ebx
  jle    L186
  movslq 0x30(%rsp),%rax
  mov    0x38(%rsp),%rcx
  xor    %r9d,%r9d
  mov    %ebx,%esi
  pxor   %xmm1,%xmm1
  mov    %rbp,%rbx
  mov    %r14,%rbp
  mov    %r12,%r14
  lea    (%rcx,%rax,4),%rcx
  mov    %r9,%r12
  mov    %rcx,0x20(%rsp)
  mov    0x40(%rsp),%rcx
  lea    (%rcx,%rax,8),%rax
  mov    %rax,0x18(%rsp)
  cs nopw 0x0(%rax,%rax,1)
L187:
  mov    %r12d,0x4(%rsp)
  lea    (%rbx,%r12,8),%rdi
  xor    %eax,%eax
  nopl   0x0(%rax,%rax,1)
L91:
  movsd  (%r15,%rax,8),%xmm0
  mulsd  (%rdi),%xmm0
  mov    %rax,%rdx
  add    %rbp,%rdi
  movsd  %xmm0,(%r14,%rax,8)
  add    $0x1,%rax
  cmp    %r13,%rdx
  jne    L91
  mov    %r14,%rdi
  xor    %eax,%eax
  mov    %esi,0x28(%rsp)
  movsd  %xmm1,0x8(%rsp)
  call   <argmax@plt>
  mov    0x20(%rsp),%rcx
  mov    0x28(%rsp),%esi
  movslq %eax,%rdi
  movsd  0x8(%rsp),%xmm1
  mov    %eax,(%rcx,%r12,4)
  mov    0x18(%rsp),%rcx
  imul   %esi,%eax
  add    0x4(%rsp),%eax
  movsd  (%r15,%rdi,8),%xmm0
  lea    0x1(%r12),%rdi
  mulsd  (%rcx,%r12,8),%xmm0
  cltq
  mulsd  (%rbx,%rax,8),%xmm0
  mov    0x10(%rsp),%rax
  addsd  %xmm0,%xmm1
  movsd  %xmm0,(%rax,%r12,8)
  cmp    %r13,%r12
  je     L163
  mov    %rdi,%r12
  jmp    L187
  nopl   0x0(%rax)
L163:
  mov    0x10(%rsp),%rcx
  mov    %r14,%r12
  mov    %rbp,%r14
  mov    %rbx,%rbp
  mov    %esi,%ebx
  mov    %rcx,%rax
  lea    (%rcx,%rdi,8),%rdi
  nopw   0x0(%rax,%rax,1)
L47:
  movsd  (%rax),%xmm0
  add    $0x8,%rax
  divsd  %xmm1,%xmm0
  movsd  %xmm0,-0x8(%rax)
  cmp    %rax,%rdi
  jne    L47
L186:
  addl   $0x1,0x2c(%rsp)
  mov    0x2c(%rsp),%eax
  add    %ebx,0x30(%rsp)
  cmp    %eax,0x34(%rsp)
  je     L134
  mov    %r15,%rax
  mov    0x10(%rsp),%r15
  mov    %rax,0x10(%rsp)
  jmp    L107
L134:
  mov    0x10(%rsp),%rdi
  mov    %ebx,%esi
  xor    %eax,%eax
  mov    %r15,%r13
  mov    %r12,%r14
  mov    %ebx,%r15d
  call   <argmax@plt>
  mov    0x48(%rsp),%rcx
  mov    %eax,(%rcx)
L127:
  mov    0x5c(%rsp),%ecx
  movslq 0x58(%rsp),%rax
  mov    0x38(%rsp),%rdi
  mov    0x50(%rsp),%rsi
  sub    %r15d,%ecx
  nop
L2:
  mov    0x4(%rsi,%rax,4),%edx
  add    %ecx,%edx
  sub    %r15d,%ecx
  movslq %edx,%rdx
  mov    (%rdi,%rdx,4),%edx
  mov    %edx,(%rsi,%rax,4)
  sub    $0x1,%rax
  test   %eax,%eax
  jns    L2
L108:
  xor    %r12d,%r12d
L147:
  mov    0x10(%rsp),%rdi
  call   <free@plt>
  mov    %r13,%rdi
  call   <free@plt>
  mov    %r14,%rdi
  call   <free@plt>
  mov    0x38(%rsp),%rdi
  call   <free@plt>
  add    $0x68,%rsp
  mov    %r12d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L31:
  mov    %r13,%rdi
  xor    %eax,%eax
  mov    %r15d,%esi
  call   <argmax@plt>
  mov    0x48(%rsp),%rcx
  mov    0x58(%rsp),%edx
  mov    %eax,(%rcx)
  mov    0x10(%rsp),%rax
  test   %edx,%edx
  mov    %r13,0x10(%rsp)
  mov    %rax,%r13
  js     L108
  jmp    L127
L126:
  mov    0x10(%rsp),%rax
  mov    $0x2,%r12d
  mov    %r13,0x10(%rsp)
  mov    %rax,%r13
  jmp    L147
```

assistant: ```c
int _compute_viterbi(int *path, const double *A, const double *pobs, const double *pi, int N, int T) {
  int i, j, t, maxi, result;
  double sum;
  double *v, *vnext, *h, *vh;
  int *ptr;
  result = 0;
  v = (double *)malloc(N * sizeof(double));
  vnext = (double *)malloc(N * sizeof(double));
  h = (double *)malloc(N * sizeof(double));
  ptr = (int *)malloc(T * N * sizeof(int));
  if (!v || !vnext || !h || !ptr) {
    result = 2;
    goto error;
  }
  sum = 0.0;
  for (i = 0; i < N; i++) {
    v[i] = pobs[i] * pi[i];
    sum += v[i];
  }
  for (i = 0; i < N; i++) {
    v[i] /= sum;
  }
  for (t = 1; t < T; t++) {
    sum = 0.0;
    for (j = 0; j < N; j++) {
      for (i = 0; i < N; i++) {
        h[i] = v[i] * A[i * N + j];
      }
      maxi = argmax(h, N);
      ptr[t * N + j] = maxi;
      vnext[j] = pobs[t * N + j] * v[maxi] * A[maxi * N + j];
      sum += vnext[j];
    }
    for (i = 0; i < N; i++) {
      vnext[i] /= sum;
    }
    vh = v;
    v = vnext;
    vnext = vh;
  }
  path[T - 1] = argmax(v, N);
  for (t = T - 2; t >= 0; t--) {
    path[t] = ptr[(t + 1) * N + path[t + 1]];
  }
error:
  free(v);
  free(vnext);
  free(h);
  free(ptr);
  return result;
}
```