user: 请显示与下面列出的汇编代码相匹配的C语言实现:

```asm
<rearrange_relocs>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x70,%rsp
  mov    %rdi,-0x58(%rbp)
  mov    %rsi,-0x60(%rbp)
  mov    %rdx,-0x68(%rbp)
  mov    %rcx,-0x70(%rbp)
  cmpq   $0x0,-0x58(%rbp)
  jne    L93
  mov    $0x1,%eax
  jmp    L15
L93:
  movl   $0x0,-0x48(%rbp)
  jmp    L76
L68:
  mov    -0x38(%rbp),%rax
  mov    (%rax),%rdx
  mov    D12(%rip),%rax
  mov    (%rax),%rax
  cmp    %rax,%rdx
  jne    L44
  mov    -0x38(%rbp),%rax
  mov    0x8(%rax),%eax
  cltq
  shr    $0x3,%rax
  mov    %eax,-0x40(%rbp)
  movl   $0x0,-0x44(%rbp)
  jmp    L20
L131:
  mov    -0x38(%rbp),%rax
  mov    0x10(%rax),%rdx
  mov    -0x58(%rbp),%rax
  add    %rax,%rdx
  mov    -0x44(%rbp),%eax
  cltq
  shl    $0x3,%rax
  add    %rdx,%rax
  mov    %rax,-0x30(%rbp)
  mov    -0x30(%rbp),%rax
  mov    %rax,-0x8(%rbp)
  mov    -0x8(%rbp),%rax
  mov    (%rax),%rax
  mov    %rax,%rdx
  mov    -0x60(%rbp),%rax
  cmp    %rax,%rdx
  jb     L79
  mov    -0x8(%rbp),%rax
  mov    (%rax),%rax
  mov    %rax,%rdx
  mov    -0x68(%rbp),%rax
  cmp    %rax,%rdx
  jae    L79
  mov    -0x8(%rbp),%rax
  mov    (%rax),%rax
  mov    %rax,%rdx
  mov    -0x70(%rbp),%rax
  add    %rdx,%rax
  mov    %rax,%rdx
  mov    -0x8(%rbp),%rax
  mov    %rdx,(%rax)
L79:
  addl   $0x1,-0x44(%rbp)
L20:
  mov    -0x44(%rbp),%eax
  cmp    -0x40(%rbp),%eax
  jl     L131
  jmp    L76
L44:
  mov    -0x38(%rbp),%rax
  mov    (%rax),%rdx
  mov    D19(%rip),%rax
  mov    (%rax),%rax
  cmp    %rax,%rdx
  jne    L76
  mov    -0x38(%rbp),%rax
  mov    0x8(%rax),%eax
  cltq
  shr    $0x4,%rax
  mov    %eax,-0x40(%rbp)
  movl   $0x0,-0x44(%rbp)
  jmp    L116
L92:
  mov    -0x38(%rbp),%rax
  mov    0x10(%rax),%rdx
  mov    -0x58(%rbp),%rax
  add    %rax,%rdx
  mov    -0x44(%rbp),%eax
  cltq
  shl    $0x4,%rax
  add    %rdx,%rax
  mov    %rax,-0x30(%rbp)
  mov    -0x30(%rbp),%rax
  mov    %rax,-0x28(%rbp)
  mov    -0x28(%rbp),%rax
  mov    (%rax),%rax
  mov    %rax,%rdx
  mov    -0x60(%rbp),%rax
  cmp    %rax,%rdx
  jb     L157
  mov    -0x28(%rbp),%rax
  mov    (%rax),%rax
  mov    %rax,%rdx
  mov    -0x68(%rbp),%rax
  cmp    %rax,%rdx
  jae    L157
  mov    -0x38(%rbp),%rax
  mov    0x1c(%rax),%edx
  mov    -0x58(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <get_s_header@plt>
  mov    %rax,-0x20(%rbp)
  mov    -0x28(%rbp),%rax
  mov    0x8(%rax),%eax
  mov    %eax,%edi
  call   <ELF64_R_SYM@plt>
  mov    %eax,-0x3c(%rbp)
  mov    -0x20(%rbp),%rax
  mov    0x10(%rax),%rdx
  mov    -0x58(%rbp),%rax
  add    %rdx,%rax
  mov    %rax,-0x18(%rbp)
  mov    -0x20(%rbp),%rax
  mov    0x18(%rax),%eax
  imul   -0x3c(%rbp),%eax
  cltq
  add    %rax,-0x18(%rbp)
  mov    -0x18(%rbp),%rax
  mov    %rax,-0x10(%rbp)
  mov    -0x28(%rbp),%rax
  mov    (%rax),%rdx
  mov    -0x10(%rbp),%rax
  mov    (%rax),%rax
  cmp    %rax,%rdx
  jne    L55
  mov    -0x10(%rbp),%rax
  mov    (%rax),%rax
  mov    %rax,%rdx
  mov    -0x70(%rbp),%rax
  add    %rdx,%rax
  mov    %rax,%rdx
  mov    -0x10(%rbp),%rax
  mov    %rdx,(%rax)
L55:
  mov    -0x28(%rbp),%rax
  mov    (%rax),%rax
  mov    %rax,%rdx
  mov    -0x70(%rbp),%rax
  add    %rdx,%rax
  mov    %rax,%rdx
  mov    -0x28(%rbp),%rax
  mov    %rdx,(%rax)
L157:
  addl   $0x1,-0x44(%rbp)
L116:
  mov    -0x44(%rbp),%eax
  cmp    -0x40(%rbp),%eax
  jl     L92
L76:
  mov    -0x48(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0x48(%rbp)
  mov    -0x58(%rbp),%rdx
  mov    %eax,%esi
  mov    %rdx,%rdi
  call   <get_s_header@plt>
  mov    %rax,-0x38(%rbp)
  cmpq   $0x0,-0x38(%rbp)
  jne    L68
  mov    $0x0,%eax
L15:
  leave
  ret
```

