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

```asm
<ss_connect_to_ipv4_host_impl>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x70,%rsp
  mov    %rdi,-0x58(%rbp)
  mov    %rsi,-0x60(%rbp)
  mov    %edx,%eax
  mov    %ecx,-0x68(%rbp)
  mov    %ax,-0x64(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  lea    -0x20(%rbp),%rax
  mov    $0x18,%edx
  mov    $0x0,%esi
  mov    %rax,%rdi
  call   <memset@plt>
  mov    D24(%rip),%rax
  mov    (%rax),%eax
  mov    %eax,-0xc(%rbp)
  mov    D65(%rip),%rax
  mov    (%rax),%eax
  mov    %eax,-0x10(%rbp)
  mov    -0x58(%rbp),%rax
  mov    %rax,%rdi
  call   <Slock_object@plt>
  cmpq   $0x0,-0x60(%rbp)
  je     L9
  mov    -0x60(%rbp),%rax
  mov    %rax,%rdi
  call   <Slock_object@plt>
L9:
  mov    $0x0,%eax
  call   <Sdeactivate_thread@plt>
  movl   $0x0,-0x48(%rbp)
  lea    -0x38(%rbp),%rcx
  lea    -0x20(%rbp),%rdx
  mov    -0x60(%rbp),%rsi
  mov    -0x58(%rbp),%rax
  mov    %rax,%rdi
  call   <getaddrinfo@plt>
  test   %rax,%rax
  jne    L131
  mov    -0x38(%rbp),%rax
  test   %rax,%rax
  jne    L129
L131:
  mov    D110(%rip),%rax
  mov    (%rax),%eax
  mov    %eax,-0x48(%rbp)
  mov    $0x0,%eax
  call   <Sactivate_thread@plt>
  mov    -0x58(%rbp),%rax
  mov    %rax,%rdi
  call   <Sunlock_object@plt>
  cmpq   $0x0,-0x60(%rbp)
  je     L44
  mov    -0x60(%rbp),%rax
  mov    %rax,%rdi
  call   <Sunlock_object@plt>
L44:
  mov    D110(%rip),%rax
  mov    -0x48(%rbp),%edx
  mov    %edx,(%rax)
  mov    $0xffffffff,%eax
  jmp    L6
L129:
  movl   $0x0,-0x40(%rbp)
  mov    -0x38(%rbp),%rax
  mov    %rax,-0x30(%rbp)
  jmp    L91
L184:
  movl   $0x0,-0x40(%rbp)
  mov    D65(%rip),%rax
  mov    (%rax),%ecx
  mov    D24(%rip),%rax
  mov    (%rax),%eax
  mov    $0x0,%edx
  mov    %ecx,%esi
  mov    %eax,%edi
  call   <socket@plt>
  mov    %eax,-0x44(%rbp)
  cmpl   $0xffffffff,-0x44(%rbp)
  jne    L146
  mov    D110(%rip),%rax
  mov    (%rax),%eax
  mov    %eax,-0x48(%rbp)
  movl   $0xfffffffe,-0x40(%rbp)
  jmp    L136
L146:
  mov    D168(%rip),%rax
  mov    (%rax),%edx
  mov    -0x44(%rbp),%eax
  mov    %edx,%esi
  mov    %eax,%edi
  mov    $0x0,%eax
  call   <fcntl@plt>
  mov    %eax,%edx
  mov    D45(%rip),%rax
  mov    (%rax),%eax
  or     %eax,%edx
  mov    D142(%rip),%rax
  mov    (%rax),%ecx
  mov    -0x44(%rbp),%eax
  mov    %ecx,%esi
  mov    %eax,%edi
  mov    $0x0,%eax
  call   <fcntl@plt>
  cmpl   $0x0,-0x68(%rbp)
  jne    L25
  mov    -0x44(%rbp),%eax
  mov    %eax,%edi
  call   <ss_set_fd_non_blocking@plt>
  test   %eax,%eax
  jne    L25
  mov    D110(%rip),%rax
  mov    (%rax),%eax
  mov    %eax,-0x48(%rbp)
  mov    -0x44(%rbp),%eax
  mov    %eax,%edi
  call   <close@plt>
  movl   $0xfffffffe,-0x40(%rbp)
  jmp    L136
L25:
  mov    -0x30(%rbp),%rax
  mov    (%rax),%rax
  mov    %rax,-0x28(%rbp)
  cmpw   $0x0,-0x64(%rbp)
  je     L114
  movzwl -0x64(%rbp),%eax
  mov    %eax,%edi
  call   <htons@plt>
  mov    -0x28(%rbp),%rdx
  mov    %eax,(%rdx)
L114:
  mov    -0x28(%rbp),%rcx
  mov    -0x44(%rbp),%eax
  mov    $0x4,%edx
  mov    %rcx,%rsi
  mov    %eax,%edi
  call   <connect@plt>
  mov    %eax,-0x3c(%rbp)
  cmpl   $0xffffffff,-0x3c(%rbp)
  jne    L47
  mov    D110(%rip),%rax
  mov    (%rax),%edx
  mov    D126(%rip),%rax
  mov    (%rax),%eax
  cmp    %eax,%edx
  je     L114
L47:
  mov    D110(%rip),%rax
  mov    (%rax),%eax
  mov    %eax,-0x48(%rbp)
  cmpl   $0xffffffff,-0x3c(%rbp)
  jne    L136
  mov    D110(%rip),%rax
  mov    (%rax),%edx
  mov    D63(%rip),%rax
  mov    (%rax),%eax
  cmp    %eax,%edx
  je     L136
  mov    -0x44(%rbp),%eax
  mov    %eax,%edi
  call   <close@plt>
  movl   $0xfffffffd,-0x40(%rbp)
  nop
  mov    -0x30(%rbp),%rax
  mov    0x8(%rax),%rax
  mov    %rax,-0x30(%rbp)
L91:
  cmpq   $0x0,-0x30(%rbp)
  jne    L184
L136:
  mov    $0x0,%eax
  call   <Sactivate_thread@plt>
  mov    -0x58(%rbp),%rax
  mov    %rax,%rdi
  call   <Sunlock_object@plt>
  cmpq   $0x0,-0x60(%rbp)
  je     L206
  mov    -0x60(%rbp),%rax
  mov    %rax,%rdi
  call   <Sunlock_object@plt>
L206:
  mov    -0x38(%rbp),%rax
  mov    %rax,%rdi
  call   <freeaddrinfo@plt>
  mov    D110(%rip),%rax
  mov    -0x48(%rbp),%edx
  mov    %edx,(%rax)
  cmpl   $0x0,-0x40(%rbp)
  je     L127
  mov    -0x40(%rbp),%eax
  jmp    L6
L127:
  mov    -0x44(%rbp),%eax
L6:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L148
  call   <__stack_chk_fail@plt>
L148:
  leave
  ret
```

