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

```asm
<decode_state>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x50,%rsp
  mov    %rdi,-0x48(%rbp)
  mov    -0x48(%rbp),%rax
  lea    D518(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <scan_file@plt>
  mov    %eax,-0x38(%rbp)
  mov    -0x48(%rbp),%rax
  lea    D86(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <scan_file@plt>
  mov    %eax,-0x34(%rbp)
  mov    -0x48(%rbp),%rax
  lea    D450(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <scan_file@plt>
  mov    %eax,-0x30(%rbp)
  mov    -0x48(%rbp),%rax
  lea    D482(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <scan_file@plt>
  mov    %eax,-0x2c(%rbp)
  mov    -0x48(%rbp),%rax
  lea    D70(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <scan_file@plt>
  mov    %eax,-0x28(%rbp)
  mov    -0x48(%rbp),%rax
  lea    D39(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <scan_file@plt>
  mov    %eax,-0x24(%rbp)
  mov    -0x48(%rbp),%rax
  lea    D2(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <scan_file@plt>
  mov    %eax,-0x20(%rbp)
  mov    -0x48(%rbp),%rax
  lea    D133(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <scan_file@plt>
  mov    %eax,-0x1c(%rbp)
  mov    -0x48(%rbp),%rax
  lea    D187(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <scan_file@plt>
  mov    %eax,-0x18(%rbp)
  mov    -0x48(%rbp),%rax
  lea    D191(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <scan_file@plt>
  mov    %eax,-0x14(%rbp)
  mov    -0x48(%rbp),%rax
  lea    D46(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <scan_file@plt>
  mov    %eax,-0x10(%rbp)
  mov    -0x48(%rbp),%rax
  lea    D414(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <scan_file@plt>
  mov    %eax,-0xc(%rbp)
  mov    -0x48(%rbp),%rax
  mov    %rax,%rsi
  lea    D425(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    -0x38(%rbp),%edx
  mov    -0x1c(%rbp),%eax
  mov    %eax,%esi
  lea    D469(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    -0x34(%rbp),%edx
  mov    -0x18(%rbp),%eax
  mov    %eax,%esi
  lea    D466(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    -0x28(%rbp),%eax
  movswl %ax,%esi
  mov    -0x28(%rbp),%ecx
  mov    -0x2c(%rbp),%edx
  mov    -0x10(%rbp),%eax
  mov    %esi,%r8d
  mov    %eax,%esi
  lea    D249(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    -0x20(%rbp),%eax
  movswl %ax,%esi
  mov    -0x20(%rbp),%ecx
  mov    -0x24(%rbp),%edx
  mov    -0xc(%rbp),%eax
  mov    %esi,%r8d
  mov    %eax,%esi
  lea    D14(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    -0x30(%rbp),%eax
  and    $0x2,%eax
  test   %eax,%eax
  je     L111
  lea    D347(%rip),%rdx
  jmp    L153
L111:
  lea    D47(%rip),%rdx
L153:
  mov    -0x30(%rbp),%eax
  and    $0x1,%eax
  test   %eax,%eax
  je     L291
  lea    D246(%rip),%rax
  jmp    L374
L291:
  lea    D540(%rip),%rax
L374:
  mov    -0x30(%rbp),%esi
  mov    %rdx,%rcx
  mov    %rax,%rdx
  lea    D406(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    -0x30(%rbp),%eax
  and    $0xc,%eax
  cmp    $0x3,%eax
  je     L85
  cmp    $0x3,%eax
  ja     L395
  cmp    $0x2,%eax
  je     L179
  cmp    $0x2,%eax
  ja     L395
  test   %eax,%eax
  je     L198
  cmp    $0x1,%eax
  je     L78
  jmp    L395
L85:
  lea    D291(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  jmp    L395
L179:
  lea    D79(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  jmp    L395
L78:
  lea    D3(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  jmp    L395
L198:
  lea    D492(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  nop
L395:
  mov    -0x30(%rbp),%eax
  and    $0x80,%eax
  test   %eax,%eax
  je     L273
  lea    D75(%rip),%rsi
  jmp    L269
L273:
  lea    D509(%rip),%rsi
L269:
  mov    -0x30(%rbp),%eax
  and    $0x40,%eax
  test   %eax,%eax
  je     L96
  lea    D117(%rip),%rcx
  jmp    L142
L96:
  lea    D509(%rip),%rcx
L142:
  mov    -0x30(%rbp),%eax
  and    $0x20,%eax
  test   %eax,%eax
  je     L290
  lea    D231(%rip),%rdx
  jmp    L60
L290:
  lea    D509(%rip),%rdx
L60:
  mov    -0x30(%rbp),%eax
  and    $0x10,%eax
  test   %eax,%eax
  je     L274
  lea    D494(%rip),%rax
  jmp    L69
L274:
  lea    D141(%rip),%rax
L69:
  mov    %rsi,%r8
  mov    %rax,%rsi
  lea    D483(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    -0x30(%rbp),%eax
  and    $0xf00,%eax
  mov    %eax,-0x8(%rbp)
  cmpl   $0x0,-0x8(%rbp)
  je     L108
  cmpl   $0x9,-0x8(%rbp)
  ja     L108
  mov    -0x8(%rbp),%eax
  mov    %eax,%esi
  lea    D98(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  jmp    L28
L108:
  cmpl   $0x9,-0x8(%rbp)
  jbe    L28
  mov    -0x8(%rbp),%eax
  mov    %eax,%esi
  lea    D165(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
L28:
  mov    -0x30(%rbp),%eax
  and    $0x7000,%eax
  mov    %eax,-0x4(%rbp)
  cmpl   $0x7,-0x4(%rbp)
  ja     L52
  mov    -0x4(%rbp),%eax
  lea    0x0(,%rax,4),%rdx
  lea    D267(%rip),%rax
  mov    (%rdx,%rax,1),%eax
  cltq
  lea    D267(%rip),%rdx
  add    %rdx,%rax
  notrack jmp *%rax
  lea    D364(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  jmp    L224
  lea    D388(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  jmp    L224
  lea    D500(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  jmp    L224
  lea    D156(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  jmp    L224
  lea    D24(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  jmp    L224
L52:
  mov    -0x4(%rbp),%eax
  mov    %eax,%esi
  lea    D182(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
L224:
  lea    D183(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
  mov    -0x14(%rbp),%eax
  and    $0x8,%eax
  test   %eax,%eax
  je     L233
  lea    D394(%rip),%rsi
  jmp    L285
L233:
  lea    D509(%rip),%rsi
L285:
  mov    -0x14(%rbp),%eax
  and    $0x4,%eax
  test   %eax,%eax
  je     L7
  lea    D76(%rip),%rcx
  jmp    L221
L7:
  lea    D509(%rip),%rcx
L221:
  mov    -0x14(%rbp),%eax
  and    $0x2,%eax
  test   %eax,%eax
  je     L200
  lea    D296(%rip),%rdx
  jmp    L212
L200:
  lea    D509(%rip),%rdx
L212:
  mov    -0x14(%rbp),%eax
  and    $0x1,%eax
  test   %eax,%eax
  je     L379
  lea    D361(%rip),%rax
  jmp    L263
L379:
  lea    D509(%rip),%rax
L263:
  mov    -0x14(%rbp),%edi
  mov    %rsi,%r9
  mov    %rcx,%r8
  mov    %rdx,%rcx
  mov    %rax,%rdx
  mov    %edi,%esi
  lea    D82(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  nop
  leave
  ret
```

