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

```asm
<z2x2>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x48,%rsp
  mov    %rdi,%r15
  mov    $0x8,%esi
  mov    $0x2,%edi
  call   <calloc@plt>
  mov    %rax,%r13
  test   %rax,%rax
  je     L19
L77:
  mov    $0x8,%esi
  mov    $0x2,%edi
  call   <calloc@plt>
  mov    %rax,%rbp
  test   %rax,%rax
  je     L142
L116:
  movsd  0x0(%r13),%xmm0
  addsd  (%r15),%xmm0
  movsd  %xmm0,0x0(%r13)
  movsd  0x0(%rbp),%xmm0
  addsd  (%r15),%xmm0
  movsd  %xmm0,0x0(%rbp)
  pxor   %xmm0,%xmm0
  addsd  (%r15),%xmm0
  movsd  0x0(%r13),%xmm1
  addsd  0x8(%r15),%xmm1
  movsd  %xmm1,0x0(%r13)
  movsd  0x8(%rbp),%xmm1
  addsd  0x8(%r15),%xmm1
  movsd  %xmm1,0x8(%rbp)
  addsd  0x8(%r15),%xmm0
  movsd  0x8(%r13),%xmm1
  addsd  0x10(%r15),%xmm1
  movsd  %xmm1,0x8(%r13)
  movsd  0x0(%rbp),%xmm1
  addsd  0x10(%r15),%xmm1
  movsd  %xmm1,0x0(%rbp)
  addsd  0x10(%r15),%xmm0
  movsd  0x8(%r13),%xmm1
  addsd  0x18(%r15),%xmm1
  movsd  %xmm1,0x8(%r13)
  movsd  0x8(%rbp),%xmm1
  addsd  0x18(%r15),%xmm1
  movsd  %xmm1,0x8(%rbp)
  addsd  0x18(%r15),%xmm0
  movapd %xmm0,%xmm7
  movsd  %xmm0,0x18(%rsp)
  movsd  D53(%rip),%xmm0
  comisd %xmm7,%xmm0
  ja     L37
L103:
  mov    %r15,%r14
  sub    %rbp,%r14
  mov    %r13,0x10(%rsp)
  mov    $0x0,%eax
  pxor   %xmm7,%xmm7
  movsd  %xmm7,0x8(%rsp)
  mov    %r13,0x38(%rsp)
  mov    %rbp,0x20(%rsp)
  mov    %eax,%ebp
  mov    %r15,0x30(%rsp)
  jmp    L82
L19:
  mov    $0x2,%esi
  lea    D52(%rip),%rdi
  mov    $0x0,%eax
  call   <fatalx@plt>
  jmp    L77
L142:
  mov    $0x2,%esi
  lea    D52(%rip),%rdi
  mov    $0x0,%eax
  call   <fatalx@plt>
  jmp    L116
L37:
  lea    D30(%rip),%rdi
  mov    $0x0,%eax
  call   <fatalx@plt>
  jmp    L103
L124:
  lea    D89(%rip),%rdi
  call   <printf@plt>
  mov    $0x2,%edx
  mov    $0x2,%esi
  mov    0x30(%rsp),%rdi
  call   <printmat@plt>
  lea    D31(%rip),%rdi
  mov    $0x0,%eax
  call   <fatalx@plt>
  jmp    L14
L87:
  mulsd  %xmm0,%xmm0
  divsd  (%rsp),%xmm0
  addsd  0x8(%rsp),%xmm0
  movsd  %xmm0,0x8(%rsp)
  add    $0x8,%rbx
  add    $0x1,%r12d
  cmp    %rbx,%r13
  je     L175
L65:
  movsd  (%r15),%xmm0
  mulsd  (%rbx),%xmm0
  divsd  0x18(%rsp),%xmm0
  movsd  %xmm0,(%rsp)
  movsd  D21(%rip),%xmm3
  comisd %xmm0,%xmm3
  ja     L124
L14:
  movsd  (%r14,%rbx,1),%xmm0
  subsd  (%rsp),%xmm0
  test   %r12d,%r12d
  jne    L87
  movsd  %xmm0,0x28(%rsp)
  jmp    L87
L175:
  add    $0x10,%r14
  add    $0x2,%ebp
  addq   $0x8,0x10(%rsp)
  cmp    $0x4,%ebp
  je     L57
L82:
  mov    0x10(%rsp),%r15
  mov    0x20(%rsp),%rbx
  lea    0x10(%rbx),%r13
  mov    %ebp,%r12d
  jmp    L65
L57:
  mov    0x38(%rsp),%r13
  mov    0x20(%rsp),%rbp
  movsd  0x8(%rsp),%xmm0
  addsd  D21(%rip),%xmm0
  pxor   %xmm1,%xmm1
  ucomisd %xmm0,%xmm1
  ja     L179
  sqrtsd %xmm0,%xmm0
  movq   %xmm0,%rbx
L92:
  pxor   %xmm0,%xmm0
  comisd 0x28(%rsp),%xmm0
  ja     L148
L157:
  mov    %r13,%rdi
  call   <free@plt>
  mov    %rbp,%rdi
  call   <free@plt>
  movq   %rbx,%xmm0
  add    $0x48,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L179:
  call   <sqrt@plt>
  movq   %xmm0,%rbx
  jmp    L92
L148:
  movq   %rbx,%xmm2
  xorpd  D26(%rip),%xmm2
  movq   %xmm2,%rbx
  jmp    L157
```

tool_calls: name: read_data
arguments: tag: D53
type: f64
name: read_data
arguments: tag: D52
type: string
name: read_data
arguments: tag: D30
type: string
name: read_data
arguments: tag: D89
type: string
name: read_data
arguments: tag: D31
type: string
name: read_data
arguments: tag: D21
type: byte[8]
name: read_data
arguments: tag: D26
type: f32[4]

tool: D53: 0.001

tool: D52: Unable to allocate %d unit(s) for item 


tool: D30: (z2x2) no data


tool: D89: bad conchi


tool: D31: (conchi) zero row or column sum


tool: {"D21": [0x11,0xea,0x2d,0x81,0x99,0x97,0x71,0x3d]}

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

assistant: ```c
double z2x2(double *a) {
  double *rsum, *csum, ee, tot = 0, chsq = 0, y, dev00, z;
  int i, j, k, m = 2, n = 2;
  if ((rsum = (double *)calloc((m), sizeof(double))) == NULL)
    fatalx("Unable to allocate %d unit(s) for item \n", m);
  if ((csum = (double *)calloc((n), sizeof(double))) == NULL)
    fatalx("Unable to allocate %d unit(s) for item \n", n);
  for (i = 0; i < m; i++) {
    for (j = 0; j < n; j++) {
      k = i * n + j;
      rsum[i] += a[k];
      csum[j] += a[k];
      tot += a[k];
    }
  }
  if (tot < 0.001)
    fatalx("(z2x2) no data\n");
  for (i = 0; i < m; i++) {
    for (j = 0; j < n; j++) {
      k = i * n + j;
      ee = rsum[i] * csum[j] / tot;
      if (ee < 1.0e-12) {
        printf("bad conchi\n");
        printmat(a, m, n);
        fatalx("(conchi) zero row or column sum\n");
      }
      y = a[k] - ee;
      if (k == 0)
        dev00 = y;
      chsq += (y * y) / ee;
    }
  }
  z = sqrt(chsq + 1.0e-12);
  if (dev00 < 0.0)
    z = -z;
  free(rsum);
  free(csum);
  return z;
}
```