#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_13__ TYPE_2__;
typedef struct TYPE_12__ TYPE_1__;

/* Type definitions */
struct TYPE_13__ {
  int e_phnum;
};
struct TYPE_12__ {
  scalar_t__ p_type;
  int p_filesz;
  int /*<<< orphan*/ p_offset;
};
typedef int /*<<< orphan*/ FILE;
typedef TYPE_1__ Elf64_Phdr;
typedef TYPE_2__ Elf64_Ehdr;
typedef TYPE_1__ Elf64_Dyn;

/* Variables and functions */
scalar_t__ PT_DYNAMIC;
int /*<<< orphan*/ SEEK_SET;
int _do_phdr_dyn64(char const *, int /*<<< orphan*/ *, TYPE_2__ *, TYPE_1__ *,
                   TYPE_1__ *, char const *);
int _error(char const *, char *, int);
int /*<<< orphan*/ errno;
scalar_t__ ferror(int /*<<< orphan*/ *);
int fread(TYPE_1__ *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(TYPE_1__ *);
scalar_t__ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/, int /*<<< orphan*/);
TYPE_1__ *malloc(int);
int /*<<< orphan*/ printf(char *, char const *);
char *strerror(int /*<<< orphan*/);
int _do_phdr64(char const *filename, FILE *fp, Elf64_Ehdr *ehdr,
               Elf64_Phdr *phdr, char const *ldpath) {
  int ret = 0;
  size_t i;
  Elf64_Dyn *dyn;
  if (fread(phdr, sizeof(*phdr), ehdr->e_phnum, fp) != ehdr->e_phnum) {
    if (ferror(fp) != 0)
      ret = -_error(filename, strerror(errno), 1);
    else
      ret = -_error(filename, "Corrupted ELF file", 1);
    return ret;
  }
  printf("%s:\n", filename);
  for (i = 0; i < ehdr->e_phnum; i++) {
    if (phdr[i].p_type != PT_DYNAMIC)
      continue;
    if (fseek(fp, phdr[i].p_offset, SEEK_SET) != 0) {
      ret |= -_error(filename, strerror(errno), 1);
      continue;
    }
    if ((dyn = malloc(phdr[i].p_filesz)) == NULL) {
      ret |= -_error(filename, strerror(errno), 1);
      continue;
    }
    if (fread(dyn, phdr[i].p_filesz, 1, fp) == 1)
      ret = _do_phdr_dyn64(filename, fp, ehdr, &phdr[i], dyn, ldpath);
    else {
      if (ferror(fp) != 0)
        ret |= -_error(filename, strerror(errno), 1);
      else
        ret |= -_error(filename, "Corrupted ELF file", 1);
    }
    free(dyn);
  }
  return ret;
}