tool_calls: name: extract_symbolic_data
arguments: data_tag: D518
type_infered: string
name: extract_symbolic_data
arguments: data_tag: D86
type_infered: string
name: extract_symbolic_data
arguments: data_tag: D450
type_infered: string
name: extract_symbolic_data
arguments: data_tag: D482
type_infered: string
name: extract_symbolic_data
arguments: data_tag: D70
type_infered: string
name: extract_symbolic_data
arguments: data_tag: D39
type_infered: string
name: extract_symbolic_data
arguments: data_tag: D2
type_infered: string
name: extract_symbolic_data
arguments: data_tag: D133
type_infered: string
name: extract_symbolic_data
arguments: data_tag: D187
type_infered: string
name: extract_symbolic_data
arguments: data_tag: D191
type_infered: string
name: extract_symbolic_data
arguments: data_tag: D46
type_infered: string
name: extract_symbolic_data
arguments: data_tag: D414
type_infered: string
name: extract_symbolic_data
arguments: data_tag: D425
type_infered: string
name: extract_symbolic_data
arguments: data_tag: D469
type_infered: string
name: extract_symbolic_data
arguments: data_tag: D466
type_infered: string
name: extract_symbolic_data
arguments: data_tag: D249
type_infered: string
name: extract_symbolic_data
arguments: data_tag: D14
type_infered: string
name: extract_symbolic_data
arguments: data_tag: D347
type_infered: string
name: extract_symbolic_data
arguments: data_tag: D47
type_infered: string
name: extract_symbolic_data
arguments: data_tag: D246
type_infered: string
name: extract_symbolic_data
arguments: data_tag: D540
type_infered: string
name: extract_symbolic_data
arguments: data_tag: D406
type_infered: string
name: extract_symbolic_data
arguments: data_tag: D291
type_infered: string
name: extract_symbolic_data
arguments: data_tag: D79
type_infered: string
name: extract_symbolic_data
arguments: data_tag: D3
type_infered: string
name: extract_symbolic_data
arguments: data_tag: D492
type_infered: string
name: extract_symbolic_data
arguments: data_tag: D75
type_infered: string
name: extract_symbolic_data
arguments: data_tag: D509
type_infered: string
name: extract_symbolic_data
arguments: data_tag: D117
type_infered: string
name: extract_symbolic_data
arguments: data_tag: D231
type_infered: string
name: extract_symbolic_data
arguments: data_tag: D494
type_infered: string
name: extract_symbolic_data
arguments: data_tag: D141
type_infered: string
name: extract_symbolic_data
arguments: data_tag: D483
type_infered: string
name: extract_symbolic_data
arguments: data_tag: D98
type_infered: string
name: extract_symbolic_data
arguments: data_tag: D165
type_infered: string
name: extract_symbolic_data
arguments: data_tag: D364
type_infered: string
name: extract_symbolic_data
arguments: data_tag: D388
type_infered: string
name: extract_symbolic_data
arguments: data_tag: D500
type_infered: string
name: extract_symbolic_data
arguments: data_tag: D156
type_infered: string
name: extract_symbolic_data
arguments: data_tag: D24
type_infered: string
name: extract_symbolic_data
arguments: data_tag: D182
type_infered: string
name: extract_symbolic_data
arguments: data_tag: D183
type_infered: string
name: extract_symbolic_data
arguments: data_tag: D394
type_infered: string
name: extract_symbolic_data
arguments: data_tag: D76
type_infered: string
name: extract_symbolic_data
arguments: data_tag: D296
type_infered: string
name: extract_symbolic_data
arguments: data_tag: D361
type_infered: string
name: extract_symbolic_data
arguments: data_tag: D82
type_infered: string

