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

```asm
<fgetns>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %r12
  push   %rbx
  sub    $0x20,%rsp
  mov    %rdi,%r12
  mov    %esi,-0x24(%rbp)
  mov    %rdx,-0x30(%rbp)
  mov    %ecx,-0x28(%rbp)
  mov    D16(%rip),%rax
  mov    (%rax),%ebx
  cmpl   $0x2,-0x28(%rbp)
  je     L205
  cmpl   $0x2,-0x28(%rbp)
  jg     L45
  cmpl   $0x0,-0x28(%rbp)
  je     L208
  cmpl   $0x1,-0x28(%rbp)
  je     L89
  jmp    L45
L205:
  mov    -0x24(%rbp),%edx
  mov    -0x30(%rbp),%rax
  mov    %r12,%rcx
  mov    $0x2,%esi
  mov    %rax,%rdi
  call   <fread@plt>
  jmp    L193
L89:
  mov    -0x24(%rbp),%edx
  mov    -0x30(%rbp),%rax
  mov    %r12,%rcx
  mov    $0x2,%esi
  mov    %rax,%rdi
  call   <fread@plt>
  mov    %eax,-0x1c(%rbp)
  mov    -0x30(%rbp),%rdx
  mov    -0x1c(%rbp),%eax
  mov    %rdx,%rsi
  mov    %eax,%edi
  call   <swap16@plt>
  mov    -0x1c(%rbp),%eax
  jmp    L193
L208:
  movl   $0x0,-0x20(%rbp)
  jmp    L185
L144:
  mov    $0x0,%esi
  mov    %r12,%rdi
  call   <fnextc@plt>
  mov    D16(%rip),%rdx
  mov    (%rdx),%edx
  cmp    %edx,%eax
  jne    L9
  mov    -0x20(%rbp),%eax
  jmp    L193
L9:
  movl   $0x0,-0x14(%rbp)
  mov    -0x14(%rbp),%eax
  mov    %eax,-0x18(%rbp)
  mov    -0x18(%rbp),%eax
  mov    %eax,-0x1c(%rbp)
  mov    %r12,%rdi
  call   <getc@plt>
  mov    %eax,%ebx
  cmp    $0x2d,%ebx
  jne    L55
  movl   $0x1,-0x18(%rbp)
  mov    %r12,%rdi
  call   <getc@plt>
  mov    %eax,%ebx
  jmp    L55
L26:
  mov    -0x1c(%rbp),%edx
  mov    %edx,%eax
  shl    $0x2,%eax
  add    %edx,%eax
  add    %eax,%eax
  add    %ebx,%eax
  sub    $0x30,%eax
  mov    %eax,-0x1c(%rbp)
  movl   $0x1,-0x14(%rbp)
  mov    %r12,%rdi
  call   <getc@plt>
  mov    %eax,%ebx
L55:
  cmp    $0x2f,%ebx
  jle    L121
  cmp    $0x39,%ebx
  jle    L26
L121:
  cmpl   $0x0,-0x14(%rbp)
  je     L173
  cmpl   $0x0,-0x18(%rbp)
  je     L148
  mov    -0x1c(%rbp),%eax
  neg    %eax
  mov    %eax,%edx
  jmp    L191
L148:
  mov    -0x1c(%rbp),%eax
  mov    %eax,%edx
L191:
  mov    -0x20(%rbp),%eax
  cltq
  lea    (%rax,%rax,1),%rcx
  mov    -0x30(%rbp),%rax
  add    %rcx,%rax
  mov    %dx,(%rax)
  addl   $0x1,-0x20(%rbp)
L185:
  mov    -0x20(%rbp),%eax
  cmp    -0x24(%rbp),%eax
  jl     L144
  jmp    L71
L173:
  nop
L71:
  mov    D16(%rip),%rax
  mov    (%rax),%eax
  cmp    %eax,%ebx
  je     L49
  mov    %r12,%rsi
  mov    %ebx,%edi
  call   <ungetc@plt>
L49:
  mov    -0x20(%rbp),%eax
  jmp    L193
L45:
  mov    $0xffffffff,%eax
L193:
  add    $0x20,%rsp
  pop    %rbx
  pop    %r12
  pop    %rbp
  ret
```

assistant: ```c
int fgetns(register FILE *f, int maxs, short *sv, int binary) {
  int ngot;
  register int c = EOF;
  int n;
  int s, any;
  switch (binary) {
  case 2:
    return fread((char *)sv, sizeof(*sv), maxs, f);
  case 1:
    n = fread((char *)sv, sizeof(*sv), maxs, f);
    swap16(n, (unsigned short *)sv);
    return n;
  case 0:
    for (ngot = 0; ngot < maxs; ngot++) {
      if (fnextc(f, 0) == EOF)
        return (ngot);
      n = s = any = 0;
      if ((c = getc(f)) == '-') {
        s = 1;
        c = getc(f);
      }
      while (c >= '0' && c <= '9') {
        n = n * 10 + c - '0';
        any = 1;
        c = getc(f);
      }
      if (!any)
        break;
      sv[ngot] = s ? -n : n;
    }
    if (c != EOF)
      ungetc(c, f);
    return (ngot);
  }
  return -1;
}
```