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

```asm
<somassign>:
  endbr64
  push   %r15
  push   %r14
  mov    %edi,%r14d
  push   %r13
  mov    %rcx,%r13
  push   %r12
  mov    %r8,%r12
  push   %rbp
  mov    %rdx,%rbp
  push   %rbx
  sub    $0x108,%rsp
  mov    0x140(%rsp),%eax
  mov    %esi,0x8(%rsp)
  mov    %r9d,0x50(%rsp)
  movsbl 0x158(%rsp),%edi
  mov    %eax,0xdc(%rsp)
  mov    0x148(%rsp),%eax
  mov    %eax,0x34(%rsp)
  mov    0x150(%rsp),%rax
  mov    %rax,0x68(%rsp)
  mov    0x160(%rsp),%rax
  mov    %rax,0xf0(%rsp)
  test   %r9d,%r9d
  jne    L323
  xor    %eax,%eax
  call   <setmetric@plt>
  movslq 0x34(%rsp),%rdi
  cltq
  mov    %rdi,%rbx
  shl    $0x3,%rdi
  mov    %rax,0x18(%rsp)
  call   <malloc@plt>
  mov    %rax,%r15
  test   %ebx,%ebx
  jle    L203
  movslq 0x8(%rsp),%rsi
  mov    0x34(%rsp),%eax
  mov    %r12,%r9
  mov    %rsi,%rdi
  lea    (%r15,%rax,8),%rax
  shl    $0x2,%rsi
  mov    %rax,0x20(%rsp)
  lea    -0x1(%rdi),%eax
  mov    %rsi,%rbx
  mov    %eax,0x10(%rsp)
  mov    %edi,%eax
  and    $0xfffffffc,%edi
  shr    $0x2,%eax
  mov    %edi,%r12d
  sub    $0x1,%eax
  add    $0x1,%rax
  shl    $0x4,%rax
  mov    %rax,0x38(%rsp)
  mov    %r13,%rax
  mov    %rbp,%r13
  mov    %r15,%rbp
  mov    %rax,%r8
L147:
  mov    %rbx,%rdi
  mov    %r9,0x48(%rsp)
  mov    %r8,0x40(%rsp)
  call   <malloc@plt>
  mov    0x8(%rsp),%esi
  mov    0x40(%rsp),%r8
  mov    %rax,0x0(%rbp)
  movdqa D12(%rip),%xmm0
  mov    %rax,%rdx
  test   %esi,%esi
  mov    0x48(%rsp),%r9
  jle    L444
  cmpl   $0x2,0x10(%rsp)
  jbe    L427
  mov    0x38(%rsp),%rdi
  lea    (%rdi,%rax,1),%rcx
L174:
  movups %xmm0,(%rax)
  add    $0x10,%rax
  cmp    %rax,%rcx
  jne    L174
  mov    %r12d,%eax
  cmp    0x8(%rsp),%r12d
  je     L444
L131:
  movslq %eax,%rdi
  mov    0x8(%rsp),%esi
  movl   $0x1,(%rdx,%rdi,4)
  lea    0x0(,%rdi,4),%rcx
  lea    0x1(%rax),%edi
  cmp    %edi,%esi
  jle    L444
  add    $0x2,%eax
  movl   $0x1,0x4(%rdx,%rcx,1)
  cmp    %eax,%esi
  jle    L444
  movl   $0x1,0x8(%rdx,%rcx,1)
L444:
  add    $0x8,%rbp
  cmp    %rbp,0x20(%rsp)
  jne    L147
  mov    %r13,%rbp
  mov    %r9,%r12
  mov    %r8,%r13
  test   %r14d,%r14d
  jle    L80
L70:
  movq   $0x0,0x50(%rsp)
  mov    %r14d,0x58(%rsp)
  mov    0x8(%rsp),%r14d
L293:
  mov    0x50(%rsp),%rax
  sub    $0x8,%rsp
  mov    %r13,%rcx
  mov    %r12,%r9
  mov    %r15,%r8
  mov    %rbp,%rsi
  mov    %r14d,%edi
  mov    %eax,0x28(%rsp)
  push   $0x0
  push   $0x0
  push   %rax
  mov    0x88(%rsp),%rbx
  mov    0x38(%rsp),%rax
  mov    (%rbx),%rdx
  call   *%rax
  movsd  %xmm0,0x28(%rsp)
  mov    0xfc(%rsp),%ecx
  add    $0x20,%rsp
  test   %ecx,%ecx
  jle    L193
  mov    %rbx,0x10(%rsp)
  mov    %r12,%rax
  mov    %rbp,%r12
  movl   $0x0,0x38(%rsp)
  mov    %rax,%rbp
  movl   $0x0,0x48(%rsp)
  movl   $0x0,0x40(%rsp)
  nop
L46:
  mov    0x34(%rsp),%edx
  xor    %ebx,%ebx
  test   %edx,%edx
  jle    L123
  nopw   0x0(%rax,%rax,1)
L489:
  sub    $0x8,%rsp
  mov    %rbp,%r9
  mov    %r15,%r8
  mov    %r13,%rcx
  push   $0x0
  mov    %r12,%rsi
  mov    %r14d,%edi
  push   %rbx
  mov    0x38(%rsp),%eax
  push   %rax
  mov    0x30(%rsp),%rax
  mov    (%rax),%rdx
  mov    0x38(%rsp),%rax
  call   *%rax
  movsd  0x28(%rsp),%xmm6
  add    $0x20,%rsp
  comisd %xmm0,%xmm6
  jbe    L187
  mov    0x38(%rsp),%eax
  mov    %ebx,0x48(%rsp)
  movsd  %xmm0,0x8(%rsp)
  mov    %eax,0x40(%rsp)
L187:
  add    $0x1,%ebx
  cmp    %ebx,0x34(%rsp)
  jne    L489
L123:
  addl   $0x1,0x38(%rsp)
  mov    0x38(%rsp),%eax
  addq   $0x8,0x10(%rsp)
  cmp    %eax,0xdc(%rsp)
  jne    L46
  mov    %rbp,%rax
  mov    %r12,%rbp
  mov    %rax,%r12
L63:
  mov    0x50(%rsp),%rax
  mov    0xf0(%rsp),%rdi
  mov    0x40(%rsp),%edx
  mov    %edx,(%rdi,%rax,8)
  mov    0x48(%rsp),%edx
  mov    %edx,0x4(%rdi,%rax,8)
  add    $0x1,%rax
  mov    %rax,0x50(%rsp)
  cmp    %eax,0x58(%rsp)
  jg     L293
  mov    0x34(%rsp),%eax
  test   %eax,%eax
  jle    L392
L80:
  xor    %ebx,%ebx
L179:
  mov    (%r15,%rbx,8),%rdi
  add    $0x1,%rbx
  call   <free@plt>
  cmp    %ebx,0x34(%rsp)
  jg     L179
L392:
  mov    %r15,%rdi
  jmp    L277
L323:
  xor    %eax,%eax
  call   <setmetric@plt>
  cltq
  mov    %rax,0x40(%rsp)
  movslq %r14d,%rax
  lea    0x0(,%rax,8),%r15
  mov    %r15,%rdi
  call   <malloc@plt>
  mov    %r15,%rdi
  mov    %rax,0x10(%rsp)
  call   <malloc@plt>
  test   %r14d,%r14d
  mov    0x10(%rsp),%r11
  mov    %rax,%r8
  jle    L209
  mov    %r14d,%eax
  mov    %r13,0x10(%rsp)
  mov    %r8,%r15
  mov    %rbp,%r13
  mov    %r12,0x18(%rsp)
  lea    (%r8,%rax,8),%rbx
  mov    %r11,%rbp
  mov    %r8,%r12
L71:
  mov    $0x4,%edi
  add    $0x8,%r15
  call   <malloc@plt>
  mov    %rax,-0x8(%r15)
  movl   $0x1,(%rax)
  cmp    %rbx,%r15
  jne    L71
  mov    %rbp,%r11
  mov    %r12,%r8
  mov    %r13,%rbp
  mov    0x18(%rsp),%r12
  mov    0x10(%rsp),%r13
L209:
  movslq 0x8(%rsp),%rax
  test   %eax,%eax
  jle    L121
  mov    %r14d,%edi
  pxor   %xmm4,%xmm4
  mov    %r13,0x60(%rsp)
  mov    %r12,%r9
  and    $0xfffffffc,%edi
  movdqa %xmm4,%xmm5
  mov    %r14d,%r12d
  mov    %rbp,0x58(%rsp)
  mov    %rax,0xf8(%rsp)
  mov    %r14d,%eax
  movdqa D65(%rip),%xmm2
  mov    %r11,%rbp
  lea    (%r11,%rax,8),%rax
  mov    %edi,0xa0(%rsp)
  movdqa D36(%rip),%xmm6
  mov    %rax,0x70(%rsp)
  mov    %r14d,%eax
  pcmpgtd %xmm2,%xmm5
  movq   $0x0,0xe8(%rsp)
  shr    $0x2,%eax
  movq   $0x0,0xa8(%rsp)
  lea    -0x1(%rax),%r15d
  movslq %edi,%rax
  shl    $0x3,%rax
  add    $0x1,%r15
  mov    %rax,0x90(%rsp)
  add    %r11,%rax
  shl    $0x5,%r15
  mov    %rax,0x98(%rsp)
  lea    0x1(%rdi),%eax
  add    %r11,%r15
  mov    %eax,0xa4(%rsp)
  cltq
  shl    $0x3,%rax
  mov    %rax,0xb0(%rsp)
  add    %r11,%rax
  mov    %rax,0xb8(%rsp)
  lea    0x2(%rdi),%eax
  mov    %eax,0xd8(%rsp)
  cltq
  shl    $0x3,%rax
  mov    %rax,0xc0(%rsp)
  add    %r11,%rax
  mov    %rax,0xc8(%rsp)
  lea    -0x1(%r14),%eax
  mov    0x68(%rsp),%r14
  mov    %eax,0x7c(%rsp)
  lea    0x8(,%rax,8),%rax
  mov    %rax,0xd0(%rsp)
L100:
  mov    0xe8(%rsp),%eax
  movq   0xa8(%rsp),%xmm7
  mov    %eax,0x48(%rsp)
  pshufd $0xe5,%xmm7,%xmm3
  movd   %xmm7,%edx
  movd   %xmm3,%eax
  test   %r12d,%r12d
  jle    L78
  movslq %edx,%rdx
  cltq
  mov    (%r14,%rdx,8),%rcx
  shl    $0x3,%rax
  lea    (%rcx,%rax,1),%rdx
  lea    0x8(%rcx,%rax,1),%rax
  cmp    %rax,%rbp
  setae  %al
  cmp    0x70(%rsp),%rdx
  setae  %cl
  or     %cl,%al
  je     L517
  cmpl   $0x5,0x7c(%rsp)
  jbe    L517
  movq   (%rdx),%xmm7
  movdqa D7(%rip),%xmm3
  mov    %rbp,%rax
  punpcklqdq %xmm7,%xmm7
L47:
  movdqa %xmm3,%xmm0
  movdqa %xmm4,%xmm8
  paddd  %xmm6,%xmm3
  add    $0x20,%rax
  movdqa %xmm0,%xmm1
  movdqa %xmm5,%xmm9
  punpckldq %xmm0,%xmm1
  punpckhdq %xmm0,%xmm0
  pcmpgtd %xmm1,%xmm8
  pmuludq %xmm1,%xmm9
  pmuludq %xmm2,%xmm1
  pmuludq %xmm2,%xmm8
  paddq  %xmm9,%xmm8
  psllq  $0x20,%xmm8
  paddq  %xmm8,%xmm1
  movdqa %xmm5,%xmm8
  paddq  %xmm7,%xmm1
  pmuludq %xmm0,%xmm8
  movups %xmm1,-0x20(%rax)
  movdqa %xmm4,%xmm1
  pcmpgtd %xmm0,%xmm1
  pmuludq %xmm2,%xmm0
  pmuludq %xmm2,%xmm1
  paddq  %xmm8,%xmm1
  psllq  $0x20,%xmm1
  paddq  %xmm1,%xmm0
  paddq  %xmm7,%xmm0
  movups %xmm0,-0x10(%rax)
  cmp    %r15,%rax
  jne    L47
  cmp    0xa0(%rsp),%r12d
  je     L78
  mov    0x98(%rsp),%rdi
  mov    0x90(%rsp),%rax
  add    (%rdx),%rax
  mov    %rax,(%rdi)
  cmp    0xa4(%rsp),%r12d
  jle    L78
  mov    0xb8(%rsp),%rdi
  mov    0xb0(%rsp),%rax
  add    (%rdx),%rax
  mov    %rax,(%rdi)
  cmp    0xd8(%rsp),%r12d
  jle    L78
  mov    0xc8(%rsp),%rdi
  mov    0xc0(%rsp),%rax
  add    (%rdx),%rax
  mov    %rax,(%rdi)
L78:
  movaps %xmm5,0x20(%rsp)
  sub    $0x8,%rsp
  mov    %rbp,%rdx
  mov    %r12d,%edi
  mov    0x58(%rsp),%eax
  push   %rax
  push   $0x0
  mov    0x60(%rsp),%eax
  push   %rax
  mov    0x80(%rsp),%rcx
  mov    0x78(%rsp),%rsi
  mov    0x60(%rsp),%rax
  mov    %r9,0x38(%rsp)
  mov    %r8,0x28(%rsp)
  call   *%rax
  movdqa D36(%rip),%xmm6
  movdqa D65(%rip),%xmm2
  pxor   %xmm4,%xmm4
  movsd  %xmm0,0x30(%rsp)
  add    $0x20,%rsp
  mov    0x8(%rsp),%r8
  movslq 0xdc(%rsp),%rax
  mov    0x18(%rsp),%r9
  movdqa 0x20(%rsp),%xmm5
  test   %eax,%eax
  jle    L512
  mov    %r8,0x68(%rsp)
  xor    %r13d,%r13d
  mov    %rax,0xe0(%rsp)
  mov    %r12d,%eax
  mov    %rbp,%r12
  movaps %xmm5,0x80(%rsp)
  mov    %eax,%ebp
  nopw   0x0(%rax,%rax,1)
L244:
  movslq 0x34(%rsp),%rax
  mov    %r13d,0x20(%rsp)
  test   %eax,%eax
  jle    L472
  mov    %rax,0x38(%rsp)
  mov    %r14,%rax
  xor    %ebx,%ebx
  mov    %r13,%r14
  mov    %r15,%r13
  mov    %rax,%r15
  nopl   (%rax)
L486:
  movd   0x20(%rsp),%xmm3
  movd   %ebx,%xmm5
  punpckldq %xmm5,%xmm3
  movq   %xmm3,0x18(%rsp)
  test   %ebp,%ebp
  jle    L120
  mov    (%r15,%r14,8),%r8
  lea    0x0(,%rbx,8),%rcx
  lea    (%r8,%rcx,1),%rsi
  lea    0x8(%r8,%rcx,1),%rcx
  cmp    %rcx,%r12
  setae  %cl
  cmp    0x70(%rsp),%rsi
  setae  %r8b
  or     %r8b,%cl
  je     L409
  cmpl   $0x5,0x7c(%rsp)
  jbe    L409
  movq   (%rsi),%xmm7
  movdqa D7(%rip),%xmm3
  mov    %r12,%rcx
  movdqa 0x80(%rsp),%xmm5
  punpcklqdq %xmm7,%xmm7
  nopl   0x0(%rax,%rax,1)
L192:
  movdqa %xmm3,%xmm0
  movdqa %xmm4,%xmm8
  paddd  %xmm6,%xmm3
  add    $0x20,%rcx
  movdqa %xmm0,%xmm1
  movdqa %xmm5,%xmm9
  punpckldq %xmm0,%xmm1
  punpckhdq %xmm0,%xmm0
  pcmpgtd %xmm1,%xmm8
  pmuludq %xmm1,%xmm9
  pmuludq %xmm2,%xmm1
  pmuludq %xmm2,%xmm8
  paddq  %xmm9,%xmm8
  psllq  $0x20,%xmm8
  paddq  %xmm8,%xmm1
  movdqa %xmm5,%xmm8
  paddq  %xmm7,%xmm1
  pmuludq %xmm0,%xmm8
  movups %xmm1,-0x20(%rcx)
  movdqa %xmm4,%xmm1
  pcmpgtd %xmm0,%xmm1
  pmuludq %xmm2,%xmm0
  pmuludq %xmm2,%xmm1
  paddq  %xmm8,%xmm1
  psllq  $0x20,%xmm1
  paddq  %xmm1,%xmm0
  paddq  %xmm7,%xmm0
  movups %xmm0,-0x10(%rcx)
  cmp    %r13,%rcx
  jne    L192
  cmp    0xa0(%rsp),%ebp
  je     L120
  mov    0x98(%rsp),%rax
  mov    0x90(%rsp),%rcx
  add    (%rsi),%rcx
  mov    %rcx,(%rax)
  cmp    0xa4(%rsp),%ebp
  jle    L120
  mov    0xb8(%rsp),%rax
  mov    0xb0(%rsp),%rcx
  add    (%rsi),%rcx
  mov    %rcx,(%rax)
  cmp    0xd8(%rsp),%ebp
  jle    L120
  mov    0xc8(%rsp),%rax
  mov    0xc0(%rsp),%rcx
  add    (%rsi),%rcx
  mov    %rcx,(%rax)
L120:
  sub    $0x8,%rsp
  mov    %r12,%rdx
  mov    %ebp,%edi
  mov    0x58(%rsp),%eax
  push   %rax
  push   $0x0
  mov    0x60(%rsp),%eax
  push   %rax
  mov    0x88(%rsp),%r8
  mov    0x80(%rsp),%rcx
  mov    0x78(%rsp),%rsi
  mov    0x60(%rsp),%rax
  mov    %r9,0x28(%rsp)
  call   *%rax
  movsd  0x30(%rsp),%xmm6
  add    $0x20,%rsp
  pxor   %xmm4,%xmm4
  movdqa D65(%rip),%xmm2
  mov    0x8(%rsp),%r9
  comisd %xmm0,%xmm6
  movdqa D36(%rip),%xmm6
  jbe    L381
  mov    0x18(%rsp),%rax
  movsd  %xmm0,0x10(%rsp)
  mov    %rax,0xa8(%rsp)
L381:
  add    $0x1,%rbx
  cmp    0x38(%rsp),%rbx
  jne    L486
  mov    %r15,%rax
  mov    %r13,%r15
  mov    %r14,%r13
  mov    %rax,%r14
L472:
  add    $0x1,%r13
  cmp    0xe0(%rsp),%r13
  jne    L244
  movdqa 0x80(%rsp),%xmm5
  mov    %ebp,%eax
  mov    0x68(%rsp),%r8
  mov    %r12,%rbp
  mov    %eax,%r12d
L512:
  mov    0xe8(%rsp),%rax
  mov    0xf0(%rsp),%rdi
  mov    0xa8(%rsp),%rdx
  mov    %rdx,(%rdi,%rax,8)
  add    $0x1,%rax
  mov    %rax,0xe8(%rsp)
  cmp    0xf8(%rsp),%rax
  jne    L100
  mov    %rbp,%r11
  mov    %r12d,%r14d
L121:
  mov    %r11,%rdi
  mov    %r8,0x8(%rsp)
  call   <free@plt>
  test   %r14d,%r14d
  mov    0x8(%rsp),%r8
  jle    L0
  mov    %r14d,%r10d
  mov    %r8,%rbx
  mov    %r8,%r12
  lea    (%r8,%r10,8),%rbp
L357:
  mov    (%rbx),%rdi
  add    $0x8,%rbx
  call   <free@plt>
  cmp    %rbp,%rbx
  jne    L357
  mov    %r12,%r8
L0:
  mov    %r8,%rdi
L277:
  add    $0x108,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  jmp    1070 <free@plt>
  nopl   (%rax)
L409:
  mov    0xd0(%rsp),%rdx
  xor    %ecx,%ecx
  nopw   0x0(%rax,%rax,1)
L161:
  mov    (%rsi),%rax
  add    %rcx,%rax
  mov    %rax,(%r12,%rcx,1)
  add    $0x8,%rcx
  cmp    %rdx,%rcx
  jne    L161
  jmp    L120
L517:
  xor    %eax,%eax
L405:
  mov    (%rdx),%rcx
  add    %rax,%rcx
  mov    %rcx,0x0(%rbp,%rax,1)
  add    $0x8,%rax
  cmp    0xd0(%rsp),%rax
  jne    L405
  jmp    L78
L193:
  movl   $0x0,0x48(%rsp)
  movl   $0x0,0x40(%rsp)
  jmp    L63
L427:
  xor    %eax,%eax
  jmp    L131
L203:
  test   %r14d,%r14d
  jg     L70
  jmp    L392
```

