user: Translate the below assembly code into C programming language:

```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    D15(%rip),%rax
  mov    (%rax),%esi
  call   <fcntl@plt>
  mov    D47(%rip),%rdi
  mov    %eax,0x4(%rsp)
  mov    (%rdi),%edx
  and    %edx,%eax
  mov    %eax,(%rsp)
  jne    L46
  lea    0x1c(%rsp),%r13
  mov    $0xc,%edx
  xor    %esi,%esi
  mov    %r13,%rdi
  call   <memset@plt>
  mov    D88(%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     L51
L92:
  mov    %r12d,%r14d
  jmp    L136
  nopl   0x0(%rax)
L7:
  mov    D103(%rip),%r15
  mov    D27(%rip),%rax
  mov    (%r15),%ecx
  cmp    (%rax),%ecx
  jne    L91
L136:
  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     L7
  movslq %eax,%rdx
  add    %rdx,%rbx
  sub    %eax,%r14d
  jne    L136
  mov    (%rsp),%eax
  test   %eax,%eax
  jne    L20
L51:
  mov    %r12d,%eax
  jmp    L65
  nopl   0x0(%rax)
L91:
  mov    (%rsp),%edx
  test   %edx,%edx
  jne    L37
L121:
  mov    %ecx,(%r15)
  mov    $0xffffffff,%eax
L65:
  mov    0x28(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L56
  add    $0x38,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  cs nopw 0x0(%rax,%rax,1)
L46:
  mov    D64(%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    D88(%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    L92
L79:
  mov    D47(%rip),%rax
  mov    (%rcx),%esi
  mov    %ebp,%edi
  mov    0x4(%rsp),%edx
  or     (%rax),%edx
  call   <fcntl@plt>
  mov    %r12d,%eax
  jmp    L65
  nopl   0x0(%rax,%rax,1)
L37:
  mov    D47(%rip),%rax
  mov    0x4(%rsp),%edx
  mov    %ebp,%edi
  mov    %ecx,(%rsp)
  or     (%rax),%edx
  mov    D64(%rip),%rax
  mov    (%rax),%esi
  call   <fcntl@plt>
  mov    (%rsp),%ecx
  jmp    L121
L20:
  mov    D64(%rip),%rcx
  jmp    L79
L56:
  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);
}
```