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

```asm
<main>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  mov    $0x28,%edi
  call   <malloc@plt>
  mov    %rax,%rbp
  mov    $0x28,%edi
  call   <malloc@plt>
  mov    %rax,%r14
  mov    $0x0,%ebx
L106:
  mov    $0x14,%edi
  call   <malloc@plt>
  mov    %rax,0x0(%rbp,%rbx,1)
  mov    $0x14,%edi
  call   <malloc@plt>
  mov    %rax,(%r14,%rbx,1)
  add    $0x8,%rbx
  cmp    $0x28,%rbx
  jne    L106
  mov    %rbp,%r12
  lea    0x28(%rbp),%r15
  lea    D5(%rip),%r13
L1:
  mov    $0x0,%ebx
L48:
  mov    %rbx,%rsi
  add    (%r12),%rsi
  mov    %r13,%rdi
  mov    $0x0,%eax
  call   <scanf@plt>
  add    $0x4,%rbx
  cmp    $0x14,%rbx
  jne    L48
  add    $0x8,%r12
  cmp    %r12,%r15
  jne    L1
  lea    D19(%rip),%rbx
L127:
  lea    0x7(%rsp),%rsi
  mov    %rbx,%rdi
  mov    $0x0,%eax
  call   <scanf@plt>
  cmp    $0x1,%eax
  jne    L117
  mov    %r14,%rdi
  mov    $0x10,%esi
  cmpb   $0x4c,0x7(%rsp)
  jne    L127
L50:
  mov    $0x0,%eax
L10:
  mov    0x0(%rbp,%rax,2),%rdx
  mov    (%rdx,%rsi,1),%ecx
  mov    (%rdi),%rdx
  mov    %ecx,(%rdx,%rax,1)
  add    $0x4,%rax
  cmp    $0x14,%rax
  jne    L10
  sub    $0x4,%rsi
  add    $0x8,%rdi
  cmp    $0xfffffffffffffffc,%rsi
  jne    L50
  mov    %rbp,%rax
  mov    %r14,%rbp
  mov    %rax,%r14
  jmp    L127
L117:
  mov    %rbp,%r12
  add    $0x28,%rbp
  lea    D5(%rip),%r13
  jmp    L42
L13:
  mov    $0xa,%edi
  call   <putchar@plt>
  add    $0x8,%r12
  cmp    %r12,%rbp
  je     L38
L42:
  mov    $0x0,%ebx
L73:
  mov    (%r12),%rax
  mov    (%rax,%rbx,1),%esi
  mov    %r13,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  add    $0x4,%rbx
  cmp    $0x14,%rbx
  je     L13
  mov    $0x20,%edi
  call   <putchar@plt>
  jmp    L73
L38:
  mov    0x8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L80
  mov    $0x0,%eax
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L80:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: unpack_data
arguments: data_tag: D5
data_type: string
name: unpack_data
arguments: data_tag: D19
data_type: string

tool: D5: %d

tool: D19: %c

assistant: ```c
int main() {
  int **Matrix = malloc(5 * sizeof(int *));
  int **result = malloc(5 * sizeof(int *));
  for (int x = 0; x < 5; x++) {
    Matrix[x] = malloc(5 * sizeof(int));
    result[x] = malloc(5 * sizeof(int));
  }
  for (int x = 0; x < 5; x++) {
    for (int y = 0; y < 5; y++) {
      scanf("%d", &Matrix[x][y]);
    }
  }
  char L;
  while (scanf("%c", &L) == 1) {
    if (L == 'L') {
      int i = 0;
      for (int x = 5 - 1; x >= 0; x--) {
        int j = 0;
        for (int y = 0; y < 5; y++) {
          result[i][j] = Matrix[y][x];
          ++j;
        }
        ++i;
      }
      int **temp = result;
      result = Matrix;
      Matrix = temp;
    }
  }
  for (int x = 0; x < 5; x++) {
    for (int y = 0, space = 0; y < 5; y++) {
      if (space)
        printf(" ");
      else
        space = 1;
      printf("%d", Matrix[x][y]);
    }
    printf("\n");
  }
  return 0;
}
```