tool_calls: name: parse_data
arguments: tag: D12
type: byte[16]
name: parse_data
arguments: tag: D65
type: byte[16]
name: parse_data
arguments: tag: D36
type: byte[16]
name: parse_data
arguments: tag: D7
type: byte[16]

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

tool: {"D65": [0x08,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x08,0x00,0x00,0x00]}

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

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

assistant: ```c
void somassign(int nrows, int ncolumns, double **data, int **mask, const double weights[], int transpose, int nxgrid, int nygrid, double ***celldata, char dist, int clusterid[][2]) {
  const int ndata = (transpose == 0) ? ncolumns : nrows;
  int i, j;
  double (*metric)(int, double **, double **, int **, int **, const double[], int, int, int) = setmetric(dist);
  if (transpose == 0) {
    int **dummymask = malloc(nygrid * sizeof(int *));
    for (i = 0; i < nygrid; i++) {
      dummymask[i] = malloc(ncolumns * sizeof(int));
      for (j = 0; j < ncolumns; j++)
        dummymask[i][j] = 1;
    }
    for (i = 0; i < nrows; i++) {
      int ixbest = 0;
      int iybest = 0;
      double closest = metric(ndata, data, celldata[ixbest], mask, dummymask, weights, i, iybest, transpose);
      int ix, iy;
      for (ix = 0; ix < nxgrid; ix++) {
        for (iy = 0; iy < nygrid; iy++) {
          double distance = metric(ndata, data, celldata[ix], mask, dummymask, weights, i, iy, transpose);
          if (distance < closest) {
            ixbest = ix;
            iybest = iy;
            closest = distance;
          }
        }
      }
      clusterid[i][0] = ixbest;
      clusterid[i][1] = iybest;
    }
    for (i = 0; i < nygrid; i++)
      free(dummymask[i]);
    free(dummymask);
  } else {
    double **celldatavector = malloc(ndata * sizeof(double *));
    int **dummymask = malloc(nrows * sizeof(int *));
    int ixbest = 0;
    int iybest = 0;
    for (i = 0; i < nrows; i++) {
      dummymask[i] = malloc(sizeof(int));
      dummymask[i][0] = 1;
    }
    for (i = 0; i < ncolumns; i++) {
      double closest;
      int ix, iy;
      for (j = 0; j < ndata; j++)
        celldatavector[j] = &(celldata[ixbest][iybest][j]);
      closest = metric(ndata, data, celldatavector, mask, dummymask, weights, i, 0, transpose);
      for (ix = 0; ix < nxgrid; ix++) {
        for (iy = 0; iy < nygrid; iy++) {
          double distance;
          for (j = 0; j < ndata; j++)
            celldatavector[j] = &(celldata[ix][iy][j]);
          distance = metric(ndata, data, celldatavector, mask, dummymask, weights, i, 0, transpose);
          if (distance < closest) {
            ixbest = ix;
            iybest = iy;
            closest = distance;
          }
        }
      }
      clusterid[i][0] = ixbest;
      clusterid[i][1] = iybest;
    }
    free(celldatavector);
    for (i = 0; i < nrows; i++)
      free(dummymask[i]);
    free(dummymask);
  }
  return;
}
```