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

```asm
<getrmap1>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0xb8,%rsp
  mov    0xf0(%rsp),%rax
  mov    %ecx,0xc(%rsp)
  imul   %edx,%ecx
  mov    %rsi,0x10(%rsp)
  mov    0xf8(%rsp),%r15d
  mov    %r8,0x80(%rsp)
  mov    %r9d,0x7c(%rsp)
  mov    %rax,0x18(%rsp)
  movss  %xmm0,0x8c(%rsp)
  mov    %fs:0x28,%rax
  mov    %rax,0xa8(%rsp)
  xor    %eax,%eax
  mov    %ecx,0x20(%rsp)
  test   %edx,%edx
  jle    L376
  mov    %edx,%r12d
  lea    0xa0(%rsp),%rdx
  movl   $0x1,0x6c(%rsp)
  mov    %rdi,%r14
  movl   $0x0,0x88(%rsp)
  mov    %r12d,%r13d
  mov    %rdx,0x50(%rsp)
  mov    0x6c(%rsp),%edx
L423:
  sub    $0x1,%edx
  mov    0xc(%rsp),%ecx
  movl   $0x0,0x5c(%rsp)
  mov    %edx,0x74(%rsp)
  movslq %eax,%rdx
  mov    %rdx,0x60(%rsp)
  test   %ecx,%ecx
  jg     L366
  jmp    L170
  nopl   0x0(%rax)
L299:
  mov    0x68(%rsp),%eax
  addq   $0x1,0x60(%rsp)
  mov    0x5c(%rsp),%edi
  add    $0x1,%eax
  cmp    %edi,0xc(%rsp)
  je     L170
L366:
  mov    0x5c(%rsp),%eax
  mov    0x60(%rsp),%rcx
  mov    %eax,%edx
  add    $0x1,%eax
  mov    %ecx,0x68(%rsp)
  mov    %eax,0x5c(%rsp)
  movswl (%r14,%rcx,2),%eax
  mov    %ecx,0x70(%rsp)
  cmp    %r15d,%eax
  jne    L299
  mov    0x18(%rsp),%rax
  mov    %rcx,%rdi
  movzbl (%rax,%rcx,1),%eax
  mov    0x80(%rsp),%rcx
  movss  (%rcx,%rax,4),%xmm3
  mov    0x10(%rsp),%rax
  comiss (%rax,%rdi,4),%xmm3
  movss  %xmm3,0x24(%rsp)
  jb     L299
  mov    0x7c(%rsp),%r8d
  mov    0x74(%rsp),%ecx
  mov    $0xffffff9c,%esi
  xor    %ebx,%ebx
  addl   $0x1,0x88(%rsp)
  mov    0x88(%rsp),%eax
  mov    %r13d,%ebp
  mov    %si,(%r14,%rdi,2)
  mov    0x50(%rsp),%r13
  add    %eax,%r8d
  lea    0x9c(%rsp),%rax
  mov    %ecx,0x9c(%rsp)
  mov    %rax,0x38(%rsp)
  lea    0xa4(%rsp),%rax
  mov    %r8d,%r12d
  mov    %edx,0xa0(%rsp)
  mov    %edi,0xa4(%rsp)
  mov    %rax,0x28(%rsp)
  nopw   0x0(%rax,%rax,1)
L340:
  sub    $0x8,%rsp
  mov    %ebp,%r9d
  mov    %r12d,%r8d
  mov    %r15d,%ecx
  push   0x30(%rsp)
  mov    0x30(%rsp),%eax
  mov    %r13,%rdx
  mov    %r14,%rdi
  push   %rax
  push   0x30(%rsp)
  push   0x30(%rsp)
  mov    0x34(%rsp),%eax
  push   %rax
  movss  0x54(%rsp),%xmm0
  mov    0x68(%rsp),%rsi
  call   <rmapgrow1@plt>
  add    $0x30,%rsp
  add    %eax,%ebx
  test   %eax,%eax
  jne    L340
  mov    %r12d,%r8d
  mov    %ebp,%r13d
  test   %ebx,%ebx
  je     L299
  mov    0x68(%rsp),%eax
  add    $0x1,%eax
  mov    %eax,0x78(%rsp)
  mov    0x5c(%rsp),%eax
  cmp    %eax,0xc(%rsp)
  jle    L434
L172:
  movslq 0x78(%rsp),%rbp
  mov    %eax,0x40(%rsp)
  mov    %r13d,%eax
  xor    %ebx,%ebx
  mov    %r14,%r13
  mov    %eax,%r14d
  mov    %rbp,%r12
  mov    %r8d,%ebp
  jmp    L173
  cs nopw 0x0(%rax,%rax,1)
L272:
  mov    0x40(%rsp),%eax
  add    $0x1,%r12
  add    $0x1,%eax
  cmp    %eax,0xc(%rsp)
  je     L105
  mov    %eax,0x40(%rsp)
L173:
  cmpw   $0xff9c,0x0(%r13,%r12,2)
  jne    L272
  mov    0x74(%rsp),%eax
  mov    %r12d,0xa4(%rsp)
  mov    %r12,0x30(%rsp)
  mov    %r14d,%r12d
  mov    0x50(%rsp),%r14
  mov    %eax,0x9c(%rsp)
  mov    0x40(%rsp),%eax
  mov    %eax,0xa0(%rsp)
  nopl   (%rax)
L298:
  sub    $0x8,%rsp
  mov    %r12d,%r9d
  mov    %ebp,%r8d
  mov    %r15d,%ecx
  push   0x30(%rsp)
  mov    0x30(%rsp),%eax
  mov    %r14,%rdx
  mov    %r13,%rdi
  push   %rax
  push   0x30(%rsp)
  push   0x30(%rsp)
  mov    0x34(%rsp),%eax
  push   %rax
  movss  0x54(%rsp),%xmm0
  mov    0x68(%rsp),%rsi
  call   <rmapgrow1@plt>
  add    $0x30,%rsp
  add    %eax,%ebx
  test   %eax,%eax
  jne    L298
  mov    %r12d,%r14d
  mov    0x30(%rsp),%r12
  jmp    L272
L105:
  mov    %r14d,%eax
  mov    0x68(%rsp),%edx
  mov    %r13,%r14
  mov    %ebp,%r8d
  mov    %eax,%r13d
  mov    0x40(%rsp),%eax
  sub    0x5c(%rsp),%eax
  lea    0x1(%rax,%rdx,1),%eax
  mov    %eax,0x58(%rsp)
  cmp    0x6c(%rsp),%r13d
  jle    L119
L35:
  mov    0x6c(%rsp),%eax
  mov    %ebx,0x40(%rsp)
  mov    %r8d,%r12d
  mov    %eax,0x30(%rsp)
  nopw   0x0(%rax,%rax,1)
L165:
  mov    0x58(%rsp),%eax
  xor    %ebx,%ebx
  lea    0x1(%rax),%r10d
  mov    %r13d,%eax
  mov    %r14,%r13
  movslq %r10d,%rbp
  mov    %eax,%r14d
  jmp    L70
  nopl   0x0(%rax,%rax,1)
L67:
  add    $0x1,%ebx
  add    $0x1,%rbp
  cmp    %ebx,0xc(%rsp)
  je     L166
L70:
  cmpw   $0xff9c,0x0(%r13,%rbp,2)
  jne    L67
  mov    0x30(%rsp),%eax
  mov    %ebx,0xa0(%rsp)
  mov    %ebp,0xa4(%rsp)
  mov    %eax,0x9c(%rsp)
  mov    %ebx,0x44(%rsp)
  mov    %r14d,%ebx
  mov    0x50(%rsp),%r14
  mov    %rbp,0x48(%rsp)
  mov    0x38(%rsp),%rbp
  nopl   0x0(%rax)
L277:
  sub    $0x8,%rsp
  mov    %ebx,%r9d
  mov    %r12d,%r8d
  mov    %r15d,%ecx
  push   0x30(%rsp)
  mov    0x30(%rsp),%eax
  mov    %r14,%rdx
  mov    %rbp,%rsi
  mov    %r13,%rdi
  push   %rax
  push   0x30(%rsp)
  push   0x30(%rsp)
  mov    0x34(%rsp),%eax
  push   %rax
  movss  0x54(%rsp),%xmm0
  call   <rmapgrow1@plt>
  add    %eax,0x70(%rsp)
  add    $0x30,%rsp
  test   %eax,%eax
  jne    L277
  mov    0x48(%rsp),%rbp
  mov    %ebx,%r14d
  mov    0x44(%rsp),%ebx
  add    $0x1,%rbp
  add    $0x1,%ebx
  cmp    %ebx,0xc(%rsp)
  jne    L70
L166:
  mov    %r14d,%eax
  addl   $0x1,0x30(%rsp)
  mov    %r13,%r14
  mov    0xc(%rsp),%edi
  mov    %eax,%r13d
  mov    0x30(%rsp),%eax
  add    %edi,0x58(%rsp)
  cmp    %eax,%r13d
  jg     L165
  mov    0x40(%rsp),%ebx
  mov    %r12d,%r8d
L119:
  test   %ebx,%ebx
  je     L299
  mov    0x5c(%rsp),%eax
  cmp    %eax,0xc(%rsp)
  jg     L172
L434:
  cmp    0x6c(%rsp),%r13d
  jle    L103
  mov    0x70(%rsp),%eax
  xor    %ebx,%ebx
  mov    %eax,0x58(%rsp)
  jmp    L35
L103:
  mov    0x70(%rsp),%eax
  add    $0x1,%eax
L170:
  mov    0x6c(%rsp),%edi
  lea    0x1(%rdi),%edx
  cmp    %r13d,%edi
  je     L345
  mov    %edx,0x6c(%rsp)
  jmp    L423
L345:
  mov    0x7c(%rsp),%r12d
  mov    0x88(%rsp),%eax
  add    %eax,%r12d
  test   %eax,%eax
  jne    L259
L164:
  mov    0xa8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L290
  add    $0xb8,%rsp
  mov    %r12d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L259:
  lea    0x1(%r12),%r13d
  mov    $0x4,%esi
  mov    %r13d,%edi
  call   <calloc@plt>
  mov    0x20(%rsp),%edx
  mov    %rax,%rbp
  test   %edx,%edx
  jle    L354
  mov    0x20(%rsp),%eax
  mov    %r14,%rdx
  sub    $0x1,%eax
  lea    0x2(%r14,%rax,2),%rcx
L465:
  movswq (%rdx),%rsi
  cmp    0x7c(%rsp),%esi
  jle    L131
  addl   $0x1,0x0(%rbp,%rsi,4)
L131:
  add    $0x2,%rdx
  cmp    %rcx,%rdx
  jne    L465
L354:
  mov    %r13d,%edi
  mov    $0x4,%esi
  call   <calloc@plt>
  mov    %rax,%rdi
  test   %r12d,%r12d
  jle    L243
  lea    -0x1(%r12),%eax
  cmp    $0x2,%eax
  jbe    L79
  mov    %r12d,%edx
  movdqa D12(%rip),%xmm0
  movdqa D3(%rip),%xmm1
  lea    0x4(%rdi),%rax
  shr    $0x2,%edx
  sub    $0x1,%edx
  shl    $0x4,%rdx
  lea    0x14(%rdi,%rdx,1),%rdx
L326:
  movdqa %xmm0,%xmm2
  add    $0x10,%rax
  paddd  %xmm1,%xmm0
  movups %xmm2,-0x10(%rax)
  cmp    %rax,%rdx
  jne    L326
  mov    %r12d,%edx
  and    $0xfffffffc,%edx
  lea    0x1(%rdx),%eax
  cmp    %r12d,%edx
  je     L243
L118:
  movslq %eax,%rcx
  mov    %eax,(%rdi,%rcx,4)
  lea    0x0(,%rcx,4),%rdx
  lea    0x1(%rax),%ecx
  cmp    %ecx,%r12d
  jl     L243
  add    $0x2,%eax
  mov    %ecx,0x4(%rdi,%rdx,1)
  cmp    %eax,%r12d
  jl     L243
  mov    %eax,0x8(%rdi,%rdx,1)
L243:
  mov    0x7c(%rsp),%eax
  mov    %rbp,%r13
  mov    %r12d,%ebx
  lea    0x8(%rdi),%r9
  sub    %rdi,%r13
  add    $0x1,%eax
  movslq %eax,%rsi
  lea    (%rdi,%rsi,4),%rdx
  jmp    L80
L481:
  add    $0x1,%rsi
  add    $0x4,%rdx
  cmp    %eax,%r12d
  jl     L443
L80:
  movss  0x8c(%rsp),%xmm4
  pxor   %xmm0,%xmm0
  add    $0x1,%eax
  cvtsi2ssl 0x0(%r13,%rdx,1),%xmm0
  comiss %xmm0,%xmm4
  jbe    L481
  cmp    %eax,%r12d
  jl     L150
  mov    %r12d,%r8d
  movslq %eax,%rcx
  sub    %eax,%r8d
  lea    (%rdi,%rcx,4),%rcx
  add    %rsi,%r8
  lea    (%r9,%r8,4),%r10
L396:
  mov    (%rcx),%r8d
  cmp    (%rdx),%r8d
  jle    L306
  sub    $0x1,%r8d
  mov    %r8d,(%rcx)
L306:
  add    $0x4,%rcx
  cmp    %rcx,%r10
  jne    L396
L150:
  mov    %r15d,(%rdx)
  sub    $0x1,%ebx
  add    $0x1,%rsi
  add    $0x4,%rdx
  cmp    %eax,%r12d
  jge    L80
L443:
  mov    0x20(%rsp),%eax
  test   %eax,%eax
  jle    L127
  mov    0x20(%rsp),%eax
  mov    %r14,%r10
  sub    $0x1,%eax
  lea    0x2(%r14,%rax,2),%rdx
L33:
  movswq (%r10),%rcx
  cmp    0x7c(%rsp),%ecx
  jle    L324
  mov    (%rdi,%rcx,4),%eax
  mov    %ax,(%r10)
L324:
  add    $0x2,%r10
  cmp    %r10,%rdx
  jne    L33
L127:
  call   <free@plt>
  mov    %rbp,%rdi
  mov    %ebx,%r12d
  call   <free@plt>
  jmp    L164
L376:
  mov    %r9d,%r12d
  jmp    L164
L79:
  mov    $0x1,%eax
  jmp    L118
L290:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: retrieve_data
arguments: label: D12
type: byte[16]
name: retrieve_data
arguments: label: D3
type: byte[16]

tool: {"D12": [0x01,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x04,0x00,0x00,0x00]}

tool: {"D3": [0x04,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x04,0x00,0x00,0x00]}

assistant: ```c
int getrmap1(short *rmap, float *J, int ny, int nx, float *threshJ, int TR, float RSIZE, unsigned char *rmap0, int n2bgrow) {
  int i, j, k, l, iy, ix, *count, *convert, newTR, loc, loc1, imgsize, grow, jy, jx;
  int grow1, ky, kx, kl;
  float threshJ1;
  imgsize = ny * nx;
  j = 0;
  loc = 0;
  for (iy = 0; iy < ny; iy++) {
    for (ix = 0; ix < nx; ix++) {
      if (rmap[loc] == n2bgrow && J[loc] <= threshJ[rmap0[loc]]) {
        threshJ1 = threshJ[rmap0[loc]];
        j++;
        rmap[loc] = -100;
        grow = 0;
        ky = iy;
        kx = ix;
        kl = loc;
        do {
          grow1 = rmapgrow1(rmap, &ky, &kx, n2bgrow, j + TR, ny, nx, J, threshJ1, rmap0, imgsize, &kl);
          grow += grow1;
        } while (grow1);
        while (grow) {
          grow = 0;
          loc1 = loc;
          jy = iy;
          for (jx = ix + 1; jx < nx; jx++) {
            loc1++;
            if (rmap[loc1] == -100) {
              ky = jy;
              kx = jx;
              kl = loc1;
              do {
                grow1 = rmapgrow1(rmap, &ky, &kx, n2bgrow, j + TR, ny, nx, J, threshJ1, rmap0, imgsize, &kl);
                grow += grow1;
              } while (grow1);
            }
          }
          for (jy = iy + 1; jy < ny; jy++) {
            for (jx = 0; jx < nx; jx++) {
              loc1++;
              if (rmap[loc1] == -100) {
                ky = jy;
                kx = jx;
                kl = loc1;
                do {
                  grow1 = rmapgrow1(rmap, &ky, &kx, n2bgrow, j + TR, ny, nx, J, threshJ1, rmap0, imgsize, &kl);
                  grow += grow1;
                } while (grow1);
              }
            }
          }
        }
      }
      loc++;
    }
  }
  newTR = j + TR;
  if (j > 0) {
    count = (int *)calloc(newTR + 1, sizeof(int));
    for (l = 0; l < imgsize; l++) {
      if (rmap[l] > TR)
        count[rmap[l]]++;
    }
    convert = (int *)calloc(newTR + 1, sizeof(int));
    for (i = 1; i <= newTR; i++)
      convert[i] = i;
    for (i = TR + 1; i <= j + TR; i++) {
      if (count[i] < RSIZE) {
        for (k = i + 1; k <= j + TR; k++) {
          if (convert[k] > convert[i])
            convert[k]--;
        }
        convert[i] = n2bgrow;
        newTR--;
      }
    }
    for (l = 0; l < imgsize; l++) {
      if (rmap[l] > TR)
        rmap[l] = convert[rmap[l]];
    }
    free(convert);
    free(count);
  }
  return newTR;
}
```