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

```asm
<factorial>:
  endbr64
  push   %rbp
  push   %rbx
  lea    -0x7a1000(%rsp),%r11
L68:
  sub    $0x1000,%rsp
  orq    $0x0,(%rsp)
  cmp    %r11,%rsp
  jne    L68
  sub    $0x208,%rsp
  mov    %rdi,%r10
  mov    %fs:0x28,%rax
  mov    %rax,0x7a11f8(%rsp)
  xor    %eax,%eax
  mov    %rdi,%rcx
  mov    $0x0,%ebx
  movabs $0xcccccccccccccccd,%rdi
  test   %r10,%r10
  je     L104
L142:
  mov    %rcx,%rax
  mul    %rdi
  shr    $0x3,%rdx
  lea    (%rdx,%rdx,4),%rax
  add    %rax,%rax
  mov    %rcx,%rsi
  sub    %rax,%rsi
  mov    %rsi,(%rsp,%rbx,8)
  mov    %rcx,%rax
  mov    %rdx,%rcx
  add    $0x1,%rbx
  cmp    $0x9,%rax
  ja     L142
  cmp    $0x1,%r10
  jbe    L44
  lea    -0x1(%r10),%r9
  mov    $0x0,%r11d
  movabs $0xcccccccccccccccd,%r8
  jmp    L24
L104:
  lea    D17(%rip),%rdi
  call   <puts@plt>
  jmp    L11
L107:
  mov    %rsp,%rsi
  lea    (%rsi,%rbx,8),%rbp
  mov    %r11,%rcx
L64:
  mov    %r9,%rdi
  imul   (%rsi),%rdi
  add    %rcx,%rdi
  mov    %rdi,%rax
  mul    %r8
  mov    %rdx,%rcx
  shr    $0x3,%rcx
  lea    (%rcx,%rcx,4),%rax
  add    %rax,%rax
  mov    %rdi,%rdx
  sub    %rax,%rdx
  mov    %rdx,(%rsi)
  add    $0x8,%rsi
  cmp    %rsi,%rbp
  jne    L64
  cmp    $0x9,%rdi
  jbe    L94
L103:
  mov    %rcx,%rax
  mul    %r8
  shr    $0x3,%rdx
  lea    (%rdx,%rdx,4),%rax
  add    %rax,%rax
  mov    %rcx,%rsi
  sub    %rax,%rsi
  mov    %rsi,(%rsp,%rbx,8)
  mov    %rcx,%rax
  mov    %rdx,%rcx
  add    $0x1,%rbx
  cmp    $0x9,%rax
  ja     L103
L94:
  sub    $0x1,%r9
  je     L44
L24:
  test   %rbx,%rbx
  jne    L107
  jmp    L94
L44:
  mov    %r10,%rsi
  lea    D29(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  test   %rbx,%rbx
  je     L83
  lea    D9(%rip),%rbp
L116:
  sub    $0x1,%rbx
  mov    (%rsp,%rbx,8),%rsi
  mov    %rbp,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  test   %rbx,%rbx
  jne    L116
L83:
  lea    D37(%rip),%rdi
  call   <puts@plt>
L11:
  mov    0x7a11f8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L21
  add    $0x7a1208,%rsp
  pop    %rbx
  pop    %rbp
  ret
L21:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: unpack_data
arguments: label: D17
data_type: string
name: unpack_data
arguments: label: D29
data_type: string
name: unpack_data
arguments: label: D9
data_type: string
name: unpack_data
arguments: label: D37
data_type: string

tool: D17: 
	0! = 1


tool: D29: 
	%lu! = 

tool: D9: %lu

tool: D37: 


assistant: ```c
void factorial(unsigned long n) {
  if (n == 0) {
    printf("\n\t0! = 1\n\n");
    return;
  }
  unsigned long a[(999999L)];
  unsigned long index = 0;
  unsigned long tmp = n;
  unsigned long digits = 0;
  unsigned long carry = 0;
  while (tmp > 0) {
    a[index++] = tmp % 10;
    tmp /= 10;
    digits++;
  }
  unsigned long m;
  for (m = n; m > 1; --m) {
    for (index = 0; index < digits; ++index) {
      tmp = a[index] * (m - 1) + carry;
      a[index] = tmp % 10;
      carry = tmp / 10;
    }
    while (carry > 0) {
      a[index++] = carry % 10;
      carry /= 10;
      digits++;
    }
  }
  printf("\n\t%lu! = ", n);
  for (index = digits; index > 0; --index)
    printf("%lu", a[index - 1]);
  printf("\n\n");
}
```