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

```asm
<dodecode>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %rdi,-0x28(%rbp)
  mov    %rsi,-0x30(%rbp)
  mov    %edx,-0x34(%rbp)
  mov    %ecx,-0x38(%rbp)
  mov    %r8,-0x40(%rbp)
  mov    -0x34(%rbp),%eax
  imul   -0x38(%rbp),%eax
  mov    %eax,-0x10(%rbp)
  mov    -0x34(%rbp),%eax
  add    $0x1,%eax
  mov    %eax,%edx
  shr    $0x1f,%edx
  add    %edx,%eax
  sar    %eax
  mov    %eax,-0xc(%rbp)
  mov    -0x38(%rbp),%eax
  add    $0x1,%eax
  mov    %eax,%edx
  shr    $0x1f,%edx
  add    %edx,%eax
  sar    %eax
  mov    %eax,-0x8(%rbp)
  movl   $0x0,-0x14(%rbp)
  jmp    L22
L137:
  mov    -0x14(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x30(%rbp),%rax
  add    %rdx,%rax
  movl   $0x0,(%rax)
  addl   $0x1,-0x14(%rbp)
L22:
  mov    -0x14(%rbp),%eax
  cmp    -0x10(%rbp),%eax
  jl     L137
  mov    $0x0,%eax
  call   <start_inputing_bits@plt>
  mov    -0x40(%rbp),%rax
  movzbl (%rax),%eax
  movzbl %al,%r8d
  mov    -0x8(%rbp),%edi
  mov    -0xc(%rbp),%ecx
  mov    -0x38(%rbp),%edx
  mov    -0x30(%rbp),%rsi
  mov    -0x28(%rbp),%rax
  mov    %r8d,%r9d
  mov    %edi,%r8d
  mov    %rax,%rdi
  call   <qtree_decode@plt>
  mov    %eax,-0x4(%rbp)
  cmpl   $0x0,-0x4(%rbp)
  je     L32
  mov    -0x4(%rbp),%eax
  jmp    L135
L32:
  mov    -0x40(%rbp),%rax
  add    $0x1,%rax
  movzbl (%rax),%eax
  movzbl %al,%edi
  mov    -0x38(%rbp),%eax
  mov    %eax,%edx
  shr    $0x1f,%edx
  add    %edx,%eax
  sar    %eax
  mov    %eax,%r8d
  mov    -0x8(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x30(%rbp),%rax
  lea    (%rdx,%rax,1),%rsi
  mov    -0xc(%rbp),%ecx
  mov    -0x38(%rbp),%edx
  mov    -0x28(%rbp),%rax
  mov    %edi,%r9d
  mov    %rax,%rdi
  call   <qtree_decode@plt>
  mov    %eax,-0x4(%rbp)
  cmpl   $0x0,-0x4(%rbp)
  je     L72
  mov    -0x4(%rbp),%eax
  jmp    L135
L72:
  mov    -0x40(%rbp),%rax
  add    $0x1,%rax
  movzbl (%rax),%eax
  movzbl %al,%edi
  mov    -0x34(%rbp),%eax
  mov    %eax,%edx
  shr    $0x1f,%edx
  add    %edx,%eax
  sar    %eax
  mov    %eax,%r10d
  mov    -0x38(%rbp),%eax
  imul   -0xc(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x30(%rbp),%rax
  lea    (%rdx,%rax,1),%rsi
  mov    -0x8(%rbp),%ecx
  mov    -0x38(%rbp),%edx
  mov    -0x28(%rbp),%rax
  mov    %edi,%r9d
  mov    %ecx,%r8d
  mov    %r10d,%ecx
  mov    %rax,%rdi
  call   <qtree_decode@plt>
  mov    %eax,-0x4(%rbp)
  cmpl   $0x0,-0x4(%rbp)
  je     L9
  mov    -0x4(%rbp),%eax
  jmp    L135
L9:
  mov    -0x40(%rbp),%rax
  add    $0x2,%rax
  movzbl (%rax),%eax
  movzbl %al,%ecx
  mov    -0x38(%rbp),%eax
  mov    %eax,%edx
  shr    $0x1f,%edx
  add    %edx,%eax
  sar    %eax
  mov    %eax,%r8d
  mov    -0x34(%rbp),%eax
  mov    %eax,%edx
  shr    $0x1f,%edx
  add    %edx,%eax
  sar    %eax
  mov    %eax,%edi
  mov    -0x38(%rbp),%eax
  imul   -0xc(%rbp),%eax
  mov    %eax,%edx
  mov    -0x8(%rbp),%eax
  add    %edx,%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x30(%rbp),%rax
  lea    (%rdx,%rax,1),%rsi
  mov    -0x38(%rbp),%edx
  mov    -0x28(%rbp),%rax
  mov    %ecx,%r9d
  mov    %edi,%ecx
  mov    %rax,%rdi
  call   <qtree_decode@plt>
  mov    %eax,-0x4(%rbp)
  cmpl   $0x0,-0x4(%rbp)
  je     L97
  mov    -0x4(%rbp),%eax
  jmp    L135
L97:
  mov    -0x28(%rbp),%rax
  mov    %rax,%rdi
  call   <input_nybble@plt>
  test   %rax,%rax
  je     L144
  lea    D0(%rip),%rax
  mov    %rax,%rdi
  call   <ffpmsg@plt>
  mov    $0x0,%eax
  jmp    L135
L144:
  mov    $0x0,%eax
  call   <start_inputing_bits@plt>
  movl   $0x0,-0x14(%rbp)
  jmp    L129
L47:
  mov    -0x14(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x30(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  test   %eax,%eax
  je     L83
  mov    -0x28(%rbp),%rax
  mov    %rax,%rdi
  call   <input_bit@plt>
  test   %rax,%rax
  je     L83
  mov    -0x14(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x30(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%edx
  mov    -0x14(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rcx
  mov    -0x30(%rbp),%rax
  add    %rcx,%rax
  neg    %edx
  mov    %edx,(%rax)
L83:
  addl   $0x1,-0x14(%rbp)
L129:
  mov    -0x14(%rbp),%eax
  cmp    -0x10(%rbp),%eax
  jl     L47
  mov    $0x0,%eax
L135:
  leave
  ret
```

