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    $0xc8,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0xb8(%rsp)
  xor    %eax,%eax
  lea    D32(%rip),%r13
  lea    0xc(%rsp),%r12
  lea    D51(%rip),%rbx
L59:
  mov    %r13,%rdi
  call   <printf@plt>
  mov    %r12,%rsi
  mov    %rbx,%rdi
  call   <scanf@plt>
  mov    0xc(%rsp),%eax
  cmp    $0x14,%eax
  ja     L59
  test   %eax,%eax
  jle    L183
  lea    0x10(%rsp),%r15
  mov    $0x0,%r14d
  lea    D9(%rip),%r13
  lea    D51(%rip),%r12
L171:
  mov    %r15,%rbx
L89:
  mov    %r13,%rdi
  call   <printf@plt>
  mov    %rbx,%rsi
  mov    %r12,%rdi
  call   <scanf@plt>
  cmpl   $0x1,(%rbx)
  ja     L89
  add    $0x1,%r14d
  mov    0xc(%rsp),%eax
  add    $0x4,%r15
  cmp    %r14d,%eax
  jg     L171
L183:
  cmpl   $0x0,0x10(%rsp)
  jne    L99
  sub    $0x1,%eax
  cltq
  mov    0x10(%rsp,%rax,4),%r12d
  test   %r12d,%r12d
  jne    L99
  mov    0xc(%rsp),%eax
  mov    $0x0,%ebx
  lea    D2(%rip),%r14
  lea    D44(%rip),%r13
  test   %eax,%eax
  jg     L81
L70:
  movl   $0x0,0x60(%rsp)
  sub    $0x1,%eax
  cltq
  movl   $0x0,0x60(%rsp,%rax,4)
  mov    $0x3e7,%ebx
  lea    0x60(%rsp),%r13
  jmp    L164
L99:
  lea    D58(%rip),%rdi
  call   <printf@plt>
  jmp    L47
L76:
  mov    %r13,%rdi
  call   <printf@plt>
L18:
  mov    0xc(%rsp),%eax
  add    $0x1,%rbx
  cmp    %ebx,%eax
  jle    L70
L81:
  mov    0x10(%rsp,%rbx,4),%eax
  test   %eax,%eax
  je     L76
  cmp    $0x1,%eax
  jne    L18
  mov    %r14,%rdi
  call   <printf@plt>
  jmp    L18
L100:
  mov    %r12d,%ebp
L136:
  sub    $0x1,%ebx
  je     L177
L164:
  mov    0xc(%rsp),%edx
  cmp    %ebp,%edx
  je     L177
  lea    0x10(%rsp),%rdi
  mov    %r13,%rsi
  call   <next_generation@plt>
  mov    0xc(%rsp),%edx
  test   %edx,%edx
  jle    L100
  lea    0x10(%rsp),%rax
  lea    -0x1(%rdx),%edx
  lea    0x14(%rsp,%rdx,4),%rdx
  mov    %r12d,%ebp
L8:
  cmpl   $0x1,(%rax)
  adc    $0x0,%ebp
  add    $0x4,%rax
  cmp    %rax,%rdx
  jne    L8
  jmp    L136
L177:
  lea    D43(%rip),%rdi
  call   <printf@plt>
L47:
  mov    0xb8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L118
  mov    $0x0,%eax
  add    $0xc8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L118:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: retrieve_data
arguments: label: D32
data_type: string
name: retrieve_data
arguments: label: D51
data_type: string
name: retrieve_data
arguments: label: D9
data_type: string
name: retrieve_data
arguments: label: D2
data_type: string
name: retrieve_data
arguments: label: D44
data_type: string
name: retrieve_data
arguments: label: D58
data_type: string
name: retrieve_data
arguments: label: D43
data_type: string

tool: D32: Enter length for the cell chain(you can only use a number between 0 and 20):


tool: D51: %d

tool: D9: Enter a number(you can only use 1 or 0):


tool: D2: *

tool: D44: .

tool: D58: Error! Cell chain must start and end with 0.


tool: D43: 


assistant: ```c
int main() {
  int currentGen[20], nextGen[20], n, i, j, temp;
  do {
    printf("Enter length for the cell chain(you can only use a number between 0 and 20):\n");
    scanf("%d", &n);
  } while (n < 0 || n > 20);
  for (i = 0; i < n; i++) {
    do {
      printf("Enter a number(you can only use 1 or 0):\n");
      scanf("%d", &currentGen[i]);
    } while (currentGen[i] != 0 && currentGen[i] != 1);
  }
  if (currentGen[0] != 0 || currentGen[n - 1] != 0) {
    printf("Error! Cell chain must start and end with 0.\n");
    return 0;
  }
  for (i = 0; i < n; i++) {
    if (currentGen[i] == 0) {
      printf(".");
    } else if (currentGen[i] == 1) {
      printf("*");
    }
  }
  nextGen[0] = 0;
  nextGen[n - 1] = 0;
  for (i = 0; i < 999 && temp != n; i++) {
    next_generation(currentGen, nextGen, n);
    for (j = 0, temp = 0; j < n; j++) {
      if (currentGen[j] == 0)
        temp++;
    }
  }
  printf("\n");
  return 0;
}
```