user: Converte this assembly snippet into its equivalent C code:

```asm
<main>:
  endbr64
  push   %r15
  lea    D1(%rip),%rdi
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x148,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x138(%rsp)
  xor    %eax,%eax
  lea    0x2c(%rsp),%rsi
  call   <scanf@plt>
  mov    0x2c(%rsp),%eax
  test   %eax,%eax
  je     L61
  lea    0x30(%rsp),%rax
  lea    0x100(%rsp),%r12
  mov    %rax,0x10(%rsp)
  lea    0x58(%rsp),%rax
  lea    0xfc(%rsp),%r13
  mov    %rax,0x8(%rsp)
  lea    0x60(%rsp),%rax
  lea    0x64(%rsp),%rbp
  mov    %rax,0x18(%rsp)
  lea    0x128(%rsp),%r14
L24:
  mov    0x10(%rsp),%rbx
L127:
  mov    %rbx,%rsi
  lea    D1(%rip),%rdi
  add    $0x4,%rbx
  call   <scanf@plt>
  cmp    0x8(%rsp),%rbx
  jne    L127
  mov    0x18(%rsp),%rdi
  mov    $0x14,%ecx
  xor    %eax,%eax
  xor    %r15d,%r15d
  movl   $0x32,0x4(%rsp)
  rep stos %rax,%es:(%rdi)
  movl   $0x1,0xac(%rsp)
  nopl   0x0(%rax)
L103:
  mov    %rbp,%rbx
  mov    %r12,%rsi
  mov    %rbp,%rdi
  mov    %r15d,%eax
  jmp    L189
  cs nopw 0x0(%rax,%rax,1)
L99:
  cmp    $0x1,%eax
  jne    L20
  movb   $0x2e,(%rsi)
L20:
  add    $0x1,%rsi
  cmp    %r14,%rsi
  je     L137
L95:
  mov    (%rdi),%eax
  add    $0x4,%rdi
L189:
  cmp    $0x2,%eax
  je     L10
  jg     L116
  test   %eax,%eax
  jne    L99
  movb   $0x20,(%rsi)
  add    $0x1,%rsi
  cmp    %r14,%rsi
  jne    L95
  cs nopw 0x0(%rax,%rax,1)
L137:
  mov    %r12,%rdi
  movb   $0x0,0x128(%rsp)
  call   <puts@plt>
  mov    0x64(%rsp),%eax
  add    %eax,%r15d
  movslq %r15d,%rsi
  mov    0x30(%rsp,%rsi,4),%esi
  mov    %esi,0x60(%rsp)
  jmp    L54
  nopl   0x0(%rax)
L172:
  mov    %eax,%r15d
  mov    (%rbx),%eax
  add    %eax,%r15d
L54:
  add    0x4(%rbx),%r15d
  add    $0x4,%rbx
  movslq %r15d,%r15
  mov    0x30(%rsp,%r15,4),%edi
  mov    %edi,-0x4(%rbx)
  cmp    %rbx,%r13
  jne    L172
  add    0xfc(%rsp),%eax
  subl   $0x1,0x4(%rsp)
  cltq
  mov    0x30(%rsp,%rax,4),%eax
  mov    %eax,0xfc(%rsp)
  je     L177
  mov    %esi,%r15d
  jmp    L103
  nopl   0x0(%rax,%rax,1)
L116:
  cmp    $0x3,%eax
  jne    L20
  movb   $0x57,(%rsi)
  jmp    L20
  nopl   0x0(%rax)
L10:
  movb   $0x78,(%rsi)
  jmp    L20
L177:
  mov    0x2c(%rsp),%eax
  cmp    $0x1,%eax
  jle    L171
  mov    $0xa,%edi
  call   <putchar@plt>
  mov    0x2c(%rsp),%eax
L171:
  sub    $0x1,%eax
  mov    %eax,0x2c(%rsp)
  jne    L24
L61:
  mov    0x138(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L40
  add    $0x148,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L40:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: disassemble_data
arguments: data_tag: D1
datatype: string

tool: D1: %d

assistant: ```c
int main(void) {
  int dna[10], dish[40], day, numcase, i, prev, sumdense;
  char dishstr[40 + 1];
  scanf("%d", &numcase);
  while (numcase) {
    for (i = 0; i < 10; ++i)
      scanf("%d", &dna[i]);
    int halfsize = 40 >> 1;
    for (i = 0; i < 40; ++i)
      dish[i] = 0;
    dish[halfsize - 1] = 1;
    for (day = 1; day <= 50; ++day) {
      for (i = 0; i < 40; i++)
        switch (dish[i]) {
        case 0:
          dishstr[i] = ' ';
          break;
        case 1:
          dishstr[i] = '.';
          break;
        case 2:
          dishstr[i] = 'x';
          break;
        case 3:
          dishstr[i] = 'W';
        }
      dishstr[40] = '\0';
      printf("%s\n", dishstr);
      prev = dish[0];
      dish[0] = dna[dish[0] + dish[1]];
      for (i = 1; i < 40 - 1; i++) {
        sumdense = prev + dish[i] + dish[i + 1];
        prev = dish[i];
        dish[i] = dna[sumdense];
      }
      dish[40 - 1] = dna[prev + dish[40 - 1]];
    }
    if (numcase > 1)
      printf("\n");
    numcase--;
  }
  return 0;
}
```