user: What would the C source look like for the assembly code provided here:

```asm
<write_elements_to_socket>:
  endbr64
  push   %r15
  push   %r14
  mov    %edi,%r14d
  push   %r13
  mov    %rdx,%r13
  push   %r12
  push   %rbp
  push   %rbx
  mov    %esi,%ebx
  sub    $0x18,%rsp
  cmp    $0x1770,%esi
  jg     L24
  lea    D26(%rip),%rdi
  call   <puts@plt>
  lea    0x0(,%rbx,8),%edx
  mov    %r13,%rsi
  mov    %r14d,%edi
  call   <write_double_array_to_socket@plt>
  test   %eax,%eax
  js     L82
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L24:
  movslq %esi,%rsi
  mov    %ebx,%eax
  lea    D6(%rip),%rdi
  xor    %ebp,%ebp
  imul   $0x57619f1,%rsi,%rsi
  sar    $0x1f,%eax
  sar    $0x27,%rsi
  sub    %eax,%esi
  xor    %eax,%eax
  imul   $0x1770,%esi,%r12d
  sub    %r12d,%ebx
  mov    %ebx,%edx
  mov    %ebx,0xc(%rsp)
  xor    %ebx,%ebx
  call   <printf@plt>
  lea    0x8(%r13),%rax
  mov    %rax,(%rsp)
L132:
  mov    $0xbb80,%edi
  call   <malloc@plt>
  mov    %rax,%r15
  mov    (%rsp),%rax
  add    %rbx,%rax
  cmp    %rax,%r15
  je     L103
  lea    0x0(%r13,%rbx,1),%rdx
  lea    0xbb80(%r15),%rcx
  mov    %r15,%rax
  sub    %r15,%rdx
  nopl   (%rax)
L44:
  movupd (%rax,%rdx,1),%xmm1
  add    $0x10,%rax
  movups %xmm1,-0x10(%rax)
  cmp    %rax,%rcx
  jne    L44
L36:
  mov    $0xbb80,%edx
  mov    %r15,%rsi
  mov    %r14d,%edi
  add    $0x1770,%ebp
  call   <write_double_array_to_socket@plt>
  xor    %eax,%eax
  add    $0xbb80,%rbx
  call   <sleep_funct2@plt>
  mov    %r15,%rdi
  call   <free@plt>
  cmp    %r12d,%ebp
  jne    L132
  mov    0xc(%rsp),%ebx
  lea    0x0(,%rbx,8),%r15d
  mov    %r15d,%edi
  call   <malloc@plt>
  mov    %rax,%rbp
  test   %ebx,%ebx
  je     L123
  movslq %r12d,%rdx
  lea    -0x1(%rbx),%ecx
  lea    0x8(,%rdx,8),%rsi
  lea    0x0(%r13,%rsi,1),%rax
  cmp    %rax,%rbp
  je     L33
  cmp    $0x2,%ecx
  jbe    L33
  shr    %ebx
  mov    %r13,%rcx
  mov    %rbp,%rax
  mov    %ebx,%edx
  sub    %rbp,%rcx
  shl    $0x4,%rdx
  lea    -0x8(%rcx,%rsi,1),%rcx
  add    %rbp,%rdx
L30:
  movupd (%rax,%rcx,1),%xmm2
  add    $0x10,%rax
  movups %xmm2,-0x10(%rax)
  cmp    %rax,%rdx
  jne    L30
  mov    0xc(%rsp),%esi
  mov    %esi,%edx
  and    $0xfffffffe,%edx
  lea    (%rdx,%r12,1),%eax
  cmp    %edx,%esi
  je     L123
  cltq
  movsd  0x0(%r13,%rax,8),%xmm0
  mov    %edx,%eax
  movsd  %xmm0,0x0(%rbp,%rax,8)
L123:
  mov    %r14d,%edi
  mov    %r15d,%edx
  mov    %rbp,%rsi
  call   <write_double_array_to_socket@plt>
  add    $0x18,%rsp
  mov    %rbp,%rdi
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  jmp    10b0 <free@plt>
L103:
  mov    %rbx,%rdx
  lea    0xbb80(%r15),%rcx
  mov    %r15,%rax
  sub    %r15,%rdx
  add    %r13,%rdx
  nop
L31:
  movsd  (%rdx,%rax,1),%xmm0
  add    $0x8,%rax
  movsd  %xmm0,-0x8(%rax)
  cmp    %rcx,%rax
  jne    L31
  jmp    L36
L82:
  add    $0x18,%rsp
  lea    D12(%rip),%rdi
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  jmp    1110 <error@plt>
L33:
  shl    $0x3,%rdx
  mov    %rbp,%rax
  lea    0x8(%rbp,%rcx,8),%rcx
  sub    %rbp,%rdx
  add    %rdx,%r13
L69:
  movsd  0x0(%r13,%rax,1),%xmm0
  add    $0x8,%rax
  movsd  %xmm0,-0x8(%rax)
  cmp    %rax,%rcx
  jne    L69
  jmp    L123
```

tool_calls: name: disassemble_data
arguments: tag: D26
type_guessed: string
name: disassemble_data
arguments: tag: D6
type_guessed: string
name: disassemble_data
arguments: tag: D12
type_guessed: string

tool: D26: transfer all at once..

tool: D6: server: nchunks = %d and nleftover = %d


tool: D12: ERROR writing to socket

assistant: ```c
void write_elements_to_socket(int sockfd, int nelements, double *elements_all) {
  int i, ind, nlen, nchunks, nleftover, chunk_num;
  double *elements_local;
  if (nelements <= 6000) {
    printf("transfer all at once..\n");
    nlen = write_double_array_to_socket(sockfd, elements_all, nelements * sizeof(double));
    if (nlen < 0)
      error("ERROR writing to socket");
  } else {
    nchunks = nelements / 6000;
    nleftover = nelements % 6000;
    printf("server: nchunks = %d and nleftover = %d\n", nchunks, nleftover);
    ind = 0;
    for (chunk_num = 0; chunk_num < nchunks; chunk_num++) {
      elements_local = (double *)malloc(6000 * sizeof(double));
      for (i = 0; i < 6000; i++) {
        elements_local[i] = elements_all[ind++];
      }
      nlen = write_double_array_to_socket(sockfd, elements_local, 6000 * sizeof(double));
      sleep_funct2();
      free(elements_local);
    }
    elements_local = (double *)malloc(nleftover * sizeof(double));
    for (i = 0; i < nleftover; i++) {
      elements_local[i] = elements_all[ind++];
    }
    nlen = write_double_array_to_socket(sockfd, elements_local, nleftover * sizeof(double));
    free(elements_local);
  }
}
```