tool: D518: NEXT_DESC_PTR

tool: D86: START_ADDR

tool: D450: CONFIG

tool: D482: X_COUNT

tool: D70: X_MODIFY

tool: D39: Y_COUNT

tool: D2: Y_MODIFY

tool: D133: CURR_DESC_PTR

tool: D187: CURR_ADDR

tool: D191: IRQ_STATUS

tool: D46: CURR_X_COUNT

tool: D414: CURR_Y_COUNT

tool: D425:   --- %s ---


tool: D469: desc: curr: 0x%08x  next: 0x%08x


tool: D466: addr: curr: 0x%08x start: 0x%08x


tool: D249: X: curr: 0x%04x count: 0x%04x mod: 0x%04x (%i)


tool: D14: Y: curr: 0x%04x count: 0x%04x mod: 0x%04x (%i)


tool: D347: write

tool: D47: read

tool: D246: en

tool: D540: dis

tool: D406: dma config: 0x%04x (%sabled %s 

tool: D291: WDSIZE:INVALID 

tool: D79: 32-bit 

tool: D3: 16-bit 

tool: D492: 8-bit 

tool: D75: interrupt 

tool: 

tool: D117: di_sel 

tool: D231: sync 

tool: D494: 2D

tool: D141: 1D

tool: D483: %s %s%s%s

tool: D98: NDSIZE_%i 

tool: D165: NDSIZE:INVALID:%i 

tool: D364: stop

tool: D388: autobuffer

tool: D500: descriptor_array

tool: D156: descriptor_list_small

tool: D24: descriptor_list_large

tool: D182: FLOW:INVALID:%i

tool: D183: )