assistant: ```c
int rearrange_relocs(char *elf, void *base, void *top, size_t n) {
  if (!elf)
    return 1;
  int sh_num;
  sh_num = 0;
  Elf64_Shdr *shdr;
  Elf64_Shdr *linked;
  while ((shdr = get_s_header(elf, sh_num++))) {
    int num, i;
    unsigned long long addr;
    if (shdr->sh_type == SHT_RELA) {
      num = shdr->sh_size / sizeof(Elf64_Rela);
      Elf64_Rela *rel;
      for (i = 0; i < num; i++) {
        addr = ((unsigned long long)elf + shdr->sh_offset + (i * sizeof(Elf64_Rela)));
        rel = (Elf64_Rela *)addr;
        if ((unsigned long long)rel->r_offset >= (unsigned long long)base && (unsigned long long)rel->r_offset < (unsigned long long)top) {
          rel->r_offset += n;
        }
      }
    } else if (shdr->sh_type == SHT_REL) {
      num = shdr->sh_size / sizeof(Elf64_Rel);
      Elf64_Rel *rel;
      for (i = 0; i < num; i++) {
        addr = ((unsigned long long)elf + shdr->sh_offset + (i * sizeof(Elf64_Rel)));
        rel = (Elf64_Rel *)addr;
        if ((unsigned long long)rel->r_offset >= (unsigned long long)base && (unsigned long long)rel->r_offset < (unsigned long long)top) {
          linked = get_s_header(elf, shdr->sh_link);
          unsigned long long sym_addr;
          Elf64_Sym *sym;
          int sym_ind = ELF64_R_SYM(rel->r_info);
          sym_addr = (unsigned long long)elf + linked->sh_offset;
          sym_addr += linked->sh_entsize * sym_ind;
          sym = (Elf64_Sym *)sym_addr;
          if (rel->r_offset == sym->st_value)
            sym->st_value += n;
          rel->r_offset += n;
        }
      }
    }
  }
  return 0;
}
```