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

```asm
<prims>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x28,%rsp
  mov    %rdi,%r12
  mov    %esi,%ebx
  mov    %esi,0x18(%rsp)
  lea    -0x1(%rsi),%eax
  mov    %eax,0x1c(%rsp)
  lea    0x0(,%rsi,4),%r14d
  mov    %r14d,%edi
  call   <malloc@plt>
  mov    %rax,(%rsp)
  lea    0x0(,%rbx,8),%edi
  call   <malloc@plt>
  mov    %rax,0x8(%rsp)
  test   %ebx,%ebx
  jle    L130
  mov    %rax,%rcx
  mov    %ebx,%edi
  mov    %rax,%rbx
  mov    %edi,%eax
  lea    (%rcx,%rax,8),%r13
  mov    %rcx,%rbp
L32:
  mov    %r14d,%edi
  call   <malloc@plt>
  mov    %rax,0x0(%rbp)
  add    $0x8,%rbp
  cmp    %r13,%rbp
  jne    L32
  mov    0x18(%rsp),%esi
  shl    $0x2,%rsi
L57:
  mov    %rbx,%rcx
  mov    $0x0,%eax
L141:
  mov    (%rcx),%rdx
  movl   $0x0,(%rdx,%rax,1)
  add    $0x4,%rax
  cmp    %rsi,%rax
  jne    L141
  add    $0x8,%rbx
  cmp    %r13,%rbx
  jne    L57
L130:
  mov    $0x1,%esi
  mov    0x18(%rsp),%ebp
  mov    %ebp,%edi
  call   <calloc@plt>
  mov    %rax,%rbx
  mov    %r14d,%edi
  call   <malloc@plt>
  mov    %rax,%r13
  movl   $0x0,(%rax)
  cmp    $0x1,%ebp
  jle    L200
  lea    0x4(%rax),%rax
  lea    -0x2(%rbp),%edx
  lea    0x8(%r13,%rdx,4),%rdx
L242:
  movl   $0x7fffffff,(%rax)
  add    $0x4,%rax
  cmp    %rdx,%rax
  jne    L242
L200:
  movb   $0x1,(%rbx)
  mov    $0x0,%r11d
  mov    0x18(%rsp),%r9d
  mov    $0x7fffffff,%r14d
  mov    (%rsp),%rbp
  sub    %r13,%rbp
  cmpl   $0x0,0x1c(%rsp)
  jle    L228
  mov    %r13,0x10(%rsp)
  mov    0x1c(%rsp),%r13d
  jmp    L148
L47:
  cmpb   $0x0,(%rdx)
  jne    L166
L189:
  mov    (%rcx),%esi
  cmp    %r10d,%esi
  jge    L166
  mov    %edi,%r15d
  mov    %esi,%r10d
L166:
  add    $0x1,%rax
  add    $0x1,%rdx
  add    $0x4,%rcx
  cmp    %rax,%r9
  je     L176
L125:
  mov    %eax,%edi
  mov    (%r8),%rsi
  mov    (%rsi,%rax,4),%esi
  test   %esi,%esi
  je     L47
  cmpb   $0x0,(%rdx)
  jne    L166
  cmp    (%rcx),%esi
  jge    L189
  mov    %esi,(%rcx)
  mov    %r11d,0x0(%rbp,%rcx,1)
  jmp    L47
L176:
  movslq %r15d,%rax
  movb   $0x1,(%rbx,%rax,1)
  mov    (%rsp),%rdi
  movslq (%rdi,%rax,4),%rdx
  mov    (%r12,%rdx,8),%rcx
  mov    (%rcx,%rax,4),%ecx
  mov    0x8(%rsp),%rdi
  mov    (%rdi,%rdx,8),%rdx
  mov    %ecx,(%rdx,%rax,4)
  sub    $0x1,%r13d
  je     L228
  mov    %r15d,%r11d
L148:
  cmpl   $0x0,0x18(%rsp)
  jle    L176
  movslq %r11d,%rax
  lea    (%r12,%rax,8),%r8
  mov    %rbx,%rdx
  mov    0x10(%rsp),%rcx
  mov    $0x0,%eax
  mov    %r14d,%r10d
  jmp    L125
L228:
  cmpl   $0x0,0x18(%rsp)
  jle    L111
  mov    0x8(%rsp),%r14
  mov    $0x0,%r13d
  lea    D8(%rip),%r15
  jmp    L22
L136:
  add    $0x1,%rbx
  cmp    %rbp,%rbx
  je     L25
L104:
  mov    %ebx,%edx
  mov    (%r12),%rax
  mov    (%rax,%rbx,4),%ecx
  test   %ecx,%ecx
  je     L136
  mov    %r13d,%esi
  mov    %r15,%rdi
  call   <printf@plt>
  jmp    L136
L25:
  add    $0x1,%r13d
  add    $0x8,%r14
  cmp    %r13d,0x18(%rsp)
  je     L111
L22:
  mov    %r14,%r12
  mov    0x18(%rsp),%ebp
  mov    $0x0,%ebx
  jmp    L104
L111:
  mov    $0x0,%eax
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

tool_calls: name: unpack_data
arguments: label: D8
data_type: string

tool: D8: 
Muchia %d - %d, cost: %d

assistant: ```c
int **prims(int **ingraph, int n) {
  int i, j, lastNode = 0, min = (1 << 31) - 1, nextNode, nodesLeft;
  nodesLeft = n - 1;
  int *parent = (int *)malloc(sizeof(int) * n);
  int **outree = (int **)malloc(sizeof(int *) * n);
  for (i = 0; i < n; i++) {
    outree[i] = (int *)malloc(sizeof(int) * n);
  }
  for (i = 0; i < n; i++)
    for (j = 0; j < n; j++) {
      outree[i][j] = 0;
    }
  char *visit = (char *)calloc(n, sizeof(char));
  int *key = (int *)malloc(sizeof(int) * n);
  key[0] = 0;
  for (i = 1; i < n; i++)
    key[i] = (1 << 31) - 1;
  visit[0] = 1;
  while (nodesLeft > 0) {
    min = (1 << 31) - 1;
    for (i = 0; i < n; i++) {
      if (ingraph[lastNode][i] && !visit[i] && ingraph[lastNode][i] < key[i]) {
        key[i] = ingraph[lastNode][i];
        parent[i] = lastNode;
      }
      if (!visit[i] && key[i] < min) {
        min = key[i];
        nextNode = i;
      }
    }
    visit[nextNode] = 1;
    outree[parent[nextNode]][nextNode] = ingraph[parent[nextNode]][nextNode];
    lastNode = nextNode;
    nodesLeft--;
  }
  for (i = 0; i < n; i++)
    for (j = 0; j < n; j++)
      if (outree[i][j] != 0)
        printf("\nMuchia %d - %d, cost: %d", i, j, outree[i][j]);
  return 0;
}
```