user: 请将以下的汇编代码转换成C语言代码：

```asm
<BuildSampler>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    %rdi,%r12
  mov    %esi,%ebx
  mov    %esi,0x4(%rsp)
  mov    %rdx,0x8(%rsp)
  mov    %rcx,%r13
  test   %esi,%esi
  setne  %dil
  movzbl %dil,%edi
  call   <assert@plt>
  test   %ebx,%ebx
  je     L79
  mov    $0x1,%ebx
L103:
  mov    %ebx,%eax
  mov    0x8(%rsp),%rsi
  mov    %ebx,(%rsi,%rax,4)
  mov    %ebx,0x0(%r13,%rax,4)
  lea    (%r12,%rax,8),%rbp
  movsd  0x0(%rbp),%xmm0
  pxor   %xmm7,%xmm7
  comisd %xmm7,%xmm0
  setae  %dil
  movzbl %dil,%edi
  call   <assert@plt>
  mov    0x4(%rsp),%esi
  mov    %esi,%eax
  pxor   %xmm0,%xmm0
  cvtsi2sd %rax,%xmm0
  mulsd  0x0(%rbp),%xmm0
  movsd  %xmm0,0x0(%rbp)
  add    $0x1,%ebx
  cmp    %ebx,%esi
  jae    L103
L79:
  movl   $0x0,0x0(%r13)
  movq   $0x0,(%r12)
  mov    0x4(%rsp),%eax
  lea    0x1(%rax),%ebx
  mov    %ebx,%eax
  mov    %ebx,0x0(%r13,%rax,4)
  mov    D76(%rip),%rdi
  mov    %rdi,(%r12,%rax,8)
  mov    $0x0,%esi
  movsd  D57(%rip),%xmm2
  movapd %xmm2,%xmm1
L13:
  add    $0x1,%esi
  mov    %esi,%eax
  lea    0x0(%r13,%rax,4),%r8
  mov    (%r8),%edi
  mov    %edi,%eax
  comisd (%r12,%rax,8),%xmm2
  ja     L13
L99:
  mov    %ebx,%ebp
  sub    $0x1,%ebx
  mov    %ebx,%eax
  lea    0x0(%r13,%rax,4),%rax
  mov    (%rax),%edx
  mov    %edx,%ecx
  movsd  (%r12,%rcx,8),%xmm0
  comisd %xmm1,%xmm0
  jae    L99
  cmp    %ebx,%esi
  jae    L102
  mov    %edx,(%r8)
  mov    %edi,(%rax)
  jmp    L13
L102:
  test   %ebx,%ebx
  jne    L36
L23:
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L111:
  cmp    %ebp,%ebx
  setb   %dil
  movzbl %dil,%edi
  call   <assert@plt>
  mov    (%r15),%eax
  mov    (%r14),%edx
  mov    %edx,(%r15)
  mov    %eax,(%r14)
  add    $0x1,%ebp
L117:
  test   %ebx,%ebx
  je     L23
L36:
  mov    %ebp,%eax
  lea    0x0(%r13,%rax,4),%r14
  mov    (%r14),%eax
  movsd  D57(%rip),%xmm5
  comisd (%r12,%rax,8),%xmm5
  jb     L7
L74:
  add    $0x1,%ebp
  mov    %ebp,%eax
  lea    0x0(%r13,%rax,4),%r14
  mov    (%r14),%eax
  movsd  D57(%rip),%xmm3
  comisd (%r12,%rax,8),%xmm3
  jae    L74
L7:
  mov    %ebx,%eax
  lea    0x0(%r13,%rax,4),%r15
  mov    (%r15),%eax
  movsd  D57(%rip),%xmm4
  comisd (%r12,%rax,8),%xmm4
  seta   %dil
  movzbl %dil,%edi
  call   <assert@plt>
  cmp    %ebp,0x4(%rsp)
  jb     L23
  mov    $0x1,%edi
  call   <assert@plt>
  mov    (%r14),%eax
  movsd  (%r12,%rax,8),%xmm0
  comisd D57(%rip),%xmm0
  seta   %dil
  movzbl %dil,%edi
  call   <assert@plt>
  mov    (%r14),%eax
  lea    (%r12,%rax,8),%rax
  mov    (%r15),%edx
  movsd  D57(%rip),%xmm1
  subsd  (%r12,%rdx,8),%xmm1
  movsd  (%rax),%xmm0
  subsd  %xmm1,%xmm0
  movsd  %xmm0,(%rax)
  mov    (%r14),%eax
  mov    (%r15),%edx
  mov    0x8(%rsp),%rsi
  mov    %eax,(%rsi,%rdx,4)
  mov    %eax,%eax
  movsd  D57(%rip),%xmm6
  comisd (%r12,%rax,8),%xmm6
  ja     L111
  sub    $0x1,%ebx
  jmp    L117
```

tool_calls: name: extract_symbolic_data
arguments: tag: D76
type: f64
name: extract_symbolic_data
arguments: tag: D57
type: f64

tool: D76: 2

tool: D57: 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--;
  }
}
```