user: What is the c source code of the assembly code below?

```asm
<berlekamp>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0xd8,%rsp
  mov    %rdx,0x18(%rsp)
  mov    %fs:0x28,%rax
  mov    %rax,0xc8(%rsp)
  xor    %eax,%eax
  movq   $0x0,0x40(%rsp)
  movq   $0x0,0x48(%rsp)
  movq   $0x0,0x50(%rsp)
  movq   $0x0,0x58(%rsp)
  movq   $0x0,0x60(%rsp)
  movq   $0x0,0x68(%rsp)
  movq   $0x0,0x70(%rsp)
  movq   $0x0,0x78(%rsp)
  movq   $0x0,0x80(%rsp)
  movq   $0x0,0x88(%rsp)
  movq   $0x0,0x90(%rsp)
  movq   $0x0,0x98(%rsp)
  movq   $0x0,0xa0(%rsp)
  movq   $0x0,0xa8(%rsp)
  movq   $0x0,0xb0(%rsp)
  movq   $0x0,0xb8(%rsp)
  lea    0x40(%rsp),%rax
  mov    %rax,0x20(%rsp)
  lea    0x80(%rsp),%rdx
L189:
  movl   $0x0,(%rax)
  add    $0x4,%rax
  cmp    %rdx,%rax
  jne    L189
  movl   $0x1,0x40(%rsp)
  movl   $0x1,0x84(%rsp)
  lea    0x1(%rdi),%eax
  mov    %eax,%r13d
  shl    $0x3,%r13d
  jne    L84
L114:
  mov    $0x0,%eax
  lea    0x44(%rsp),%rcx
  mov    0x18(%rsp),%rsi
L120:
  mov    (%rcx,%rax,1),%edx
  mov    %edx,(%rsi,%rax,1)
  add    $0x4,%rax
  cmp    $0x20,%rax
  jne    L120
  lea    D32(%rip),%rdi
  mov    $0x0,%eax
  call   <pr_debug@plt>
  mov    0x18(%rsp),%rbp
  mov    %rbp,%rbx
  add    $0x20,%rbp
  lea    D25(%rip),%r12
L72:
  mov    (%rbx),%esi
  mov    %r12,%rdi
  mov    $0x0,%eax
  call   <pr_debug@plt>
  add    $0x4,%rbx
  cmp    %rbp,%rbx
  jne    L72
  mov    0xc8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L221
  mov    %r13d,%eax
  add    $0xd8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L84:
  shl    $0x2,%eax
  mov    %eax,0x3c(%rsp)
  mov    %rsi,0x28(%rsp)
  mov    %r13d,0x38(%rsp)
  movl   $0x1,0xc(%rsp)
  mov    $0x0,%r13d
  movl   $0x0,0x8(%rsp)
  movl   $0x0,0x34(%rsp)
L62:
  mov    0x8(%rsp),%esi
  lea    D64(%rip),%rdi
  mov    $0x0,%eax
  call   <pr_debug@plt>
  mov    0x28(%rsp),%r14
  mov    $0x0,%ebx
  mov    $0x0,%r15d
L225:
  mov    0x40(%rsp,%rbx,4),%edi
  mov    (%r14),%esi
  call   <mpy_mod_gf@plt>
  mov    %eax,%ebp
  mov    %r15d,%r12d
  xor    %eax,%r15d
  mov    %eax,%ecx
  mov    %r13d,%edx
  mov    %ebx,%esi
  lea    D34(%rip),%rdi
  mov    $0x0,%eax
  call   <pr_debug@plt>
  add    $0x1,%rbx
  sub    $0x4,%r14
  cmp    %ebx,%r13d
  jae    L225
  mov    %r15d,0x10(%rsp)
  lea    (%r15,%r15,1),%ebx
  cmp    %r12d,%ebp
  je     L59
  movl   $0x2000,0x14(%rsp)
  movl   $0x201b,0x30(%rsp)
  mov    $0x1,%r12d
  mov    $0xffffffff,%r15d
  mov    $0x0,%r14d
  mov    $0x0,%ebp
  jmp    L29
L121:
  mov    %eax,%ebx
  mov    %edx,0x14(%rsp)
  jmp    L6
L76:
  mov    %r14d,%esi
  call   <mpy_mod_gf@plt>
  mov    %eax,%ecx
  mov    %eax,0x80(%rsp,%rbp,4)
  mov    %r13d,%edx
  mov    %ebp,%esi
  lea    D79(%rip),%rdi
  mov    $0x0,%eax
  call   <pr_debug@plt>
  mov    %ebx,(%r12)
  cmp    %ebp,0x30(%rsp)
  je     L180
L70:
  add    $0x1,%rbp
  add    $0x4,%r12
  lea    -0x1(%rbp),%eax
  cmp    0x8(%rsp),%eax
  jg     L59
L213:
  mov    0x80(%rsp,%rbp,4),%esi
  mov    0x10(%rsp),%edi
  call   <mpy_mod_gf@plt>
  mov    %eax,%ebx
  mov    %eax,%ecx
  mov    %r13d,%edx
  mov    %ebp,%esi
  lea    D24(%rip),%rdi
  mov    $0x0,%eax
  call   <pr_debug@plt>
  mov    (%r12),%edi
  xor    %edi,%ebx
  mov    0xc(%rsp),%ecx
  cmp    %ecx,0x14(%rsp)
  jb     L76
  mov    %ebx,(%r12)
  cmp    %ebp,0x30(%rsp)
  je     L59
  mov    %r14d,%esi
  mov    %ebx,%edi
  call   <mpy_mod_gf@plt>
  mov    %eax,%ecx
  mov    %eax,0x80(%rsp,%rbp,4)
  mov    %r13d,%edx
  mov    %ebp,%esi
  lea    D79(%rip),%rdi
  mov    $0x0,%eax
  call   <pr_debug@plt>
  jmp    L70
L180:
  mov    0x34(%rsp),%eax
  add    $0x1,%eax
  sub    %r13d,%eax
  mov    %eax,%r13d
L59:
  lea    0x80(%rsp),%rsi
  lea    0xb8(%rsp),%rax
L32:
  mov    %rax,%rdx
  mov    (%rax),%ecx
  mov    %ecx,0x4(%rax)
  sub    $0x4,%rax
  cmp    %rdx,%rsi
  jne    L32
  movl   $0x0,0x80(%rsp)
  addl   $0x1,0x8(%rsp)
  mov    0x8(%rsp),%eax
  mov    %eax,0x34(%rsp)
  cmp    0x38(%rsp),%eax
  je     L114
  addl   $0x1,0xc(%rsp)
  addq   $0x4,0x28(%rsp)
  cmp    0x3c(%rsp),%r13d
  jbe    L62
  jmp    L114
L211:
  mov    0xc(%rsp),%eax
  mov    %eax,0x30(%rsp)
  lea    0x0(%r13,%r13,1),%esi
  mov    %esi,0x14(%rsp)
  mov    0x20(%rsp),%r12
  mov    $0x0,%ebp
  test   %eax,%eax
  jns    L213
  jmp    L59
L144:
  add    %ebx,%ebx
  and    $0x3fff,%ebx
L6:
  shr    %r14d
  sub    $0x1,%r15d
  add    $0x1,%ebp
  cmp    $0x19,%ebp
  je     L211
L29:
  mov    %r13d,%edx
  mov    %ebp,%esi
  lea    D70(%rip),%rdi
  mov    $0x0,%eax
  call   <pr_debug@plt>
  mov    %ebx,%eax
  shr    $0xd,%eax
  and    $0x1,%eax
  test   %r15d,%r15d
  sete   %dl
  movzbl %dl,%edx
  mov    %eax,%ecx
  and    %r12d,%ecx
  xor    %ecx,%edx
  mov    %r12d,%ecx
  xor    %edx,%r12d
  test   %eax,%eax
  je     L144
  mov    0x14(%rsp),%edi
  mov    %edi,%edx
  xor    %r14d,%edx
  mov    0x30(%rsp),%eax
  xor    %ebx,%eax
  add    %eax,%eax
  and    $0x3fff,%eax
  cmp    $0x1,%ecx
  jne    L121
  neg    %r15d
  mov    %ebx,0x30(%rsp)
  mov    %eax,%ebx
  mov    %edi,%r14d
  mov    %edx,0x14(%rsp)
  jmp    L6
L221:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: extract_symbolic_data
arguments: label: D32
datatype: string
name: extract_symbolic_data
arguments: label: D25
datatype: string
name: extract_symbolic_data
arguments: label: D64
datatype: string
name: extract_symbolic_data
arguments: label: D34
datatype: string
name: extract_symbolic_data
arguments: label: D79
datatype: string
name: extract_symbolic_data
arguments: label: D24
datatype: string
name: extract_symbolic_data
arguments: label: D70
datatype: string

tool: D32: 
 Err poly:

tool: D25: 0x%x 

tool: D64: 
Iteration.............%d


tool: D34: %02d. s=0 LL=%x poly %x


tool: D79: %02d. s=3 LL=%x poly %x


tool: D24: %02d. s=2 LL=%x poly %x


tool: D70: %02d. s=1 LL=%x poly NULL


assistant: ```c
unsigned int berlekamp(unsigned int select_4_8, unsigned int synd[], unsigned int err[]) {
  int loop, iteration;
  unsigned int LL = 0;
  unsigned int d = 0;
  unsigned int invd = 0;
  unsigned int gammas[16] = {0};
  unsigned int D[16] = {0};
  unsigned int next_gamma = 0;
  int e = 0;
  unsigned int sign = 0;
  unsigned int u = 0;
  unsigned int v = 0;
  unsigned int C1 = 0, C2 = 0;
  unsigned int ss = 0;
  unsigned int tmp_v = 0, tmp_s = 0;
  unsigned int tmp_poly;
  for (loop = 0; loop < 16; loop++)
    gammas[loop] = 0;
  gammas[0] = 1;
  D[1] = 1;
  iteration = 0;
  LL = 0;
  while ((iteration < ((select_4_8 + 1) * 2 * 4)) && (LL <= ((select_4_8 + 1) * 4))) {
    pr_debug("\nIteration.............%d\n", iteration);
    d = 0;
    for (loop = 0; loop <= LL; loop++) {
      tmp_poly = mpy_mod_gf(gammas[loop], synd[iteration - loop]);
      d ^= tmp_poly;
      pr_debug("%02d. s=0 LL=%x poly %x\n", loop, LL, tmp_poly);
    }
    v = d << 1;
    e = -1;
    sign = 1;
    ss = 0x2000;
    invd = 0;
    u = 0x201B;
    for (loop = 0; (d != 0) && (loop <= (2 * 12)); loop++) {
      pr_debug("%02d. s=1 LL=%x poly NULL\n", loop, LL);
      C1 = (v >> 13) & 1;
      C2 = C1 & sign;
      sign ^= C2 ^ (e == 0);
      tmp_v = v;
      tmp_s = ss;
      if (C1 == 1) {
        v ^= u;
        ss ^= invd;
      }
      v = (v << 1) & 0x3FFF;
      if (C2 == 1) {
        u = tmp_v;
        invd = tmp_s;
        e = -e;
      }
      invd >>= 1;
      e--;
    }
    for (loop = 0; (d != 0) && (loop <= (iteration + 1)); loop++) {
      tmp_poly = mpy_mod_gf(d, D[loop]);
      pr_debug("%02d. s=2 LL=%x poly %x\n", loop, LL, tmp_poly);
      next_gamma = gammas[loop] ^ tmp_poly;
      if ((2 * LL) < (iteration + 1)) {
      } else {
        gammas[loop] = next_gamma;
        if (loop == (iteration + 1)) {
          break;
        }
      }
      D[loop] = mpy_mod_gf(gammas[loop], invd);
      pr_debug("%02d. s=3 LL=%x poly %x\n", loop, LL, D[loop]);
      gammas[loop] = next_gamma;
      if (loop == (iteration + 1)) {
        LL = iteration - LL + 1;
        break;
      }
    }
    for (loop = 0; loop < 15; loop++)
      D[15 - loop] = D[14 - loop];
    D[0] = 0;
    iteration++;
  }
  for (loop = 0; loop < 8; loop++)
    err[loop] = gammas[loop + 1];
  pr_debug("\n Err poly:");
  for (loop = 0; loop < 8; loop++)
    pr_debug("0x%x ", err[loop]);
  return LL;
}
```