user: 请从给定的汇编指令推导出C源代码:

```asm
<random_sample>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %rbx
  sub    $0x58,%rsp
  mov    %edi,-0x44(%rbp)
  mov    %rsi,-0x50(%rbp)
  mov    %edx,-0x48(%rbp)
  mov    %rcx,-0x58(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x18(%rbp)
  xor    %eax,%eax
  mov    %rsp,%rax
  mov    %rax,%rbx
  mov    -0x44(%rbp),%eax
  cmp    -0x48(%rbp),%eax
  jg     L63
  cmpl   $0x0,-0x44(%rbp)
  jg     L58
L63:
  lea    D0(%rip),%rax
  mov    %rax,%rdi
  call   <printf@plt>
  mov    $0xffffffff,%eax
  jmp    L95
L58:
  mov    -0x44(%rbp),%eax
  cmp    -0x48(%rbp),%eax
  jne    L38
  lea    D6(%rip),%rax
  mov    %rax,%rdi
  call   <printf@plt>
  mov    -0x44(%rbp),%eax
  cltq
  shl    $0x3,%eax
  mov    %eax,%edx
  mov    -0x50(%rbp),%rcx
  mov    -0x58(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <memcpy@plt>
  mov    $0x0,%eax
  jmp    L95
L38:
  mov    -0x44(%rbp),%eax
  movslq %eax,%rdx
  sub    $0x1,%rdx
  mov    %rdx,-0x28(%rbp)
  movslq %eax,%rdx
  mov    %rdx,%r10
  mov    $0x0,%r11d
  movslq %eax,%rdx
  mov    %rdx,%r8
  mov    $0x0,%r9d
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    $0x10,%eax
  sub    $0x1,%rax
  add    %rdx,%rax
  mov    $0x10,%esi
  mov    $0x0,%edx
  div    %rsi
  imul   $0x10,%rax,%rax
  mov    %rax,%rcx
  and    $0xfffffffffffff000,%rcx
  mov    %rsp,%rdx
  sub    %rcx,%rdx
L129:
  cmp    %rdx,%rsp
  je     L45
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  jmp    L129
L45:
  mov    %rax,%rdx
  and    $0xfff,%edx
  sub    %rdx,%rsp
  mov    %rax,%rdx
  and    $0xfff,%edx
  test   %rdx,%rdx
  je     L69
  and    $0xfff,%eax
  sub    $0x8,%rax
  add    %rsp,%rax
  orq    $0x0,(%rax)
L69:
  mov    %rsp,%rax
  add    $0x3,%rax
  shr    $0x2,%rax
  shl    $0x2,%rax
  mov    %rax,-0x20(%rbp)
  movl   $0x0,-0x34(%rbp)
  jmp    L128
L149:
  mov    -0x20(%rbp),%rax
  mov    -0x34(%rbp),%edx
  movslq %edx,%rdx
  mov    -0x48(%rbp),%ecx
  mov    %ecx,(%rax,%rdx,4)
  addl   $0x1,-0x34(%rbp)
L128:
  mov    -0x34(%rbp),%eax
  cmp    -0x44(%rbp),%eax
  jl     L149
  mov    $0x0,%edi
  call   <time@plt>
  mov    %eax,%edi
  call   <srand@plt>
  movl   $0x0,-0x30(%rbp)
  jmp    L103
L81:
  mov    $0x0,%eax
  call   <rand@plt>
  cltd
  idivl  -0x48(%rbp)
  mov    %edx,-0x2c(%rbp)
  mov    -0x44(%rbp),%edx
  mov    -0x20(%rbp),%rcx
  mov    -0x2c(%rbp),%eax
  mov    %rcx,%rsi
  mov    %eax,%edi
  call   <in_int_array@plt>
  cmp    $0x1,%eax
  jne    L47
  jmp    L103
L47:
  mov    -0x30(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x20(%rbp),%rax
  add    %rax,%rdx
  mov    -0x2c(%rbp),%eax
  mov    %eax,(%rdx)
  mov    -0x2c(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x50(%rbp),%rax
  add    %rax,%rdx
  mov    -0x30(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rcx
  mov    -0x58(%rbp),%rax
  add    %rcx,%rax
  movsd  (%rdx),%xmm0
  movsd  %xmm0,(%rax)
  addl   $0x1,-0x30(%rbp)
L103:
  mov    -0x30(%rbp),%eax
  cmp    -0x44(%rbp),%eax
  jl     L81
  mov    $0x0,%eax
L95:
  mov    %rbx,%rsp
  mov    -0x18(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L114
  call   <__stack_chk_fail@plt>
L114:
  mov    -0x8(%rbp),%rbx
  leave
  ret
```

tool_calls: name: unpack_data
arguments: tag: D0
datatype: string
name: unpack_data
arguments: tag: D6
datatype: string

tool: D0: ERROR: k > arr_len || k < 1, ABORTING


tool: D6: INFO: k == arr_len, COPYING ORIGINAL ARRAY


assistant: ```c
int random_sample(int k, double *arr, int arr_len, double *buf) {
  if (k > arr_len || k < 1) {
    printf("ERROR: k > arr_len || k < 1, ABORTING\n");
    return -1;
  }
  if (k == arr_len) {
    printf("INFO: k == arr_len, COPYING ORIGINAL ARRAY\n");
    memcpy(buf, arr, sizeof(double) * k);
    return 0;
  }
  int used_indexes[k];
  int random_index;
  for (int i = 0; i < k; i++) {
    used_indexes[i] = arr_len;
  }
  srand((unsigned)time(NULL));
  int i = 0;
  while (i < k) {
    random_index = rand() % arr_len;
    if (in_int_array(random_index, used_indexes, k) == 1) {
      continue;
    }
    *(used_indexes + i) = random_index;
    *(buf + i) = *(arr + random_index);
    i++;
  }
  return 0;
}
```