user: What would the C source look like for the assembly code provided here?

```asm
<getListenSocket>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %rdi,-0x38(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  mov    D29(%rip),%rax
  mov    (%rax),%ecx
  mov    D10(%rip),%rax
  mov    (%rax),%rax
  mov    $0x0,%edx
  mov    %ecx,%esi
  mov    %rax,%rdi
  call   <socket@plt>
  mov    %eax,-0x24(%rbp)
  cmpl   $0x0,-0x24(%rbp)
  jns    L120
  mov    $0xffffffff,%eax
  jmp    L88
L120:
  movl   $0x1,-0x28(%rbp)
  mov    D52(%rip),%rax
  mov    (%rax),%edx
  mov    D77(%rip),%rax
  mov    (%rax),%esi
  lea    -0x28(%rbp),%rcx
  mov    -0x24(%rbp),%eax
  mov    $0x4,%r8d
  mov    %eax,%edi
  call   <setsockopt@plt>
  mov    -0x38(%rbp),%rax
  mov    (%rax),%eax
  test   %eax,%eax
  je     L46
  mov    D10(%rip),%rax
  mov    (%rax),%rax
  mov    %rax,-0x10(%rbp)
  mov    -0x38(%rbp),%rax
  mov    (%rax),%eax
  mov    %eax,%edi
  call   <htons@plt>
  mov    %rax,-0x18(%rbp)
  mov    D2(%rip),%rax
  mov    (%rax),%eax
  mov    %eax,%edi
  call   <htonl@plt>
  mov    %rax,-0x20(%rbp)
  lea    -0x20(%rbp),%rcx
  mov    -0x24(%rbp),%eax
  mov    $0x18,%edx
  mov    %rcx,%rsi
  mov    %eax,%edi
  call   <bind@plt>
  test   %rax,%rax
  jns    L47
  mov    $0xffffffff,%eax
  jmp    L88
L46:
  movl   $0x0,-0x28(%rbp)
L100:
  mov    D10(%rip),%rax
  mov    (%rax),%rax
  mov    %rax,-0x10(%rbp)
  mov    $0x0,%eax
  call   <random@plt>
  movslq %eax,%rdx
  imul   $0xffffffff82082083,%rdx,%rdx
  shr    $0x20,%rdx
  add    %eax,%edx
  sar    $0xf,%edx
  mov    %eax,%ecx
  sar    $0x1f,%ecx
  sub    %ecx,%edx
  imul   $0xfc00,%edx,%ecx
  sub    %ecx,%eax
  mov    %eax,%edx
  add    $0x400,%edx
  mov    -0x38(%rbp),%rax
  mov    %edx,(%rax)
  mov    -0x38(%rbp),%rax
  mov    (%rax),%eax
  mov    %eax,%edi
  call   <htons@plt>
  mov    %rax,-0x18(%rbp)
  mov    D2(%rip),%rax
  mov    (%rax),%eax
  mov    %eax,%edi
  call   <htonl@plt>
  mov    %rax,-0x20(%rbp)
  lea    -0x20(%rbp),%rcx
  mov    -0x24(%rbp),%eax
  mov    $0x18,%edx
  mov    %rcx,%rsi
  mov    %eax,%edi
  call   <bind@plt>
  test   %rax,%rax
  jns    L93
  mov    -0x28(%rbp),%eax
  cmp    $0x9,%eax
  jg     L44
  mov    -0x28(%rbp),%eax
  add    $0x1,%eax
  mov    %eax,-0x28(%rbp)
  jmp    L56
L44:
  mov    $0xffffffff,%eax
  jmp    L88
L56:
  jmp    L100
L93:
  nop
L47:
  mov    -0x24(%rbp),%eax
  mov    $0x8,%esi
  mov    %eax,%edi
  call   <listen@plt>
  test   %rax,%rax
  jns    L77
  mov    $0xffffffff,%eax
  jmp    L88
L77:
  mov    -0x24(%rbp),%eax
L88:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L31
  call   <__stack_chk_fail@plt>
L31:
  leave
  ret
```

assistant: ```c
int getListenSocket(uint16_t *desiredPort) {
  int sock, t;
  struct sockaddr_in addr;
  if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
    return -1;
  }
  t = 1;
  setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &t, sizeof(int));
  if (*desiredPort != 0) {
    addr.sin_family = AF_INET;
    addr.sin_port = htons(*desiredPort);
    addr.sin_addr.s_addr = htonl(INADDR_ANY);
    if (bind(sock, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
      return -1;
    }
  } else {
    t = 0;
    while (1) {
      addr.sin_family = AF_INET;
      *desiredPort = (random() % 64512) + 1024;
      addr.sin_port = htons(*desiredPort);
      addr.sin_addr.s_addr = htonl(INADDR_ANY);
      if (bind(sock, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
        if (t < 10) {
          ++t;
          continue;
        } else {
          return -1;
        }
      }
      break;
    }
  }
  if (listen(sock, 8) < 0) {
    return -1;
  }
  return sock;
}
```