#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
struct elf32_fdpic_loadmap {
  int dummy;
};

/* Variables and functions */
void *__reloc_pointer(void **, struct elf32_fdpic_loadmap const *);
void ***reloc_range_indirect(void ***, void ***,
                             struct elf32_fdpic_loadmap const *);
void *__attribute__((__visibility__("hidden")))
__self_reloc(const struct elf32_fdpic_loadmap *map, void ***p, void ***e) {
  p = reloc_range_indirect(p, e - 1, map);
  if (p >= e)
    return (void *)-1;
  return __reloc_pointer(*p, map);
}


x86 assembly (clang, -O0):
<__self_reloc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
add    $0xfffffffffffffff8,%rsi
mov    -0x10(%rbp),%rdx
call   1040 <reloc_range_indirect@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x20(%rbp),%rax
jb     116b <__self_reloc+0x4b>
mov    $0xffffffffffffffff,%rax
mov    %rax,-0x8(%rbp)
jmp    117f <__self_reloc+0x5f>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <__reloc_pointer@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__self_reloc>:
push   %r14
push   %rbx
push   %rax
mov    %rdx,%rbx
mov    %rsi,%rax
mov    %rdi,%r14
lea    -0x8(%rdx),%rsi
mov    %rax,%rdi
mov    %r14,%rdx
call   1040 <reloc_range_indirect@plt>
cmp    %rbx,%rax
jae    1153 <__self_reloc+0x33>
mov    (%rax),%rdi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <__reloc_pointer@plt>
mov    $0xffffffffffffffff,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.elf32_fdpic_loadmap = type { i32 }
define hidden i8* @__self_reloc(%struct.elf32_fdpic_loadmap* %0, i8*** %1, i8*** %2) {
%4 = alloca i8*
%5 = alloca %struct.elf32_fdpic_loadmap*
%6 = alloca i8***
%7 = alloca i8***
store %struct.elf32_fdpic_loadmap* %0, %struct.elf32_fdpic_loadmap** %5
store i8*** %1, i8**** %6
store i8*** %2, i8**** %7
%8 = load i8***, i8**** %6
%9 = load i8***, i8**** %7
%10 = getelementptr inbounds i8**, i8*** %9, i64 -1
%11 = load %struct.elf32_fdpic_loadmap*, %struct.elf32_fdpic_loadmap** %5
%12 = call i8*** @reloc_range_indirect(i8*** %8, i8*** %10, %struct.elf32_fdpic_loadmap* %11)
store i8*** %12, i8**** %6
%13 = load i8***, i8**** %6
%14 = load i8***, i8**** %7
%15 = icmp uge i8*** %13, %14
br i1 %15, label %16, label %17
16: ; preds = %3
store i8* inttoptr (i64 -1 to i8*), i8** %4
br label %22
17: ; preds = %3
%18 = load i8***, i8**** %6
%19 = load i8**, i8*** %18
%20 = load %struct.elf32_fdpic_loadmap*, %struct.elf32_fdpic_loadmap** %5
%21 = call i8* @__reloc_pointer(i8** %19, %struct.elf32_fdpic_loadmap* %20)
store i8* %21, i8** %4
br label %22
22: ; preds = %17, %16
%23 = load i8*, i8** %4
ret i8* %23
}

LLVM IR (-O2):
%struct.elf32_fdpic_loadmap = type { i32 }
define hidden i8* @__self_reloc(%struct.elf32_fdpic_loadmap* %0, i8*** %1, i8*** %2) {
%4 = getelementptr inbounds i8**, i8*** %2, i64 -1
%5 = tail call i8*** @reloc_range_indirect(i8*** %1, i8*** %4, %struct.elf32_fdpic_loadmap* %0)
%6 = icmp ult i8*** %5, %2
br i1 %6, label %7, label %10
7: ; preds = %3
%8 = load i8**, i8*** %5
%9 = tail call i8* @__reloc_pointer(i8** %8, %struct.elf32_fdpic_loadmap* %0)
br label %10
10: ; preds = %3, %7
%11 = phi i8* [ %9, %7 ], [ inttoptr (i64 -1 to i8*), %3 ]
ret i8* %11
}