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

```asm
<maskregion>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x158,%rsp
  mov    %rdi,0x10(%rsp)
  mov    %esi,%r13d
  mov    %rdx,%rbp
  mov    %rcx,%rbx
  mov    %r8d,%r12d
  mov    %fs:0x28,%rax
  mov    %rax,0x148(%rsp)
  xor    %eax,%eax
  mov    %esi,%edi
  call   <gridInqXsize@plt>
  mov    %eax,%r15d
  mov    %r13d,%edi
  mov    $0x0,%eax
  call   <gridInqYsize@plt>
  mov    %eax,0x28(%rsp)
  mov    %r15d,0x1c(%rsp)
  movslq %r15d,%rcx
  shl    $0x3,%rcx
  mov    $0x94,%edx
  lea    D11(%rip),%r15
  mov    %r15,%rsi
  lea    D46(%rip),%r14
  mov    %r14,%rdi
  mov    $0x0,%eax
  call   <Malloc@plt>
  mov    %eax,0x2c(%rsp)
  movslq %eax,%rsi
  mov    %rsi,0x30(%rsp)
  movslq 0x28(%rsp),%rcx
  shl    $0x3,%rcx
  mov    $0x95,%edx
  mov    %r15,%rsi
  mov    %r14,%rdi
  mov    $0x0,%eax
  call   <Malloc@plt>
  mov    %eax,%r14d
  movslq %eax,%rcx
  mov    %rcx,%r15
  mov    0x30(%rsp),%rsi
  mov    %r13d,%edi
  mov    $0x0,%eax
  call   <gridInqXvals@plt>
  mov    %r15,0x38(%rsp)
  mov    %r15,%rsi
  mov    %r13d,%edi
  mov    $0x0,%eax
  call   <gridInqYvals@plt>
  lea    0x40(%rsp),%r15
  mov    %r15,%rsi
  mov    %r13d,%edi
  mov    $0x0,%eax
  call   <gridInqXunits@plt>
  lea    D78(%rip),%rcx
  mov    0x30(%rsp),%rdx
  mov    0x1c(%rsp),%esi
  mov    %r15,%rdi
  mov    $0x0,%eax
  call   <grid_to_degree@plt>
  mov    %r15,%rsi
  mov    %r13d,%edi
  mov    $0x0,%eax
  call   <gridInqYunits@plt>
  lea    D72(%rip),%rcx
  mov    0x38(%rsp),%r13
  mov    %r13,%rdx
  mov    0x28(%rsp),%esi
  mov    %r15,%rdi
  mov    $0x0,%eax
  call   <grid_to_degree@plt>
  mov    0x30(%rsp),%rax
  movsd  (%rax),%xmm6
  movsd  0x0(%r13),%xmm8
  mov    0x1c(%rsp),%edi
  cmp    $0x1,%edi
  jle    L62
  movslq 0x2c(%rsp),%rdx
  lea    0x8(%rdx),%rax
  lea    -0x2(%rdi),%ecx
  lea    0x10(%rdx,%rcx,8),%rdx
  movapd %xmm6,%xmm7
L425:
  movsd  (%rax),%xmm0
  movapd %xmm0,%xmm5
  minsd  %xmm6,%xmm5
  movapd %xmm5,%xmm6
  maxsd  %xmm7,%xmm0
  movapd %xmm0,%xmm7
  add    $0x8,%rax
  cmp    %rdx,%rax
  jne    L425
L44:
  mov    0x28(%rsp),%edi
  cmp    $0x1,%edi
  jle    L348
  movslq %r14d,%rdx
  lea    0x8(%rdx),%rax
  lea    -0x2(%rdi),%ecx
  lea    0x10(%rdx,%rcx,8),%rdx
  movapd %xmm8,%xmm9
L435:
  movsd  (%rax),%xmm0
  movapd %xmm0,%xmm4
  minsd  %xmm8,%xmm4
  movapd %xmm4,%xmm8
  maxsd  %xmm9,%xmm0
  movapd %xmm0,%xmm9
  add    $0x8,%rax
  cmp    %rdx,%rax
  jne    L435
L390:
  lea    -0x1(%r12),%eax
  mov    %eax,0xc(%rsp)
  movslq %r14d,%rax
  mov    %rax,0x20(%rsp)
  mov    0x1c(%rsp),%r14d
  movl   $0x0,0x18(%rsp)
  lea    -0x1(%r12),%r13d
  movsd  D3(%rip),%xmm5
  movsd  D10(%rip),%xmm10
  movapd %xmm10,%xmm11
  jmp    L11
L62:
  movapd %xmm6,%xmm7
  jmp    L44
L348:
  cmpl   $0x1,0x28(%rsp)
  je     L110
L136:
  mov    0x30(%rsp),%rcx
  mov    $0xe7,%edx
  lea    D11(%rip),%rbp
  mov    %rbp,%rsi
  lea    D46(%rip),%rbx
  mov    %rbx,%rdi
  mov    $0x0,%eax
  call   <Free@plt>
  mov    0x38(%rsp),%rcx
  mov    $0xe8,%edx
  mov    %rbp,%rsi
  mov    %rbx,%rdi
  mov    $0x0,%eax
  call   <Free@plt>
  mov    0x148(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L51
  add    $0x158,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L110:
  movapd %xmm8,%xmm9
  jmp    L390
L238:
  movslq %edx,%rdx
  movsd  0x0(%rbp,%rax,8),%xmm12
  movsd  0x0(%rbp,%rdx,8),%xmm0
  subsd  %xmm12,%xmm0
  movapd %xmm1,%xmm13
  subsd  %xmm2,%xmm13
  mulsd  %xmm13,%xmm0
  movsd  (%rbx,%rdx,8),%xmm13
  subsd  %xmm2,%xmm13
  divsd  %xmm13,%xmm0
  addsd  %xmm12,%xmm0
  mov    %ecx,%edx
  xor    $0x1,%ecx
  comisd %xmm3,%xmm0
  cmovbe %edx,%ecx
L326:
  lea    0x1(%rax),%rdx
  cmp    %r8,%rax
  je     L54
  mov    %rdx,%rax
L384:
  mov    %esi,%edx
  mov    %eax,%esi
  movsd  (%rbx,%rax,8),%xmm2
  comisd %xmm2,%xmm1
  jb     L383
  movslq %edx,%rdi
  movsd  (%rbx,%rdi,8),%xmm0
  comisd %xmm1,%xmm0
  ja     L238
L383:
  movslq %edx,%rdi
  comisd (%rbx,%rdi,8),%xmm1
  jb     L326
  comisd %xmm1,%xmm2
  jbe    L326
  jmp    L238
L100:
  mov    0xc(%rsp),%esi
  mov    $0x0,%eax
  jmp    L217
L172:
  movslq %edx,%rdx
  movsd  0x0(%rbp,%rax,8),%xmm12
  movapd %xmm3,%xmm2
  subsd  %xmm10,%xmm2
  movsd  0x0(%rbp,%rdx,8),%xmm0
  subsd  %xmm12,%xmm0
  movapd %xmm1,%xmm14
  subsd  %xmm13,%xmm14
  mulsd  %xmm14,%xmm0
  movsd  (%rbx,%rdx,8),%xmm14
  subsd  %xmm13,%xmm14
  divsd  %xmm14,%xmm0
  addsd  %xmm12,%xmm0
  mov    %ecx,%edx
  xor    $0x1,%ecx
  comisd %xmm2,%xmm0
  cmovbe %edx,%ecx
L312:
  add    $0x1,%rax
  cmp    %eax,%r12d
  jle    L113
L217:
  mov    %esi,%edx
  mov    %eax,%esi
  comisd %xmm5,%xmm3
  jbe    L312
  movsd  (%rbx,%rax,8),%xmm13
  comisd %xmm13,%xmm1
  jb     L188
  movslq %edx,%rdi
  movsd  (%rbx,%rdi,8),%xmm0
  comisd %xmm1,%xmm0
  ja     L172
L188:
  movslq %edx,%rdi
  comisd (%rbx,%rdi,8),%xmm1
  jb     L312
  comisd %xmm1,%xmm13
  jbe    L312
  jmp    L172
L215:
  movslq %edx,%rdx
  movsd  0x0(%rbp,%rax,8),%xmm12
  movapd %xmm3,%xmm2
  addsd  %xmm11,%xmm2
  movsd  0x0(%rbp,%rdx,8),%xmm0
  subsd  %xmm12,%xmm0
  movapd %xmm1,%xmm14
  subsd  %xmm13,%xmm14
  mulsd  %xmm14,%xmm0
  movsd  (%rbx,%rdx,8),%xmm14
  subsd  %xmm13,%xmm14
  divsd  %xmm14,%xmm0
  addsd  %xmm12,%xmm0
  mov    %ecx,%edx
  xor    $0x1,%ecx
  comisd %xmm2,%xmm0
  cmovbe %edx,%ecx
L270:
  add    $0x1,%rax
  cmp    %eax,%r12d
  jle    L71
L19:
  mov    %r9d,%edx
  mov    %eax,%r9d
  comisd %xmm3,%xmm4
  jbe    L270
  movsd  (%rbx,%rax,8),%xmm13
  comisd %xmm13,%xmm1
  jb     L56
  movslq %edx,%rsi
  movsd  (%rbx,%rsi,8),%xmm0
  comisd %xmm1,%xmm0
  ja     L215
L56:
  movslq %edx,%rsi
  comisd (%rbx,%rsi,8),%xmm1
  jb     L270
  comisd %xmm1,%xmm13
  jbe    L270
  jmp    L215
L71:
  test   %ecx,%ecx
  je     L176
  jmp    L431
L111:
  addl   $0x1,0x18(%rsp)
  mov    0x18(%rsp),%eax
  addq   $0x8,0x20(%rsp)
  add    0x1c(%rsp),%r14d
  cmp    %eax,0x28(%rsp)
  jle    L136
L11:
  mov    0x20(%rsp),%rax
  movsd  (%rax),%xmm1
  mov    0x1c(%rsp),%eax
  test   %eax,%eax
  jle    L111
  mov    %r14d,%r10d
  sub    %eax,%r10d
  movslq 0x2c(%rsp),%r11
  mov    $0x0,%r15d
  pxor   %xmm4,%xmm4
  jmp    L233
L113:
  test   %ecx,%ecx
  jne    L431
  mov    $0x0,%eax
  jmp    L19
L54:
  test   %ecx,%ecx
  je     L100
L431:
  movslq %r10d,%rax
  mov    0x10(%rsp),%rdi
  movl   $0x0,(%rdi,%rax,4)
L176:
  add    $0x8,%r11
  add    $0x1,%r10d
  cmp    %r14d,%r10d
  je     L111
L233:
  movsd  (%r11),%xmm3
  comisd %xmm6,%xmm3
  ja     L231
  comisd %xmm3,%xmm7
  ja     L231
  comisd %xmm8,%xmm1
  ja     L231
  comisd %xmm1,%xmm9
  jbe    L431
L231:
  mov    %r13d,%r9d
  test   %r12d,%r12d
  jle    L176
  mov    0xc(%rsp),%r8d
  mov    %r13d,%esi
  mov    %r15,%rax
  mov    $0x0,%ecx
  jmp    L384
L51:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: unpack_data
arguments: data_label: D11
type_guessed: string
name: unpack_data
arguments: data_label: D46
type_guessed: string
name: unpack_data
arguments: data_label: D78
type_guessed: string
name: unpack_data
arguments: data_label: D72
type_guessed: string
name: unpack_data
arguments: data_label: D3
type_guessed: byte[8]
name: unpack_data
arguments: data_label: D10
type_guessed: byte[8]

tool: D11: /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: D46: maskregion

tool: D78: grid center lon

tool: D72: grid center lat

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

tool: {"D10": [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));
}
```