user: Translate the below assembly code into C programming language:

```asm
<iap_get_sector>:
  endbr64
  mov    %edi,%eax
  xor    %r8d,%r8d
  cmp    $0xfff,%edi
  jle    L5
  lea    -0x1000(%rdi),%edx
  mov    $0x1,%r8d
  cmp    $0xfff,%edx
  jbe    L5
  lea    -0x2000(%rdi),%edx
  mov    $0x2,%r8d
  cmp    $0xfff,%edx
  jbe    L5
  lea    -0x3000(%rdi),%edx
  mov    $0x3,%r8d
  cmp    $0xfff,%edx
  jbe    L5
  lea    -0x4000(%rdi),%edx
  mov    $0x4,%r8d
  cmp    $0xfff,%edx
  jbe    L5
  lea    -0x5000(%rdi),%edx
  mov    $0x5,%r8d
  cmp    $0xfff,%edx
  jbe    L5
  lea    -0x6000(%rdi),%edx
  mov    $0x6,%r8d
  cmp    $0xfff,%edx
  jbe    L5
  lea    -0x7000(%rdi),%edx
  mov    $0x7,%r8d
  cmp    $0xfff,%edx
  jbe    L5
  lea    -0x8000(%rdi),%edx
  mov    $0x8,%r8d
  cmp    $0x7fff,%edx
  jbe    L5
  lea    -0x10000(%rdi),%edx
  mov    $0x9,%r8d
  cmp    $0x7fff,%edx
  jbe    L5
  lea    -0x18000(%rdi),%edx
  mov    $0xa,%r8d
  cmp    $0x7fff,%edx
  jbe    L5
  lea    -0x20000(%rdi),%edx
  mov    $0xb,%r8d
  cmp    $0x7fff,%edx
  jbe    L5
  lea    -0x28000(%rdi),%edx
  mov    $0xc,%r8d
  cmp    $0x7fff,%edx
  jbe    L5
  lea    -0x30000(%rdi),%edx
  mov    $0xd,%r8d
  cmp    $0x7fff,%edx
  jbe    L5
  lea    -0x38000(%rdi),%edx
  mov    $0xe,%r8d
  cmp    $0x7fff,%edx
  jbe    L5
  lea    -0x40000(%rdi),%edx
  mov    $0xf,%r8d
  cmp    $0x7fff,%edx
  jbe    L5
  lea    -0x48000(%rdi),%edx
  mov    $0x10,%r8d
  cmp    $0x7fff,%edx
  jbe    L5
  lea    -0x50000(%rdi),%edx
  mov    $0x11,%r8d
  cmp    $0x7fff,%edx
  jbe    L5
  lea    -0x58000(%rdi),%edx
  mov    $0x12,%r8d
  cmp    $0x7fff,%edx
  jbe    L5
  lea    -0x60000(%rdi),%edx
  mov    $0x13,%r8d
  cmp    $0x7fff,%edx
  jbe    L5
  lea    -0x68000(%rdi),%edx
  mov    $0x14,%r8d
  cmp    $0x7fff,%edx
  jbe    L5
  lea    -0x70000(%rdi),%edx
  mov    $0x15,%r8d
  cmp    $0x7fff,%edx
  jbe    L5
  lea    -0x78000(%rdi),%edx
  mov    $0x16,%r8d
  cmp    $0xfff,%edx
  jbe    L5
  lea    -0x79000(%rdi),%edx
  mov    $0x17,%r8d
  cmp    $0xfff,%edx
  jbe    L5
  lea    -0x7a000(%rdi),%edx
  mov    $0x18,%r8d
  cmp    $0xfff,%edx
  jbe    L5
  lea    -0x7b000(%rdi),%edx
  mov    $0x19,%r8d
  cmp    $0xfff,%edx
  jbe    L5
  lea    -0x7c000(%rdi),%edx
  mov    $0x1a,%r8d
  cmp    $0xfff,%edx
  jbe    L5
  sub    $0x7d000,%eax
  cmp    $0x1000,%eax
  sbb    %r8d,%r8d
  and    $0x1c,%r8b
  add    $0xff,%r8d
L5:
  mov    %r8d,%eax
  ret
```

assistant: ```c
uint8_t iap_get_sector(uint32_t addr) {
  if (addr <= 0x00000FFF) {
    return 0;
  }
  if ((addr >= 0x00001000) && (addr <= 0x00001FFF)) {
    return 1;
  }
  if ((addr >= 0x00002000) && (addr <= 0x00002FFF)) {
    return 2;
  }
  if ((addr >= 0x00003000) && (addr <= 0x00003FFF)) {
    return 3;
  }
  if ((addr >= 0x00004000) && (addr <= 0x00004FFF)) {
    return 4;
  }
  if ((addr >= 0x00005000) && (addr <= 0x00005FFF)) {
    return 5;
  }
  if ((addr >= 0x00006000) && (addr <= 0x00006FFF)) {
    return 6;
  }
  if ((addr >= 0x00007000) && (addr <= 0x00007FFF)) {
    return 7;
  }
  if ((addr >= 0x00008000) && (addr <= 0x0000FFFF)) {
    return 8;
  }
  if ((addr >= 0x00010000) && (addr <= 0x00017FFF)) {
    return 9;
  }
  if ((addr >= 0x00018000) && (addr <= 0x0001FFFF)) {
    return 10;
  }
  if ((addr >= 0x00020000) && (addr <= 0x00027FFF)) {
    return 11;
  }
  if ((addr >= 0x00028000) && (addr <= 0x0002FFFF)) {
    return 12;
  }
  if ((addr >= 0x00030000) && (addr <= 0x00037FFF)) {
    return 13;
  }
  if ((addr >= 0x00038000) && (addr <= 0x0003FFFF)) {
    return 14;
  }
  if ((addr >= 0x00040000) && (addr <= 0x00047FFF)) {
    return 15;
  }
  if ((addr >= 0x00048000) && (addr <= 0x0004FFFF)) {
    return 16;
  }
  if ((addr >= 0x00050000) && (addr <= 0x00057FFF)) {
    return 17;
  }
  if ((addr >= 0x00058000) && (addr <= 0x0005FFFF)) {
    return 18;
  }
  if ((addr >= 0x00060000) && (addr <= 0x00067FFF)) {
    return 19;
  }
  if ((addr >= 0x00068000) && (addr <= 0x0006FFFF)) {
    return 20;
  }
  if ((addr >= 0x00070000) && (addr <= 0x00077FFF)) {
    return 21;
  }
  if ((addr >= 0x00078000) && (addr <= 0x00078FFF)) {
    return 22;
  }
  if ((addr >= 0x00079000) && (addr <= 0x00079FFF)) {
    return 23;
  }
  if ((addr >= 0x0007A000) && (addr <= 0x0007AFFF)) {
    return 24;
  }
  if ((addr >= 0x0007B000) && (addr <= 0x0007BFFF)) {
    return 25;
  }
  if ((addr >= 0x0007C000) && (addr <= 0x0007CFFF)) {
    return 26;
  }
  if ((addr >= 0x0007D000) && (addr <= 0x0007DFFF)) {
    return 27;
  }
  return (0xFF);
}
```