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

```asm
<rebuildchain>:
  endbr64
  push   %rbp
  mov    %rdx,%r11
  mov    %rsp,%rbp
  push   %r14
  push   %r13
  push   %r12
  push   %rbx
  sub    $0x10,%rsp
  mov    (%rcx),%r13d
  mov    %fs:0x28,%rax
  mov    %rax,-0x28(%rbp)
  xor    %eax,%eax
  cmp    $0x1,%r13d
  je     L138
  mov    (%rdx),%edx
  mov    %rcx,%r12
  mov    %rsp,%rcx
  mov    %rsp,%rbx
  lea    0xf(,%rdx,4),%r8
  mov    %r8,%rax
  shr    $0x4,%rax
  shl    $0x4,%rax
  mov    %rax,%r9
  and    $0xfffffffffffff000,%r9
  sub    %r9,%rcx
  cmp    %rcx,%rsp
  je     L71
L77:
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  cmp    %rcx,%rsp
  jne    L77
L71:
  and    $0xfff,%eax
  sub    %rax,%rsp
  test   %rax,%rax
  jne    L64
L20:
  shr    $0x4,%r8
  mov    %rsp,%rax
  mov    %rsp,%rcx
  shl    $0x4,%r8
  mov    %r8,%r9
  and    $0xfffffffffffff000,%r9
  sub    %r9,%rax
L31:
  cmp    %rax,%rsp
  je     L102
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  jmp    L31
  cs nopw 0x0(%rax,%rax,1)
L138:
  mov    0x4(%rdi),%edx
  mov    (%r11),%eax
  mov    %edx,(%rdi,%rax,4)
  mov    0x4(%rsi),%edx
  mov    (%r11),%eax
  mov    %edx,(%rsi,%rax,4)
  movl   $0x320,0x4(%rdi)
  movl   $0x320,0x4(%rsi)
L91:
  mov    -0x28(%rbp),%rax
  sub    %fs:0x28,%rax
  jne    L134
  lea    -0x20(%rbp),%rsp
  pop    %rbx
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %rbp
  ret
L64:
  orq    $0x0,-0x8(%rsp,%rax,1)
  jmp    L20
L102:
  and    $0xfff,%r8d
  sub    %r8,%rsp
  test   %r8,%r8
  jne    L63
L147:
  mov    %r13d,%eax
  mov    %rsp,%r8
  mov    (%rdi,%rax,4),%r14d
  mov    (%rsi,%rax,4),%r10d
  lea    0x1(%r13),%eax
  mov    %r14d,(%rcx,%rdx,4)
  mov    %r10d,(%r8,%rdx,4)
  mov    $0x1,%edx
  jmp    L24
  nop
L32:
  mov    %eax,%edx
  add    $0x1,%eax
  mov    (%rdi,%rdx,4),%r14d
  mov    (%rsi,%rdx,4),%r10d
  mov    %r9d,%edx
L24:
  mov    %edx,%r9d
  mov    %eax,(%r12)
  mov    %r14d,(%rcx,%r9,4)
  mov    %r10d,(%r8,%r9,4)
  lea    0x1(%rdx),%r9d
  cmp    %eax,(%r11)
  jne    L32
  movl   $0x1,(%r12)
  mov    $0x1,%eax
  nopl   (%rax)
L6:
  mov    %eax,%r10d
  lea    (%rdx,%rax,1),%r9d
  add    $0x1,%eax
  mov    (%rdi,%r10,4),%r14d
  mov    (%rsi,%r10,4),%r10d
  mov    %eax,(%r12)
  mov    %r14d,(%rcx,%r9,4)
  mov    %r10d,(%r8,%r9,4)
  cmp    %eax,%r13d
  jne    L6
  movl   $0x1,(%r12)
  mov    $0x1,%edx
  nopl   0x0(%rax,%rax,1)
L115:
  mov    %edx,%eax
  mov    (%rcx,%rax,4),%r9d
  mov    %r9d,(%rdi,%rax,4)
  mov    (%r8,%rax,4),%r9d
  mov    %r9d,(%rsi,%rax,4)
  mov    %edx,%eax
  add    $0x1,%edx
  cmp    %eax,(%r11)
  jne    L115
  movl   $0x320,0x4(%rdi)
  movl   $0x320,0x4(%rsi)
  mov    %rbx,%rsp
  jmp    L91
L63:
  orq    $0x0,-0x8(%rsp,%r8,1)
  jmp    L147
L134:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
void rebuildchain(unsigned int *x, unsigned int *y, unsigned int *LENGTH, unsigned int *mv) {
  if (*mv == 1) {
    x[*LENGTH] = x[1];
    y[*LENGTH] = y[1];
    x[1] = ((100) * 8);
    y[1] = ((100) * 8);
    return;
  }
  unsigned int count = 1, Nmv = *mv;
  unsigned int xn[*LENGTH], yn[*LENGTH];
  xn[*LENGTH] = x[*mv];
  yn[*LENGTH] = y[*mv];
  do {
    xn[count] = x[*mv];
    yn[count] = y[*mv];
    count++;
    (*mv)++;
  } while (*mv != *LENGTH);
  *mv = 1;
  do {
    xn[count] = x[*mv];
    yn[count] = y[*mv];
    count++;
    (*mv)++;
  } while (*mv != Nmv);
  count = 1;
  *mv = 1;
  do {
    x[count] = xn[count];
    y[count] = yn[count];
    count++;
  } while (count != (*LENGTH + 1));
  x[1] = ((100) * 8);
  y[1] = ((100) * 8);
}
```