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

```asm
<BuildSampler>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  mov    %rcx,%r13
  push   %r12
  mov    %rdi,%r12
  xor    %edi,%edi
  push   %rbp
  mov    %esi,%ebp
  push   %rbx
  mov    $0x1,%ebx
  sub    $0x28,%rsp
  test   %ebp,%ebp
  setne  %dil
  mov    %ebp,0x4(%rsp)
  mov    %rdx,0x8(%rsp)
  call   <assert@plt>
  test   %ebp,%ebp
  je     L105
  nopl   0x0(%rax)
L106:
  mov    %ebx,%eax
  mov    0x8(%rsp),%rsi
  pxor   %xmm3,%xmm3
  xor    %edi,%edi
  lea    (%r12,%rax,8),%r14
  movsd  (%r14),%xmm0
  mov    %ebx,(%rsi,%rax,4)
  mov    %ebx,0x0(%r13,%rax,4)
  comisd %xmm3,%xmm0
  setae  %dil
  add    $0x1,%ebx
  call   <assert@plt>
  pxor   %xmm0,%xmm0
  cvtsi2sd %rbp,%xmm0
  mulsd  (%r14),%xmm0
  movsd  %xmm0,(%r14)
  cmp    %ebx,0x4(%rsp)
  jae    L106
L105:
  mov    0x4(%rsp),%eax
  mov    D0(%rip),%rdx
  xor    %r8d,%r8d
  movl   $0x0,0x0(%r13)
  movq   $0x0,(%r12)
  movsd  D18(%rip),%xmm0
  add    $0x1,%eax
  mov    %eax,0x0(%r13,%rax,4)
  mov    %rax,%rbx
  mov    %rdx,(%r12,%rax,8)
  nopl   0x0(%rax)
L5:
  lea    0x1(%r8),%eax
  lea    0x0(%r13,%rax,4),%r10
  mov    %rax,%r8
  mov    (%r10),%eax
  comisd (%r12,%rax,8),%xmm0
  mov    %rax,%r9
  ja     L5
  nopw   0x0(%rax,%rax,1)
L85:
  lea    -0x1(%rbx),%r14d
  mov    %ebx,%ebp
  lea    0x0(%r13,%r14,4),%rax
  mov    %r14,%rbx
  mov    (%rax),%edi
  movsd  (%r12,%rdi,8),%xmm1
  comisd %xmm0,%xmm1
  jae    L85
  cmp    %r14d,%r8d
  jae    L86
  mov    %edi,(%r10)
  mov    %r9d,(%rax)
  jmp    L5
  nopl   0x0(%rax)
L86:
  mov    %ebp,%r15d
  test   %r14d,%r14d
  jne    L112
  jmp    L84
  nopl   (%rax)
L118:
  lea    0x1(%rbp),%r15d
  mov    %r15,%rbp
L112:
  lea    0x0(%r13,%r15,4),%rcx
  mov    (%rcx),%eax
  comisd (%r12,%rax,8),%xmm0
  jae    L118
  xor    %edi,%edi
  comisd %xmm1,%xmm0
  lea    0x0(%r13,%r14,4),%rax
  mov    %rcx,0x10(%rsp)
  mov    %rax,0x18(%rsp)
  seta   %dil
  call   <assert@plt>
  cmp    %ebp,0x4(%rsp)
  jb     L84
  mov    $0x1,%edi
  call   <assert@plt>
  mov    0x10(%rsp),%rcx
  xor    %edi,%edi
  mov    (%rcx),%eax
  movsd  (%r12,%rax,8),%xmm1
  mov    D18(%rip),%rax
  movq   %rax,%xmm0
  comisd %xmm0,%xmm1
  seta   %dil
  call   <assert@plt>
  mov    0x10(%rsp),%rcx
  mov    0x8(%rsp),%rsi
  mov    D18(%rip),%rdx
  mov    (%rcx),%eax
  movq   %rdx,%xmm2
  movq   %rdx,%xmm0
  lea    (%r12,%rax,8),%r9
  mov    %rax,%rdi
  lea    0x0(%r13,%r14,4),%rax
  mov    (%rax),%eax
  movsd  (%r9),%xmm1
  subsd  (%r12,%rax,8),%xmm2
  subsd  %xmm2,%xmm1
  movsd  %xmm1,(%r9)
  mov    %edi,(%rsi,%rax,4)
  mov    (%rcx),%eax
  comisd (%r12,%rax,8),%xmm0
  ja     L17
  sub    $0x1,%ebx
  je     L84
  mov    %ebx,%r14d
L98:
  mov    0x0(%r13,%r14,4),%eax
  movsd  (%r12,%rax,8),%xmm1
  jmp    L112
  nopl   0x0(%rax)
L17:
  xor    %edi,%edi
  cmp    %ebx,%ebp
  lea    0x1(%rbp),%r15d
  seta   %dil
  mov    %r15,%rbp
  call   <assert@plt>
  mov    0x18(%rsp),%rdx
  mov    0x10(%rsp),%rcx
  mov    (%rdx),%eax
  mov    (%rcx),%edi
  mov    %edi,(%rdx)
  mov    %eax,(%rcx)
  mov    D18(%rip),%rax
  movq   %rax,%xmm0
  jmp    L98
  nopl   0x0(%rax)
L84:
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

tool_calls: name: disassemble_data
arguments: data_label: D0
datatype: f64
name: disassemble_data
arguments: data_label: D18
datatype: f64

tool: D0: 2

tool: D18: 1

assistant: ```c
void BuildSampler(double *X, unsigned N, unsigned *A, unsigned *B) {
  unsigned i, j, k;
  assert(1 <= N);
  for (i = 1; i <= N; i++) {
    A[i] = i;
    B[i] = i;
    assert(X[i] >= 0.0);
    X[i] = X[i] * N;
  }
  B[0] = 0;
  X[0] = 0.0;
  B[N + 1] = N + 1;
  X[N + 1] = 2.0;
  i = 0;
  j = N + 1;
  for (;;) {
    do {
      i++;
    } while (X[B[i]] < 1.0);
    do {
      j--;
    } while (X[B[j]] >= 1.0);
    if (i >= j)
      break;
    k = B[i];
    B[i] = B[j];
    B[j] = k;
  }
  i = j;
  j++;
  while (i > 0) {
    while (X[B[j]] <= 1.0)
      j++;
    assert(X[B[i]] < 1.0);
    if (j > N)
      break;
    assert(j <= N);
    assert(X[B[j]] > 1.0);
    X[B[j]] -= 1.0 - X[B[i]];
    A[B[i]] = B[j];
    if (X[B[j]] < 1.0) {
      assert(i < j);
      k = B[i];
      B[i] = B[j];
      B[j] = k;
      j++;
    } else
      i--;
  }
}
```