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

```asm
<checkAllBusesWright>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    $0x0,%r15d
  lea    D1(%rip),%r12
  jmp    L155
L64:
  lea    D57(%rip),%rdi
  call   <puts@plt>
  jmp    L39
L101:
  add    $0x1,%ebx
  cmp    $0x8,%ebx
  je     L147
L137:
  mov    %ebx,%edx
  mov    %r14d,%esi
  mov    %r15d,%edi
  call   <checkDevice@plt>
  cmp    $0xffffffff,%eax
  je     L101
  cmp    $0x8086,%ax
  jne    L101
  shr    $0x10,%eax
  cmp    $0x1e00,%eax
  jne    L101
  mov    %ebx,%ecx
  mov    %r14d,%edx
  mov    %r15d,%esi
  lea    D22(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    %ebx,%edi
  shl    $0x8,%edi
  or     0x4(%rsp),%edi
  or     $0x80000018,%edi
  mov    $0xcf8,%esi
  call   <outl@plt>
  mov    $0xcfc,%edi
  call   <inl@plt>
  mov    %eax,%ebp
  mov    %eax,%esi
  lea    D24(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  and    $0xfffc,%ebp
  mov    %ebp,%esi
  lea    D24(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  lea    0x2(%rbp),%r13d
  mov    %r13d,0x8(%rsp)
  mov    %r13d,%esi
  mov    $0x5a,%edi
  call   <outb@plt>
  mov    %r13d,%edi
  call   <inb@plt>
  mov    %eax,%esi
  lea    D24(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    %r13d,%edi
  call   <inb@plt>
  cmp    $0x5a,%eax
  je     L64
L39:
  lea    0x6(%rbp),%eax
  mov    %eax,(%rsp)
  mov    %eax,%esi
  mov    $0xe0,%edi
  call   <outb@plt>
  lea    0x7(%rbp),%r13d
  mov    %r13d,%edi
  call   <inb@plt>
  mov    %eax,%esi
  lea    D24(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
L51:
  mov    %r13d,%edi
  call   <inb@plt>
  test   $0x80,%al
  jne    L51
  mov    (%rsp),%esi
  mov    $0xe0,%edi
  call   <outb@plt>
  mov    0x8(%rsp),%esi
  mov    $0x1,%edi
  call   <outb@plt>
  lea    0x3(%rbp),%esi
  mov    $0x0,%edi
  call   <outb@plt>
  lea    0x4(%rbp),%esi
  mov    $0x0,%edi
  call   <outb@plt>
  lea    0x5(%rbp),%esi
  mov    $0x0,%edi
  call   <outb@plt>
  mov    (%rsp),%esi
  mov    $0xe0,%edi
  call   <outb@plt>
  mov    %r13d,%esi
  mov    $0x20,%edi
  call   <outb@plt>
L127:
  mov    %r13d,%edi
  call   <inb@plt>
  test   $0x80,%al
  jne    L127
  mov    %r13d,%edi
  call   <inb@plt>
  test   $0x80,%al
  jne    L101
  mov    $0x100,%r13d
L84:
  movslq %ebp,%rdi
  call   <inw@plt>
  mov    %eax,%esi
  mov    %r12,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  sub    $0x1,%r13d
  jne    L84
  jmp    L101
L147:
  add    $0x1,%r14d
  cmp    $0x20,%r14d
  je     L49
L53:
  mov    %r14d,%eax
  shl    $0xb,%eax
  or     0xc(%rsp),%eax
  mov    %eax,0x4(%rsp)
  mov    $0x0,%ebx
  jmp    L137
L49:
  add    $0x1,%r15d
  cmp    $0x100,%r15d
  je     L159
L155:
  mov    %r15d,%eax
  shl    $0x10,%eax
  mov    %eax,0xc(%rsp)
  mov    $0x0,%r14d
  jmp    L53
L159:
  mov    $0x0,%eax
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

tool_calls: name: retrieve_data
arguments: tag: D1
datatype: string
name: retrieve_data
arguments: tag: D57
datatype: string
name: retrieve_data
arguments: tag: D22
datatype: string
name: retrieve_data
arguments: tag: D24
datatype: string

tool: D1: 0x%X


tool: D57: register pritomen

tool: D22: @ %d %d %d


tool: D24: %X


assistant: ```c
int checkAllBusesWright() {
  int bus;
  int device;
  int function;
  uint32_t got, bar2, base;
  uint16_t ven, dev;
  for (bus = 0; bus < 256; bus++) {
    for (device = 0; device < 32; device++) {
      for (function = 0; function < 8; function++) {
        got = checkDevice(bus, device, function);
        if (got != 0xFFFFFFFF) {
          dev = (uint16_t)((got >> 16) & 0xffff);
          ven = (uint16_t)((got >> 0) & 0xffff);
          if (ven == 0x8086 && (dev == 0x1e00)) {
            printf("@ %d %d %d\n", bus, device, function);
            outl(0x80000000 | (bus << 16) | (device << 11) | (function << 8) | 0x18 & 0xfc, 0xCF8);
            bar2 = inl(0xCFC);
            printf("%X\n", bar2);
            base = bar2 & 0xFFFC;
            printf("%X\n", base);
            outb(0x5A, base + 2);
            printf("%X\n", inb(base + 2));
            if (inb(base + 2) == 0x5A) {
              printf("register pritomen\n");
            }
            outb(0xE0, base + 6);
            printf("%X\n", inb(base + 7));
            while ((inb(base + 7) & 0x80) != 0)
              ;
            outb(0xE0, base + 6);
            outb(0x01, base + 2);
            outb(0x00, base + 3);
            outb(0x00, base + 4);
            outb(0x00, base + 5);
            outb(0xE0, base + 6);
            outb(0x20, base + 7);
            while ((inb(base + 7) & 0x80) != 0)
              ;
            if ((inb(base + 7) & 0x80) == 0) {
              int i;
              for (i = 0; i < 256; i++) {
                printf("0x%X\n", inw(base + 0));
              }
            }
          }
        }
      }
    }
  }
  return 0;
}
```