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

```asm
<A2toRH>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x1000,%rsp
  orq    $0x0,(%rsp)
  sub    $0x5c8,%rsp
  mov    0x1600(%rsp),%r13
  mov    %rdx,0x8(%rsp)
  mov    %rcx,%r12
  mov    %rdi,%r15
  mov    $0xd2,%ecx
  lea    0x90(%rsp),%rbp
  mov    %rsi,%r14
  mov    $0x2,%edx
  mov    %r8,%rbx
  mov    %rbp,%rdi
  mov    %fs:0x28,%rax
  mov    %rax,0x15b8(%rsp)
  xor    %eax,%eax
  mov    %r9,(%rsp)
  rep stos %rax,%es:(%rdi)
  mov    (%r9),%eax
  mov    %rbp,%rdi
  lea    (%rax,%rax,4),%eax
  add    %eax,%eax
  cltq
  lea    (%r8,%rax,8),%rsi
  call   <Zu@plt>
  mov    (%rsp),%r9
  mov    $0x2,%edx
  lea    0xc8(%rsp),%rdi
  mov    0x4(%r9),%eax
  lea    (%rax,%rax,4),%eax
  add    %eax,%eax
  cltq
  lea    (%rbx,%rax,8),%rsi
  call   <Zu@plt>
  mov    $0x2,%ecx
  mov    %r15,%rdx
  mov    %r14,%rsi
  lea    0x480(%rsp),%rdi
  call   <Znd@plt>
  mov    0x8(%rsp),%rdx
  mov    %r12,%rsi
  lea    0x608(%rsp),%rdi
  mov    $0x2,%ecx
  lea    0x7a0(%rsp),%r12
  call   <Znd@plt>
  mov    %rbp,%rsi
  mov    $0xe,%ecx
  mov    %r12,%rdi
  mov    $0xf,%edx
  lea    0xeb0(%rsp),%rbp
  call   <mattr@plt>
  xor    %eax,%eax
  mov    $0xf,%ecx
  mov    %rbp,%rsi
  lea    0xe30(%rsp),%rdx
  mov    %rdx,%rdi
  mov    $0xf,%edx
  rep stos %rax,%es:(%rdi)
  lea    0x10(%rsp),%rcx
  mov    %r12,%rdi
  call   <nullspace@plt>
  mov    $0x48,%edx
  mov    %rbp,%rsi
  mov    %r13,%rdi
  mov    %eax,%ebx
  call   <memcpy@plt>
  mov    $0x3,%esi
  mov    %r13,%rdi
  call   <trnm@plt>
  cmp    $0x1,%ebx
  setne  %al
  mov    0x15b8(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L2
  add    $0x15c8,%rsp
  movzbl %al,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L2:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int A2toRH(double *N1, double *D1, double *N2, double *D2, double *u, int *samidx, double *h) {
  int do_norm = 0, i;
  double Z[15 * 15], ZT[15 * 15];
  double U[15 * 15];
  double T1[3 * 3], iT1[3 * 3], T2[3 * 3], iT2[3 * 3];
  double N1N[3 * 3], N2N[3 * 3], D1N[3 * 3], D2N[3 * 3], temp[3 * 3];
  int nullsize, nullspace_buff[2 * 15];
  for (i = 0; i < 2 * 7 * 15; ++i) {
    Z[i] = 0.0;
  }
  if (do_norm) {
    norm2pt(u[10 * samidx[0] + 0], u[10 * samidx[0] + 1], u[10 * samidx[1] + 0], u[10 * samidx[1] + 1], T1, iT1);
    norm2pt(u[10 * samidx[0] + 5], u[10 * samidx[0] + 6], u[10 * samidx[1] + 5], u[10 * samidx[1] + 6], T2, iT2);
    ZuN(Z, u + 10 * samidx[0], T1, T2, 2);
    ZuN(Z + 7, u + 10 * samidx[1], T1, T2, 2);
    mmul(N1N, iT2, N1, 3);
    mmul(N2N, iT2, N2, 3);
    mmul(D1N, D1, T1, 3);
    mmul(D2N, D2, T1, 3);
    Znd(Z + 2 * 7 * 9, D1N, N1N, 2);
    Znd(Z + 2 * 7 * 9 + 2 * 7 * 3 + 7, D2N, N2N, 2);
  } else {
    Zu(Z, u + 10 * samidx[0], 2);
    Zu(Z + 7, u + 10 * samidx[1], 2);
    Znd(Z + 2 * 7 * 9, D1, N1, 2);
    Znd(Z + 2 * 7 * 9 + 2 * 7 * 3 + 7, D2, N2, 2);
  }
  mattr(ZT, Z, 15, 2 * 7);
  for (i = 14 * 15; i < 15 * 15; ++i) {
    ZT[i] = 0;
  }
  nullsize = nullspace(ZT, U, 15, nullspace_buff);
  memcpy(h, U, 3 * 3 * sizeof(double));
  trnm(h, 3);
  if (do_norm) {
    mmul(temp, T2, h, 3);
    mmul(h, temp, iT1, 3);
  }
  return nullsize != 1;
}
```