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

```asm
<MTX_AHUFF_BitsUsed>:
  endbr64
  push   %rbx
  mov    %rdi,%rbx
  not    %rdi
  shr    $0x3f,%rdi
  call   <assert@plt>
  test   $0xffff0000,%ebx
  je     L107
  test   $0xff000000,%ebx
  je     L36
  test   $0xf0000000,%ebx
  je     L97
  test   $0xc0000000,%ebx
  je     L112
  xor    %eax,%eax
  test   $0x80000000,%ebx
  pop    %rbx
  setne  %al
  add    $0x1f,%rax
  ret
  nopl   (%rax)
L36:
  test   $0xf00000,%ebx
  je     L93
  test   $0xc00000,%ebx
  je     L73
  xor    %eax,%eax
  test   $0x800000,%ebx
  pop    %rbx
  setne  %al
  add    $0x17,%rax
  ret
  nopl   0x0(%rax)
L107:
  test   $0xff,%bh
  je     L100
  test   $0xf0,%bh
  je     L105
  test   $0xc0,%bh
  je     L117
  xor    %eax,%eax
  and    $0x80,%bh
  pop    %rbx
  setne  %al
  add    $0xf,%rax
  ret
  nopl   0x0(%rax)
L100:
  test   $0xf0,%bl
  je     L38
  test   $0xc0,%bl
  je     L133
  shr    $0x7,%bl
  movzbl %bl,%eax
  pop    %rbx
  add    $0x7,%rax
  ret
  nopw   0x0(%rax,%rax,1)
L38:
  test   $0xc,%bl
  je     L59
  xor    %eax,%eax
  and    $0x8,%ebx
  pop    %rbx
  setne  %al
  add    $0x3,%rax
  ret
  nop
L105:
  test   $0xc,%bh
  je     L26
  xor    %eax,%eax
  and    $0x8,%bh
  pop    %rbx
  setne  %al
  add    $0xb,%rax
  ret
  nopl   0x0(%rax,%rax,1)
L97:
  test   $0xc000000,%ebx
  je     L21
  xor    %eax,%eax
  test   $0x8000000,%ebx
  pop    %rbx
  setne  %al
  add    $0x1b,%rax
  ret
  nopl   (%rax)
L93:
  test   $0xc0000,%ebx
  je     L66
  xor    %eax,%eax
  test   $0x80000,%ebx
  pop    %rbx
  setne  %al
  add    $0x13,%rax
  ret
  nopl   0x0(%rax)
L26:
  xor    %eax,%eax
  and    $0x2,%bh
  pop    %rbx
  setne  %al
  add    $0x9,%rax
  ret
  cs nopw 0x0(%rax,%rax,1)
L66:
  xor    %eax,%eax
  test   $0x20000,%ebx
  pop    %rbx
  setne  %al
  add    $0x11,%rax
  ret
  nopl   0x0(%rax)
L117:
  xor    %eax,%eax
  and    $0x20,%bh
  pop    %rbx
  setne  %al
  add    $0xd,%rax
  ret
  cs nopw 0x0(%rax,%rax,1)
L112:
  xor    %eax,%eax
  test   $0x20000000,%ebx
  pop    %rbx
  setne  %al
  add    $0x1d,%rax
  ret
  nopl   0x0(%rax)
L133:
  xor    %eax,%eax
  and    $0x20,%ebx
  pop    %rbx
  setne  %al
  add    $0x5,%rax
  ret
  cs nopw 0x0(%rax,%rax,1)
L21:
  xor    %eax,%eax
  test   $0x2000000,%ebx
  pop    %rbx
  setne  %al
  add    $0x19,%rax
  ret
  nopl   0x0(%rax)
L59:
  xor    %eax,%eax
  and    $0x2,%ebx
  pop    %rbx
  setne  %al
  add    $0x1,%rax
  ret
  cs nopw 0x0(%rax,%rax,1)
L73:
  xor    %eax,%eax
  test   $0x200000,%ebx
  pop    %rbx
  setne  %al
  add    $0x15,%rax
  ret
```

assistant: ```c
long MTX_AHUFF_BitsUsed(register long x) {
  register long n;
  assert(x >= 0);
  if (x & 0xffff0000) {
    if (x & 0xff000000) {
      if (x & 0xf0000000) {
        if (x & 0xC0000000) {
          n = x & 0x80000000 ? 32 : 31;
        } else {
          n = x & 0x20000000 ? 30 : 29;
        }
      } else {
        if (x & 0x0C000000) {
          n = x & 0x08000000 ? 28 : 27;
        } else {
          n = x & 0x02000000 ? 26 : 25;
        }
      }
    } else {
      if (x & 0x00f00000) {
        if (x & 0x00C00000) {
          n = x & 0x00800000 ? 24 : 23;
        } else {
          n = x & 0x00200000 ? 22 : 21;
        }
      } else {
        if (x & 0x000C0000) {
          n = x & 0x00080000 ? 20 : 19;
        } else {
          n = x & 0x00020000 ? 18 : 17;
        }
      }
    }
  } else {
    if (x & 0xff00) {
      if (x & 0xf000) {
        if (x & 0xC000) {
          n = x & 0x8000 ? 16 : 15;
        } else {
          n = x & 0x2000 ? 14 : 13;
        }
      } else {
        if (x & 0x0C00) {
          n = x & 0x0800 ? 12 : 11;
        } else {
          n = x & 0x0200 ? 10 : 9;
        }
      }
    } else {
      if (x & 0xf0) {
        if (x & 0x00C0) {
          n = x & 0x0080 ? 8 : 7;
        } else {
          n = x & 0x0020 ? 6 : 5;
        }
      } else {
        if (x & 0x000C) {
          n = x & 0x0008 ? 4 : 3;
        } else {
          n = x & 0x0002 ? 2 : 1;
        }
      }
    }
  }
  return n;
}
```