user: Please show me the C implementation that matches the assembly code listed below:

```asm
<read_mosaic_contact>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x1000,%rsp
  orq    $0x0,(%rsp)
  sub    $0x1000,%rsp
  orq    $0x0,(%rsp)
  sub    $0x9c8,%rsp
  mov    0x2a00(%rsp),%rax
  mov    %rax,0x28(%rsp)
  mov    0x2a08(%rsp),%rax
  mov    %rdi,%r14
  mov    %rdi,0x8(%rsp)
  mov    %rax,0x30(%rsp)
  mov    0x2a10(%rsp),%rax
  mov    %rsi,0xb0(%rsp)
  lea    D22(%rip),%rsi
  mov    %rax,0x38(%rsp)
  mov    0x2a18(%rsp),%rax
  mov    %rdx,0xb8(%rsp)
  mov    %rax,0x40(%rsp)
  mov    0x2a20(%rsp),%rax
  mov    %rcx,0x70(%rsp)
  mov    %r8,0x78(%rsp)
  mov    %r9,0x20(%rsp)
  mov    %rax,0x48(%rsp)
  mov    %fs:0x28,%rax
  mov    %rax,0x29b8(%rsp)
  xor    %eax,%eax
  call   <get_dimlen@plt>
  movslq %eax,%rdi
  mov    %eax,0x14(%rsp)
  mov    %eax,%r13d
  mov    %rdi,%rbx
  shl    $0x3,%rdi
  call   <malloc@plt>
  movl   $0x0,0xc8(%rsp)
  mov    %rax,%rbp
  test   %ebx,%ebx
  jle    L148
  lea    0xc8(%rsp),%r15
  xor    %r12d,%r12d
  lea    D11(%rip),%rbx
  mov    %r15,0x18(%rsp)
  nopw   0x0(%rax,%rax,1)
L295:
  mov    $0xff,%edi
  movslq %r12d,%r12
  call   <malloc@plt>
  mov    %r15,%rcx
  mov    %rbx,%rsi
  mov    %r14,%rdi
  mov    %rax,0x0(%rbp,%r12,8)
  mov    %rax,%rdx
  xor    %eax,%eax
  call   <get_string_data_level@plt>
  mov    0xc8(%rsp),%eax
  lea    0x1(%rax),%r12d
  mov    %r12d,0xc8(%rsp)
  cmp    %r13d,%r12d
  jl     L295
  mov    0x8(%rsp),%rdi
  lea    D69(%rip),%rsi
  xor    %eax,%eax
  call   <get_dimlen@plt>
  movl   $0x0,0xc8(%rsp)
  mov    %eax,0xa8(%rsp)
  test   %eax,%eax
  jle    L83
L58:
  lea    0x28b0(%rsp),%rax
  lea    0x1cf(%rsp),%r12
  mov    %rax,0x50(%rsp)
  lea    0xcc(%rsp),%rax
  lea    D136(%rip),%rbx
  mov    %rax,0x58(%rsp)
  lea    0xd0(%rsp),%rax
  mov    %rax,(%rsp)
  lea    0x3cd(%rsp),%rax
  mov    %rax,0x68(%rsp)
  lea    0x2ce(%rsp),%rax
  mov    %rax,0xa0(%rsp)
  lea    0x4cc(%rsp),%rax
  mov    %rax,0x98(%rsp)
  lea    0x5cb(%rsp),%rax
  mov    %rax,0x90(%rsp)
  lea    0x6ca(%rsp),%rax
  mov    %rax,0x88(%rsp)
  lea    0x7c9(%rsp),%rax
  mov    %rax,0x80(%rsp)
  nopl   0x0(%rax)
L188:
  mov    0x50(%rsp),%r14
  mov    0x18(%rsp),%rcx
  lea    D134(%rip),%rsi
  xor    %eax,%eax
  mov    0x8(%rsp),%rdi
  mov    %r14,%rdx
  call   <get_string_data_level@plt>
  mov    0x58(%rsp),%r9
  mov    (%rsp),%r8
  xor    %eax,%eax
  mov    $0x28,%ecx
  mov    $0xff,%edx
  lea    D125(%rip),%rsi
  mov    %r14,%rdi
  call   <tokenize@plt>
  cmpl   $0x4,0xcc(%rsp)
  je     L216
  lea    D53(%rip),%rdi
  xor    %eax,%eax
  call   <error_handler@plt>
L216:
  mov    0x14(%rsp),%eax
  test   %eax,%eax
  jle    L171
  lea    0x1(%rax),%r14d
  mov    $0x1,%r15d
  jmp    L110
  nopl   0x0(%rax)
L282:
  add    $0x1,%r15
  cmp    %r15,%r14
  je     L286
L110:
  mov    -0x8(%rbp,%r15,8),%rdi
  mov    %r12,%rsi
  call   <strcmp@plt>
  test   %eax,%eax
  jne    L282
  movslq 0xc8(%rsp),%rax
  mov    0xb0(%rsp),%rdx
  mov    %r15d,(%rdx,%rax,4)
L79:
  mov    %rbp,0x60(%rsp)
  mov    0x14(%rsp),%r15d
  xor    %r14d,%r14d
  mov    0x68(%rsp),%r13
  jmp    L291
  xchg   %ax,%ax
L92:
  add    $0x8,%rbp
  cmp    %r14d,%r15d
  jle    L194
L291:
  mov    0x0(%rbp),%rdi
  mov    %r13,%rsi
  add    $0x1,%r14d
  call   <strcmp@plt>
  test   %eax,%eax
  jne    L92
  movslq 0xc8(%rsp),%rax
  mov    0xb8(%rsp),%rdx
  mov    0x60(%rsp),%rbp
  mov    %r14d,(%rdx,%rax,4)
L198:
  mov    0x50(%rsp),%r14
  mov    0x18(%rsp),%rcx
  lea    D51(%rip),%rsi
  xor    %eax,%eax
  mov    0x8(%rsp),%rdi
  mov    %r14,%rdx
  call   <get_string_data_level@plt>
  mov    0x58(%rsp),%r9
  mov    (%rsp),%r8
  xor    %eax,%eax
  mov    $0x28,%ecx
  mov    $0xff,%edx
  lea    D72(%rip),%rsi
  mov    %r14,%rdi
  call   <tokenize@plt>
  cmpl   $0x8,0xcc(%rsp)
  je     L14
  lea    D10(%rip),%rdi
  xor    %eax,%eax
  call   <error_handler@plt>
  mov    0xcc(%rsp),%edx
  test   %edx,%edx
  je     L93
L14:
  mov    (%rsp),%r13
  xor    %r14d,%r14d
  nopl   0x0(%rax,%rax,1)
L107:
  xor    %r15d,%r15d
  jmp    L42
  nopl   (%rax)
L186:
  add    $0x1,%r15
L42:
  mov    %r13,%rdi
  call   <strlen@plt>
  cmp    %r15,%rax
  jbe    L308
  movzbl 0x0(%r13,%r15,1),%eax
  sub    $0x30,%eax
  cmp    $0x9,%al
  jbe    L186
  mov    %rbx,%rdi
  xor    %eax,%eax
  call   <error_handler@plt>
  jmp    L186
  nopw   0x0(%rax,%rax,1)
L308:
  add    $0x1,%r14d
  add    $0xff,%r13
  cmp    %r14d,0xcc(%rsp)
  ja     L107
L93:
  mov    0x70(%rsp),%r15
  movslq 0xc8(%rsp),%rax
  mov    (%rsp),%rdi
  lea    (%r15,%rax,4),%r14
  xor    %eax,%eax
  call   <atoi@plt>
  mov    0x78(%rsp),%r13
  mov    %r12,%rdi
  mov    %eax,(%r14)
  movslq 0xc8(%rsp),%rax
  lea    0x0(%r13,%rax,4),%r14
  xor    %eax,%eax
  call   <atoi@plt>
  mov    0x20(%rsp),%rdx
  mov    0xa0(%rsp),%rdi
  mov    %eax,(%r14)
  movslq 0xc8(%rsp),%rax
  lea    (%rdx,%rax,4),%r14
  xor    %eax,%eax
  call   <atoi@plt>
  mov    0x28(%rsp),%rcx
  mov    0x68(%rsp),%rdi
  mov    %eax,(%r14)
  movslq 0xc8(%rsp),%rax
  lea    (%rcx,%rax,4),%r14
  xor    %eax,%eax
  call   <atoi@plt>
  mov    0x30(%rsp),%rsi
  mov    0x98(%rsp),%rdi
  mov    %eax,(%r14)
  movslq 0xc8(%rsp),%rax
  lea    (%rsi,%rax,4),%r14
  xor    %eax,%eax
  call   <atoi@plt>
  mov    0x38(%rsp),%rdi
  mov    %eax,(%r14)
  movslq 0xc8(%rsp),%rax
  lea    (%rdi,%rax,4),%r14
  mov    0x90(%rsp),%rdi
  xor    %eax,%eax
  call   <atoi@plt>
  mov    0x40(%rsp),%r10
  mov    0x88(%rsp),%rdi
  mov    %eax,(%r14)
  movslq 0xc8(%rsp),%rax
  lea    (%r10,%rax,4),%r14
  xor    %eax,%eax
  call   <atoi@plt>
  mov    0x48(%rsp),%r11
  mov    0x80(%rsp),%rdi
  mov    %eax,(%r14)
  movslq 0xc8(%rsp),%rax
  lea    (%r11,%rax,4),%r14
  xor    %eax,%eax
  call   <atoi@plt>
  mov    $0x2,%r8d
  mov    %eax,(%r14)
  movslq 0xc8(%rsp),%rax
  shl    $0x2,%rax
  lea    0x0(%r13,%rax,1),%rcx
  add    %r15,%rax
  mov    (%rcx),%esi
  mov    (%rax),%edi
  mov    %rax,%rdx
  xor    %eax,%eax
  call   <transfer_to_model_index@plt>
  mov    0x28(%rsp),%rcx
  mov    $0x2,%r8d
  mov    %eax,0x60(%rsp)
  mov    %eax,%r13d
  movslq 0xc8(%rsp),%rax
  shl    $0x2,%rax
  add    %rax,%rcx
  add    0x20(%rsp),%rax
  mov    (%rcx),%esi
  mov    (%rax),%edi
  mov    %rax,%rdx
  xor    %eax,%eax
  call   <transfer_to_model_index@plt>
  mov    0x38(%rsp),%rdi
  mov    $0x2,%r8d
  mov    %eax,%r15d
  movslq 0xc8(%rsp),%rax
  shl    $0x2,%rax
  lea    (%rdi,%rax,1),%rcx
  add    0x30(%rsp),%rax
  mov    (%rcx),%esi
  mov    (%rax),%edi
  mov    %rax,%rdx
  xor    %eax,%eax
  call   <transfer_to_model_index@plt>
  mov    0x48(%rsp),%r11
  mov    $0x2,%r8d
  mov    %eax,%r14d
  movslq 0xc8(%rsp),%rax
  shl    $0x2,%rax
  lea    (%r11,%rax,1),%rcx
  add    0x40(%rsp),%rax
  mov    (%rax),%edi
  mov    (%rcx),%esi
  mov    %rax,%rdx
  xor    %eax,%eax
  call   <transfer_to_model_index@plt>
  or     %r15d,%r13d
  mov    %eax,%edx
  je     L267
L181:
  mov    %r14d,%eax
  or     %edx,%eax
  je     L209
L141:
  mov    0x60(%rsp),%eax
  add    %edx,%r14d
  add    %r15d,%eax
  cmp    %r14d,%eax
  je     L112
  lea    D161(%rip),%rdi
  xor    %eax,%eax
  call   <error_handler@plt>
L112:
  mov    0xc8(%rsp),%eax
  add    $0x1,%eax
  mov    %eax,0xc8(%rsp)
  cmp    0xa8(%rsp),%eax
  jl     L188
  mov    0x14(%rsp),%eax
  test   %eax,%eax
  jle    L177
L83:
  mov    0x14(%rsp),%r12d
  xor    %ebx,%ebx
  nopl   0x0(%rax,%rax,1)
L176:
  mov    0x0(%rbp,%rbx,8),%rdi
  add    $0x1,%rbx
  call   <free@plt>
  cmp    %ebx,%r12d
  jg     L176
L177:
  mov    0x29b8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L133
  add    $0x29c8,%rsp
  mov    %rbp,%rdi
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  jmp    1100 <free@plt>
L194:
  mov    0x60(%rsp),%rbp
L184:
  lea    D151(%rip),%rdi
  xor    %eax,%eax
  call   <error_handler@plt>
  jmp    L198
L286:
  lea    D20(%rip),%rdi
  xor    %eax,%eax
  call   <error_handler@plt>
  jmp    L79
L209:
  lea    D166(%rip),%rdi
  xor    %eax,%eax
  mov    %edx,0xac(%rsp)
  call   <error_handler@plt>
  mov    0xac(%rsp),%edx
  jmp    L141
L267:
  mov    %eax,0xac(%rsp)
  lea    D81(%rip),%rdi
  xor    %eax,%eax
  call   <error_handler@plt>
  mov    0xac(%rsp),%edx
  jmp    L181
L171:
  lea    D20(%rip),%rdi
  xor    %eax,%eax
  call   <error_handler@plt>
  jmp    L184
L148:
  mov    0x8(%rsp),%rdi
  lea    D69(%rip),%rsi
  xor    %eax,%eax
  call   <get_dimlen@plt>
  lea    0xc8(%rsp),%rdx
  movl   $0x0,0xc8(%rsp)
  mov    %eax,0xa8(%rsp)
  mov    %rdx,0x18(%rsp)
  test   %eax,%eax
  jg     L58
  jmp    L177
L133:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: retrieve_data
arguments: data_tag: D22
datatype: string
name: retrieve_data
arguments: data_tag: D11
datatype: string
name: retrieve_data
arguments: data_tag: D69
datatype: string
name: retrieve_data
arguments: data_tag: D136
datatype: string
name: retrieve_data
arguments: data_tag: D134
datatype: string
name: retrieve_data
arguments: data_tag: D125
datatype: string
name: retrieve_data
arguments: data_tag: D53
datatype: string
name: retrieve_data
arguments: data_tag: D51
datatype: string
name: retrieve_data
arguments: data_tag: D72
datatype: string
name: retrieve_data
arguments: data_tag: D10
datatype: string
name: retrieve_data
arguments: data_tag: D161
datatype: string
name: retrieve_data
arguments: data_tag: D151
datatype: string
name: retrieve_data
arguments: data_tag: D20
datatype: string
name: retrieve_data
arguments: data_tag: D166
datatype: string
name: retrieve_data
arguments: data_tag: D81
datatype: string

tool: D22: ntiles

tool: D11: gridtiles

tool: D69: ncontact

tool: D136: Error from read_mosaic: some of the character in contact_indices except token is not digit number

tool: D134: contacts

tool: D125: :

tool: D53: Error from read_mosaic: number of elements in contact seperated by :/:: should be 4

tool: D51: contact_index

tool: D72: :,

tool: D10: Error from read_mosaic: number of elements in contact_index seperated by :/, should be 8

tool: D161: Error from read_mosaic_contact: It is not a line or overlap contact

tool: D151: error from read_mosaic: the second tile name specified in contact is not found in tile list

tool: D20: error from read_mosaic: the first tile name specified in contact is not found in tile list

tool: D166: Error from read_mosaic_contact:istart2==iend2 and jstart2==jend2

tool: D81: Error from read_mosaic_contact:istart1==iend1 and jstart1==jend1

assistant: ```c
void read_mosaic_contact(const char *mosaic_file, int *tile1, int *tile2, int *istart1, int *iend1, int *jstart1, int *jend1, int *istart2, int *iend2, int *jstart2, int *jend2) {
  char contacts[255];
  char **gridtiles;
  char pstring[40][255];
  int ntiles, ncontacts, n, m, l, found;
  unsigned int nstr;
  const int x_refine = 2, y_refine = 2;
  int i1_type, j1_type, i2_type, j2_type;
  ntiles = get_dimlen(mosaic_file, "ntiles");
  gridtiles = (char **)malloc(ntiles * sizeof(char *));
  for (n = 0; n < ntiles; n++) {
    gridtiles[n] = (char *)malloc(255 * sizeof(char));
    get_string_data_level(mosaic_file, "gridtiles", gridtiles[n], &n);
  }
  ncontacts = get_dimlen(mosaic_file, "ncontact");
  for (n = 0; n < ncontacts; n++) {
    get_string_data_level(mosaic_file, "contacts", contacts, &n);
    tokenize(contacts, ":", 255, 40, (char *)pstring, &nstr);
    if (nstr != 4)
      error_handler("Error from read_mosaic: number of elements "
                    "in contact seperated by :/:: should be 4");
    found = 0;
    for (m = 0; m < ntiles; m++) {
      if (strcmp(gridtiles[m], pstring[1]) == 0) {
        found = 1;
        tile1[n] = m + 1;
        break;
      }
    }
    if (!found)
      error_handler("error from read_mosaic: the first tile name specified "
                    "in contact is not found in tile list");
    found = 0;
    for (m = 0; m < ntiles; m++) {
      if (strcmp(gridtiles[m], pstring[3]) == 0) {
        found = 1;
        tile2[n] = m + 1;
        break;
      }
    }
    if (!found)
      error_handler("error from read_mosaic: the second tile name specified "
                    "in contact is not found in tile list");
    get_string_data_level(mosaic_file, "contact_index", contacts, &n);
    tokenize(contacts, ":,", 255, 40, (char *)pstring, &nstr);
    if (nstr != 8)
      error_handler("Error from read_mosaic: number of elements "
                    "in contact_index seperated by :/, should be 8");
    for (m = 0; m < nstr; m++)
      for (l = 0; l < strlen(pstring[m]); l++) {
        if (pstring[m][l] > '9' || pstring[m][l] < '0') {
          error_handler("Error from read_mosaic: some of the character in "
                        "contact_indices except token is not digit number");
        }
      }
    istart1[n] = atoi(pstring[0]);
    iend1[n] = atoi(pstring[1]);
    jstart1[n] = atoi(pstring[2]);
    jend1[n] = atoi(pstring[3]);
    istart2[n] = atoi(pstring[4]);
    iend2[n] = atoi(pstring[5]);
    jstart2[n] = atoi(pstring[6]);
    jend2[n] = atoi(pstring[7]);
    i1_type = transfer_to_model_index(istart1[n], iend1[n], istart1 + n, iend1 + n, x_refine);
    j1_type = transfer_to_model_index(jstart1[n], jend1[n], jstart1 + n, jend1 + n, y_refine);
    i2_type = transfer_to_model_index(istart2[n], iend2[n], istart2 + n, iend2 + n, x_refine);
    j2_type = transfer_to_model_index(jstart2[n], jend2[n], jstart2 + n, jend2 + n, y_refine);
    if (i1_type == 0 && j1_type == 0)
      error_handler("Error from read_mosaic_contact:istart1==iend1 and jstart1==jend1");
    if (i2_type == 0 && j2_type == 0)
      error_handler("Error from read_mosaic_contact:istart2==iend2 and jstart2==jend2");
    if (i1_type + j1_type != i2_type + j2_type)
      error_handler("Error from read_mosaic_contact: It is not a line or overlap contact");
  }
  for (m = 0; m < ntiles; m++) {
    free(gridtiles[m]);
  }
  free(gridtiles);
}
```