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

```asm
<maskregion>:
  endbr64
  push   %r15
  mov    %esi,%r15d
  push   %r14
  push   %r13
  mov    %rdi,%r13
  mov    %esi,%edi
  push   %r12
  mov    %r8d,%r12d
  push   %rbp
  mov    %rdx,%rbp
  push   %rbx
  mov    %rcx,%rbx
  sub    $0x148,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x138(%rsp)
  xor    %eax,%eax
  call   <gridInqXsize@plt>
  mov    %r15d,%edi
  mov    %eax,%r14d
  xor    %eax,%eax
  call   <gridInqYsize@plt>
  movslq %r14d,%rcx
  mov    $0x94,%edx
  lea    D101(%rip),%rsi
  mov    %eax,0x1c(%rsp)
  shl    $0x3,%rcx
  lea    D30(%rip),%rdi
  xor    %eax,%eax
  call   <Malloc@plt>
  mov    $0x95,%edx
  lea    D101(%rip),%rsi
  lea    D30(%rip),%rdi
  movslq %eax,%rcx
  xor    %eax,%eax
  mov    %rcx,0x20(%rsp)
  movslq 0x1c(%rsp),%rcx
  shl    $0x3,%rcx
  call   <Malloc@plt>
  mov    0x20(%rsp),%rsi
  movslq %eax,%rdi
  xor    %eax,%eax
  mov    %rdi,0x28(%rsp)
  mov    %r15d,%edi
  call   <gridInqXvals@plt>
  mov    0x28(%rsp),%rsi
  mov    %r15d,%edi
  xor    %eax,%eax
  call   <gridInqYvals@plt>
  lea    0x30(%rsp),%r8
  mov    %r15d,%edi
  xor    %eax,%eax
  mov    %r8,%rsi
  mov    %r8,0x8(%rsp)
  call   <gridInqXunits@plt>
  mov    0x20(%rsp),%rdx
  mov    %r14d,%esi
  xor    %eax,%eax
  mov    0x8(%rsp),%rdi
  lea    D106(%rip),%rcx
  call   <grid_to_degree@plt>
  mov    0x8(%rsp),%rsi
  mov    %r15d,%edi
  xor    %eax,%eax
  call   <gridInqYunits@plt>
  mov    0x28(%rsp),%r15
  mov    0x1c(%rsp),%esi
  xor    %eax,%eax
  mov    0x8(%rsp),%rdi
  lea    D22(%rip),%rcx
  mov    %r15,%rdx
  call   <grid_to_degree@plt>
  mov    0x20(%rsp),%rcx
  movsd  (%r15),%xmm3
  movsd  (%rcx),%xmm12
  cmp    $0x1,%r14d
  jle    L185
  lea    -0x2(%r14),%edx
  lea    0x8(%rcx),%rax
  movapd %xmm12,%xmm8
  lea    0x10(%rcx,%rdx,8),%rdx
  movapd %xmm12,%xmm7
  nopl   0x0(%rax)
L178:
  movsd  (%rax),%xmm0
  add    $0x8,%rax
  movapd %xmm0,%xmm5
  maxsd  %xmm8,%xmm0
  minsd  %xmm7,%xmm5
  movapd %xmm0,%xmm8
  movapd %xmm5,%xmm7
  cmp    %rdx,%rax
  jne    L178
L436:
  mov    0x1c(%rsp),%ecx
  cmp    $0x1,%ecx
  jle    L152
  mov    0x28(%rsp),%rdi
  lea    -0x2(%rcx),%edx
  movapd %xmm3,%xmm11
  movapd %xmm3,%xmm10
  lea    0x8(%rdi),%rax
  lea    0x10(%rdi,%rdx,8),%rdx
  nopl   0x0(%rax,%rax,1)
L225:
  movsd  (%rax),%xmm0
  add    $0x8,%rax
  movapd %xmm0,%xmm6
  maxsd  %xmm11,%xmm0
  minsd  %xmm10,%xmm6
  movapd %xmm0,%xmm11
  movapd %xmm6,%xmm10
  cmp    %rdx,%rax
  jne    L225
L104:
  mov    0x28(%rsp),%rax
  lea    -0x1(%r14),%r10d
  pxor   %xmm5,%xmm5
  lea    -0x1(%r12),%r11d
  movl   $0x0,0x8(%rsp)
  movsd  D17(%rip),%xmm6
  movsd  D109(%rip),%xmm9
  add    $0x8,%rax
  mov    %rax,0x10(%rsp)
  movslq %r11d,%rax
  lea    (%rbx,%rax,8),%r15
  nopl   0x0(%rax,%rax,1)
L173:
  test   %r14d,%r14d
  jle    L192
  mov    %r10d,%eax
  movapd %xmm12,%xmm4
  mov    %r11d,%edi
  sub    %r14d,%eax
  lea    0x1(%rax),%r8d
  mov    0x20(%rsp),%rax
  lea    0x8(%rax),%r9
  jmp    L431
  cs nopw 0x0(%rax,%rax,1)
L384:
  comisd %xmm4,%xmm8
  ja     L182
  comisd %xmm10,%xmm3
  ja     L182
  comisd %xmm3,%xmm11
  ja     L182
L251:
  movslq %r8d,%rax
  movl   $0x0,0x0(%r13,%rax,4)
L329:
  cmp    %r8d,%r10d
  je     L192
L302:
  movsd  (%r9),%xmm4
  add    $0x1,%r8d
  add    $0x8,%r9
L431:
  comisd %xmm7,%xmm4
  jbe    L384
L182:
  test   %r12d,%r12d
  jle    L329
  movsd  (%r15),%xmm2
  mov    %r11d,%edx
  xor    %eax,%eax
  xor    %ecx,%ecx
  jmp    L322
L102:
  comisd %xmm3,%xmm14
  jbe    L327
L282:
  movsd  0x0(%rbp,%rax,8),%xmm13
  movsd  0x0(%rbp,%rsi,8),%xmm1
  movapd %xmm3,%xmm0
  mov    %ecx,%esi
  subsd  %xmm2,%xmm0
  subsd  %xmm2,%xmm14
  xor    $0x1,%esi
  subsd  %xmm13,%xmm1
  mulsd  %xmm1,%xmm0
  divsd  %xmm14,%xmm0
  addsd  %xmm13,%xmm0
  comisd %xmm4,%xmm0
  cmova  %esi,%ecx
L307:
  lea    0x1(%rax),%rsi
  cmp    %rax,%rdi
  je     L409
L451:
  mov    %rsi,%rax
L322:
  movapd %xmm2,%xmm14
  movsd  (%rbx,%rax,8),%xmm2
  movslq %edx,%rsi
  mov    %eax,%edx
  comisd %xmm2,%xmm3
  jae    L102
L327:
  comisd %xmm14,%xmm3
  jb     L307
  comisd %xmm3,%xmm2
  ja     L282
  lea    0x1(%rax),%rsi
  cmp    %rax,%rdi
  jne    L451
  nopw   0x0(%rax,%rax,1)
L409:
  mov    %r11d,%esi
  xor    %eax,%eax
  test   %ecx,%ecx
  jne    L251
  jmp    L143
  nop
L101:
  comisd %xmm3,%xmm2
  jbe    L132
L170:
  movsd  0x0(%rbp,%rax,8),%xmm13
  movsd  0x0(%rbp,%rdx,8),%xmm1
  movapd %xmm3,%xmm0
  mov    %ecx,%edx
  subsd  %xmm14,%xmm0
  subsd  %xmm14,%xmm2
  xor    $0x1,%edx
  subsd  %xmm13,%xmm1
  mulsd  %xmm1,%xmm0
  movapd %xmm4,%xmm1
  subsd  %xmm9,%xmm1
  divsd  %xmm2,%xmm0
  addsd  %xmm13,%xmm0
  comisd %xmm1,%xmm0
  cmova  %edx,%ecx
L289:
  lea    0x1(%rax),%rdx
  cmp    %rax,%rdi
  je     L400
L82:
  mov    %rdx,%rax
L143:
  comisd %xmm6,%xmm4
  movslq %esi,%rdx
  mov    %eax,%esi
  jbe    L289
  movsd  (%rbx,%rax,8),%xmm14
  movsd  (%rbx,%rdx,8),%xmm2
  comisd %xmm14,%xmm3
  jae    L101
L132:
  comisd %xmm2,%xmm3
  jb     L289
  comisd %xmm3,%xmm14
  ja     L170
  lea    0x1(%rax),%rdx
  cmp    %rax,%rdi
  jne    L82
  nopw   0x0(%rax,%rax,1)
L400:
  test   %ecx,%ecx
  jne    L251
  mov    %r11d,%esi
  xor    %eax,%eax
  jmp    L446
  nop
L447:
  lea    0x1(%rax),%rdx
  cmp    %rax,%rdi
  je     L295
L110:
  mov    %rdx,%rax
L446:
  comisd %xmm4,%xmm5
  movslq %esi,%rdx
  mov    %eax,%esi
  jbe    L447
  movsd  (%rbx,%rax,8),%xmm14
  movsd  (%rbx,%rdx,8),%xmm2
  comisd %xmm14,%xmm3
  jb     L125
  comisd %xmm3,%xmm2
  jbe    L125
L444:
  movsd  0x0(%rbp,%rax,8),%xmm13
  movsd  0x0(%rbp,%rdx,8),%xmm1
  movapd %xmm3,%xmm0
  mov    %ecx,%edx
  subsd  %xmm14,%xmm0
  subsd  %xmm14,%xmm2
  xor    $0x1,%edx
  subsd  %xmm13,%xmm1
  mulsd  %xmm1,%xmm0
  movapd %xmm4,%xmm1
  addsd  %xmm9,%xmm1
  divsd  %xmm2,%xmm0
  addsd  %xmm13,%xmm0
  comisd %xmm1,%xmm0
  cmova  %edx,%ecx
  lea    0x1(%rax),%rdx
  cmp    %rax,%rdi
  jne    L110
  nopw   0x0(%rax,%rax,1)
L295:
  test   %ecx,%ecx
  jne    L251
  cmp    %r8d,%r10d
  jne    L302
L192:
  addl   $0x1,0x8(%rsp)
  add    %r14d,%r10d
  mov    0x8(%rsp),%eax
  cmp    %eax,0x1c(%rsp)
  jle    L57
  mov    0x10(%rsp),%rax
  movsd  (%rax),%xmm3
  add    $0x8,%rax
  mov    %rax,0x10(%rsp)
  jmp    L173
  nopw   0x0(%rax,%rax,1)
L125:
  comisd %xmm2,%xmm3
  jb     L447
  comisd %xmm3,%xmm14
  jbe    L447
  jmp    L444
L152:
  je     L408
L57:
  mov    0x20(%rsp),%rcx
  xor    %eax,%eax
  mov    $0xe7,%edx
  lea    D101(%rip),%rsi
  lea    D30(%rip),%rdi
  call   <Free@plt>
  mov    0x138(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L60
  mov    0x28(%rsp),%rcx
  add    $0x148,%rsp
  xor    %eax,%eax
  mov    $0xe8,%edx
  pop    %rbx
  lea    D101(%rip),%rsi
  lea    D30(%rip),%rdi
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  jmp    1150 <Free@plt>
L185:
  movapd %xmm12,%xmm8
  movapd %xmm12,%xmm7
  jmp    L436
L408:
  movapd %xmm3,%xmm11
  movapd %xmm3,%xmm10
  jmp    L104
L60:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: parse_data
arguments: label: D101
type_guessed: string
name: parse_data
arguments: label: D30
type_guessed: string
name: parse_data
arguments: label: D106
type_guessed: string
name: parse_data
arguments: label: D22
type_guessed: string
name: parse_data
arguments: label: D17
type_guessed: byte[8]
name: parse_data
arguments: label: D109
type_guessed: byte[8]

tool: D101: /scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/AZed/cdo/refs/heads/master/src/Maskbox.c

tool: D30: maskregion

tool: D106: grid center lon

tool: D22: grid center lat

tool: {"D17": [0x00,0x00,0x00,0x00,0x00,0x80,0x66,0x40]}

tool: {"D109": [0x00,0x00,0x00,0x00,0x00,0x80,0x76,0x40]}

assistant: ```c
void maskregion(int *mask, int gridID, double *xcoords, double *ycoords, int nofcoords) {
  int i, j;
  int nlon, nlat;
  int ilat, ilon;
  int c;
  double *xvals, *yvals;
  double xval, yval;
  double xmin, xmax, ymin, ymax;
  nlon = gridInqXsize(gridID);
  nlat = gridInqYsize(gridID);
  xvals = (double *)Malloc(__func__, "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/AZed/cdo/refs/heads/master/src/Maskbox.c", 148, (nlon * sizeof(double)));
  yvals = (double *)Malloc(__func__, "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/AZed/cdo/refs/heads/master/src/Maskbox.c", 149, (nlat * sizeof(double)));
  gridInqXvals(gridID, xvals);
  gridInqYvals(gridID, yvals);
  {
    char units[256];
    gridInqXunits(gridID, units);
    grid_to_degree(units, nlon, xvals, "grid center lon");
    gridInqYunits(gridID, units);
    grid_to_degree(units, nlat, yvals, "grid center lat");
  }
  xmin = xvals[0];
  xmax = xvals[0];
  ymin = yvals[0];
  ymax = yvals[0];
  for (i = 1; i < nlon; i++) {
    if (xvals[i] < xmin)
      xmin = xvals[i];
    if (xvals[i] > xmax)
      xmax = xvals[i];
  }
  for (i = 1; i < nlat; i++) {
    if (yvals[i] < ymin)
      ymin = yvals[i];
    if (yvals[i] > ymax)
      ymax = yvals[i];
  }
  for (ilat = 0; ilat < nlat; ilat++) {
    yval = yvals[ilat];
    for (ilon = 0; ilon < nlon; ilon++) {
      c = 0;
      xval = xvals[ilon];
      if (!(((xval > xmin) || (xval < xmax)) || ((yval > ymin) || (yval < ymax))))
        c = !c;
      if (c == 0) {
        for (i = 0, j = nofcoords - 1; i < nofcoords; j = i++)
          if ((((ycoords[i] <= yval) && (yval < ycoords[j])) || ((ycoords[j] <= yval) && (yval < ycoords[i]))) && ((xval) < (xcoords[j] - (xcoords[i])) * (yval - ycoords[i]) / (ycoords[j] - ycoords[i]) + (xcoords[i])))
            c = !c;
      }
      if (c == 0) {
        for (i = 0, j = nofcoords - 1; i < nofcoords; j = i++) {
          if (xvals[ilon] > 180) {
            if ((((ycoords[i] <= yval) && (yval < ycoords[j])) || ((ycoords[j] <= yval) && (yval < ycoords[i]))) && ((xval - 360) < (xcoords[j] - (xcoords[i])) * (yval - ycoords[i]) / (ycoords[j] - ycoords[i]) + (xcoords[i])))
              c = !c;
          }
        }
      }
      if (c == 0) {
        for (i = 0, j = nofcoords - 1; i < nofcoords; j = i++) {
          if (xval < 0) {
            if ((((ycoords[i] <= yval) && (yval < ycoords[j])) || ((ycoords[j] <= yval) && (yval < ycoords[i]))) && ((xval + 360) < (xcoords[j] - (xcoords[i])) * (yval - ycoords[i]) / (ycoords[j] - ycoords[i]) + (xcoords[i])))
              c = !c;
          }
        }
      }
      if (c != 0)
        mask[nlon * ilat + ilon] = 0;
    }
  }
  Free(__func__, "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/AZed/cdo/refs/heads/master/src/Maskbox.c", 231, (xvals));
  Free(__func__, "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/AZed/cdo/refs/heads/master/src/Maskbox.c", 232, (yvals));
}
```