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

```asm
<main>:
  endbr64
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x1000,%rsp
  orq    $0x0,(%rsp)
  sub    $0x1000,%rsp
  orq    $0x0,(%rsp)
  sub    $0x10,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x2008(%rsp)
  xor    %eax,%eax
  mov    %rsp,%r8
  lea    0x1000(%rsp),%rdi
  mov    %rdi,%rsi
  mov    %rdi,%rcx
  mov    %r8,%rdx
L72:
  mov    $0x0,%eax
L99:
  movl   $0x0,(%rdx,%rax,1)
  movl   $0x0,(%rcx,%rax,1)
  add    $0x4,%rax
  cmp    $0x80,%rax
  jne    L99
  sub    $0xffffffffffffff80,%rdx
  sub    $0xffffffffffffff80,%rcx
  cmp    %rsi,%rdx
  jne    L72
  lea    0x80(%rsp),%rsi
  lea    0x1080(%rsp),%r9
  lea    0xf80(%r8),%r10
  mov    $0x12403,%edx
L18:
  mov    $0x1,%eax
L71:
  imul   $0x51d,%edx,%edx
  add    $0x3619,%edx
  mov    %edx,%ecx
  and    $0x1,%ecx
  mov    %ecx,(%rsi,%rax,4)
  mov    %ecx,(%r9,%rax,4)
  add    $0x1,%rax
  cmp    $0x1f,%rax
  jne    L71
  sub    $0xffffffffffffff80,%rsi
  sub    $0xffffffffffffff80,%r9
  cmp    %r10,%rsi
  jne    L18
  mov    $0x5,%r9d
  lea    0xff8(%r8),%rsi
  lea    0xff8(%rdi),%rcx
L116:
  lea    0x1084(%rsp),%rbp
  lea    0xf8(%r8),%rbx
L23:
  lea    -0x78(%rbx),%rax
  mov    %rbp,%r11
L106:
  mov    -0x7c(%rax),%edx
  add    -0x80(%rax),%edx
  mov    (%rax),%r10d
  add    -0x78(%rax),%r10d
  add    %r10d,%edx
  mov    0x80(%rax),%r10d
  add    0x8(%rax),%r10d
  mov    0x88(%rax),%r12d
  add    0x84(%rax),%r12d
  add    %r12d,%r10d
  add    %r10d,%edx
  cmp    $0x2,%edx
  sete   %r10b
  movzbl %r10b,%r10d
  and    0x4(%rax),%r10d
  cmp    $0x3,%edx
  sete   %dl
  movzbl %dl,%edx
  or     %r10d,%edx
  mov    %edx,(%r11)
  add    $0x4,%rax
  add    $0x4,%r11
  cmp    %rbx,%rax
  jne    L106
  sub    $0xffffffffffffff80,%rbp
  sub    $0xffffffffffffff80,%rbx
  cmp    %rsi,%rbx
  jne    L23
  lea    0x84(%rsp),%rbp
  lea    0xf8(%rdi),%rbx
L102:
  lea    -0x78(%rbx),%rax
  mov    %rbp,%r11
L33:
  mov    -0x7c(%rax),%edx
  add    -0x80(%rax),%edx
  mov    (%rax),%r10d
  add    -0x78(%rax),%r10d
  add    %r10d,%edx
  mov    0x80(%rax),%r10d
  add    0x8(%rax),%r10d
  mov    0x88(%rax),%r12d
  add    0x84(%rax),%r12d
  add    %r12d,%r10d
  add    %r10d,%edx
  cmp    $0x2,%edx
  sete   %r10b
  movzbl %r10b,%r10d
  and    0x4(%rax),%r10d
  cmp    $0x3,%edx
  sete   %dl
  movzbl %dl,%edx
  or     %r10d,%edx
  mov    %edx,(%r11)
  add    $0x4,%rax
  add    $0x4,%r11
  cmp    %rbx,%rax
  jne    L33
  sub    $0xffffffffffffff80,%rbp
  sub    $0xffffffffffffff80,%rbx
  cmp    %rcx,%rbx
  jne    L102
  sub    $0x1,%r9d
  jne    L116
  lea    0x80(%rdi),%rcx
  add    $0x1080,%rdi
  mov    $0x0,%edx
L95:
  lea    -0x80(%rcx),%rax
L109:
  add    (%rax),%edx
  add    $0x4,%rax
  cmp    %rax,%rcx
  jne    L109
  sub    $0xffffffffffffff80,%rcx
  cmp    %rdi,%rcx
  jne    L95
  cmp    $0xc4,%edx
  mov    $0xbadbeef,%eax
  mov    $0xbad,%edx
  cmovne %edx,%eax
  mov    0x2008(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L83
  add    $0x2010,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
L83:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int main() {
  int it, i, j, sum;
  int seed, checksum;
  int data1[32][32], data2[32][32];
  for (i = 0; i < 32; i++) {
    for (j = 0; j < 32; j++) {
      data1[i][j] = 0;
      data2[i][j] = 0;
    }
  }
  seed = 74755;
  for (i = 1; i < 32 - 1; i++) {
    for (j = 1; j < 32 - 1; j++) {
      seed = (seed * 1309 + 13849);
      data1[i][j] = seed & 1;
      data2[i][j] = seed & 1;
    }
  }
  it = 0;
  while (it < 10) {
    for (i = 1; i < 32 - 1; i++) {
      for (j = 1; j < 32 - 1; j++) {
        sum = ((data1[i - 1][j - 1] + data1[i - 1][j]) + (data1[i - 1][j + 1] + data1[i][j - 1])) + ((data1[i][j + 1] + data1[i + 1][j - 1]) + (data1[i + 1][j] + data1[i + 1][j + 1]));
        data2[i][j] = (sum == 3) | (data1[i][j] & (sum == 2));
      }
    }
    for (i = 1; i < 32 - 1; i++) {
      for (j = 1; j < 32 - 1; j++) {
        sum = ((data2[i - 1][j - 1] + data2[i - 1][j]) + (data2[i - 1][j + 1] + data2[i][j - 1])) + ((data2[i][j + 1] + data2[i + 1][j - 1]) + (data2[i + 1][j] + data2[i + 1][j + 1]));
        data1[i][j] = (sum == 3) | (data2[i][j] & (sum == 2));
      }
    }
    it += 2;
  }
  checksum = 0;
  for (i = 0; i < 32; i++)
    for (j = 0; j < 32; j++)
      checksum += data2[i][j];
  if (checksum == 196) {
    return 0xbadbeef;
  } else {
    return 0xbad;
  }
}
```