#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 */
typedef struct TYPE_9__ TYPE_2__;
typedef struct TYPE_8__ TYPE_1__;

/* Type definitions */
struct TYPE_9__ {
  scalar_t__ d_tag;
};
struct TYPE_8__ {
  scalar_t__ p_filesz;
  int /*<<< orphan*/ p_offset;
  int /*<<< orphan*/ p_memsz;
};
typedef TYPE_1__ Elf32_Phdr;
typedef int /*<<< orphan*/ Elf32_Ehdr;
typedef TYPE_2__ Elf32_Dyn;

/* Variables and functions */
scalar_t__ DT_NULL;
int /*<<< orphan*/ O_RDWR;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ elf_close(int);
int /*<<< orphan*/ elf_dynpath_tag(scalar_t__);
scalar_t__ elf_find_dynamic_section(int, int /*<<< orphan*/ *, TYPE_1__ *);
int elf_open(char const *, int /*<<< orphan*/, int /*<<< orphan*/ *);
int lseek(int, int /*<<< orphan*/, int /*<<< orphan*/);
TYPE_2__ *malloc(int /*<<< orphan*/);
int /*<<< orphan*/ memset(TYPE_2__ *, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int read(int, TYPE_2__ *, scalar_t__);
int write(int, TYPE_2__ *, scalar_t__);
int killrpath(const char *filename) {
  int fd;
  Elf32_Ehdr ehdr;
  int i;
  Elf32_Phdr phdr;
  Elf32_Dyn *dyns;
  int dynpos;
  fd = elf_open(filename, O_RDWR, &ehdr);
  if (fd == -1) {
    perror("elf_open");
    return 1;
  }
  if (0 != elf_find_dynamic_section(fd, &ehdr, &phdr)) {
    perror("found no dynamic section");
    return 1;
  }
  dyns = malloc(phdr.p_memsz);
  if (dyns == NULL) {
    perror("allocating memory for dynamic section");
    return 1;
  }
  memset(dyns, 0, phdr.p_memsz);
  if (lseek(fd, phdr.p_offset, SEEK_SET) == -1 ||
      read(fd, dyns, phdr.p_filesz) != (int)phdr.p_filesz) {
    perror("reading dynamic section");
    return 1;
  }
  dynpos = 0;
  for (i = 0; dyns[i].d_tag != DT_NULL; i++) {
    dyns[dynpos] = dyns[i];
    if (!elf_dynpath_tag(dyns[i].d_tag))
      dynpos++;
  }
  for (; dynpos < i; dynpos++)
    dyns[dynpos].d_tag = DT_NULL;
  if (lseek(fd, phdr.p_offset, SEEK_SET) == -1 ||
      write(fd, dyns, phdr.p_filesz) != (int)phdr.p_filesz) {
    perror("writing dynamic section");
    return 1;
  }
  elf_close(fd);
  return 0;
}


x86 assembly (clang, -O0):
<killrpath>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2e31(%rip),%rax
mov    (%rax),%esi
lea    -0x18(%rbp),%rdx
call   1090 <elf_open@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    11e7 <killrpath+0x47>
lea    0xe2a(%rip),%rdi
call   10c0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    13b8 <killrpath+0x218>
mov    -0x14(%rbp),%edi
lea    -0x18(%rbp),%rsi
lea    -0x30(%rbp),%rdx
call   1070 <elf_find_dynamic_section@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
je     121d <killrpath+0x7d>
lea    0xdfd(%rip),%rdi
call   10c0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    13b8 <killrpath+0x218>
mov    -0x24(%rbp),%edi
call   10a0 <malloc@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    124c <killrpath+0xac>
lea    0xde7(%rip),%rdi
call   10c0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    13b8 <killrpath+0x218>
mov    -0x38(%rbp),%rdi
mov    -0x24(%rbp),%edx
xor    %esi,%esi
call   1060 <memset@plt>
mov    -0x14(%rbp),%edi
mov    -0x28(%rbp),%esi
mov    0x2d71(%rip),%rax
mov    (%rax),%edx
call   1050 <lseek@plt>
cmp    $0xffffffff,%eax
je     1293 <killrpath+0xf3>
mov    -0x14(%rbp),%edi
mov    -0x38(%rbp),%rsi
mov    -0x30(%rbp),%rdx
call   1080 <read@plt>
mov    -0x30(%rbp),%rcx
cmp    %ecx,%eax
je     12ab <killrpath+0x10b>
lea    0xdae(%rip),%rdi
call   10c0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    13b8 <killrpath+0x218>
movl   $0x0,-0x3c(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x38(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    0x2d04(%rip),%rcx
cmp    (%rcx),%rax
je     1323 <killrpath+0x183>
mov    -0x38(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    -0x38(%rbp),%rdx
movslq -0x1c(%rbp),%rsi
mov    (%rdx,%rsi,8),%rdx
mov    %rdx,(%rax,%rcx,8)
mov    -0x38(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1040 <elf_dynpath_tag@plt>
cmp    $0x0,%eax
jne    1310 <killrpath+0x170>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1315 <killrpath+0x175>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    12b9 <killrpath+0x119>
jmp    1328 <killrpath+0x188>
mov    -0x3c(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1358 <killrpath+0x1b8>
mov    0x2c95(%rip),%rax
mov    (%rax),%rdx
mov    -0x38(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1328 <killrpath+0x188>
mov    -0x14(%rbp),%edi
mov    -0x28(%rbp),%esi
mov    0x2c73(%rip),%rax
mov    (%rax),%edx
call   1050 <lseek@plt>
cmp    $0xffffffff,%eax
je     1391 <killrpath+0x1f1>
mov    -0x14(%rbp),%edi
mov    -0x38(%rbp),%rsi
mov    -0x30(%rbp),%rdx
call   1030 <write@plt>
mov    -0x30(%rbp),%rcx
cmp    %ecx,%eax
je     13a9 <killrpath+0x209>
lea    0xcc8(%rip),%rdi
call   10c0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    13b8 <killrpath+0x218>
mov    -0x14(%rbp),%edi
call   10b0 <elf_close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<killrpath>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    0x2e33(%rip),%rax
mov    (%rax),%esi
lea    0x14(%rsp),%rdx
call   1090 <elf_open@plt>
cmp    $0xffffffff,%eax
je     12d9 <killrpath+0x139>
mov    %eax,%r14d
lea    0x14(%rsp),%rsi
mov    %rsp,%rdx
mov    %eax,%edi
call   1070 <elf_find_dynamic_section@plt>
test   %rax,%rax
jne    12e5 <killrpath+0x145>
mov    0xc(%rsp),%ebp
mov    %ebp,%edi
call   10a0 <malloc@plt>
test   %rax,%rax
je     12f1 <killrpath+0x151>
mov    %rax,%r13
mov    %rax,%rdi
xor    %esi,%esi
mov    %ebp,%edx
call   1060 <memset@plt>
mov    0x8(%rsp),%esi
mov    0x2dc5(%rip),%r15
mov    (%r15),%edx
mov    %r14d,%edi
call   1050 <lseek@plt>
cmp    $0xffffffff,%eax
je     12cd <killrpath+0x12d>
mov    (%rsp),%rdx
mov    %r14d,%edi
mov    %r13,%rsi
call   1080 <read@plt>
cmp    (%rsp),%eax
jne    12cd <killrpath+0x12d>
mov    0x0(%r13),%rax
mov    0x2d86(%rip),%r12
cmp    (%r12),%rax
je     13ce <killrpath+0x22e>
xor    %ebp,%ebp
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    %ebx,%ecx
mov    %rax,0x0(%r13,%rcx,8)
mov    0x0(%r13,%rbp,8),%rdi
call   1040 <elf_dynpath_tag@plt>
cmp    $0x1,%eax
adc    $0x0,%ebx
mov    0x8(%r13,%rbp,8),%rax
add    $0x1,%rbp
cmp    (%r12),%rax
jne    1260 <killrpath+0xc0>
cmp    %ebp,%ebx
jae    13ce <killrpath+0x22e>
mov    %ebx,%ecx
mov    %ebp,%r10d
sub    %rcx,%r10
cmp    $0x4,%r10
jb     13bc <killrpath+0x21c>
mov    %r10,%r8
and    $0xfffffffffffffffc,%r8
movq   %rax,%xmm0
pshufd $0x44,%xmm0,%xmm0
lea    -0x4(%r8),%rdx
mov    %rdx,%r9
shr    $0x2,%r9
add    $0x1,%r9
cmp    $0xc,%rdx
jae    12fd <killrpath+0x15d>
xor    %edx,%edx
jmp    1369 <killrpath+0x1c9>
lea    0xd74(%rip),%rdi
jmp    1409 <killrpath+0x269>
lea    0xd20(%rip),%rdi
jmp    1409 <killrpath+0x269>
lea    0xd1d(%rip),%rdi
jmp    1409 <killrpath+0x269>
lea    0xd2a(%rip),%rdi
jmp    1409 <killrpath+0x269>
lea    0x70(,%rcx,8),%rsi
add    %r13,%rsi
mov    %ebp,%edi
sub    %rcx,%rdi
and    $0xfffffffffffffffc,%rdi
add    $0xfffffffffffffffc,%rdi
shr    $0x2,%rdi
add    $0x1,%rdi
and    $0xfffffffffffffffc,%rdi
xor    %edx,%edx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movdqu %xmm0,-0x70(%rsi,%rdx,8)
movdqu %xmm0,-0x60(%rsi,%rdx,8)
movdqu %xmm0,-0x50(%rsi,%rdx,8)
movdqu %xmm0,-0x40(%rsi,%rdx,8)
movdqu %xmm0,-0x30(%rsi,%rdx,8)
movdqu %xmm0,-0x20(%rsi,%rdx,8)
movdqu %xmm0,-0x10(%rsi,%rdx,8)
movdqu %xmm0,(%rsi,%rdx,8)
add    $0x10,%rdx
add    $0xfffffffffffffffc,%rdi
jne    1330 <killrpath+0x190>
test   $0x3,%r9b
je     13b4 <killrpath+0x214>
add    %rcx,%rdx
lea    0x10(,%rdx,8),%rdx
add    %r13,%rdx
mov    %ebp,%esi
sub    %ecx,%esi
and    $0xc,%sil
add    $0xfc,%sil
shr    $0x2,%sil
add    $0x1,%sil
movzbl %sil,%esi
and    $0x3,%esi
shl    $0x5,%rsi
xor    %edi,%edi
xchg   %ax,%ax
movdqu %xmm0,-0x10(%rdx,%rdi,1)
movdqu %xmm0,(%rdx,%rdi,1)
add    $0x20,%rdi
cmp    %rdi,%rsi
jne    13a0 <killrpath+0x200>
cmp    %r8,%r10
je     13ce <killrpath+0x22e>
add    %r8,%rcx
mov    %ebp,%edx
xchg   %ax,%ax
mov    %rax,0x0(%r13,%rcx,8)
add    $0x1,%rcx
cmp    %rcx,%rdx
jne    13c0 <killrpath+0x220>
mov    0x8(%rsp),%esi
mov    (%r15),%edx
mov    %r14d,%edi
call   1050 <lseek@plt>
cmp    $0xffffffff,%eax
je     1402 <killrpath+0x262>
mov    (%rsp),%rdx
mov    %r14d,%edi
mov    %r13,%rsi
call   1030 <write@plt>
cmp    (%rsp),%eax
jne    1402 <killrpath+0x262>
mov    %r14d,%edi
call   10b0 <elf_close@plt>
xor    %eax,%eax
jmp    1413 <killrpath+0x273>
lea    0xc57(%rip),%rdi
call   10c0 <perror@plt>
mov    $0x1,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.TYPE_8__ = type { i64, i32, i32 }
%struct.TYPE_9__ = type { i64 }
@O_RDWR = global i32 0
@.str = [9 x i8] c"elf_open\00"
@.str.1 = [25 x i8] c"found no dynamic section\00"
@.str.2 = [38 x i8] c"allocating memory for dynamic section\00"
@SEEK_SET = global i32 0
@.str.3 = [24 x i8] c"reading dynamic section\00"
@DT_NULL = global i64 0
@.str.4 = [24 x i8] c"writing dynamic section\00"
define i32 @killrpath(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca %struct.TYPE_8__
%8 = alloca %struct.TYPE_9__*
%9 = alloca i32
store i8* %0, i8** %3
%10 = load i8*, i8** %3
%11 = load i32, i32* @O_RDWR
%12 = call i32 @elf_open(i8* %10, i32 %11, i32* %5)
store i32 %12, i32* %4
%13 = load i32, i32* %4
%14 = icmp eq i32 %13, -1
br i1 %14, label %15, label %17
15: ; preds = %1
%16 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %2
br label %127
17: ; preds = %1
%18 = load i32, i32* %4
%19 = call i64 @elf_find_dynamic_section(i32 %18, i32* %5, %struct.TYPE_8__* %7)
%20 = icmp ne i64 0, %19
br i1 %20, label %21, label %23
21: ; preds = %17
%22 = call i32 @perror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %2
br label %127
23: ; preds = %17
%24 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %7, i32 0, i32 2
%25 = load i32, i32* %24
%26 = call %struct.TYPE_9__* @malloc(i32 %25)
store %struct.TYPE_9__* %26, %struct.TYPE_9__** %8
%27 = load %struct.TYPE_9__*, %struct.TYPE_9__** %8
%28 = icmp eq %struct.TYPE_9__* %27, null
br i1 %28, label %29, label %31
29: ; preds = %23
%30 = call i32 @perror(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %2
br label %127
31: ; preds = %23
%32 = load %struct.TYPE_9__*, %struct.TYPE_9__** %8
%33 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %7, i32 0, i32 2
%34 = load i32, i32* %33
%35 = call i32 @memset(%struct.TYPE_9__* %32, i32 0, i32 %34)
%36 = load i32, i32* %4
%37 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %7, i32 0, i32 1
%38 = load i32, i32* %37
%39 = load i32, i32* @SEEK_SET
%40 = call i32 @lseek(i32 %36, i32 %38, i32 %39)
%41 = icmp eq i32 %40, -1
br i1 %41, label %52, label %42
42: ; preds = %31
%43 = load i32, i32* %4
%44 = load %struct.TYPE_9__*, %struct.TYPE_9__** %8
%45 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %7, i32 0, i32 0
%46 = load i64, i64* %45
%47 = call i32 @read(i32 %43, %struct.TYPE_9__* %44, i64 %46)
%48 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %7, i32 0, i32 0
%49 = load i64, i64* %48
%50 = trunc i64 %49 to i32
%51 = icmp ne i32 %47, %50
br i1 %51, label %52, label %54
52: ; preds = %42, %31
%53 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %2
br label %127
54: ; preds = %42
store i32 0, i32* %9
store i32 0, i32* %6
br label %55
55: ; preds = %87, %54
%56 = load %struct.TYPE_9__*, %struct.TYPE_9__** %8
%57 = load i32, i32* %6
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %56, i64 %58
%60 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %59, i32 0, i32 0
%61 = load i64, i64* %60
%62 = load i64, i64* @DT_NULL
%63 = icmp ne i64 %61, %62
br i1 %63, label %64, label %90
64: ; preds = %55
%65 = load %struct.TYPE_9__*, %struct.TYPE_9__** %8
%66 = load i32, i32* %9
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %65, i64 %67
%69 = load %struct.TYPE_9__*, %struct.TYPE_9__** %8
%70 = load i32, i32* %6
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %69, i64 %71
%73 = bitcast %struct.TYPE_9__* %68 to i8*
%74 = bitcast %struct.TYPE_9__* %72 to i8*
%75 = load %struct.TYPE_9__*, %struct.TYPE_9__** %8
%76 = load i32, i32* %6
%77 = sext i32 %76 to i64
%78 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %75, i64 %77
%79 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %78, i32 0, i32 0
%80 = load i64, i64* %79
%81 = call i32 @elf_dynpath_tag(i64 %80)
%82 = icmp ne i32 %81, 0
br i1 %82, label %86, label %83
83: ; preds = %64
%84 = load i32, i32* %9
%85 = add nsw i32 %84, 1
store i32 %85, i32* %9
br label %86
86: ; preds = %83, %64
br label %87
87: ; preds = %86
%88 = load i32, i32* %6
%89 = add nsw i32 %88, 1
store i32 %89, i32* %6
br label %55
90: ; preds = %55
br label %91
91: ; preds = %102, %90
%92 = load i32, i32* %9
%93 = load i32, i32* %6
%94 = icmp slt i32 %92, %93
br i1 %94, label %95, label %105
95: ; preds = %91
%96 = load i64, i64* @DT_NULL
%97 = load %struct.TYPE_9__*, %struct.TYPE_9__** %8
%98 = load i32, i32* %9
%99 = sext i32 %98 to i64
%100 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %97, i64 %99
%101 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %100, i32 0, i32 0
store i64 %96, i64* %101
br label %102
102: ; preds = %95
%103 = load i32, i32* %9
%104 = add nsw i32 %103, 1
store i32 %104, i32* %9
br label %91
105: ; preds = %91
%106 = load i32, i32* %4
%107 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %7, i32 0, i32 1
%108 = load i32, i32* %107
%109 = load i32, i32* @SEEK_SET
%110 = call i32 @lseek(i32 %106, i32 %108, i32 %109)
%111 = icmp eq i32 %110, -1
br i1 %111, label %122, label %112
112: ; preds = %105
%113 = load i32, i32* %4
%114 = load %struct.TYPE_9__*, %struct.TYPE_9__** %8
%115 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %7, i32 0, i32 0
%116 = load i64, i64* %115
%117 = call i32 @write(i32 %113, %struct.TYPE_9__* %114, i64 %116)
%118 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %7, i32 0, i32 0
%119 = load i64, i64* %118
%120 = trunc i64 %119 to i32
%121 = icmp ne i32 %117, %120
br i1 %121, label %122, label %124
122: ; preds = %112, %105
%123 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
store i32 1, i32* %2
br label %127
124: ; preds = %112
%125 = load i32, i32* %4
%126 = call i32 @elf_close(i32 %125)
store i32 0, i32* %2
br label %127
127: ; preds = %124, %122, %52, %29, %21, %15
%128 = load i32, i32* %2
ret i32 %128
}

LLVM IR (-O2):
%struct.TYPE_8__ = type { i64, i32, i32 }
%struct.TYPE_9__ = type { i64 }
@O_RDWR = global i32 0
@.str = [9 x i8] c"elf_open\00"
@.str.1 = [25 x i8] c"found no dynamic section\00"
@.str.2 = [38 x i8] c"allocating memory for dynamic section\00"
@SEEK_SET = global i32 0
@.str.3 = [24 x i8] c"reading dynamic section\00"
@DT_NULL = global i64 0
@.str.4 = [24 x i8] c"writing dynamic section\00"
define i32 @killrpath(i8* %0) {
%2 = alloca i32
%3 = alloca %struct.TYPE_8__
%4 = bitcast i32* %2 to i8*
%5 = bitcast %struct.TYPE_8__* %3 to i8*
%6 = load i32, i32* @O_RDWR
%7 = call i32 @elf_open(i8* %0, i32 %6, i32* %2)
%8 = icmp eq i32 %7, -1
br i1 %8, label %9, label %11
9: ; preds = %1
%10 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
br label %150
11: ; preds = %1
%12 = call i64 @elf_find_dynamic_section(i32 %7, i32* %2, %struct.TYPE_8__* %3)
%13 = icmp eq i64 %12, 0
br i1 %13, label %16, label %14
14: ; preds = %11
%15 = call i32 @perror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
br label %150
16: ; preds = %11
%17 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %3, i64 0, i32 2
%18 = load i32, i32* %17
%19 = call %struct.TYPE_9__* @malloc(i32 %18)
%20 = icmp eq %struct.TYPE_9__* %19, null
br i1 %20, label %21, label %23
21: ; preds = %16
%22 = call i32 @perror(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0))
br label %150
23: ; preds = %16
%24 = call i32 @memset(%struct.TYPE_9__* %19, i32 0, i32 %18)
%25 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %3, i64 0, i32 1
%26 = load i32, i32* %25
%27 = load i32, i32* @SEEK_SET
%28 = call i32 @lseek(i32 %7, i32 %26, i32 %27)
%29 = icmp eq i32 %28, -1
br i1 %29, label %42, label %30
30: ; preds = %23
%31 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %3, i64 0, i32 0
%32 = load i64, i64* %31
%33 = call i32 @read(i32 %7, %struct.TYPE_9__* %19, i64 %32)
%34 = load i64, i64* %31
%35 = trunc i64 %34 to i32
%36 = icmp eq i32 %33, %35
br i1 %36, label %37, label %42
37: ; preds = %30
%38 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %19, i64 0, i32 0
%39 = load i64, i64* %38
%40 = load i64, i64* @DT_NULL
%41 = icmp eq i64 %39, %40
br i1 %41, label %135, label %113
42: ; preds = %30, %23
%43 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
br label %150
44: ; preds = %113
%45 = trunc i64 %125 to i32
%46 = icmp ult i32 %124, %45
br i1 %46, label %47, label %135
47: ; preds = %44
%48 = zext i32 %124 to i64
%49 = and i64 %125, 4294967295
%50 = sub nsw i64 %49, %48
%51 = icmp ult i64 %50, 4
br i1 %51, label %111, label %52
52: ; preds = %47
%53 = and i64 %50, -4
%54 = add nsw i64 %53, %48
%55 = insertelement <2 x i64> poison, i64 %127, i64 0
%56 = shufflevector <2 x i64> %55, <2 x i64> poison, <2 x i32> zeroinitializer
%57 = insertelement <2 x i64> poison, i64 %127, i64 0
%58 = shufflevector <2 x i64> %57, <2 x i64> poison, <2 x i32> zeroinitializer
%59 = add nsw i64 %53, -4
%60 = lshr exact i64 %59, 2
%61 = add nuw nsw i64 %60, 1
%62 = and i64 %61, 3
%63 = icmp ult i64 %59, 12
br i1 %63, label %95, label %64
64: ; preds = %52
%65 = and i64 %61, 9223372036854775804
br label %66
66: ; preds = %66, %64
%67 = phi i64 [ 0, %64 ], [ %92, %66 ]
%68 = phi i64 [ 0, %64 ], [ %93, %66 ]
%69 = add i64 %67, %48
%70 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %19, i64 %69, i32 0
%71 = bitcast i64* %70 to <2 x i64>*
store <2 x i64> %56, <2 x i64>* %71
%72 = getelementptr inbounds i64, i64* %70, i64 2
%73 = bitcast i64* %72 to <2 x i64>*
store <2 x i64> %58, <2 x i64>* %73
%74 = or i64 %67, 4
%75 = add i64 %74, %48
%76 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %19, i64 %75, i32 0
%77 = bitcast i64* %76 to <2 x i64>*
store <2 x i64> %56, <2 x i64>* %77
%78 = getelementptr inbounds i64, i64* %76, i64 2
%79 = bitcast i64* %78 to <2 x i64>*
store <2 x i64> %58, <2 x i64>* %79
%80 = or i64 %67, 8
%81 = add i64 %80, %48
%82 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %19, i64 %81, i32 0
%83 = bitcast i64* %82 to <2 x i64>*
store <2 x i64> %56, <2 x i64>* %83
%84 = getelementptr inbounds i64, i64* %82, i64 2
%85 = bitcast i64* %84 to <2 x i64>*
store <2 x i64> %58, <2 x i64>* %85
%86 = or i64 %67, 12
%87 = add i64 %86, %48
%88 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %19, i64 %87, i32 0
%89 = bitcast i64* %88 to <2 x i64>*
store <2 x i64> %56, <2 x i64>* %89
%90 = getelementptr inbounds i64, i64* %88, i64 2
%91 = bitcast i64* %90 to <2 x i64>*
store <2 x i64> %58, <2 x i64>* %91
%92 = add nuw i64 %67, 16
%93 = add nuw i64 %68, 4
%94 = icmp eq i64 %93, %65
br i1 %94, label %95, label %66
95: ; preds = %66, %52
%96 = phi i64 [ 0, %52 ], [ %92, %66 ]
%97 = icmp eq i64 %62, 0
br i1 %97, label %109, label %98
98: ; preds = %95, %98
%99 = phi i64 [ %106, %98 ], [ %96, %95 ]
%100 = phi i64 [ %107, %98 ], [ 0, %95 ]
%101 = add i64 %99, %48
%102 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %19, i64 %101, i32 0
%103 = bitcast i64* %102 to <2 x i64>*
store <2 x i64> %56, <2 x i64>* %103
%104 = getelementptr inbounds i64, i64* %102, i64 2
%105 = bitcast i64* %104 to <2 x i64>*
store <2 x i64> %58, <2 x i64>* %105
%106 = add nuw i64 %99, 4
%107 = add i64 %100, 1
%108 = icmp eq i64 %107, %62
br i1 %108, label %109, label %98
109: ; preds = %98, %95
%110 = icmp eq i64 %50, %53
br i1 %110, label %135, label %111
111: ; preds = %47, %109
%112 = phi i64 [ %48, %47 ], [ %54, %109 ]
br label %130
113: ; preds = %37, %113
%114 = phi i64 [ %125, %113 ], [ 0, %37 ]
%115 = phi i64 [ %127, %113 ], [ %39, %37 ]
%116 = phi i64* [ %126, %113 ], [ %38, %37 ]
%117 = phi i32 [ %124, %113 ], [ 0, %37 ]
%118 = zext i32 %117 to i64
%119 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %19, i64 %118, i32 0
store i64 %115, i64* %119
%120 = load i64, i64* %116
%121 = call i32 @elf_dynpath_tag(i64 %120)
%122 = icmp eq i32 %121, 0
%123 = zext i1 %122 to i32
%124 = add nuw nsw i32 %117, %123
%125 = add nuw i64 %114, 1
%126 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %19, i64 %125, i32 0
%127 = load i64, i64* %126
%128 = load i64, i64* @DT_NULL
%129 = icmp eq i64 %127, %128
br i1 %129, label %44, label %113
130: ; preds = %111, %130
%131 = phi i64 [ %133, %130 ], [ %112, %111 ]
%132 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %19, i64 %131, i32 0
store i64 %127, i64* %132
%133 = add nuw nsw i64 %131, 1
%134 = icmp eq i64 %133, %49
br i1 %134, label %135, label %130
135: ; preds = %130, %109, %37, %44
%136 = load i32, i32* %25
%137 = load i32, i32* @SEEK_SET
%138 = call i32 @lseek(i32 %7, i32 %136, i32 %137)
%139 = icmp eq i32 %138, -1
br i1 %139, label %146, label %140
140: ; preds = %135
%141 = load i64, i64* %31
%142 = call i32 @write(i32 %7, %struct.TYPE_9__* %19, i64 %141)
%143 = load i64, i64* %31
%144 = trunc i64 %143 to i32
%145 = icmp eq i32 %142, %144
br i1 %145, label %148, label %146
146: ; preds = %140, %135
%147 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
br label %150
148: ; preds = %140
%149 = call i32 @elf_close(i32 %7)
br label %150
150: ; preds = %148, %146, %42, %21, %14, %9
%151 = phi i32 [ 1, %9 ], [ 1, %14 ], [ 1, %21 ], [ 1, %42 ], [ 1, %146 ], [ 0, %148 ]
ret i32 %151
}