user: What is the c source code of the assembly code below?

```asm
<rdiscrete>:
  endbr64
  push   %r14
  push   %r13
  mov    %rsi,%r13
  push   %r12
  push   %rbp
  movslq %edi,%rbp
  push   %rbx
  lea    0x0(,%rbp,8),%edi
  mov    %rbp,%rbx
  sub    $0x10,%rsp
  call   <malloc@plt>
  mov    %rax,%r14
  test   %ebp,%ebp
  jle    L95
  cmp    $0x1,%ebp
  je     L176
  mov    %ebp,%edx
  pxor   %xmm1,%xmm1
  mov    %r13,%rax
  shr    %edx
  movapd %xmm1,%xmm0
  sub    $0x1,%edx
  shl    $0x4,%rdx
  lea    0x10(%r13,%rdx,1),%rdx
  nopl   0x0(%rax)
L129:
  movsd  (%rax),%xmm2
  add    $0x10,%rax
  addsd  %xmm2,%xmm0
  movsd  -0x8(%rax),%xmm2
  addsd  %xmm2,%xmm0
  cmp    %rdx,%rax
  jne    L129
  mov    %ebx,%eax
  and    $0xfffffffe,%eax
  test   $0x1,%bl
  je     L20
L73:
  cltq
  addsd  0x0(%r13,%rax,8),%xmm0
L20:
  lea    0x8(%r13),%rax
  cmp    %rax,%r14
  je     L71
  cmp    $0x1,%ebx
  je     L71
  mov    %ebx,%edx
  movapd %xmm0,%xmm3
  mov    %r13,%rcx
  mov    %r14,%rax
  shr    %edx
  unpcklpd %xmm3,%xmm3
  sub    %r14,%rcx
  shl    $0x4,%rdx
  add    %r14,%rdx
  nopw   0x0(%rax,%rax,1)
L54:
  movupd (%rax,%rcx,1),%xmm2
  add    $0x10,%rax
  divpd  %xmm3,%xmm2
  movups %xmm2,-0x10(%rax)
  cmp    %rdx,%rax
  jne    L54
  mov    %ebx,%eax
  and    $0xfffffffe,%eax
  test   $0x1,%bl
  je     L36
  movsd  0x0(%r13,%rax,8),%xmm2
  divsd  %xmm0,%xmm2
  movsd  %xmm2,(%r14,%rax,8)
L36:
  lea    0x8(,%rbx,8),%edi
  movsd  %xmm1,0x8(%rsp)
  shl    $0x3,%rbp
  call   <malloc@plt>
  movsd  0x8(%rsp),%xmm1
  movq   $0x0,(%rax)
  mov    %rax,%r13
L28:
  lea    -0x1(%rbx),%eax
  mov    $0x8,%ecx
  lea    (%r14,%rax,8),%rsi
  sub    %r14,%rcx
  mov    %r14,%rax
  nopl   0x0(%rax)
L112:
  addsd  (%rax),%xmm1
  lea    (%rax,%r13,1),%rdx
  add    $0x8,%rax
  movsd  %xmm1,(%rdx,%rcx,1)
  cmp    %rsi,%rax
  jne    L112
  mov    D5(%rip),%rax
  mov    %rax,0x0(%r13,%rbp,1)
  xor    %eax,%eax
  call   <runif@plt>
L138:
  mov    %r13,%rax
  xor    %r12d,%r12d
  nop
L52:
  comisd (%rax),%xmm0
  jb     L150
  movsd  0x8(%rax),%xmm1
  comisd %xmm0,%xmm1
  jae    L18
L150:
  add    $0x1,%r12d
  add    $0x8,%rax
  cmp    %r12d,%ebx
  jg     L52
L18:
  mov    %r14,%rdi
  call   <free@plt>
  mov    %r13,%rdi
  call   <free@plt>
  add    $0x10,%rsp
  mov    %r12d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
  xchg   %ax,%ax
L71:
  mov    %ebx,%eax
  sub    %r14,%r13
  lea    (%r14,%rax,8),%rdx
  mov    %r14,%rax
  nopl   0x0(%rax)
L33:
  movsd  0x0(%r13,%rax,1),%xmm2
  add    $0x8,%rax
  divsd  %xmm0,%xmm2
  movsd  %xmm2,-0x8(%rax)
  cmp    %rdx,%rax
  jne    L33
  lea    0x8(,%rbx,8),%edi
  movsd  %xmm1,0x8(%rsp)
  shl    $0x3,%rbp
  call   <malloc@plt>
  cmp    $0x1,%ebx
  movsd  0x8(%rsp),%xmm1
  movq   $0x0,(%rax)
  mov    %rax,%r13
  jg     L28
  jmp    L175
  nopw   0x0(%rax,%rax,1)
L95:
  lea    0x8(,%rbp,8),%edi
  shl    $0x3,%rbp
  call   <malloc@plt>
  movq   $0x0,(%rax)
  mov    %rax,%r13
L175:
  mov    D5(%rip),%rax
  mov    %rax,0x0(%r13,%rbp,1)
  xor    %eax,%eax
  call   <runif@plt>
  cmp    $0x1,%ebx
  je     L138
  jmp    L18
L176:
  pxor   %xmm1,%xmm1
  xor    %eax,%eax
  movapd %xmm1,%xmm0
  jmp    L73
```

tool_calls: name: parse_data
arguments: data_tag: D5
datatype: f32[2]

tool: {"D5": [0.0,1.875]}

assistant: ```c
int rdiscrete(int M, double *prob_original) {
  double sum = 0;
  int ans;
  double *prob = (double *)malloc(M * sizeof(double));
  for (int i = 0; i < M; i++) {
    sum += prob_original[i];
  }
  for (int i = 0; i < M; i++) {
    prob[i] = prob_original[i] / sum;
  }
  double *cum_prob = (double *)malloc((M + 1) * sizeof(double));
  cum_prob[0] = 0;
  for (int i = 1; i < M; i++) {
    cum_prob[i] = cum_prob[i - 1] + prob[i - 1];
  }
  cum_prob[M] = 1;
  double u = runif();
  for (int i = 0; i < M; i++) {
    if ((u >= cum_prob[i]) && (u <= cum_prob[i + 1])) {
      ans = i;
      break;
    }
  }
  free(prob);
  free(cum_prob);
  return ans;
}
```