tool_calls: name: extract_symbolic_data
arguments: data_label: D0
type_guessed: string

tool: D0: dodecode: bad bit plane values

assistant: ```c
int dodecode(unsigned char *infile, int a[], int nx, int ny, unsigned char nbitplanes[3]) {
  int i, nel, nx2, ny2, stat;
  nel = nx * ny;
  nx2 = (nx + 1) / 2;
  ny2 = (ny + 1) / 2;
  for (i = 0; i < nel; i++)
    a[i] = 0;
  start_inputing_bits();
  stat = qtree_decode(infile, &a[0], ny, nx2, ny2, nbitplanes[0]);
  if (stat)
    return (stat);
  stat = qtree_decode(infile, &a[ny2], ny, nx2, ny / 2, nbitplanes[1]);
  if (stat)
    return (stat);
  stat = qtree_decode(infile, &a[ny * nx2], ny, nx / 2, ny2, nbitplanes[1]);
  if (stat)
    return (stat);
  stat = qtree_decode(infile, &a[ny * nx2 + ny2], ny, nx / 2, ny / 2, nbitplanes[2]);
  if (stat)
    return (stat);
  if (input_nybble(infile) != 0) {
    ffpmsg("dodecode: bad bit plane values");
    return (0);
  }
  start_inputing_bits();
  for (i = 0; i < nel; i++) {
    if (a[i]) {
      if (input_bit(infile))
        a[i] = -a[i];
    }
  }
  return (0);
}
```