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

```asm
<dub_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    -0x4(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x24(%rbp),%eax
  cltq
  add    %rdx,%rax
  add    $0x1,%rax
  lea    0x0(,%rax,4),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    -0x20(%rbp),%edx
  movslq %edx,%rdx
  mov    -0x24(%rbp),%ecx
  movslq %ecx,%rcx
  sub    %rcx,%rdx
  add    $0x1,%rdx
  lea    0x0(,%rdx,4),%rcx
  mov    -0x18(%rbp),%rdx
  add    %rcx,%rdx
  mov    (%rax),%eax
  mov    %eax,(%rdx)
  mov    -0x4(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x24(%rbp),%eax
  cltq
  add    %rdx,%rax
  add    $0x1,%rax
  lea    0x0(,%rax,4),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  test   %eax,%eax
  je     L56
  mov    -0x4(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x24(%rbp),%eax
  cltq
  add    %rdx,%rax
  add    $0x1,%rax
  lea    0x0(,%rax,4),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  cltq
  add    $0x1,%rax
  lea    0x0(,%rax,4),%rdx
  mov    -0x18(%rbp),%rax
  add    %rax,%rdx
  mov    -0x20(%rbp),%eax
  mov    %eax,(%rdx)
L56:
  mov    -0x4(%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    -0x4(%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
  test   %eax,%eax
  je     L95
  mov    -0x4(%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
  cltq
  add    $0x1,%rax
  lea    0x0(,%rax,4),%rdx
  mov    -0x18(%rbp),%rax
  add    %rax,%rdx
  mov    -0x1c(%rbp),%eax
  mov    %eax,(%rdx)
L95:
  mov    -0x4(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x24(%rbp),%eax
  cltq
  add    %rdx,%rax
  add    $0x1,%rax
  lea    0x0(,%rax,4),%rdx
  mov    -0x18(%rbp),%rax
  add    %rax,%rdx
  mov    -0x20(%rbp),%eax
  mov    %eax,(%rdx)
  mov    -0x4(%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    -0x4(%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),%eax
  cmp    %eax,%edx
  jne    L18
  mov    -0x20(%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)
  jmp    L84
L18:
  mov    -0x20(%rbp),%eax
  cltq
  add    $0x3,%rax
  lea    0x0(,%rax,4),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  movl   $0x0,(%rax)
L84:
  mov    -0x4(%rbp),%eax
  cltq
  add    $0x3,%rax
  lea    0x0(,%rax,4),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%edx
  mov    -0x1c(%rbp),%eax
  cltq
  add    $0x3,%rax
  lea    0x0(,%rax,4),%rcx
  mov    -0x18(%rbp),%rax
  add    %rcx,%rax
  mov    (%rax),%eax
  cmp    %eax,%edx
  jne    L90
  mov    -0x1c(%rbp),%eax
  cltq
  add    $0x3,%rax
  lea    0x0(,%rax,4),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%edx
  mov    -0x1c(%rbp),%eax
  cltq
  add    $0x3,%rax
  lea    0x0(,%rax,4),%rcx
  mov    -0x18(%rbp),%rax
  add    %rcx,%rax
  neg    %edx
  mov    %edx,(%rax)
  jmp    L25
L90:
  mov    -0x1c(%rbp),%eax
  cltq
  add    $0x3,%rax
  lea    0x0(,%rax,4),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  movl   $0x0,(%rax)
L25:
  mov    -0x4(%rbp),%eax
  cltq
  add    $0x3,%rax
  lea    0x0(,%rax,4),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  movl   $0x0,(%rax)
  mov    -0x20(%rbp),%eax
  cltq
  add    $0x1,%rax
  lea    0x0(,%rax,4),%rdx
  mov    -0x18(%rbp),%rax
  add    %rax,%rdx
  mov    -0x4(%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    -0x4(%rbp),%eax
  mov    %eax,(%rdx)
  mov    -0x4(%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)
  cmpl   $0x0,-0x8(%rbp)
  jle    L83
  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    L81
  mov    $0xfffffffffffffffc,%rax
  jmp    L72
L81:
  mov    $0x4,%eax
L72:
  add    %rax,%rdx
  mov    -0x18(%rbp),%rax
  add    %rax,%rdx
  mov    -0x4(%rbp),%eax
  mov    %eax,(%rdx)
  jmp    L14
L83:
  mov    -0x18(%rbp),%rax
  lea    0x4(%rax),%rdx
  mov    -0x4(%rbp),%eax
  mov    %eax,(%rdx)
L14:
  nop
  pop    %rbp
  ret
```

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