user: 请从给定的汇编指令推导出C源代码:

```asm
<sing_rot>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %rdi,-0x18(%rbp)
  mov    %esi,-0x1c(%rbp)
  mov    %edx,-0x20(%rbp)
  mov    %ecx,-0x24(%rbp)
  mov    -0x1c(%rbp),%eax
  cltq
  add    $0x1,%rax
  lea    0x0(,%rax,4),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  mov    %eax,-0x8(%rbp)
  mov    -0x20(%rbp),%eax
  cltq
  mov    -0x24(%rbp),%edx
  movslq %edx,%rdx
  sub    %rdx,%rax
  add    $0x1,%rax
  lea    0x0(,%rax,4),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  mov    %eax,-0x4(%rbp)
  mov    -0x20(%rbp),%eax
  cltq
  mov    -0x24(%rbp),%edx
  movslq %edx,%rdx
  sub    %rdx,%rax
  add    $0x1,%rax
  lea    0x0(,%rax,4),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    -0x1c(%rbp),%edx
  movslq %edx,%rcx
  mov    -0x24(%rbp),%edx
  movslq %edx,%rdx
  add    %rcx,%rdx
  add    $0x1,%rdx
  lea    0x0(,%rdx,4),%rcx
  mov    -0x18(%rbp),%rdx
  add    %rcx,%rdx
  mov    (%rax),%eax
  mov    %eax,(%rdx)
  mov    -0x20(%rbp),%eax
  cltq
  mov    -0x24(%rbp),%edx
  movslq %edx,%rdx
  sub    %rdx,%rax
  add    $0x1,%rax
  lea    0x0(,%rax,4),%rdx
  mov    -0x18(%rbp),%rax
  add    %rax,%rdx
  mov    -0x1c(%rbp),%eax
  mov    %eax,(%rdx)
  mov    -0x1c(%rbp),%eax
  cltq
  add    $0x3,%rax
  lea    0x0(,%rax,4),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%edx
  mov    -0x20(%rbp),%eax
  cltq
  add    $0x3,%rax
  lea    0x0(,%rax,4),%rcx
  mov    -0x18(%rbp),%rax
  add    %rcx,%rax
  mov    (%rax),%ecx
  mov    -0x1c(%rbp),%eax
  cltq
  add    $0x3,%rax
  lea    0x0(,%rax,4),%rsi
  mov    -0x18(%rbp),%rax
  add    %rsi,%rax
  sub    %ecx,%edx
  mov    %edx,(%rax)
  mov    -0x1c(%rbp),%eax
  cltq
  add    $0x3,%rax
  lea    0x0(,%rax,4),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%edx
  mov    -0x20(%rbp),%eax
  cltq
  add    $0x3,%rax
  lea    0x0(,%rax,4),%rcx
  mov    -0x18(%rbp),%rax
  add    %rcx,%rax
  neg    %edx
  mov    %edx,(%rax)
  cmpl   $0x0,-0x8(%rbp)
  jle    L36
  mov    -0x8(%rbp),%eax
  cltq
  add    $0x1,%rax
  lea    0x0(,%rax,4),%rdx
  mov    -0x8(%rbp),%eax
  cltq
  add    $0x1,%rax
  shl    $0x2,%rax
  lea    -0x4(%rax),%rcx
  mov    -0x18(%rbp),%rax
  add    %rcx,%rax
  mov    (%rax),%eax
  cmp    %eax,-0x1c(%rbp)
  jne    L33
  mov    $0xfffffffffffffffc,%rax
  jmp    L11
L33:
  mov    $0x4,%eax
L11:
  add    %rax,%rdx
  mov    -0x18(%rbp),%rax
  add    %rax,%rdx
  mov    -0x20(%rbp),%eax
  mov    %eax,(%rdx)
  jmp    L18
L36:
  mov    -0x18(%rbp),%rax
  lea    0x4(%rax),%rdx
  mov    -0x20(%rbp),%eax
  mov    %eax,(%rdx)
L18:
  mov    -0x20(%rbp),%eax
  cltq
  add    $0x1,%rax
  lea    0x0(,%rax,4),%rdx
  mov    -0x18(%rbp),%rax
  add    %rax,%rdx
  mov    -0x8(%rbp),%eax
  mov    %eax,(%rdx)
  mov    -0x1c(%rbp),%eax
  cltq
  add    $0x1,%rax
  lea    0x0(,%rax,4),%rdx
  mov    -0x18(%rbp),%rax
  add    %rax,%rdx
  mov    -0x20(%rbp),%eax
  mov    %eax,(%rdx)
  cmpl   $0x0,-0x4(%rbp)
  je     L9
  mov    -0x4(%rbp),%eax
  cltq
  add    $0x1,%rax
  lea    0x0(,%rax,4),%rdx
  mov    -0x18(%rbp),%rax
  add    %rax,%rdx
  mov    -0x1c(%rbp),%eax
  mov    %eax,(%rdx)
L9:
  nop
  pop    %rbp
  ret
```

assistant: ```c
void sing_rot(int *root, int parent, int child, int dir) {
  int gparent = *(root + parent + 1);
  int gchild = *(root + child + 1 - dir);
  *(root + parent + 1 + dir) = *(root + child + 1 - dir);
  *(root + child + 1 - dir) = parent;
  *(root + parent + 3) -= *(root + child + 3);
  *(root + child + 3) = -(*(root + parent + 3));
  if (gparent > 0)
    *(root + gparent + 1 + (*(root + gparent + 1 + -1) == parent ? -1 : 1)) = child;
  else
    *(root + 1) = child;
  *(root + child + 1) = gparent;
  *(root + parent + 1) = child;
  if (gchild)
    *(root + gchild + 1) = parent;
}
```