user: Please show me the C implementation that matches the assembly code listed below:

```asm
<test_write_binary>:
  endbr64
  push   %r15
  mov    $0x201f,%edx
  lea    D3(%rip),%rdi
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  sub    $0x40,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x38(%rsp)
  xor    %eax,%eax
  mov    $0xf0e,%eax
  lea    0x8(%rsp),%rbp
  mov    %dx,0x35(%rsp)
  mov    %ax,0x2e(%rsp)
  lea    0x2b(%rsp),%rax
  lea    0x26(%rsp),%r12
  movb   $0x18,0x24(%rsp)
  lea    0x10(%rsp),%r13
  lea    0x25(%rsp),%r15
  movl   $0x17161514,0x20(%rsp)
  lea    0x2a(%rsp),%r14
  movl   $0x21201f1e,0x18(%rsp)
  movl   $0x17161514,0x25(%rsp)
  movb   $0x18,0x29(%rsp)
  movl   $0x21201f1e,0x1c(%rsp)
  movl   $0xd0c0b0a,0x2a(%rsp)
  movb   $0x10,0x30(%rsp)
  movl   $0x1716150a,0x31(%rsp)
  movb   $0x10,0x37(%rsp)
  mov    %rax,0x8(%rsp)
  movq   $0x0,0x10(%rsp)
  call   <printf@plt>
  xor    %edx,%edx
  xor    %esi,%esi
  mov    %rbp,%rdi
  call   <write_binary@plt>
  mov    %eax,%edi
  call   <assert@plt>
  xor    %edx,%edx
  xor    %esi,%esi
  xor    %edi,%edi
  call   <write_binary@plt>
  mov    %eax,%edi
  call   <assert@plt>
  xor    %edx,%edx
  mov    %r12,%rsi
  xor    %edi,%edi
  call   <write_binary@plt>
  mov    %eax,%edi
  call   <assert@plt>
  xor    %edx,%edx
  mov    %r12,%rsi
  mov    %r13,%rdi
  call   <write_binary@plt>
  mov    %eax,%edi
  call   <assert@plt>
  xor    %edx,%edx
  xor    %esi,%esi
  mov    %r13,%rdi
  call   <write_binary@plt>
  mov    %eax,%edi
  call   <assert@plt>
  xor    %esi,%esi
  mov    $0x35,%edx
  mov    %rbp,%rdi
  call   <write_binary@plt>
  xor    %edi,%edi
  test   %eax,%eax
  sete   %dil
  call   <assert@plt>
  xor    %esi,%esi
  mov    $0x1,%edx
  xor    %edi,%edi
  call   <write_binary@plt>
  xor    %edi,%edi
  test   %eax,%eax
  sete   %dil
  call   <assert@plt>
  mov    %r12,%rsi
  mov    $0x17,%edx
  xor    %edi,%edi
  call   <write_binary@plt>
  xor    %edi,%edi
  test   %eax,%eax
  sete   %dil
  call   <assert@plt>
  mov    %r12,%rsi
  mov    $0x1,%edx
  mov    %r13,%rdi
  call   <write_binary@plt>
  xor    %edi,%edi
  test   %eax,%eax
  sete   %dil
  call   <assert@plt>
  xor    %esi,%esi
  mov    $0x6,%edx
  mov    %r13,%rdi
  call   <write_binary@plt>
  xor    %edi,%edi
  test   %eax,%eax
  sete   %dil
  call   <assert@plt>
  mov    0x8(%rsp),%rax
  xor    %edi,%edi
  cmpb   $0xb,(%rax)
  sete   %dil
  call   <assert@plt>
  mov    %r12,%rsi
  mov    $0x3,%edx
  mov    %rbp,%rdi
  call   <write_binary@plt>
  lea    0x1c(%rsp),%r12
  mov    %eax,%edi
  call   <assert@plt>
  mov    0x8(%rsp),%rax
  xor    %edi,%edi
  cmpb   $0xe,(%rax)
  sete   %dil
  call   <assert@plt>
  lea    0x1d(%rsp),%rsi
  mov    $0x2,%edx
  mov    %rbp,%rdi
  call   <write_binary@plt>
  mov    %eax,%edi
  call   <assert@plt>
  mov    0x8(%rsp),%rax
  xor    %edi,%edi
  cmpb   $0x10,(%rax)
  sete   %dil
  call   <assert@plt>
  xor    %edx,%edx
  mov    %r12,%rsi
  mov    %rbp,%rdi
  call   <write_binary@plt>
  mov    %eax,%edi
  call   <assert@plt>
  mov    0x8(%rsp),%rax
  xor    %edi,%edi
  cmpb   $0x10,(%rax)
  sete   %dil
  call   <assert@plt>
  lea    0x20(%rsp),%rsi
  mov    $0x5,%edx
  mov    %r15,%rdi
  call   <memcmp@plt>
  xor    %edi,%edi
  test   %rax,%rax
  sete   %dil
  call   <assert@plt>
  lea    0x18(%rsp),%rsi
  mov    $0x4,%edx
  mov    %r12,%rdi
  call   <memcmp@plt>
  xor    %edi,%edi
  test   %rax,%rax
  sete   %dil
  call   <assert@plt>
  lea    0x31(%rsp),%rsi
  mov    $0x7,%edx
  mov    %r14,%rdi
  call   <memcmp@plt>
  xor    %edi,%edi
  test   %rax,%rax
  sete   %dil
  call   <assert@plt>
  lea    D18(%rip),%rdi
  call   <printf@plt>
  mov    0x38(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L2
  add    $0x40,%rsp
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L2:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: unpack_data
arguments: data_tag: D3
datatype: string
name: unpack_data
arguments: data_tag: D18
datatype: string

tool: D3: 	Start  test_write_binary


tool: D18: 	Finish test_write_binary


assistant: ```c
void test_write_binary(void) {
  unsigned char original_src[] = {20, 21, 22, 23, 24};
  unsigned char original_src2[] = {30, 31, 32, 33};
  unsigned char src[] = {20, 21, 22, 23, 24};
  unsigned char src2[] = {30, 31, 32, 33};
  unsigned char dest[] = {10, 11, 12, 13, 14, 15, 16};
  unsigned char expected[] = {10, 21, 22, 23, 31, 32, 16};
  unsigned char *p = dest + 1;
  unsigned char *null_ptr = NULL;
  printf("\tStart  test_write_binary\n");
  assert(write_binary(&p, NULL, 0));
  assert(write_binary(NULL, NULL, 0));
  assert(write_binary(NULL, src + 1, 0));
  assert(write_binary(&null_ptr, src + 1, 0));
  assert(write_binary(&null_ptr, NULL, 0));
  assert(!write_binary(&p, NULL, 53));
  assert(!write_binary(NULL, NULL, 1));
  assert(!write_binary(NULL, src + 1, 23));
  assert(!write_binary(&null_ptr, src + 1, 1));
  assert(!write_binary(&null_ptr, NULL, 6));
  assert(*p == 11);
  assert(write_binary(&p, src + 1, 3));
  assert(*p == 14);
  assert(write_binary(&p, src2 + 1, 2));
  assert(*p == 16);
  assert(write_binary(&p, src2, 0));
  assert(*p == 16);
  assert(memcmp(src, original_src, sizeof src) == 0);
  assert(memcmp(src2, original_src2, sizeof src2) == 0);
  assert(memcmp(dest, expected, sizeof dest) == 0);
  printf("\tFinish test_write_binary\n");
}
```