user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<sock_bsendto>:
  endbr64
  push   %r15
  mov    %rcx,%r15
  push   %r14
  mov    %r8d,%r14d
  push   %r13
  push   %r12
  mov    %edx,%r12d
  xor    %edx,%edx
  push   %rbp
  mov    %edi,%ebp
  push   %rbx
  mov    %rsi,%rbx
  sub    $0x38,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x28(%rsp)
  xor    %eax,%eax
  mov    D86(%rip),%rax
  mov    (%rax),%esi
  call   <fcntl@plt>
  mov    D0(%rip),%rdi
  mov    %eax,0x4(%rsp)
  mov    (%rdi),%edx
  and    %edx,%eax
  mov    %eax,(%rsp)
  jne    L116
  lea    0x1c(%rsp),%r13
  mov    $0xc,%edx
  xor    %esi,%esi
  mov    %r13,%rdi
  call   <memset@plt>
  mov    D64(%rip),%rax
  lea    0x20(%rsp),%rsi
  mov    %r15,%rdi
  mov    (%rax),%eax
  mov    %eax,0x24(%rsp)
  call   <inet_aton@plt>
  mov    %r14d,%edi
  call   <htons@plt>
  mov    %eax,0x1c(%rsp)
  test   %r12d,%r12d
  je     L94
L38:
  mov    %r12d,%r14d
  jmp    L47
  nopl   0x0(%rax)
L90:
  mov    D74(%rip),%r15
  mov    D37(%rip),%rax
  mov    (%r15),%ecx
  cmp    (%rax),%ecx
  jne    L16
L47:
  xor    %ecx,%ecx
  mov    $0xc,%r9d
  mov    %r13,%r8
  mov    %r14d,%edx
  mov    %rbx,%rsi
  mov    %ebp,%edi
  call   <sendto@plt>
  test   %eax,%eax
  js     L90
  movslq %eax,%rdx
  add    %rdx,%rbx
  sub    %eax,%r14d
  jne    L47
  mov    (%rsp),%eax
  test   %eax,%eax
  jne    L43
L94:
  mov    %r12d,%eax
  jmp    L29
  nopl   0x0(%rax)
L16:
  mov    (%rsp),%edx
  test   %edx,%edx
  jne    L137
L106:
  mov    %ecx,(%r15)
  mov    $0xffffffff,%eax
L29:
  mov    0x28(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L108
  add    $0x38,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  cs nopw 0x0(%rax,%rax,1)
L116:
  mov    D87(%rip),%rcx
  mov    %ebp,%edi
  not    %edx
  lea    0x1c(%rsp),%r13
  and    0x4(%rsp),%edx
  mov    (%rcx),%esi
  mov    %rcx,0x8(%rsp)
  call   <fcntl@plt>
  mov    $0xc,%edx
  xor    %esi,%esi
  mov    %r13,%rdi
  call   <memset@plt>
  mov    D64(%rip),%rax
  lea    0x20(%rsp),%rsi
  mov    %r15,%rdi
  mov    (%rax),%eax
  mov    %eax,0x24(%rsp)
  call   <inet_aton@plt>
  mov    %r14d,%edi
  call   <htons@plt>
  test   %r12d,%r12d
  mov    0x8(%rsp),%rcx
  movl   $0x1,(%rsp)
  mov    %eax,0x1c(%rsp)
  jne    L38
L121:
  mov    D0(%rip),%rax
  mov    (%rcx),%esi
  mov    %ebp,%edi
  mov    0x4(%rsp),%edx
  or     (%rax),%edx
  call   <fcntl@plt>
  mov    %r12d,%eax
  jmp    L29
  nopl   0x0(%rax,%rax,1)
L137:
  mov    D0(%rip),%rax
  mov    0x4(%rsp),%edx
  mov    %ebp,%edi
  mov    %ecx,(%rsp)
  or     (%rax),%edx
  mov    D87(%rip),%rax
  mov    (%rax),%esi
  call   <fcntl@plt>
  mov    (%rsp),%ecx
  jmp    L106
L43:
  mov    D87(%rip),%rcx
  jmp    L121
L108:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int sock_bsendto(int s, void *buf, int len, char *hostname, int port) {
  int flag = 0;
  int oldfl, ret, comp = len;
  int olderrno;
  struct sockaddr_in sa;
  oldfl = fcntl(s, F_GETFL, 0);
  if (oldfl & O_NONBLOCK) {
    fcntl(s, F_SETFL, oldfl & (~O_NONBLOCK));
    flag = 1;
  }
  memset((char *)&sa, 0, sizeof(struct sockaddr_in));
  sa.sin_family = AF_INET;
  inet_aton(hostname, &sa.sin_addr);
  sa.sin_port = htons(port);
  while (comp) {
  bsendto_restart:
    if ((ret = sendto(s, (char *)buf, comp, 0, (struct sockaddr *)&sa, sizeof(struct sockaddr_in))) < 0) {
      if (errno == EINTR)
        goto bsendto_restart;
      olderrno = errno;
      if (flag)
        fcntl(s, F_SETFL, oldfl | O_NONBLOCK);
      errno = olderrno;
      return -1;
    }
    comp -= ret;
    buf += ret;
  }
  if (flag)
    fcntl(s, F_SETFL, oldfl | O_NONBLOCK);
  return (len - comp);
}
```