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

```asm
<test_P_A1_or_A2_in_C>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x38,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x28(%rsp)
  xor    %eax,%eax
  movl   $0x12,0x4(%rsp)
  movl   $0x12,0x8(%rsp)
  mov    D21(%rip),%rax
  mov    %rax,0x10(%rsp)
  movl   $0x3e8,0xc(%rsp)
  cmp    $0x2,%edi
  jle    L53
  mov    %rsi,%r14
  lea    0x10(%rsi),%rbx
  lea    -0x3(%rdi),%eax
  lea    0x18(%rsi,%rax,8),%r13
  lea    D14(%rip),%r12
  lea    D29(%rip),%r15
  jmp    L69
L113:
  lea    0x10(%rsp),%rdx
  lea    D11(%rip),%rsi
  mov    (%rbx),%rdi
  mov    $0x0,%eax
  call   <sscanf@plt>
  cmp    $0x1,%eax
  jne    L124
L54:
  add    $0x8,%rbx
  cmp    %r13,%rbx
  je     L127
L69:
  lea    0x4(%rsp),%rdx
  mov    %r12,%rsi
  mov    (%rbx),%rdi
  mov    $0x0,%eax
  call   <sscanf@plt>
  cmp    $0x1,%eax
  je     L54
  lea    0x8(%rsp),%rdx
  mov    %r15,%rsi
  mov    (%rbx),%rdi
  mov    $0x0,%eax
  call   <sscanf@plt>
  cmp    $0x1,%eax
  je     L54
  lea    0x4(%rsp),%rdx
  lea    D12(%rip),%rsi
  mov    (%rbx),%rdi
  mov    $0x0,%eax
  call   <sscanf@plt>
  cmp    $0x1,%eax
  jne    L113
  mov    0x4(%rsp),%eax
  mov    %eax,0x8(%rsp)
  jmp    L54
L124:
  lea    0xc(%rsp),%rdx
  lea    D26(%rip),%rsi
  mov    (%rbx),%rdi
  mov    $0x0,%eax
  call   <sscanf@plt>
  cmp    $0x1,%eax
  je     L54
  mov    0x8(%r14),%rsi
  mov    $0x0,%edx
  mov    (%r14),%rdi
  call   <usage@plt>
  jmp    L54
L127:
  cmpl   $0x2,0x4(%rsp)
  jle    L5
  cmpl   $0x2,0x8(%rsp)
  jg     L53
L5:
  mov    0x8(%r14),%rsi
  mov    $0x1,%edx
  mov    (%r14),%rdi
  call   <usage@plt>
L53:
  mov    $0x0,%edx
  mov    0x8(%rsp),%esi
  mov    0x4(%rsp),%edi
  call   <allocate_matrix@plt>
  mov    %rax,%r12
  mov    $0x0,%edx
  mov    0x8(%rsp),%esi
  mov    0x4(%rsp),%edi
  call   <allocate_matrix@plt>
  mov    %rax,%rbp
  mov    $0x2e,%edx
  mov    0x8(%rsp),%esi
  mov    0x4(%rsp),%edi
  call   <allocate_matrix@plt>
  mov    %rax,%rbx
  lea    0x20(%rsp),%r14
  lea    0x18(%rsp),%r13
  mov    0x8(%rsp),%ecx
  mov    0x4(%rsp),%edx
  mov    %r14,%rsi
  mov    %r13,%rdi
  call   <set_A1_A2@plt>
  push   %r14
  push   %r13
  mov    0x1c(%rsp),%r9d
  movsd  0x20(%rsp),%xmm0
  mov    0x18(%rsp),%r8d
  mov    0x14(%rsp),%ecx
  mov    %rbp,%rdx
  mov    %r12,%rsi
  mov    %rbx,%rdi
  call   <P_A1_or_A2_in_C@plt>
  movapd %xmm0,%xmm1
  mov    0x1c(%rsp),%ecx
  movsd  0x20(%rsp),%xmm0
  mov    0x18(%rsp),%edx
  mov    0x14(%rsp),%esi
  lea    D7(%rip),%rdi
  call   <printf@plt>
  mov    0x18(%rsp),%edx
  mov    0x14(%rsp),%esi
  mov    %r12,%rdi
  call   <free_matrix@plt>
  mov    0x18(%rsp),%edx
  mov    0x14(%rsp),%esi
  mov    %rbp,%rdi
  call   <free_matrix@plt>
  mov    0x18(%rsp),%edx
  mov    0x14(%rsp),%esi
  mov    %rbx,%rdi
  call   <free_matrix@plt>
  add    $0x10,%rsp
  mov    0x28(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L30
  add    $0x38,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L30:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: unpack_data
arguments: label: D21
data_type: f64
name: unpack_data
arguments: label: D14
data_type: string
name: unpack_data
arguments: label: D29
data_type: string
name: unpack_data
arguments: label: D11
data_type: string
name: unpack_data
arguments: label: D12
data_type: string
name: unpack_data
arguments: label: D26
data_type: string
name: unpack_data
arguments: label: D7
data_type: string

tool: D21: 0.6

tool: D14: M=%d

tool: D29: N=%d

tool: D11: p=%lf

tool: D12: MN=%d

tool: D26: reps=%d

tool: D7: M=%d N=%d p=%.4lf reps=%d PU2inC=%11.7lf


assistant: ```c
void test_P_A1_or_A2_in_C(int argc, char **argv) {
  int M = 18;
  int N = 18;
  double p = 0.6;
  int argi;
  int **vbonds;
  int **hbonds;
  int **site_marks;
  int A1[2], A2[2];
  int reps = 1000;
  double P;
  for (argi = 2; argi < argc; argi++) {
    if (sscanf(argv[argi], "M=%d", &M) == 1)
      ;
    else if (sscanf(argv[argi], "N=%d", &N) == 1)
      ;
    else if (sscanf(argv[argi], "MN=%d", &M) == 1)
      N = M;
    else if (sscanf(argv[argi], "p=%lf", &p) == 1)
      ;
    else if (sscanf(argv[argi], "reps=%d", &reps) == 1)
      ;
    else
      usage(argv[0], argv[1], 0);
  }
  if ((M < 3) || (N < 3))
    usage(argv[0], argv[1], 1);
  vbonds = allocate_matrix(M, N, 0);
  hbonds = allocate_matrix(M, N, 0);
  site_marks = allocate_matrix(M, N, '.');
  set_A1_A2(A1, A2, M, N);
  P = P_A1_or_A2_in_C(site_marks, vbonds, hbonds, M, N, p, reps, A1, A2);
  printf("M=%d N=%d p=%.4lf reps=%d PU2inC=%11.7lf\n", M, N, p, reps, P);
  free_matrix(vbonds, M, N);
  free_matrix(hbonds, M, N);
  free_matrix(site_marks, M, N);
}
```