user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<read_mosaic_grid_data>:
  endbr64
  push   %r15
  mov    %rsi,%r15
  push   %r14
  push   %r13
  mov    %ecx,%r13d
  push   %r12
  mov    %edx,%r12d
  push   %rbp
  mov    %rdi,%rbp
  push   %rbx
  mov    %r8,%rbx
  sub    $0x338,%rsp
  mov    %r9d,0x1c(%rsp)
  lea    0x220(%rsp),%r8
  lea    0x20(%rsp),%r14
  mov    %r8,%rsi
  mov    %fs:0x28,%rax
  mov    %rax,0x328(%rsp)
  xor    %eax,%eax
  mov    %r8,0x10(%rsp)
  call   <get_file_dir@plt>
  lea    0x120(%rsp),%r9
  mov    %rbp,%rdi
  lea    0x1c(%rsp),%rcx
  mov    %r9,%rdx
  lea    D48(%rip),%rsi
  mov    %r9,0x8(%rsp)
  call   <get_string_data_level@plt>
  mov    0x10(%rsp),%rdx
  mov    0x8(%rsp),%rcx
  mov    %r14,%rdi
  lea    D31(%rip),%rsi
  call   <sprintf@plt>
  lea    D15(%rip),%rsi
  mov    %r14,%rdi
  call   <get_dimlen@plt>
  lea    D24(%rip),%rsi
  mov    %r14,%rdi
  mov    %eax,%ebp
  call   <get_dimlen@plt>
  mov    %eax,%edx
  lea    (%r12,%r12,1),%eax
  cmp    %ebp,%eax
  jne    L63
  lea    0x0(%r13,%r13,1),%eax
  cmp    %edx,%eax
  je     L45
L63:
  lea    D29(%rip),%rdi
  mov    %edx,0x8(%rsp)
  call   <error_handler@plt>
  mov    0x8(%rsp),%edx
L45:
  lea    0x1(%rbp),%ecx
  add    $0x1,%edx
  imul   %ecx,%edx
  mov    %ecx,0x8(%rsp)
  lea    0x0(,%rdx,8),%edi
  call   <malloc@plt>
  mov    %r15,%rsi
  mov    %r14,%rdi
  mov    %rax,%rdx
  mov    %rax,%rbp
  call   <get_double_data@plt>
  lea    0x1(%r13),%r8d
  lea    0x1(%r12),%r9d
  sub    0x378(%rsp),%r8d
  sub    0x370(%rsp),%r9d
  test   %r8d,%r8d
  jle    L40
  mov    0x8(%rsp),%ecx
  mov    0x378(%rsp),%esi
  xor    %r10d,%r10d
  xor    %edi,%edi
  movslq 0x370(%rsp),%r11
  lea    -0x1(%r9),%r14d
  lea    0x8(%rbx),%r13
  imul   %ecx,%esi
  lea    (%rcx,%rcx,1),%r12d
  nopl   0x0(%rax)
L27:
  test   %r9d,%r9d
  jle    L14
  movslq %esi,%rax
  movslq %r10d,%rcx
  add    %r11,%rax
  lea    0x0(%rbp,%rax,8),%rdx
  lea    (%rbx,%rcx,8),%rax
  add    %r14,%rcx
  lea    0x0(%r13,%rcx,8),%rcx
  nop
L67:
  movsd  (%rdx),%xmm0
  add    $0x8,%rax
  add    $0x10,%rdx
  movsd  %xmm0,-0x8(%rax)
  cmp    %rcx,%rax
  jne    L67
L14:
  add    $0x1,%edi
  add    %r12d,%esi
  add    %r9d,%r10d
  cmp    %edi,%r8d
  jne    L27
L40:
  mov    %rbp,%rdi
  call   <free@plt>
  mov    0x328(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L51
  add    $0x338,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L51:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: disassemble_data
arguments: tag: D48
type_infered: string
name: disassemble_data
arguments: tag: D31
type_infered: string
name: disassemble_data
arguments: tag: D15
type_infered: string
name: disassemble_data
arguments: tag: D24
type_infered: string
name: disassemble_data
arguments: tag: D29
type_infered: string

tool: D48: gridfiles

tool: D31: %s/%s

tool: D15: nx

tool: D24: ny

tool: D29: supergrid size should be double of the model grid size

assistant: ```c
void read_mosaic_grid_data(const char *mosaic_file, const char *name, int nx, int ny, double *data, int level, int ioff, int joff) {
  char tilefile[255], gridfile[255], dir[255];
  double *tmp;
  int ni, nj, nxp, nyp, i, j;
  get_file_dir(mosaic_file, dir);
  get_string_data_level(mosaic_file, "gridfiles", gridfile, &level);
  sprintf(tilefile, "%s/%s", dir, gridfile);
  ni = get_dimlen(tilefile, "nx");
  nj = get_dimlen(tilefile, "ny");
  if (ni != nx * 2 || nj != ny * 2)
    error_handler("supergrid size should be double of the model grid size");
  tmp = (double *)malloc((ni + 1) * (nj + 1) * sizeof(double));
  get_double_data(tilefile, name, tmp);
  nxp = nx + 1 - ioff;
  nyp = ny + 1 - joff;
  for (j = 0; j < nyp; j++)
    for (i = 0; i < nxp; i++)
      data[j * nxp + i] = tmp[(2 * j + joff) * (ni + 1) + 2 * i + ioff];
  free(tmp);
}
```