user: 请将以下的汇编代码转换成C语言代码：

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