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

```asm
<CreateUmtsInterleaver>:
  endbr64
  movabs $0x500000002,%rcx
  push   %r15
  mov    %edi,%r11d
  movabs $0x500000003,%r9
  movabs $0x600000002,%r8
  push   %r14
  movabs $0x500000007,%r10
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  mov    %rsi,%rbx
  movabs $0x300000002,%rsi
  sub    $0x328,%rsp
  mov    %edi,0x20(%rsp)
  movabs $0x110000000d,%rdi
  mov    %rdx,0x70(%rsp)
  movabs $0x200000002,%rdx
  mov    %fs:0x28,%rax
  mov    %rax,0x318(%rsp)
  movabs $0xb00000007,%rax
  mov    %rdi,0x178(%rsp)
  mov    %rax,0x170(%rsp)
  movabs $0x1700000013,%rax
  mov    %rax,0x180(%rsp)
  movabs $0x1f0000001d,%rax
  mov    %rax,0x188(%rsp)
  movabs $0x2900000025,%rax
  mov    %rax,0x190(%rsp)
  movabs $0x2f0000002b,%rax
  mov    %rax,0x198(%rsp)
  movabs $0x3b00000035,%rax
  mov    %rax,0x1a0(%rsp)
  movabs $0x430000003d,%rax
  mov    %rax,0x1a8(%rsp)
  movabs $0x4900000047,%rax
  mov    %rax,0x1b0(%rsp)
  movabs $0x530000004f,%rax
  mov    %rax,0x1b8(%rsp)
  movabs $0x6100000059,%rax
  mov    %rax,0x1c0(%rsp)
  movabs $0x6700000065,%rax
  mov    %rax,0x1c8(%rsp)
  movabs $0x6d0000006b,%rax
  mov    %rax,0x1d0(%rsp)
  movabs $0x7f00000071,%rax
  mov    %rax,0x1d8(%rsp)
  movabs $0x8900000083,%rax
  mov    %rax,0x1e0(%rsp)
  movabs $0x950000008b,%rax
  mov    %rax,0x1e8(%rsp)
  movabs $0x9d00000097,%rax
  mov    %rax,0x1f0(%rsp)
  movabs $0xa7000000a3,%rax
  mov    %rax,0x1f8(%rsp)
  movabs $0xb3000000ad,%rax
  mov    %rax,0x200(%rsp)
  movabs $0xbf000000b5,%rax
  mov    %rax,0x208(%rsp)
  movabs $0xc5000000c1,%rax
  mov    %rax,0x210(%rsp)
  movabs $0xd3000000c7,%rax
  mov    %rax,0x218(%rsp)
  movabs $0xe3000000df,%rax
  mov    %rax,0x220(%rsp)
  movabs $0xe9000000e5,%rax
  mov    %rsi,0x248(%rsp)
  mov    %rsi,0x258(%rsp)
  mov    %rsi,0x2b0(%rsp)
  movabs $0x500000006,%rsi
  mov    %rax,0x228(%rsp)
  movabs $0xf1000000ef,%rax
  mov    %rsi,0x2c0(%rsp)
  movabs $0x1300000002,%rsi
  mov    %rax,0x230(%rsp)
  movabs $0x101000000fb,%rax
  mov    %rcx,0x250(%rsp)
  mov    %rcx,0x298(%rsp)
  mov    %rcx,0x2c8(%rsp)
  movabs $0x200000005,%rcx
  mov    %rsi,0x2d8(%rsp)
  movabs $0x700000007,%rsi
  mov    %rax,0x238(%rsp)
  movabs $0x200000003,%rax
  mov    %r9,0x268(%rsp)
  mov    %rdx,0x270(%rsp)
  mov    %rdx,0x278(%rsp)
  mov    %r9,0x290(%rsp)
  movabs $0x300000003,%r9
  mov    %rdx,0x2b8(%rsp)
  mov    %rdx,0x2d0(%rsp)
  movabs $0x300000006,%rdx
  mov    %rcx,0x2e0(%rsp)
  movabs $0x300000004,%rcx
  mov    %rsi,0x300(%rsp)
  movabs $0x100000002,%rsi
  mov    %rax,0x240(%rsp)
  mov    %r8,0x260(%rsp)
  mov    %r10,0x280(%rsp)
  movabs $0xb00000006,%r10
  mov    %rax,0x288(%rsp)
  mov    %r8,0x2a0(%rsp)
  movabs $0x40000000e,%r8
  mov    %r9,0x2a8(%rsp)
  movabs $0x900000013,%r9
  mov    %rax,0x2e8(%rsp)
  mov    %rax,0x2f0(%rsp)
  mov    %rdx,0x2f8(%rsp)
  mov    %rdx,0x308(%rsp)
  movabs $0x120000000c,%rdx
  mov    %rcx,0x80(%rsp)
  movabs $0x800000009,%rcx
  mov    %rsi,0x88(%rsp)
  movabs $0x600000007,%rsi
  movl   $0x0,0x90(%rsp)
  mov    %rax,0xb8(%rsp)
  movabs $0xd00000010,%rax
  mov    %rax,0xf8(%rsp)
  movabs $0xf00000011,%rax
  mov    %rax,0x100(%rsp)
  movabs $0x100000003,%rax
  mov    %rax,0x108(%rsp)
  mov    %rax,0x158(%rsp)
  movabs $0x600000010,%rax
  mov    %rcx,0xa0(%rsp)
  movabs $0x400000005,%rcx
  mov    %rsi,0xa8(%rsp)
  movabs $0x200000000,%rsi
  mov    %rax,0x160(%rsp)
  movabs $0xb0000000f,%rax
  mov    %rcx,0xb0(%rsp)
  movabs $0x700000005,%rcx
  mov    %rsi,0xe0(%rsp)
  mov    %r10,0x110(%rsp)
  movabs $0xa00000008,%r10
  mov    %rsi,0x130(%rsp)
  movabs $0x80000000a,%rsi
  mov    %rax,0x168(%rsp)
  lea    -0x28(%r11),%eax
  mov    %rdx,0xf0(%rsp)
  mov    %rdx,0x140(%rsp)
  lea    -0x1e1(%r11),%edx
  movq   $0x1,0xc0(%rsp)
  mov    %r9,0xd0(%rsp)
  mov    %r8,0xd8(%rsp)
  mov    %rcx,0xe8(%rsp)
  mov    %r10,0x118(%rsp)
  mov    %r9,0x120(%rsp)
  mov    %r8,0x128(%rsp)
  mov    %rcx,0x138(%rsp)
  mov    %rsi,0x148(%rsp)
  mov    %rdi,0x150(%rsp)
  cmp    $0x77,%eax
  jbe    L151
  lea    -0xa0(%r11),%eax
  cmp    $0x28,%eax
  ja     L398
  movq   $0x24,0x60(%rsp)
  mov    $0xa,%esi
  mov    $0xa,%ebp
  cmp    $0x31,%edx
  ja     L647
L454:
  imul   $0x35,%ebp,%eax
  movl   $0x35,0x8(%rsp)
  mov    $0x34,%r15d
  mov    $0x2,%r13d
  movl   $0x35,0x24(%rsp)
  mov    %eax,0x2c(%rsp)
  imul   $0x34,%esi,%eax
  mov    %eax,0x6c(%rsp)
  imul   $0x35,%esi,%eax
  mov    %eax,0x68(%rsp)
L73:
  mov    0x2c(%rsp),%r12d
  mov    $0x4,%esi
  mov    %r12d,%edi
  call   <calloc@plt>
  mov    %r12d,%edi
  mov    $0x4,%esi
  mov    %rax,%r14
  mov    %rax,0x38(%rsp)
  call   <calloc@plt>
  mov    %r12d,%edi
  mov    $0x4,%esi
  movslq %ebp,%r12
  mov    %rax,0x30(%rsp)
  shl    $0x2,%r12
  call   <calloc@plt>
  movslq 0x24(%rsp),%r9
  mov    %r14,%rdi
  xor    %r8d,%r8d
  mov    %rax,0x18(%rsp)
  mov    0x20(%rsp),%r10d
  mov    %r14,0x50(%rsp)
  mov    %r9,%r11
  xor    %r14d,%r14d
  nopw   0x0(%rax,%rax,1)
L426:
  movslq %r8d,%rax
  mov    %rdi,%rdx
  lea    (%r9,%rax,1),%rsi
  test   %r11d,%r11d
  jle    L480
  nop
L243:
  mov    $0xffffffff,%ecx
  cmp    %eax,%r10d
  jle    L156
  mov    (%rbx,%rax,4),%ecx
L156:
  add    $0x1,%rax
  mov    %ecx,(%rdx)
  add    %r12,%rdx
  cmp    %rsi,%rax
  jne    L243
  add    %r11d,%r8d
L480:
  lea    0x1(%r14),%eax
  add    $0x4,%rdi
  cmp    %eax,%ebp
  je     L702
  mov    %eax,%r14d
  jmp    L426
L151:
  movq   $0x10,0x60(%rsp)
  mov    $0x5,%esi
  mov    $0x5,%ebp
  cmp    $0x31,%edx
  jbe    L454
L647:
  mov    0x20(%rsp),%r8d
  xor    %eax,%eax
  mov    $0x7,%edi
  jmp    L140
  nopl   (%rax)
L626:
  add    $0x1,%rax
  cmp    $0x34,%rax
  je     L635
  mov    0x170(%rsp,%rax,4),%edi
L140:
  lea    0x1(%rdi),%edx
  movslq %eax,%rcx
  imul   %ebp,%edx
  cmp    %r8d,%edx
  jl     L626
  mov    %edi,0x8(%rsp)
L252:
  mov    0x240(%rsp,%rcx,4),%r13d
  mov    0x8(%rsp),%ecx
  lea    -0x1(%rcx),%r15d
  mov    %r15d,%edi
  mov    %r15d,%eax
  mov    %r15d,0x24(%rsp)
  imul   %esi,%edi
  imul   %ebp,%eax
  add    %edi,%esi
  mov    %edi,0x6c(%rsp)
  mov    0x20(%rsp),%edi
  mov    %eax,0x2c(%rsp)
  mov    %esi,0x68(%rsp)
  cmp    %edi,%eax
  jge    L73
  add    %ebp,%eax
  mov    %ecx,0x24(%rsp)
  mov    %eax,0x2c(%rsp)
  cmp    %edi,%eax
  jge    L73
  lea    0x1(%rcx),%edi
  add    %ebp,%eax
  mov    %edi,0x24(%rsp)
  mov    %eax,0x2c(%rsp)
  jmp    L73
L398:
  cmp    $0x31,%edx
  ja     L559
  movq   $0x24,0x60(%rsp)
  mov    $0x34,%r15d
  mov    $0xa,%ebp
  mov    $0x2,%r13d
  movl   $0x212,0x68(%rsp)
  movl   $0x208,0x6c(%rsp)
  movl   $0x212,0x2c(%rsp)
  movl   $0x35,0x8(%rsp)
  movl   $0x35,0x24(%rsp)
  jmp    L73
L702:
  mov    $0x4,%esi
  mov    %r15d,%edi
  mov    %eax,0x28(%rsp)
  mov    %r14d,0xc(%rsp)
  call   <calloc@plt>
  mov    %rax,0x40(%rsp)
  mov    %rax,%rbx
  movl   $0x1,(%rax)
  cmp    $0x1,%r15d
  jle    L283
  lea    0x4(%rax),%rsi
  lea    -0x1(%r15),%eax
  mov    0x8(%rsp),%ecx
  mov    $0x1,%edx
  lea    (%rbx,%rax,4),%rdi
  jmp    L119
  nopw   0x0(%rax,%rax,1)
L498:
  add    $0x4,%rsi
L119:
  mov    %edx,%eax
  imul   %r13d,%eax
  cltd
  idiv   %ecx
  mov    %edx,(%rsi)
  cmp    %rsi,%rdi
  jne    L498
L283:
  mov    0x28(%rsp),%edi
  mov    $0x4,%esi
  call   <calloc@plt>
  mov    0xc(%rsp),%ebx
  mov    %r12,0x58(%rsp)
  mov    %rax,0x48(%rsp)
  movl   $0x1,(%rax)
  mov    %rax,(%rsp)
  lea    (%rax,%rbx,4),%rax
  mov    %rax,0x10(%rsp)
  mov    %rbx,0x78(%rsp)
  xor    %ebx,%ebx
  nopw   0x0(%rax,%rax,1)
L102:
  movslq %ebx,%r14
  lea    0x170(%rsp),%r12
  cmp    $0x33,%ebx
  jle    L89
  jmp    L515
  nopw   0x0(%rax,%rax,1)
L310:
  add    $0x1,%r14
  lea    0x1(%rbp),%ebx
  cmp    $0x33,%r14d
  jg     L515
L89:
  mov    (%r12,%r14,4),%r13d
  mov    %r15d,%esi
  mov    %r14d,%ebp
  mov    %r14d,%ebx
  mov    %r13d,%edi
  call   <gcd@plt>
  cmp    $0x1,%eax
  jne    L310
  mov    (%rsp),%rax
  cmp    (%rax),%r13d
  jle    L310
  mov    %r13d,0x4(%rax)
L515:
  addq   $0x4,(%rsp)
  mov    (%rsp),%rax
  cmp    %rax,0x10(%rsp)
  jne    L102
  mov    0x28(%rsp),%ebx
  mov    $0x4,%esi
  mov    0x58(%rsp),%r12
  mov    %ebx,%edi
  call   <calloc@plt>
  mov    %rax,%rbp
  cmp    $0x5,%ebx
  je     L221
  cmpl   $0xa,0x28(%rsp)
  je     L256
  mov    0x20(%rsp),%edi
  lea    -0x8e9(%rdi),%eax
  cmp    $0xc7,%eax
  jbe    L60
  lea    -0xc59(%rdi),%esi
  xor    %eax,%eax
  mov    $0x13,%edx
  cmp    $0x31,%esi
  jbe    L60
  mov    0x48(%rsp),%rsi
  jmp    L237
  nopw   0x0(%rax,%rax,1)
L475:
  movslq 0x120(%rsp,%rax,1),%rdx
L237:
  mov    (%rsi,%rax,1),%ecx
  add    $0x4,%rax
  mov    %ecx,0x0(%rbp,%rdx,4)
  cmp    $0x50,%rax
  jne    L475
L705:
  mov    0x18(%rsp),%r10
  mov    0x60(%rsp),%r13
  mov    %rbp,%r9
  xor    %r8d,%r8d
  mov    0x8(%rsp),%eax
  mov    0x6c(%rsp),%r11d
  mov    %rbp,0x10(%rsp)
  xor    %ecx,%ecx
  add    %r10,%r13
  mov    0x24(%rsp),%r14d
  mov    0x38(%rsp),%rdi
  mov    %r10,%rsi
  lea    0x1(%rax),%ebx
  mov    %r13,0x58(%rsp)
  mov    0x28(%rsp),%ebp
  mov    %ebx,(%rsp)
  mov    0x50(%rsp),%r13
  mov    0x40(%rsp),%rbx
  cmp    0x8(%rsp),%r14d
  je     L196
  nopl   0x0(%rax)
L218:
  cmp    %r14d,(%rsp)
  je     L335
  test   %r15d,%r15d
  jle    L499
  nop
L186:
  mov    (%r9),%eax
  imul   %ecx,%eax
  add    $0x1,%ecx
  cltd
  idiv   %r15d
  movslq %edx,%rdx
  mov    (%rbx,%rdx,4),%eax
  sub    $0x1,%eax
  imul   %ebp,%eax
  add    %r8d,%eax
  cltq
  mov    (%rdi,%rax,4),%eax
  mov    %eax,(%rsi)
  add    %r12,%rsi
  cmp    %r15d,%ecx
  jne    L186
L499:
  lea    0x1(%r8),%eax
  add    $0x1,%r11d
  add    $0x4,%r13
  add    $0x4,%r10
  add    $0x4,%r9
  cmp    %r8d,0xc(%rsp)
  je     L289
  mov    %eax,%r8d
  mov    %r10,%rsi
  xor    %ecx,%ecx
  cmp    0x8(%rsp),%r14d
  jne    L218
L196:
  test   %r15d,%r15d
  jle    L631
  xchg   %ax,%ax
L205:
  mov    (%r9),%eax
  imul   %ecx,%eax
  add    $0x1,%ecx
  cltd
  idiv   %r15d
  movslq %edx,%rdx
  mov    (%rbx,%rdx,4),%eax
  imul   %ebp,%eax
  add    %r8d,%eax
  cltq
  mov    (%rdi,%rax,4),%eax
  mov    %eax,(%rsi)
  add    %r12,%rsi
  cmp    %r15d,%ecx
  jne    L205
L631:
  mov    0x0(%r13),%edx
  mov    0x18(%rsp),%rsi
  movslq %r11d,%rax
  mov    %edx,(%rsi,%rax,4)
  jmp    L499
  nopl   0x0(%rax)
L335:
  test   %r15d,%r15d
  jle    L233
  nopl   (%rax)
L133:
  mov    (%r9),%eax
  imul   %ecx,%eax
  add    $0x1,%ecx
  cltd
  idiv   %r15d
  movslq %edx,%rdx
  mov    (%rbx,%rdx,4),%eax
  imul   %ebp,%eax
  add    %r8d,%eax
  cltq
  mov    (%rdi,%rax,4),%eax
  mov    %eax,(%rsi)
  add    %r12,%rsi
  cmp    %r15d,%ecx
  jne    L133
L233:
  mov    0x0(%r13),%edx
  mov    0x18(%rsp),%rsi
  movslq %r11d,%rax
  mov    0x2c(%rsp),%ecx
  mov    %edx,(%rsi,%rax,4)
  mov    0x68(%rsp),%eax
  lea    (%r8,%rax,1),%edx
  movslq %edx,%rdx
  lea    (%rsi,%rdx,4),%rax
  mov    (%rdi,%rdx,4),%edx
  mov    %edx,(%rax)
  cmp    %ecx,0x20(%rsp)
  jne    L499
  cmp    %r8d,0xc(%rsp)
  jne    L499
  mov    0x58(%rsp),%rsi
  mov    (%rsi),%ecx
  mov    %edx,(%rsi)
  mov    %ecx,(%rax)
  jmp    L499
L289:
  mov    0x20(%rsp),%eax
  mov    0x10(%rsp),%rbp
  xor    %r8d,%r8d
  mov    0x30(%rsp),%rsi
  mov    0x24(%rsp),%edi
  mov    0x18(%rsp),%r13
  mov    0x28(%rsp),%ebx
  lea    -0x8e9(%rax),%r9d
  lea    -0xc59(%rax),%r10d
L645:
  cmp    $0x5,%ebx
  je     L97
  cmp    $0xa,%ebx
  je     L135
  cmp    $0xc7,%r9d
  jbe    L591
  cmp    $0x31,%r10d
  jbe    L591
  movslq 0x120(%rsp,%r8,4),%rax
L188:
  test   %edi,%edi
  jle    L317
  lea    0x0(%r13,%rax,4),%r11
  xor    %edx,%edx
  xor    %eax,%eax
  cs nopw 0x0(%rax,%rax,1)
L450:
  mov    (%r11,%rax,1),%ecx
  add    $0x1,%edx
  mov    %ecx,(%rsi,%rax,1)
  add    %r12,%rax
  cmp    %edx,%edi
  jne    L450
L317:
  add    $0x1,%r8
  add    $0x4,%rsi
  cmp    %r8d,%ebx
  jg     L645
  mov    0x24(%rsp),%eax
  test   %eax,%eax
  jle    L488
  mov    0x78(%rsp),%rax
  mov    0x30(%rsp),%rdi
  xor    %r8d,%r8d
  xor    %ecx,%ecx
  mov    $0xfffffffffffffffc,%r9
  mov    0x24(%rsp),%r11d
  mov    0x70(%rsp),%r10
  shl    $0x2,%rax
  lea    0x4(%rdi,%rax,1),%rsi
  sub    %rax,%r9
  nopw   0x0(%rax,%rax,1)
L603:
  lea    (%r9,%rsi,1),%rax
  nopl   0x0(%rax)
L251:
  mov    (%rax),%edx
  test   %edx,%edx
  js     L286
  movslq %ecx,%rdi
  add    $0x1,%ecx
  mov    %edx,(%r10,%rdi,4)
L286:
  add    $0x4,%rax
  cmp    %rax,%rsi
  jne    L251
  add    $0x1,%r8d
  add    %r12,%rsi
  cmp    %r8d,%r11d
  jne    L603
L488:
  mov    0x38(%rsp),%rdi
  call   <free@plt>
  mov    0x30(%rsp),%rdi
  call   <free@plt>
  mov    0x18(%rsp),%rdi
  call   <free@plt>
  mov    0x40(%rsp),%rdi
  call   <free@plt>
  mov    0x48(%rsp),%rdi
  call   <free@plt>
  mov    0x318(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L149
  add    $0x328,%rsp
  mov    %rbp,%rdi
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  jmp    1080 <free@plt>
  nopw   0x0(%rax,%rax,1)
L97:
  movslq 0x80(%rsp,%r8,4),%rax
  jmp    L188
  nopl   (%rax)
L135:
  movslq 0xa0(%rsp,%r8,4),%rax
  jmp    L188
L591:
  movslq 0xd0(%rsp,%r8,4),%rax
  jmp    L188
L221:
  mov    0x48(%rsp),%rsi
  xor    %eax,%eax
  mov    $0x4,%edx
L412:
  mov    (%rsi,%rax,1),%ecx
  add    $0x4,%rax
  mov    %ecx,0x0(%rbp,%rdx,4)
  cmp    $0x14,%rax
  je     L705
  movslq 0x80(%rsp,%rax,1),%rdx
  jmp    L412
L60:
  mov    0x48(%rsp),%rsi
  xor    %eax,%eax
  mov    $0x13,%edx
  jmp    L55
  nopl   0x0(%rax,%rax,1)
L58:
  movslq 0xd0(%rsp,%rax,1),%rdx
L55:
  mov    (%rsi,%rax,1),%ecx
  add    $0x4,%rax
  mov    %ecx,0x0(%rbp,%rdx,4)
  cmp    $0x50,%rax
  jne    L58
  jmp    L705
L256:
  mov    0x48(%rsp),%rsi
  xor    %eax,%eax
  mov    $0x9,%edx
  jmp    L449
  nopl   0x0(%rax)
L199:
  movslq 0xa0(%rsp,%rax,1),%rdx
L449:
  mov    (%rsi,%rax,1),%ecx
  add    $0x4,%rax
  mov    %ecx,0x0(%rbp,%rdx,4)
  cmp    $0x28,%rax
  jne    L199
  jmp    L705
L559:
  movq   $0x4c,0x60(%rsp)
  mov    $0x14,%esi
  mov    $0x14,%ebp
  jmp    L647
L635:
  mov    0x240(%rsp),%eax
  mov    $0x34,%ecx
  mov    %eax,0x8(%rsp)
  jmp    L252
L149:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
void CreateUmtsInterleaver(int LL, int *input, int *output) {
  int RR, CC;
  int index, i, j, itemp;
  int pValue, vValue;
  int pTable[52] = {7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257};
  int vTable[52] = {3, 2, 2, 3, 2, 5, 2, 3, 2, 6, 3, 5, 2, 2, 2, 2, 7, 5, 3, 2, 3, 5, 2, 5, 2, 6, 3, 3, 2, 3, 2, 2, 6, 5, 2, 5, 2, 2, 2, 19, 5, 2, 3, 2, 3, 2, 6, 3, 7, 7, 6, 3};
  int T5[5] = {4, 3, 2, 1, 0};
  int T10[10] = {9, 8, 7, 6, 5, 4, 3, 2, 1, 0};
  int T20a[20] = {19, 9, 14, 4, 0, 2, 5, 7, 12, 18, 16, 13, 17, 15, 3, 1, 6, 11, 8, 10};
  int T20b[20] = {19, 9, 14, 4, 0, 2, 5, 7, 12, 18, 10, 8, 13, 17, 3, 1, 16, 6, 15, 11};
  int *Matrix, *IntraMatrix, *InterMatrix, *s, *q, *r;
  if ((40 <= LL) && (LL <= 159)) {
    RR = 5;
  } else if ((160 <= LL) && (LL <= 200)) {
    RR = 10;
  } else if ((481 <= LL) && (LL <= 530)) {
    RR = 10;
  } else {
    RR = 20;
  }
  if ((481 <= LL) && (LL <= 530)) {
    pValue = 53;
    CC = pValue;
    vValue = 2;
  } else {
    for (index = 0; index < 52; index++) {
      if (LL <= RR * (pTable[index] + 1)) {
        break;
      }
    }
    pValue = pTable[index];
    vValue = vTable[index];
    if (LL <= RR * (pValue - 1)) {
      CC = pValue - 1;
    } else if (RR * pValue < LL) {
      CC = pValue + 1;
    } else {
      CC = pValue;
    }
  }
  Matrix = calloc(RR * CC, sizeof(int));
  InterMatrix = calloc(RR * CC, sizeof(int));
  IntraMatrix = calloc(RR * CC, sizeof(int));
  index = 0;
  for (i = 0; i < RR; i++) {
    for (j = 0; j < CC; j++) {
      if (index < LL) {
        Matrix[i + j * RR] = input[index];
      } else {
        Matrix[i + j * RR] = -1;
      }
      index++;
    }
  }
  s = calloc(pValue - 1, sizeof(int));
  s[0] = 1;
  for (j = 1; j < pValue - 1; j++) {
    s[j] = (vValue * s[j - 1]) % pValue;
  }
  q = calloc(RR, sizeof(int));
  q[0] = 1;
  index = 0;
  for (i = 1; i < RR; i++) {
    itemp = index;
    for (index = itemp; index < 52; index++) {
      if ((gcd(pTable[index], pValue - 1) == 1) && (pTable[index] > q[i - 1])) {
        q[i] = pTable[index];
        break;
      }
    }
  }
  r = calloc(RR, sizeof(int));
  if (RR == 5) {
    for (i = 0; i < RR; i++) {
      r[T5[i]] = q[i];
    }
  } else if (RR == 10) {
    for (i = 0; i < RR; i++) {
      r[T10[i]] = q[i];
    }
  } else if (((2281 <= LL) && (LL <= 2480)) || ((3161 <= LL) && (LL <= 3210))) {
    for (i = 0; i < RR; i++) {
      r[T20a[i]] = q[i];
    }
  } else {
    for (i = 0; i < RR; i++) {
      r[T20b[i]] = q[i];
    }
  }
  for (i = 0; i < RR; i++) {
    if (CC == pValue) {
      for (j = 0; j <= pValue - 2; j++) {
        index = s[(j * r[i]) % (pValue - 1)];
        IntraMatrix[i + j * RR] = Matrix[i + index * RR];
      }
      IntraMatrix[i + (pValue - 1) * RR] = Matrix[i];
    } else if (CC == pValue + 1) {
      for (j = 0; j <= pValue - 2; j++) {
        index = s[(j * r[i]) % (pValue - 1)];
        IntraMatrix[i + j * RR] = Matrix[i + index * RR];
      }
      IntraMatrix[i + (pValue - 1) * RR] = Matrix[i];
      IntraMatrix[i + pValue * RR] = Matrix[i + pValue * RR];
      if ((LL == RR * CC) && (i == RR - 1)) {
        itemp = IntraMatrix[RR - 1];
        IntraMatrix[RR - 1] = IntraMatrix[(RR - 1) + RR * pValue];
        IntraMatrix[(RR - 1) + RR * pValue] = itemp;
      }
    } else {
      for (j = 0; j <= pValue - 2; j++) {
        index = s[(j * r[i]) % (pValue - 1)] - 1;
        IntraMatrix[i + j * RR] = Matrix[i + index * RR];
      }
    }
  }
  for (i = 0; i < RR; i++) {
    if (RR == 5) {
      index = T5[i];
    } else if (RR == 10) {
      index = T10[i];
    } else if (((2281 <= LL) && (LL <= 2480)) || ((3161 <= LL) && (LL <= 3210))) {
      index = T20a[i];
    } else {
      index = T20b[i];
    }
    for (j = 0; j < CC; j++) {
      InterMatrix[i + j * RR] = IntraMatrix[index + j * RR];
    }
  }
  index = 0;
  for (j = 0; j < CC; j++) {
    for (i = 0; i < RR; i++) {
      if (InterMatrix[i + j * RR] >= 0) {
        output[index] = InterMatrix[i + j * RR];
        index++;
      }
    }
  }
  free(Matrix);
  free(InterMatrix);
  free(IntraMatrix);
  free(s);
  free(q);
  free(r);
}
```