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

```asm
<repeated_random>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x4e8,%rsp
  mov    %edi,%ebx
  mov    %edi,0xc(%rsp)
  mov    %fs:0x28,%rax
  mov    %rax,0x4d8(%rsp)
  xor    %eax,%eax
  mov    $0x190,%edi
  call   <malloc@plt>
  mov    %rax,0x18(%rsp)
  test   %ebx,%ebx
  jle    L97
  mov    $0x0,%r14d
  mov    $0xffffffff,%r15d
  lea    0x1b0(%rsp),%r12
  lea    0x340(%rsp),%rdi
  mov    %rdi,0x10(%rsp)
  lea    0x20(%rsp),%r13
  sub    %rax,%r13
  jmp    L63
L97:
  mov    $0xffffffff,%r15d
L125:
  mov    %r15d,%esi
  lea    D8(%rip),%rdi
  call   <printf@plt>
  mov    0x4d8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L115
  mov    0x18(%rsp),%rax
  add    $0x4e8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L32:
  add    $0x4,%rbp
  cmp    %r12,%rbp
  je     L43
L81:
  mov    $0x0,%eax
  call   <rand@plt>
  test   $0x1,%al
  jne    L32
  negl   0x0(%rbp)
  jmp    L32
L43:
  mov    $0x0,%esi
  mov    $0x0,%ebp
  jmp    L51
L168:
  movslq %esi,%rdx
  mov    %eax,0x340(%rsp,%rdx,4)
  add    $0x1,%esi
L143:
  add    $0x4,%rbx
  cmp    %r12,%rbx
  je     L42
L51:
  mov    (%rbx),%eax
  test   %eax,%eax
  js     L168
  movslq %ebp,%rdx
  mov    %eax,0x1b0(%rsp,%rdx,4)
  add    $0x1,%ebp
  jmp    L143
L42:
  mov    0x10(%rsp),%rdi
  call   <sum_subset@plt>
  mov    %eax,%ebx
  mov    %ebp,%esi
  mov    %r12,%rdi
  call   <sum_subset@plt>
  cmp    $0xffffffff,%r15d
  je     L150
  add    %eax,%ebx
  mov    %ebx,%esi
  neg    %esi
  cmovs  %ebx,%esi
  cmp    %r15d,%esi
  jl     L54
L53:
  add    $0x1,%r14d
  cmp    %r14d,0xc(%rsp)
  je     L125
L63:
  lea    0x20(%rsp),%rbx
  mov    %rbx,%rbp
L61:
  mov    $0x0,%eax
  call   <rand@plt>
  mov    %eax,0x0(%rbp)
  add    $0x4,%rbp
  cmp    %r12,%rbp
  jne    L61
  mov    %rbx,%rbp
  jmp    L81
L150:
  add    %ebx,%eax
  mov    %eax,%r15d
  neg    %r15d
  cmovs  %eax,%r15d
  mov    0x18(%rsp),%rax
  lea    0x190(%rax),%rcx
L136:
  mov    0x0(%r13,%rax,1),%edx
  mov    %edx,(%rax)
  add    $0x4,%rax
  cmp    %rax,%rcx
  jne    L136
  jmp    L53
L54:
  mov    0x18(%rsp),%rax
  lea    0x190(%rax),%rcx
L16:
  mov    0x0(%r13,%rax,1),%edx
  mov    %edx,(%rax)
  add    $0x4,%rax
  cmp    %rcx,%rax
  jne    L16
  mov    %esi,%r15d
  jmp    L53
L115:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: disassemble_data
arguments: tag: D8
type_infered: string

tool: D8: repeated random residue = %d


assistant: ```c
int *repeated_random(int loop_cnt) {
  int set_A[100];
  int pos_A[100];
  int neg_A[100];
  int size_pos;
  int size_neg;
  int sum_pos;
  int sum_neg;
  int residue;
  int sub_residue;
  int i, j;
  int *ret_int = (int *)malloc(sizeof(int) * 100);
  int k;
  residue = -1;
  for (i = 0; i < loop_cnt; i++) {
    for (j = 0; j < 100; j++)
      set_A[j] = rand();
    for (j = 0; j < 100; j++) {
      if ((rand() % 2) == 0)
        set_A[j] = set_A[j] * -1;
    }
    size_pos = size_neg = 0;
    for (j = 0; j < 100; j++) {
      if (set_A[j] < 0) {
        neg_A[size_neg] = set_A[j];
        size_neg++;
      } else {
        pos_A[size_pos] = set_A[j];
        size_pos++;
      }
    }
    sum_neg = sum_subset(neg_A, size_neg);
    sum_pos = sum_subset(pos_A, size_pos);
    if (residue == -1) {
      residue = abs(sum_neg + sum_pos);
      for (k = 0; k < 100; k++)
        ret_int[k] = set_A[k];
    } else {
      sub_residue = abs(sum_neg + sum_pos);
      if (sub_residue < residue) {
        residue = sub_residue;
        for (k = 0; k < 100; k++)
          ret_int[k] = set_A[k];
      }
    }
  }
  printf("repeated random residue = %d\n", residue);
  return ret_int;
}
```