user: Demonstrate the C code that generates the assembly output below:

```asm
<bindresvport>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %edi,-0x34(%rbp)
  mov    %rsi,-0x40(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  cmpq   $0x0,-0x40(%rbp)
  jne    L12
  lea    -0x20(%rbp),%rax
  mov    %rax,-0x40(%rbp)
  mov    -0x40(%rbp),%rax
  mov    $0x10,%esi
  mov    %rax,%rdi
  call   <__bzero@plt>
  mov    D10(%rip),%rax
  mov    (%rax),%rdx
  mov    -0x40(%rbp),%rax
  mov    %rdx,(%rax)
  jmp    L84
L12:
  mov    -0x40(%rbp),%rax
  mov    (%rax),%rdx
  mov    D10(%rip),%rax
  mov    (%rax),%rax
  cmp    %rax,%rdx
  je     L84
  mov    D86(%rip),%rax
  mov    (%rax),%eax
  mov    %eax,%edi
  call   <__set_errno@plt>
  mov    $0xffffffff,%eax
  jmp    L0
L84:
  movzwl D37(%rip),%eax
  test   %ax,%ax
  jne    L55
  mov    $0x0,%eax
  call   <__getpid@plt>
  mov    D23(%rip),%rdx
  mov    (%rdx),%edx
  lea    -0x258(%rdx),%ecx
  cltd
  idiv   %ecx
  mov    %edx,%eax
  add    $0x258,%ax
  mov    %ax,D139(%rip)
L55:
  movl   $0xffffffff,-0x2c(%rbp)
  mov    D23(%rip),%rax
  mov    (%rax),%eax
  lea    -0x1(%rax),%edx
  movzwl D139(%rip),%eax
  movswl %ax,%ecx
  mov    %edx,%eax
  sub    %ecx,%eax
  add    $0x1,%eax
  mov    %eax,-0x28(%rbp)
  mov    D23(%rip),%rax
  mov    (%rax),%eax
  sub    $0x1,%eax
  mov    %eax,-0x24(%rbp)
L45:
  movl   $0x0,-0x30(%rbp)
  jmp    L111
L39:
  movzwl D139(%rip),%eax
  mov    %eax,%edx
  add    $0x1,%edx
  mov    %dx,D144(%rip)
  cwtl
  mov    %eax,%edi
  call   <htons@plt>
  mov    -0x40(%rbp),%rdx
  mov    %eax,0x8(%rdx)
  movzwl D144(%rip),%eax
  cwtl
  cmp    %eax,-0x24(%rbp)
  jge    L139
  movzwl D139(%rip),%eax
  mov    %ax,D144(%rip)
L139:
  mov    -0x40(%rbp),%rcx
  mov    -0x34(%rbp),%eax
  mov    $0x10,%edx
  mov    %rcx,%rsi
  mov    %eax,%edi
  call   <__bind@plt>
  mov    %eax,-0x2c(%rbp)
  cmpl   $0x0,-0x2c(%rbp)
  jns    L56
  mov    D144(%rip),%rax
  mov    (%rax),%rdx
  mov    D103(%rip),%rax
  mov    (%rax),%rax
  cmp    %rax,%rdx
  jne    L56
  addl   $0x1,-0x30(%rbp)
L111:
  mov    -0x30(%rbp),%eax
  cmp    -0x28(%rbp),%eax
  jl     L39
L56:
  mov    -0x30(%rbp),%eax
  cmp    -0x28(%rbp),%eax
  jne    L92
  movzwl D139(%rip),%eax
  cmp    $0x200,%ax
  je     L92
  movw   $0x200,D139(%rip)
  movl   $0x257,-0x24(%rbp)
  movl   $0x58,-0x28(%rbp)
  movzwl D144(%rip),%ecx
  movswl %cx,%eax
  imul   $0xba3,%eax,%eax
  shr    $0x10,%eax
  sar    $0x2,%ax
  mov    %ecx,%esi
  sar    $0xf,%si
  sub    %esi,%eax
  mov    %eax,%edx
  mov    %edx,%eax
  shl    $0x2,%eax
  add    %edx,%eax
  add    %eax,%eax
  add    %edx,%eax
  shl    $0x3,%eax
  sub    %eax,%ecx
  mov    %ecx,%edx
  mov    %edx,%eax
  add    $0x200,%ax
  mov    %ax,D170(%rip)
  jmp    L45
L92:
  mov    -0x2c(%rbp),%eax
L0:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L68
  call   <__stack_chk_fail@plt>
L68:
  leave
  ret
```

assistant: ```c
int bindresvport(int sd, struct sockaddr_in *sin) {
  static short port;
  struct sockaddr_in myaddr;
  int i;
  static short startport = 600;
  if (sin == (struct sockaddr_in *)0) {
    sin = &myaddr;
    __bzero(sin, sizeof(*sin));
    sin->sin_family = AF_INET;
  } else if (sin->sin_family != AF_INET) {
    __set_errno(EAFNOSUPPORT);
    return -1;
  }
  if (port == 0) {
    port = (__getpid() % ((IPPORT_RESERVED - 1) - 600 + 1)) + 600;
  }
  int res = -1;
  int nports = (IPPORT_RESERVED - 1) - startport + 1;
  int endport = (IPPORT_RESERVED - 1);
again:
  for (i = 0; i < nports; ++i) {
    sin->sin_port = htons(port++);
    if (port > endport)
      port = startport;
    res = __bind(sd, sin, sizeof(struct sockaddr_in));
    if (res >= 0 || errno != EADDRINUSE)
      break;
  }
  if (i == nports && startport != 512) {
    startport = 512;
    endport = 600 - 1;
    nports = 600 - 512;
    port = 512 + port % (600 - 512);
    goto again;
  }
  return res;
}
```