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

```asm
<lw_sock_connect>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x60,%rsp
  mov    %rdi,-0x48(%rbp)
  mov    %rsi,-0x50(%rbp)
  mov    %edx,-0x54(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  movl   $0x0,-0x34(%rbp)
  movl   $0x1,-0x3c(%rbp)
  movl   $0x0,-0x38(%rbp)
  mov    D99(%rip),%rax
  mov    (%rax),%ecx
  mov    D65(%rip),%rax
  mov    (%rax),%rax
  mov    $0x0,%edx
  mov    %ecx,%esi
  mov    %rax,%rdi
  call   <socket@plt>
  mov    -0x48(%rbp),%rdx
  mov    %eax,(%rdx)
  mov    -0x48(%rbp),%rax
  mov    (%rax),%eax
  test   %eax,%eax
  js     L23
  mov    D65(%rip),%rax
  mov    (%rax),%rax
  mov    %rax,-0x10(%rbp)
  mov    D50(%rip),%rax
  mov    (%rax),%eax
  mov    %eax,-0x18(%rbp)
  movq   $0x0,-0x20(%rbp)
  mov    -0x48(%rbp),%rax
  mov    (%rax),%eax
  lea    -0x20(%rbp),%rcx
  mov    $0x18,%edx
  mov    %rcx,%rsi
  mov    %eax,%edi
  call   <bind@plt>
  test   %rax,%rax
  js     L23
  mov    D65(%rip),%rax
  mov    (%rax),%rax
  mov    %rax,-0x10(%rbp)
  lea    -0x20(%rbp),%rax
  lea    0x8(%rax),%rdx
  mov    -0x50(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <inet_aton@plt>
  test   %rax,%rax
  je     L23
  mov    -0x54(%rbp),%eax
  mov    %eax,%edi
  call   <htons@plt>
  mov    %rax,-0x20(%rbp)
  mov    -0x48(%rbp),%rax
  mov    (%rax),%eax
  lea    -0x20(%rbp),%rcx
  mov    $0x18,%edx
  mov    %rcx,%rsi
  mov    %eax,%edi
  call   <connect@plt>
  test   %rax,%rax
  js     L23
  movq   $0x0,-0x28(%rbp)
  movq   $0x0,-0x30(%rbp)
  mov    D117(%rip),%rax
  mov    (%rax),%edx
  mov    D128(%rip),%rax
  mov    (%rax),%esi
  mov    -0x48(%rbp),%rax
  mov    (%rax),%eax
  lea    -0x3c(%rbp),%rcx
  mov    $0x4,%r8d
  mov    %eax,%edi
  call   <setsockopt@plt>
  mov    D49(%rip),%rax
  mov    (%rax),%edx
  mov    D128(%rip),%rax
  mov    (%rax),%esi
  mov    -0x48(%rbp),%rax
  mov    (%rax),%eax
  lea    -0x38(%rbp),%rcx
  mov    $0x4,%r8d
  mov    %eax,%edi
  call   <setsockopt@plt>
  mov    D15(%rip),%rax
  mov    (%rax),%edx
  mov    D128(%rip),%rax
  mov    (%rax),%esi
  mov    -0x48(%rbp),%rax
  mov    (%rax),%eax
  lea    -0x30(%rbp),%rcx
  mov    $0x10,%r8d
  mov    %eax,%edi
  call   <setsockopt@plt>
  mov    D42(%rip),%rax
  mov    (%rax),%edx
  mov    D105(%rip),%rax
  mov    (%rax),%esi
  mov    -0x48(%rbp),%rax
  mov    (%rax),%eax
  mov    $0x0,%ecx
  mov    %eax,%edi
  call   <fcntl@plt>
  movl   $0x1,-0x34(%rbp)
L23:
  mov    -0x34(%rbp),%eax
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L17
  call   <__stack_chk_fail@plt>
L17:
  leave
  ret
```

assistant: ```c
int lw_sock_connect(int *sock, char *ip, int port) {
  int result = 0;
  struct sockaddr_in name;
  int enable = 1;
  int disable = 0;
  struct linger li;
  *sock = socket(AF_INET, SOCK_STREAM, 0);
  if (*sock >= 0) {
    name.sin_family = AF_INET;
    name.sin_addr.s_addr = INADDR_ANY;
    name.sin_port = 0;
    if (bind(*sock, (struct sockaddr *)&name, sizeof name) >= 0) {
      name.sin_family = AF_INET;
      if (inet_aton(ip, &name.sin_addr) != 0) {
        name.sin_port = htons(port);
        if (connect((*sock), (struct sockaddr *)&name, sizeof name) >= 0) {
          li.l_onoff = 0;
          li.l_linger = 0;
          setsockopt(*sock, SOL_SOCKET, SO_KEEPALIVE, (char *)&enable, sizeof(int));
          setsockopt(*sock, SOL_SOCKET, SO_OOBINLINE, (char *)&disable, sizeof(int));
          setsockopt(*sock, SOL_SOCKET, SO_LINGER, (char *)&li, sizeof(struct linger));
          fcntl(*sock, F_SETFL, O_NONBLOCK, 0);
          result = 1;
        }
      }
    }
  }
  return result;
}
```