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

```asm
<rclose>:
  endbr64
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0xb0,%rsp
  mov    %rdi,%r13
  mov    %esi,%ebx
  mov    %fs:0x28,%rax
  mov    %rax,0xa8(%rsp)
  xor    %eax,%eax
  movabs $0x65736f6c6372,%rax
  mov    $0x0,%edx
  mov    %rax,(%rsp)
  mov    %rdx,0x8(%rsp)
  movq   $0x0,0x10(%rsp)
  movq   $0x0,0x18(%rsp)
  movq   $0x0,0x20(%rsp)
  movq   $0x0,0x28(%rsp)
  movq   $0x0,0x30(%rsp)
  movq   $0x0,0x38(%rsp)
  movq   $0x0,0x40(%rsp)
  movq   $0x0,0x48(%rsp)
  movq   $0x0,0x50(%rsp)
  movq   $0x0,0x58(%rsp)
  movq   $0x0,0x60(%rsp)
  movq   $0x0,0x68(%rsp)
  movq   $0x0,0x70(%rsp)
  movq   $0x0,0x78(%rsp)
  movq   $0x0,0x80(%rsp)
  movq   $0x0,0x88(%rsp)
  movq   $0x0,0x90(%rsp)
  movq   $0x0,0x98(%rsp)
  test   %esi,%esi
  js     L23
  cmp    $0x3,%esi
  ja     L144
  mov    $0x1,%r14d
  mov    $0x0,%r12d
  jmp    L142
L23:
  mov    %esi,%eax
  neg    %eax
  mov    $0x0,%r14d
  cmp    $0x3,%eax
  jbe    L75
L2:
  mov    %rsp,%rsi
  mov    %ebx,%edx
  lea    D11(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    $0x2,%r12d
L142:
  mov    0x0(%r13),%ebp
  test   %ebp,%ebp
  jle    L55
  cmp    $0x2,%ebx
  jle    L76
L104:
  test   %r14d,%r14d
  jne    L125
L47:
  movl   $0x0,0x0(%r13)
  mov    0xa8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L128
  mov    %r12d,%eax
  add    $0xb0,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
L144:
  mov    $0x1,%r14d
  jmp    L2
L75:
  mov    %eax,%ebx
  mov    $0x0,%r14d
  mov    $0x0,%r12d
  jmp    L142
L76:
  mov    %ebx,%esi
  mov    %ebp,%edi
  call   <shutdown@plt>
  test   %eax,%eax
  je     L104
  mov    %rsp,%rdx
  lea    0x20(%rsp),%r12
  mov    %eax,%r8d
  mov    %ebx,%ecx
  lea    D8(%rip),%rsi
  mov    %r12,%rdi
  mov    $0x0,%eax
  call   <sprintf@plt>
  mov    %r12,%rdi
  call   <perror@plt>
  mov    $0xffffffff,%r12d
  jmp    L104
L125:
  mov    %ebp,%edi
  call   <close@plt>
  test   %eax,%eax
  je     L47
  mov    %rsp,%rdx
  lea    0x20(%rsp),%rbx
  mov    %eax,%ecx
  lea    D34(%rip),%rsi
  mov    %rbx,%rdi
  mov    $0x0,%eax
  call   <sprintf@plt>
  mov    %rbx,%rdi
  call   <perror@plt>
  mov    $0xfffffffe,%r12d
  jmp    L47
L55:
  mov    %rsp,%rsi
  mov    %ebp,%edx
  lea    D12(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    $0x1,%r12d
  jmp    L47
L128:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: read_data
arguments: label: D11
datatype: string
name: read_data
arguments: label: D8
datatype: string
name: read_data
arguments: label: D34
datatype: string
name: read_data
arguments: label: D12
datatype: string

tool: D11: -E- %s: invalid shutdown mode: %d


tool: D8: -E- %s: shutdown(%d) rc = %d

tool: D34: -E- %s: close rc = %d

tool: D12: -E- %s: invalid socket: %d


assistant: ```c
int rclose(int *piSocket, int iMode) {
  int iSocket;
  int iRC;
  int iDebug = 0;
  int iError = 0;
  int iClose = 1;
  char cModule[32] = "rclose";
  char cMsg[128] = "";
  if (iMode < 0) {
    iMode = -iMode;
    iClose = 0;
  }
  if ((iMode < 0) || (iMode > 3)) {
    if (iClose == 0)
      iMode = -iMode;
    printf("-E- %s: invalid shutdown mode: %d\n", cModule, iMode);
    iError = 2;
  }
  iSocket = *piSocket;
  if (iSocket > 0) {
    if (iMode < 3) {
      iRC = shutdown(iSocket, iMode);
      if (iRC) {
        sprintf(cMsg, "-E- %s: shutdown(%d) rc = %d", cModule, iMode, iRC);
        perror(cMsg);
        iError = -1;
      } else if (iDebug)
        printf("    %s: shutdown(%d) successfull\n", cModule, iMode);
    }
    if (iClose) {
      iRC = close(iSocket);
      if (iRC) {
        sprintf(cMsg, "-E- %s: close rc = %d", cModule, iRC);
        perror(cMsg);
        iError = -2;
      } else if (iDebug)
        printf("    %s: connection closed\n", cModule);
    }
  } else {
    printf("-E- %s: invalid socket: %d\n", cModule, iSocket);
    iError = 1;
  }
  *piSocket = 0;
  return (iError);
}
```