tool: D394: run 

tool: D76: dfetch 

tool: D296: err 

tool: D361: done 

tool: D82: irq status: 0x%04x (%s%s%s%s)


assistant: ```c
void decode_state(const char *prefix) {
  unsigned int NEXT_DESC_PTR = scan_file(prefix, "NEXT_DESC_PTR");
  unsigned int START_ADDR = scan_file(prefix, "START_ADDR");
  unsigned int CONFIG = scan_file(prefix, "CONFIG");
  unsigned int X_COUNT = scan_file(prefix, "X_COUNT");
  unsigned int X_MODIFY = scan_file(prefix, "X_MODIFY");
  unsigned int Y_COUNT = scan_file(prefix, "Y_COUNT");
  unsigned int Y_MODIFY = scan_file(prefix, "Y_MODIFY");
  unsigned int CURR_DESC_PTR = scan_file(prefix, "CURR_DESC_PTR");
  unsigned int CURR_ADDR = scan_file(prefix, "CURR_ADDR");
  unsigned int IRQ_STATUS = scan_file(prefix, "IRQ_STATUS");
  unsigned int CURR_X_COUNT = scan_file(prefix, "CURR_X_COUNT");
  unsigned int CURR_Y_COUNT = scan_file(prefix, "CURR_Y_COUNT");
  printf("  --- %s ---\n", prefix);
  printf("desc: curr: 0x%08x  next: 0x%08x\n", CURR_DESC_PTR, NEXT_DESC_PTR);
  printf("addr: curr: 0x%08x start: 0x%08x\n", CURR_ADDR, START_ADDR);
  printf("X: curr: 0x%04x count: 0x%04x mod: 0x%04x (%i)\n", CURR_X_COUNT, X_COUNT, X_MODIFY, (short)X_MODIFY);
  printf("Y: curr: 0x%04x count: 0x%04x mod: 0x%04x (%i)\n", CURR_Y_COUNT, Y_COUNT, Y_MODIFY, (short)Y_MODIFY);
  printf("dma config: 0x%04x (%sabled %s ", CONFIG, (CONFIG & (1 << 0)) ? "en" : "dis", (CONFIG & (0x1 << 1)) ? "write" : "read");
  switch (CONFIG & (0x3 << 2)) {
  case 0x3:
    printf("WDSIZE:INVALID ");
    break;
  case 0x2:
    printf("32-bit ");
    break;
  case 0x1:
    printf("16-bit ");
    break;
  case 0x0:
    printf("8-bit ");
    break;
  }
  printf("%s %s%s%s", (CONFIG & (0x1 << 4)) ? "2D" : "1D", (CONFIG & (0x1 << 5)) ? "sync " : "", (CONFIG & (0x1 << 6)) ? "di_sel " : "", (CONFIG & (0x1 << 7)) ? "interrupt " : "");
  unsigned int NDSIZE = CONFIG & (0xF << 8);
  if (NDSIZE > 0 && NDSIZE < 10)
    printf("NDSIZE_%i ", NDSIZE);
  else if (NDSIZE >= 10)
    printf("NDSIZE:INVALID:%i ", NDSIZE);
  unsigned int FLOW = CONFIG & (0x7 << 12);
  switch (FLOW) {
  case 0:
    printf("stop");
    break;
  case 1:
    printf("autobuffer");
    break;
  case 4:
    printf("descriptor_array");
    break;
  case 6:
    printf("descriptor_list_small");
    break;
  case 7:
    printf("descriptor_list_large");
    break;
  default:
    printf("FLOW:INVALID:%i", FLOW);
  }
  printf(")\n");
  printf("irq status: 0x%04x (%s%s%s%s)\n", IRQ_STATUS, (IRQ_STATUS & (0x1 << 0)) ? "done " : "", (IRQ_STATUS & (0x1 << 1)) ? "err " : "", (IRQ_STATUS & (0x1 << 2)) ? "dfetch " : "", (IRQ_STATUS & (0x1 << 3)) ? "run " : "");
}
```