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

```asm
<test_plot_lattice>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x48,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x38(%rsp)
  xor    %eax,%eax
  mov    D70(%rip),%rax
  movl   $0xc8,0x18(%rsp)
  movl   $0xc8,0x1c(%rsp)
  mov    %rax,0x20(%rsp)
  cmp    $0x2,%edi
  jle    L138
  lea    -0x3(%rdi),%eax
  mov    %rsi,%r13
  lea    0x10(%rsi),%r15
  lea    0x18(%rsi,%rax,8),%r12
  lea    D73(%rip),%rax
  mov    %rax,0x8(%rsp)
  lea    0x18(%rsp),%rbx
  lea    D54(%rip),%rbp
  lea    D24(%rip),%r14
  jmp    L48
  nopw   0x0(%rax,%rax,1)
L120:
  mov    0x18(%rsp),%eax
  mov    %eax,0x1c(%rsp)
  nopl   0x0(%rax,%rax,1)
L114:
  add    $0x8,%r15
  cmp    %r12,%r15
  je     L65
L48:
  mov    (%r15),%rdi
  xor    %eax,%eax
  mov    %rbx,%rdx
  mov    %rbp,%rsi
  call   <sscanf@plt>
  cmp    $0x1,%eax
  je     L114
  mov    (%r15),%rdi
  xor    %eax,%eax
  lea    0x1c(%rsp),%rdx
  mov    %r14,%rsi
  call   <sscanf@plt>
  cmp    $0x1,%eax
  je     L114
  mov    (%r15),%rdi
  xor    %eax,%eax
  mov    %rbx,%rdx
  lea    D28(%rip),%rsi
  call   <sscanf@plt>
  cmp    $0x1,%eax
  je     L120
  mov    (%r15),%rdi
  xor    %eax,%eax
  lea    0x20(%rsp),%rdx
  lea    D71(%rip),%rsi
  call   <sscanf@plt>
  cmp    $0x1,%eax
  je     L114
  mov    (%r15),%rdi
  mov    $0x2,%edx
  lea    D61(%rip),%rsi
  call   <strncmp@plt>
  test   %rax,%rax
  jne    L28
  mov    (%r15),%rax
  add    $0x8,%r15
  add    $0x2,%rax
  mov    %rax,0x8(%rsp)
  cmp    %r12,%r15
  jne    L48
  nopl   0x0(%rax,%rax,1)
L65:
  cmpl   $0x2,0x18(%rsp)
  jle    L102
  mov    0x1c(%rsp),%esi
  cmp    $0x2,%esi
  jg     L60
L102:
  mov    0x8(%r13),%rsi
  mov    0x0(%r13),%rdi
  mov    $0x1,%edx
  call   <usage@plt>
  mov    0x1c(%rsp),%esi
L60:
  mov    0x18(%rsp),%edi
  xor    %edx,%edx
  lea    0x28(%rsp),%rbx
  lea    0x30(%rsp),%r14
  call   <allocate_matrix@plt>
  mov    0x1c(%rsp),%esi
  mov    0x18(%rsp),%edi
  xor    %edx,%edx
  mov    %rax,%r12
  call   <allocate_matrix@plt>
  mov    0x1c(%rsp),%esi
  mov    0x18(%rsp),%edi
  mov    $0x2e,%edx
  mov    %rax,%rbp
  call   <allocate_matrix@plt>
  mov    0x1c(%rsp),%ecx
  mov    0x18(%rsp),%edx
  mov    %r14,%rsi
  mov    %rbx,%rdi
  mov    %rax,%r13
  call   <set_A1_A2@plt>
  mov    0x1c(%rsp),%ecx
  mov    0x18(%rsp),%edx
  mov    %rbp,%rsi
  movsd  0x20(%rsp),%xmm0
  mov    %r12,%rdi
  call   <populate_bonds@plt>
  mov    0x8(%rsp),%r15
  mov    %rbx,%r9
  mov    %rbp,%rdx
  mov    %r12,%rsi
  mov    %r13,%rdi
  push   %r15
  push   %r14
  mov    0x2c(%rsp),%r8d
  mov    0x28(%rsp),%ecx
  call   <plot_lattice@plt>
  mov    %r15,%rsi
  lea    D49(%rip),%rdi
  call   <printf@plt>
  mov    0x2c(%rsp),%edx
  mov    0x28(%rsp),%esi
  mov    %r12,%rdi
  call   <free_matrix@plt>
  mov    0x2c(%rsp),%edx
  mov    0x28(%rsp),%esi
  mov    %rbp,%rdi
  call   <free_matrix@plt>
  mov    0x2c(%rsp),%edx
  mov    0x28(%rsp),%esi
  mov    %r13,%rdi
  call   <free_matrix@plt>
  pop    %rax
  pop    %rdx
  mov    0x38(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L107
  add    $0x48,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L28:
  mov    0x8(%r13),%rsi
  mov    0x0(%r13),%rdi
  xor    %edx,%edx
  call   <usage@plt>
  jmp    L114
  nopl   0x0(%rax)
L138:
  lea    D73(%rip),%rax
  mov    $0xc8,%esi
  mov    %rax,0x8(%rsp)
  jmp    L60
L107:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: unpack_data
arguments: data_tag: D70
type_infered: f64
name: unpack_data
arguments: data_tag: D73
type_infered: string
name: unpack_data
arguments: data_tag: D54
type_infered: string
name: unpack_data
arguments: data_tag: D24
type_infered: string
name: unpack_data
arguments: data_tag: D28
type_infered: string
name: unpack_data
arguments: data_tag: D71
type_infered: string
name: unpack_data
arguments: data_tag: D61
type_infered: string
name: unpack_data
arguments: data_tag: D49
type_infered: string

tool: D70: 0.6

tool: D73: p2.ppm

tool: D54: M=%d

tool: D24: N=%d

tool: D28: MN=%d

tool: D71: p=%lf

tool: D61: f=

tool: D49: Wrote %s.


assistant: ```c
void test_plot_lattice(int argc, char **argv) {
  int M = 200;
  int N = 200;
  double p = 0.6;
  int argi;
  int **vbonds;
  int **hbonds;
  int **site_marks;
  int A1[2];
  int A2[2];
  char *image_file_name = "p2.ppm";
  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 (strncmp(argv[argi], "f=", 2) == 0)
      image_file_name = &argv[argi][2];
    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);
  populate_bonds(vbonds, hbonds, M, N, p);
  plot_lattice(site_marks, vbonds, hbonds, M, N, A1, A2, image_file_name);
  printf("Wrote %s.\n", image_file_name);
  free_matrix(vbonds, M, N);
  free_matrix(hbonds, M, N);
  free_matrix(site_marks, M, N);
}
```