x86 assembly (clang, -O0):
<_do_phdr64>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rax
mov    (%rax),%edx
mov    -0x18(%rbp),%rcx
mov    $0x10,%esi
call   1050 <fread@plt>
mov    -0x20(%rbp),%rcx
cmp    (%rcx),%eax
je     1248 <_do_phdr64+0xb8>
mov    -0x18(%rbp),%rdi
call   1040 <ferror@plt>
cmp    $0x0,%rax
je     121f <_do_phdr64+0x8f>
mov    -0x10(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    0x2de7(%rip),%rax
mov    (%rax),%edi
call   10b0 <strerror@plt>
mov    -0x50(%rbp),%rdi
mov    %rax,%rsi
mov    $0x1,%edx
call   1090 <_error@plt>
mov    %eax,%ecx
xor    %eax,%eax
sub    %ecx,%eax
mov    %eax,-0x34(%rbp)
jmp    123d <_do_phdr64+0xad>
mov    -0x10(%rbp),%rdi
lea    0xdd6(%rip),%rsi
mov    $0x1,%edx
call   1090 <_error@plt>
mov    %eax,%ecx
xor    %eax,%eax
sub    %ecx,%eax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    144c <_do_phdr64+0x2bc>
mov    -0x10(%rbp),%rsi
lea    0xdc0(%rip),%rdi
call   1070 <printf@plt>
movq   $0x0,-0x40(%rbp)
mov    -0x40(%rbp),%rax
mov    -0x20(%rbp),%rcx
movslq (%rcx),%rcx
cmp    %rcx,%rax
jae    1446 <_do_phdr64+0x2b6>
mov    -0x28(%rbp),%rax
mov    -0x40(%rbp),%rcx
shl    $0x4,%rcx
add    %rcx,%rax
mov    (%rax),%rax
mov    0x2d3b(%rip),%rcx
cmp    (%rcx),%rax
je     129b <_do_phdr64+0x10b>
jmp    1435 <_do_phdr64+0x2a5>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rax
mov    -0x40(%rbp),%rcx
shl    $0x4,%rcx
add    %rcx,%rax
mov    0xc(%rax),%esi
mov    0x2d20(%rip),%rax
mov    (%rax),%edx
call   10a0 <fseek@plt>
cmp    $0x0,%rax
je     1301 <_do_phdr64+0x171>
mov    -0x10(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    0x2d08(%rip),%rax
mov    (%rax),%edi
call   10b0 <strerror@plt>
mov    -0x58(%rbp),%rdi
mov    %rax,%rsi
mov    $0x1,%edx
call   1090 <_error@plt>
mov    %eax,%ecx
xor    %eax,%eax
sub    %ecx,%eax
or     -0x34(%rbp),%eax
mov    %eax,-0x34(%rbp)
jmp    1435 <_do_phdr64+0x2a5>
mov    -0x28(%rbp),%rax
mov    -0x40(%rbp),%rcx
shl    $0x4,%rcx
add    %rcx,%rax
mov    0x8(%rax),%edi
call   1080 <malloc@plt>
mov    %rax,-0x48(%rbp)
cmp    $0x0,%rax
jne    135e <_do_phdr64+0x1ce>
mov    -0x10(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    0x2cab(%rip),%rax
mov    (%rax),%edi
call   10b0 <strerror@plt>
mov    -0x60(%rbp),%rdi
mov    %rax,%rsi
mov    $0x1,%edx
call   1090 <_error@plt>
mov    %eax,%ecx
xor    %eax,%eax
sub    %ecx,%eax
or     -0x34(%rbp),%eax
mov    %eax,-0x34(%rbp)
jmp    1435 <_do_phdr64+0x2a5>
mov    -0x48(%rbp),%rdi
mov    -0x28(%rbp),%rax
mov    -0x40(%rbp),%rcx
shl    $0x4,%rcx
add    %rcx,%rax
mov    0x8(%rax),%esi
mov    -0x18(%rbp),%rcx
mov    $0x1,%edx
call   1050 <fread@plt>
cmp    $0x1,%eax
jne    13bb <_do_phdr64+0x22b>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x40(%rbp),%rax
shl    $0x4,%rax
add    %rax,%rcx
mov    -0x48(%rbp),%r8
mov    -0x30(%rbp),%r9
call   1060 <_do_phdr_dyn64@plt>
mov    %eax,-0x34(%rbp)
jmp    142c <_do_phdr64+0x29c>
mov    -0x18(%rbp),%rdi
call   1040 <ferror@plt>
cmp    $0x0,%rax
je     1406 <_do_phdr64+0x276>
mov    -0x10(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    0x2c03(%rip),%rax
mov    (%rax),%edi
call   10b0 <strerror@plt>
mov    -0x68(%rbp),%rdi
mov    %rax,%rsi
mov    $0x1,%edx
call   1090 <_error@plt>
mov    %eax,%ecx
xor    %eax,%eax
sub    %ecx,%eax
or     -0x34(%rbp),%eax
mov    %eax,-0x34(%rbp)
jmp    1427 <_do_phdr64+0x297>
mov    -0x10(%rbp),%rdi
lea    0xbef(%rip),%rsi
mov    $0x1,%edx
call   1090 <_error@plt>
mov    %eax,%ecx
xor    %eax,%eax
sub    %ecx,%eax
or     -0x34(%rbp),%eax
mov    %eax,-0x34(%rbp)
jmp    142c <_do_phdr64+0x29c>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
mov    -0x40(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x40(%rbp)
jmp    1260 <_do_phdr64+0xd0>
mov    -0x34(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_do_phdr64>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r8,%rbp
mov    %rcx,%rbx
mov    %rdx,%r12
mov    %rsi,%r14
mov    %rdi,%r15
mov    (%rdx),%edx
mov    %rcx,%rdi
mov    $0x10,%esi
mov    %r14,%rcx
call   1050 <fread@plt>
cmp    (%r12),%eax
jne    134d <_do_phdr64+0x1bd>
lea    0xe43(%rip),%rdi
mov    %r15,%rsi
call   1070 <printf@plt>
mov    %r12,0x10(%rsp)
cmpl   $0x0,(%r12)
je     136d <_do_phdr64+0x1dd>
mov    %rbp,0x20(%rsp)
xor    %r12d,%r12d
mov    0x2dd1(%rip),%rcx
xor    %r13d,%r13d
mov    0x10(%rsp),%rbp
mov    %r15,0x8(%rsp)
mov    %r14,0x18(%rsp)
jmp    124f <_do_phdr64+0xbf>
nopl   0x0(%rax,%rax,1)
mov    0x2dc9(%rip),%rax
mov    (%rax),%edi
call   10b0 <strerror@plt>
mov    %r15,%rdi
mov    %rax,%rsi
mov    $0x1,%edx
call   1090 <_error@plt>
neg    %eax
or     %eax,%r13d
mov    0x2d8e(%rip),%rcx
add    $0x1,%r12
movslq 0x0(%rbp),%rax
add    $0x10,%rbx
cmp    %rax,%r12
jae    138c <_do_phdr64+0x1fc>
mov    (%rbx),%rax
cmp    (%rcx),%rax
jne    123a <_do_phdr64+0xaa>
mov    0xc(%rbx),%esi
mov    0x2d77(%rip),%rax
mov    (%rax),%edx
mov    %r14,%rdi
call   10a0 <fseek@plt>
test   %rax,%rax
jne    1210 <_do_phdr64+0x80>
mov    0x8(%rbx),%r15d
mov    %r15d,%edi
call   1080 <malloc@plt>
test   %rax,%rax
je     12c6 <_do_phdr64+0x136>
mov    %rax,%r14
mov    %rax,%rdi
mov    %r15d,%esi
mov    $0x1,%edx
mov    0x18(%rsp),%rbp
mov    %rbp,%rcx
call   1050 <fread@plt>
cmp    $0x1,%eax
jne    12f0 <_do_phdr64+0x160>
mov    0x8(%rsp),%r15
mov    %r15,%rdi
mov    %rbp,%rsi
mov    0x10(%rsp),%rdx
mov    %rbx,%rcx
mov    %r14,%r8
mov    0x20(%rsp),%r9
call   1060 <_do_phdr_dyn64@plt>
mov    %eax,%r13d
jmp    1336 <_do_phdr64+0x1a6>
mov    0x2d13(%rip),%rax
mov    (%rax),%edi
call   10b0 <strerror@plt>
mov    0x8(%rsp),%r15
mov    %r15,%rdi
mov    %rax,%rsi
mov    $0x1,%edx
call   1090 <_error@plt>
neg    %eax
or     %eax,%r13d
jmp    133e <_do_phdr64+0x1ae>
mov    %rbp,%rdi
call   1040 <ferror@plt>
test   %rax,%rax
je     1318 <_do_phdr64+0x188>
mov    0x2cdc(%rip),%rax
mov    (%rax),%edi
call   10b0 <strerror@plt>
mov    0x8(%rsp),%r15
mov    %r15,%rdi
mov    %rax,%rsi
jmp    1327 <_do_phdr64+0x197>
mov    0x8(%rsp),%r15
mov    %r15,%rdi
lea    0xcd9(%rip),%rsi
mov    $0x1,%edx
call   1090 <_error@plt>
neg    %eax
or     %eax,%r13d
mov    %r14,%rdi
call   1030 <free@plt>
mov    0x18(%rsp),%r14
mov    0x10(%rsp),%rbp
jmp    1233 <_do_phdr64+0xa3>
mov    %r14,%rdi
call   1040 <ferror@plt>
test   %rax,%rax
je     1372 <_do_phdr64+0x1e2>
mov    0x2c7f(%rip),%rax
mov    (%rax),%edi
call   10b0 <strerror@plt>
mov    %rax,%rsi
jmp    1379 <_do_phdr64+0x1e9>
xor    %r13d,%r13d
jmp    138c <_do_phdr64+0x1fc>
lea    0xc87(%rip),%rsi
mov    %r15,%rdi
mov    $0x1,%edx
call   1090 <_error@plt>
mov    %eax,%r13d
neg    %r13d
mov    %r13d,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.TYPE_13__ = type { i32 }
%struct.TYPE_12__ = type { i64, i32, i32 }
@errno = global i32 0
@.str = [19 x i8] c"Corrupted ELF file\00"
@.str.1 = [5 x i8] c"%s:\0A\00"
@PT_DYNAMIC = global i64 0
@SEEK_SET = global i32 0
define i32 @_do_phdr64(i8* %0, i32* %1, %struct.TYPE_13__* %2, %struct.TYPE_12__* %3, i8* %4) {
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32*
%9 = alloca %struct.TYPE_13__*
%10 = alloca %struct.TYPE_12__*
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i64
%14 = alloca %struct.TYPE_12__*
store i8* %0, i8** %7
store i32* %1, i32** %8
store %struct.TYPE_13__* %2, %struct.TYPE_13__** %9
store %struct.TYPE_12__* %3, %struct.TYPE_12__** %10
store i8* %4, i8** %11
store i32 0, i32* %12
%15 = load %struct.TYPE_12__*, %struct.TYPE_12__** %10
%16 = load %struct.TYPE_13__*, %struct.TYPE_13__** %9
%17 = getelementptr inbounds %struct.TYPE_13__, %struct.TYPE_13__* %16, i32 0, i32 0
%18 = load i32, i32* %17
%19 = load i32*, i32** %8
%20 = call i32 @fread(%struct.TYPE_12__* %15, i32 16, i32 %18, i32* %19)
%21 = load %struct.TYPE_13__*, %struct.TYPE_13__** %9
%22 = getelementptr inbounds %struct.TYPE_13__, %struct.TYPE_13__* %21, i32 0, i32 0
%23 = load i32, i32* %22
%24 = icmp ne i32 %20, %23
br i1 %24, label %25, label %41
25: ; preds = %5
%26 = load i32*, i32** %8
%27 = call i64 @ferror(i32* %26)
%28 = icmp ne i64 %27, 0
br i1 %28, label %29, label %35
29: ; preds = %25
%30 = load i8*, i8** %7
%31 = load i32, i32* @errno
%32 = call i8* @strerror(i32 %31)
%33 = call i32 @_error(i8* %30, i8* %32, i32 1)
%34 = sub nsw i32 0, %33
store i32 %34, i32* %12
br label %39
35: ; preds = %25
%36 = load i8*, i8** %7
%37 = call i32 @_error(i8* %36, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 1)
%38 = sub nsw i32 0, %37
store i32 %38, i32* %12
br label %39
39: ; preds = %35, %29
%40 = load i32, i32* %12
store i32 %40, i32* %6
br label %141
41: ; preds = %5
%42 = load i8*, i8** %7
%43 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %42)
store i64 0, i64* %13
br label %44
44: ; preds = %136, %41
%45 = load i64, i64* %13
%46 = load %struct.TYPE_13__*, %struct.TYPE_13__** %9
%47 = getelementptr inbounds %struct.TYPE_13__, %struct.TYPE_13__* %46, i32 0, i32 0
%48 = load i32, i32* %47
%49 = sext i32 %48 to i64
%50 = icmp ult i64 %45, %49
br i1 %50, label %51, label %139
51: ; preds = %44
%52 = load %struct.TYPE_12__*, %struct.TYPE_12__** %10
%53 = load i64, i64* %13
%54 = getelementptr inbounds %struct.TYPE_12__, %struct.TYPE_12__* %52, i64 %53
%55 = getelementptr inbounds %struct.TYPE_12__, %struct.TYPE_12__* %54, i32 0, i32 0
%56 = load i64, i64* %55
%57 = load i64, i64* @PT_DYNAMIC
%58 = icmp ne i64 %56, %57
br i1 %58, label %59, label %60
59: ; preds = %51
br label %136
60: ; preds = %51
%61 = load i32*, i32** %8
%62 = load %struct.TYPE_12__*, %struct.TYPE_12__** %10
%63 = load i64, i64* %13
%64 = getelementptr inbounds %struct.TYPE_12__, %struct.TYPE_12__* %62, i64 %63
%65 = getelementptr inbounds %struct.TYPE_12__, %struct.TYPE_12__* %64, i32 0, i32 2
%66 = load i32, i32* %65
%67 = load i32, i32* @SEEK_SET
%68 = call i64 @fseek(i32* %61, i32 %66, i32 %67)
%69 = icmp ne i64 %68, 0
br i1 %69, label %70, label %78
70: ; preds = %60
%71 = load i8*, i8** %7
%72 = load i32, i32* @errno
%73 = call i8* @strerror(i32 %72)
%74 = call i32 @_error(i8* %71, i8* %73, i32 1)
%75 = sub nsw i32 0, %74
%76 = load i32, i32* %12
%77 = or i32 %76, %75
store i32 %77, i32* %12
br label %136
78: ; preds = %60
%79 = load %struct.TYPE_12__*, %struct.TYPE_12__** %10
%80 = load i64, i64* %13
%81 = getelementptr inbounds %struct.TYPE_12__, %struct.TYPE_12__* %79, i64 %80
%82 = getelementptr inbounds %struct.TYPE_12__, %struct.TYPE_12__* %81, i32 0, i32 1
%83 = load i32, i32* %82
%84 = call %struct.TYPE_12__* @malloc(i32 %83)
store %struct.TYPE_12__* %84, %struct.TYPE_12__** %14
%85 = icmp eq %struct.TYPE_12__* %84, null
br i1 %85, label %86, label %94
86: ; preds = %78
%87 = load i8*, i8** %7
%88 = load i32, i32* @errno
%89 = call i8* @strerror(i32 %88)
%90 = call i32 @_error(i8* %87, i8* %89, i32 1)
%91 = sub nsw i32 0, %90
%92 = load i32, i32* %12
%93 = or i32 %92, %91
store i32 %93, i32* %12
br label %136
94: ; preds = %78
%95 = load %struct.TYPE_12__*, %struct.TYPE_12__** %14
%96 = load %struct.TYPE_12__*, %struct.TYPE_12__** %10
%97 = load i64, i64* %13
%98 = getelementptr inbounds %struct.TYPE_12__, %struct.TYPE_12__* %96, i64 %97
%99 = getelementptr inbounds %struct.TYPE_12__, %struct.TYPE_12__* %98, i32 0, i32 1
%100 = load i32, i32* %99
%101 = load i32*, i32** %8
%102 = call i32 @fread(%struct.TYPE_12__* %95, i32 %100, i32 1, i32* %101)
%103 = icmp eq i32 %102, 1
br i1 %103, label %104, label %114
104: ; preds = %94
%105 = load i8*, i8** %7
%106 = load i32*, i32** %8
%107 = load %struct.TYPE_13__*, %struct.TYPE_13__** %9
%108 = load %struct.TYPE_12__*, %struct.TYPE_12__** %10
%109 = load i64, i64* %13
%110 = getelementptr inbounds %struct.TYPE_12__, %struct.TYPE_12__* %108, i64 %109
%111 = load %struct.TYPE_12__*, %struct.TYPE_12__** %14
%112 = load i8*, i8** %11
%113 = call i32 @_do_phdr_dyn64(i8* %105, i32* %106, %struct.TYPE_13__* %107, %struct.TYPE_12__* %110, %struct.TYPE_12__* %111, i8* %112)
store i32 %113, i32* %12
br label %133
114: ; preds = %94
%115 = load i32*, i32** %8
%116 = call i64 @ferror(i32* %115)
%117 = icmp ne i64 %116, 0
br i1 %117, label %118, label %126
118: ; preds = %114
%119 = load i8*, i8** %7
%120 = load i32, i32* @errno
%121 = call i8* @strerror(i32 %120)
%122 = call i32 @_error(i8* %119, i8* %121, i32 1)
%123 = sub nsw i32 0, %122
%124 = load i32, i32* %12
%125 = or i32 %124, %123
store i32 %125, i32* %12
br label %132
126: ; preds = %114
%127 = load i8*, i8** %7
%128 = call i32 @_error(i8* %127, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 1)
%129 = sub nsw i32 0, %128
%130 = load i32, i32* %12
%131 = or i32 %130, %129
store i32 %131, i32* %12
br label %132
132: ; preds = %126, %118
br label %133
133: ; preds = %132, %104
%134 = load %struct.TYPE_12__*, %struct.TYPE_12__** %14
%135 = call i32 @free(%struct.TYPE_12__* %134)
br label %136
136: ; preds = %133, %86, %70, %59
%137 = load i64, i64* %13
%138 = add i64 %137, 1
store i64 %138, i64* %13
br label %44
139: ; preds = %44
%140 = load i32, i32* %12
store i32 %140, i32* %6
br label %141
141: ; preds = %139, %39
%142 = load i32, i32* %6
ret i32 %142
}

LLVM IR (-O2):
%struct.TYPE_13__ = type { i32 }
%struct.TYPE_12__ = type { i64, i32, i32 }
@errno = global i32 0
@.str = [19 x i8] c"Corrupted ELF file\00"
@.str.1 = [5 x i8] c"%s:\0A\00"
@PT_DYNAMIC = global i64 0
@SEEK_SET = global i32 0
define i32 @_do_phdr64(i8* %0, i32* %1, %struct.TYPE_13__* %2, %struct.TYPE_12__* %3, i8* %4) {
%6 = getelementptr inbounds %struct.TYPE_13__, %struct.TYPE_13__* %2, i64 0, i32 0
%7 = load i32, i32* %6
%8 = tail call i32 @fread(%struct.TYPE_12__* %3, i32 16, i32 %7, i32* %1)
%9 = load i32, i32* %6
%10 = icmp eq i32 %8, %9
br i1 %10, label %21, label %11
11: ; preds = %5
%12 = tail call i64 @ferror(i32* %1)
%13 = icmp eq i64 %12, 0
br i1 %13, label %17, label %14
14: ; preds = %11
%15 = load i32, i32* @errno
%16 = tail call i8* @strerror(i32 %15)
br label %17
17: ; preds = %11, %14
%18 = phi i8* [ %16, %14 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), %11 ]
%19 = tail call i32 @_error(i8* %0, i8* %18, i32 1)
%20 = sub nsw i32 0, %19
br label %83
21: ; preds = %5
%22 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%23 = load i32, i32* %6
%24 = icmp eq i32 %23, 0
br i1 %24, label %83, label %25
25: ; preds = %21, %77
%26 = phi i64 [ %79, %77 ], [ 0, %21 ]
%27 = phi i32 [ %78, %77 ], [ 0, %21 ]
%28 = getelementptr inbounds %struct.TYPE_12__, %struct.TYPE_12__* %3, i64 %26
%29 = getelementptr inbounds %struct.TYPE_12__, %struct.TYPE_12__* %28, i64 0, i32 0
%30 = load i64, i64* %29
%31 = load i64, i64* @PT_DYNAMIC
%32 = icmp eq i64 %30, %31
br i1 %32, label %33, label %77
33: ; preds = %25
%34 = getelementptr inbounds %struct.TYPE_12__, %struct.TYPE_12__* %3, i64 %26, i32 2
%35 = load i32, i32* %34
%36 = load i32, i32* @SEEK_SET
%37 = tail call i64 @fseek(i32* %1, i32 %35, i32 %36)
%38 = icmp eq i64 %37, 0
br i1 %38, label %45, label %39
39: ; preds = %33
%40 = load i32, i32* @errno
%41 = tail call i8* @strerror(i32 %40)
%42 = tail call i32 @_error(i8* %0, i8* %41, i32 1)
%43 = sub nsw i32 0, %42
%44 = or i32 %27, %43
br label %77
45: ; preds = %33
%46 = getelementptr inbounds %struct.TYPE_12__, %struct.TYPE_12__* %3, i64 %26, i32 1
%47 = load i32, i32* %46
%48 = tail call %struct.TYPE_12__* @malloc(i32 %47)
%49 = icmp eq %struct.TYPE_12__* %48, null
br i1 %49, label %50, label %56
50: ; preds = %45
%51 = load i32, i32* @errno
%52 = tail call i8* @strerror(i32 %51)
%53 = tail call i32 @_error(i8* %0, i8* %52, i32 1)
%54 = sub nsw i32 0, %53
%55 = or i32 %27, %54
br label %77
56: ; preds = %45
%57 = tail call i32 @fread(%struct.TYPE_12__* %48, i32 %47, i32 1, i32* %1)
%58 = icmp eq i32 %57, 1
br i1 %58, label %59, label %61
59: ; preds = %56
%60 = tail call i32 @_do_phdr_dyn64(i8* %0, i32* %1, %struct.TYPE_13__* %2, %struct.TYPE_12__* %28, %struct.TYPE_12__* %48, i8* %4)
br label %74
61: ; preds = %56
%62 = tail call i64 @ferror(i32* %1)
%63 = icmp eq i64 %62, 0
br i1 %63, label %70, label %64
64: ; preds = %61
%65 = load i32, i32* @errno
%66 = tail call i8* @strerror(i32 %65)
%67 = tail call i32 @_error(i8* %0, i8* %66, i32 1)
%68 = sub nsw i32 0, %67
%69 = or i32 %27, %68
br label %74
70: ; preds = %61
%71 = tail call i32 @_error(i8* %0, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 1)
%72 = sub nsw i32 0, %71
%73 = or i32 %27, %72
br label %74
74: ; preds = %64, %70, %59
%75 = phi i32 [ %60, %59 ], [ %69, %64 ], [ %73, %70 ]
%76 = tail call i32 @free(%struct.TYPE_12__* %48)
br label %77
77: ; preds = %25, %74, %50, %39
%78 = phi i32 [ %27, %25 ], [ %44, %39 ], [ %55, %50 ], [ %75, %74 ]
%79 = add nuw i64 %26, 1
%80 = load i32, i32* %6
%81 = sext i32 %80 to i64
%82 = icmp ult i64 %79, %81
br i1 %82, label %25, label %83
83: ; preds = %77, %21, %17
%84 = phi i32 [ %20, %17 ], [ 0, %21 ], [ %78, %77 ]
ret i32 %84
}