assistant: ```c
int ss_connect_to_ipv4_host_impl(const char *address, const char *service, unsigned short port, int blocking) {
  struct addrinfo hints;
  memset(&hints, 0, sizeof(hints));
  hints.ai_family = AF_INET;
  hints.ai_socktype = SOCK_STREAM;
  Slock_object((void *)address);
  if (service)
    Slock_object((void *)service);
  Sdeactivate_thread();
  struct addrinfo *info;
  int saved_errno = 0;
  if (getaddrinfo(address, service, &hints, &info) || info == NULL) {
    saved_errno = errno;
    Sactivate_thread();
    Sunlock_object((void *)address);
    if (service)
      Sunlock_object((void *)service);
    errno = saved_errno;
    return -1;
  }
  int sock;
  struct addrinfo *tmp;
  int err = 0;
  for (tmp = info; tmp != NULL; tmp = tmp->ai_next) {
    err = 0;
    sock = socket(AF_INET, SOCK_STREAM, 0);
    if (sock == -1) {
      saved_errno = errno;
      err = -2;
      break;
    }
    fcntl(sock, F_SETFD, fcntl(sock, F_GETFD) | FD_CLOEXEC);
    if (!blocking && !(ss_set_fd_non_blocking(sock))) {
      saved_errno = errno;
      close(sock);
      err = -2;
      break;
    }
    struct sockaddr *in = tmp->ai_addr;
    if (port > 0)
      ((struct sockaddr_in *)in)->sin_port = htons(port);
    int res;
    do {
      res = connect(sock, in, sizeof(struct sockaddr_in));
    } while (res == -1 && errno == EINTR);
    saved_errno = errno;
    if (res == -1 && errno != EINPROGRESS) {
      close(sock);
      err = -3;
      continue;
    } else
      break;
  }
  Sactivate_thread();
  Sunlock_object((void *)address);
  if (service)
    Sunlock_object((void *)service);
  freeaddrinfo(info);
  errno = saved_errno;
  if (err)
    return err;
  return sock;
}
```