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

```asm
<main>:
  endbr64
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x228,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x218(%rsp)
  xor    %eax,%eax
  lea    D14(%rip),%r12
  lea    D0(%rip),%r13
  lea    0x10f(%rsp),%rbp
  jmp    L83
L125:
  mov    %esi,%eax
L181:
  lea    0x1(%rax),%esi
  cltq
  movslq %ecx,%rdx
  movzbl 0x10(%rsp,%rdx,1),%edx
  mov    %dl,0x110(%rsp,%rax,1)
  add    $0x1,%ecx
  cmp    %ecx,%ebx
  jle    L92
  mov    %ecx,%eax
  cltd
  idiv   %edi
  test   %edx,%edx
  jne    L125
  test   %ecx,%ecx
  je     L125
  add    %edi,%ecx
  add    %edi,%esi
  jmp    L125
L92:
  mov    0xc(%rsp),%ecx
  lea    (%rcx,%rcx,1),%edx
  cmp    %ebx,%ecx
  jge    L135
  lea    (%rcx,%rcx,2),%r8d
  mov    %ecx,%eax
  jmp    L182
L130:
  sub    $0x1,%edx
  movslq %edx,%rsi
  movslq %eax,%rdi
  movzbl 0x10(%rsp,%rdi,1),%edi
  mov    %dil,0x110(%rsp,%rsi,1)
  add    $0x1,%eax
  cmp    %eax,%ebx
  jle    L135
L182:
  lea    (%rcx,%rdx,1),%esi
  cmp    %eax,%esi
  jne    L130
  add    %ecx,%eax
  add    %r8d,%edx
  jmp    L130
L135:
  lea    0x110(%rsp),%rsi
  lea    0x10(%rsp),%rdi
  call   <strcpy@plt>
  mov    0xc(%rsp),%edi
  test   %edi,%edi
  jle    L91
  mov    %edi,%r9d
  mov    $0x0,%r8d
  mov    $0x0,%esi
  movslq %edi,%rdi
  jmp    L179
L15:
  mov    %eax,%esi
  movzbl 0x10(%rsp,%rdx,1),%ecx
  mov    %cl,0x0(%rbp,%rax,1)
  add    $0x1,%rax
  add    %rdi,%rdx
  cmp    %edx,%ebx
  jg     L15
L33:
  add    $0x1,%r8
  cmp    %r8,%r9
  je     L45
L179:
  lea    0x1(%rsi),%eax
  cltq
  mov    %r8,%rdx
  cmp    %r8d,%ebx
  jg     L15
  jmp    L33
L91:
  mov    $0x0,%esi
L45:
  movslq %esi,%rsi
  movb   $0x0,0x110(%rsp,%rsi,1)
  lea    0x110(%rsp),%rsi
  lea    D29(%rip),%rdi
  call   <printf@plt>
L83:
  lea    0xc(%rsp),%rsi
  mov    %r12,%rdi
  mov    $0x0,%eax
  call   <scanf@plt>
  test   %rax,%rax
  je     L204
  cmpl   $0x0,0xc(%rsp)
  je     L204
  lea    0x10(%rsp),%rbx
  mov    %rbx,%rsi
  mov    %r13,%rdi
  mov    $0x0,%eax
  call   <scanf@plt>
  mov    %rbx,%rdi
  call   <strlen@plt>
  mov    %eax,%ebx
  test   %eax,%eax
  jle    L92
  mov    0xc(%rsp),%edi
  mov    $0x0,%ecx
  mov    $0x0,%eax
  jmp    L181
L204:
  mov    0x218(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L98
  mov    $0x0,%eax
  add    $0x228,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
L98:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: retrieve_data
arguments: tag: D14
type_infered: string
name: retrieve_data
arguments: tag: D0
type_infered: string
name: retrieve_data
arguments: tag: D29
type_infered: string

tool: D14: %d

tool: D0: %s

tool: D29: %s


assistant: ```c
int main(int argc, char **argv) {
  int cur, i, len, offset, range;
  char code[255], solution[255];
  while (scanf("%d", &range) && range) {
    scanf("%s", code);
    len = strlen(code);
    for (cur = 0, i = 0; i < len; i++) {
      if (i % range == 0 && i) {
        i += range;
        cur += range;
      }
      solution[cur++] = code[i];
    }
    for (cur = range * 2, i = range; i < len; ++i) {
      if (cur + range == i) {
        i += range;
        cur += range * 3;
      }
      solution[--cur] = code[i];
    }
    strcpy(code, solution);
    for (cur = 0, offset = 0; offset < range; offset++) {
      for (i = offset; i < len; i += range) {
        solution[cur++] = code[i];
      }
    }
    solution[cur] = '\0';
    printf("%s\n", solution);
  }
  return 0;
}
```