#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 */
typedef int /*<<< orphan*/ uint32_t;
struct dirent {
  char *d_name;
};
typedef int /*<<< orphan*/ DIR;

/* Variables and functions */
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ closedir(int /*<<< orphan*/ *);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, char *);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ *opendir(char *);
int read(int, int /*<<< orphan*/ *, int);
scalar_t__ read_uint32(int, int /*<<< orphan*/ *);
struct dirent *readdir(int /*<<< orphan*/ *);
int /*<<< orphan*/ snprintf(char *, int, char *, char *);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int /*<<< orphan*/ strncmp(char *, char *, int);
int cpu_drcindex_to_interruptserver(uint32_t drc_idx, uint32_t *int_servs,
                                    int array_elements) {
  DIR *dir;
  struct dirent *entry;
  int intr_fd, drc_fd, found = 0;
  char buffer[1024];
  uint32_t temp;
  dir = opendir("/proc/device-tree/cpus");
  if (!dir)
    return 0;
  while (!found && (entry = readdir(dir)) != NULL) {
    if (!strncmp(entry->d_name, "PowerPC,POWER", 13)) {
      snprintf(buffer, 1024,
               "/proc/device-tree/cpus/%s/"
               "ibm,my-drc-index",
               entry->d_name);
      if ((drc_fd = open(buffer, O_RDONLY)) < 0) {
        fprintf(stderr,
                "Error opening %s:\n"
                "%s\n",
                buffer, strerror(errno));
        closedir(dir);
        return 0;
      }
      while (read_uint32(drc_fd, &temp) == 0) {
        if (temp == drc_idx) {
          snprintf(buffer, 1024,
                   "/proc/device-"
                   "tree/cpus/%s/"
                   "ibm,ppc-interrupt-server#s",
                   entry->d_name);
          if ((intr_fd = open(buffer, O_RDONLY)) < 0) {
            fprintf(stderr,
                    "Error "
                    "opening %s:\n%s\n",
                    buffer, strerror(errno));
            close(drc_fd);
            closedir(dir);
            return 0;
          }
          while (found < array_elements && (read(intr_fd, &temp, 4)) == 4)
            int_servs[found++] = temp;
          close(intr_fd);
          break;
        }
      }
      close(drc_fd);
    }
  }
  closedir(dir);
  return found;
}


x86 assembly (clang, -O0):
<cpu_drcindex_to_interruptserver>:
push   %rbp
mov    %rsp,%rbp
sub    $0x470,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x34(%rbp)
lea    0xe2d(%rip),%rdi
call   1050 <opendir@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11f3 <cpu_drcindex_to_interruptserver+0x43>
movl   $0x0,-0x4(%rbp)
jmp    145f <cpu_drcindex_to_interruptserver+0x2af>
jmp    11f8 <cpu_drcindex_to_interruptserver+0x48>
xor    %eax,%eax
cmpl   $0x0,-0x34(%rbp)
mov    %al,-0x445(%rbp)
jne    1224 <cpu_drcindex_to_interruptserver+0x74>
mov    -0x20(%rbp),%rdi
call   10b0 <readdir@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
setne  %al
mov    %al,-0x445(%rbp)
mov    -0x445(%rbp),%al
test   $0x1,%al
jne    1237 <cpu_drcindex_to_interruptserver+0x87>
jmp    1450 <cpu_drcindex_to_interruptserver+0x2a0>
mov    -0x28(%rbp),%rax
mov    (%rax),%rdi
lea    0xdd2(%rip),%rsi
mov    $0xd,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    144b <cpu_drcindex_to_interruptserver+0x29b>
lea    -0x440(%rbp),%rdi
mov    -0x28(%rbp),%rax
mov    (%rax),%rcx
mov    $0x400,%esi
lea    0xdb3(%rip),%rdx
call   1060 <snprintf@plt>
lea    -0x440(%rbp),%rdi
mov    0x2d63(%rip),%rax
mov    (%rax),%esi
call   10c0 <open@plt>
mov    %eax,-0x30(%rbp)
cmp    $0x0,%eax
jge    12f4 <cpu_drcindex_to_interruptserver+0x144>
mov    0x2d39(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x454(%rbp)
lea    -0x440(%rbp),%rax
mov    %rax,-0x450(%rbp)
mov    0x2d14(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    -0x454(%rbp),%edi
mov    -0x450(%rbp),%rdx
mov    %rax,%rcx
lea    0xd76(%rip),%rsi
call   10a0 <fprintf@plt>
mov    -0x20(%rbp),%rdi
call   1080 <closedir@plt>
movl   $0x0,-0x4(%rbp)
jmp    145f <cpu_drcindex_to_interruptserver+0x2af>
jmp    12f9 <cpu_drcindex_to_interruptserver+0x149>
mov    -0x30(%rbp),%edi
lea    -0x444(%rbp),%rsi
call   1040 <read_uint32@plt>
cmp    $0x0,%rax
jne    1443 <cpu_drcindex_to_interruptserver+0x293>
mov    -0x444(%rbp),%eax
cmp    -0x8(%rbp),%eax
jne    143e <cpu_drcindex_to_interruptserver+0x28e>
lea    -0x440(%rbp),%rdi
mov    -0x28(%rbp),%rax
mov    (%rax),%rcx
mov    $0x400,%esi
lea    0xd2b(%rip),%rdx
call   1060 <snprintf@plt>
lea    -0x440(%rbp),%rdi
mov    0x2c9a(%rip),%rax
mov    (%rax),%esi
call   10c0 <open@plt>
mov    %eax,-0x2c(%rbp)
cmp    $0x0,%eax
jge    13c5 <cpu_drcindex_to_interruptserver+0x215>
mov    0x2c70(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x464(%rbp)
lea    -0x440(%rbp),%rax
mov    %rax,-0x460(%rbp)
mov    0x2c4b(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    -0x464(%rbp),%edi
mov    -0x460(%rbp),%rdx
mov    %rax,%rcx
lea    0xcad(%rip),%rsi
call   10a0 <fprintf@plt>
mov    -0x30(%rbp),%edi
call   1070 <close@plt>
mov    -0x20(%rbp),%rdi
call   1080 <closedir@plt>
movl   $0x0,-0x4(%rbp)
jmp    145f <cpu_drcindex_to_interruptserver+0x2af>
jmp    13ca <cpu_drcindex_to_interruptserver+0x21a>
mov    -0x34(%rbp),%ecx
xor    %eax,%eax
cmp    -0x14(%rbp),%ecx
mov    %al,-0x465(%rbp)
jge    13fe <cpu_drcindex_to_interruptserver+0x24e>
mov    -0x2c(%rbp),%edi
lea    -0x444(%rbp),%rsi
mov    $0x4,%edx
call   1090 <read@plt>
cmp    $0x4,%eax
sete   %al
mov    %al,-0x465(%rbp)
mov    -0x465(%rbp),%al
test   $0x1,%al
jne    1411 <cpu_drcindex_to_interruptserver+0x261>
jmp    1431 <cpu_drcindex_to_interruptserver+0x281>
mov    -0x444(%rbp),%edx
mov    -0x10(%rbp),%rax
mov    -0x34(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x34(%rbp)
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
jmp    13ca <cpu_drcindex_to_interruptserver+0x21a>
mov    -0x2c(%rbp),%edi
call   1070 <close@plt>
jmp    1443 <cpu_drcindex_to_interruptserver+0x293>
jmp    12f9 <cpu_drcindex_to_interruptserver+0x149>
mov    -0x30(%rbp),%edi
call   1070 <close@plt>
jmp    11f8 <cpu_drcindex_to_interruptserver+0x48>
mov    -0x20(%rbp),%rdi
call   1080 <closedir@plt>
mov    -0x34(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x470,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cpu_drcindex_to_interruptserver>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x428,%rsp
mov    %edx,%ebx
mov    %rsi,%r15
mov    %edi,%r14d
lea    0xe30(%rip),%rdi
call   1050 <opendir@plt>
test   %rax,%rax
je     1336 <cpu_drcindex_to_interruptserver+0x186>
mov    %rax,%rbp
mov    %r15,0x18(%rsp)
mov    %ebx,0x4(%rsp)
mov    %ebx,%eax
mov    %rax,0x10(%rsp)
lea    0xe1f(%rip),%rbx
mov    %rbp,0x8(%rsp)
jmp    121a <cpu_drcindex_to_interruptserver+0x6a>
xor    %r13d,%r13d
lea    0xe0e(%rip),%rbx
mov    %r12d,%edi
call   1070 <close@plt>
test   %r13d,%r13d
jne    13af <cpu_drcindex_to_interruptserver+0x1ff>
mov    %rbp,%rdi
call   10b0 <readdir@plt>
test   %rax,%rax
je     133b <cpu_drcindex_to_interruptserver+0x18b>
mov    %rax,%r15
mov    (%rax),%rdi
mov    %rbx,%rsi
mov    $0xd,%edx
call   1030 <strncmp@plt>
xor    %r13d,%r13d
test   %eax,%eax
jne    1211 <cpu_drcindex_to_interruptserver+0x61>
mov    (%r15),%rcx
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x400,%esi
lea    0xdc9(%rip),%rdx
call   1060 <snprintf@plt>
mov    0x2d80(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   10c0 <open@plt>
mov    %eax,%r12d
test   %eax,%eax
mov    %rsp,%rbx
js     1340 <cpu_drcindex_to_interruptserver+0x190>
mov    %r12d,%edi
mov    %rbx,%rsi
call   1040 <read_uint32@plt>
test   %rax,%rax
jne    11ff <cpu_drcindex_to_interruptserver+0x4f>
cmp    %r14d,(%rsp)
jne    1280 <cpu_drcindex_to_interruptserver+0xd0>
mov    (%r15),%rcx
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x400,%esi
lea    0xdb5(%rip),%rdx
call   1060 <snprintf@plt>
mov    0x2d2b(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   10c0 <open@plt>
test   %eax,%eax
js     1372 <cpu_drcindex_to_interruptserver+0x1c2>
mov    %eax,%r15d
cmpl   $0x0,0x4(%rsp)
jle    131a <cpu_drcindex_to_interruptserver+0x16a>
xor    %r13d,%r13d
mov    0x18(%rsp),%rbx
mov    0x10(%rsp),%rbp
cs nopw 0x0(%rax,%rax,1)
mov    %r15d,%edi
mov    %rsp,%rsi
mov    $0x4,%edx
call   1090 <read@plt>
cmp    $0x4,%eax
jne    131d <cpu_drcindex_to_interruptserver+0x16d>
mov    (%rsp),%eax
mov    %eax,(%rbx,%r13,4)
add    $0x1,%r13
cmp    %r13,%rbp
jne    12f0 <cpu_drcindex_to_interruptserver+0x140>
mov    %ebp,%r13d
jmp    131d <cpu_drcindex_to_interruptserver+0x16d>
xor    %r13d,%r13d
lea    0xcf3(%rip),%rbx
mov    %r15d,%edi
call   1070 <close@plt>
mov    0x8(%rsp),%rbp
jmp    1209 <cpu_drcindex_to_interruptserver+0x59>
xor    %r13d,%r13d
jmp    13b7 <cpu_drcindex_to_interruptserver+0x207>
xor    %r13d,%r13d
jmp    13af <cpu_drcindex_to_interruptserver+0x1ff>
mov    0x2c91(%rip),%rax
mov    (%rax),%ebx
mov    0x2c80(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
lea    0xcf2(%rip),%rsi
lea    0x20(%rsp),%rdx
mov    %ebx,%edi
mov    %rax,%rcx
call   10a0 <fprintf@plt>
xor    %r13d,%r13d
jmp    13af <cpu_drcindex_to_interruptserver+0x1ff>
mov    0x2c5f(%rip),%rax
mov    (%rax),%ebx
mov    0x2c4e(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
lea    0xcc0(%rip),%rsi
lea    0x20(%rsp),%rdx
mov    %ebx,%edi
mov    %rax,%rcx
call   10a0 <fprintf@plt>
mov    %r12d,%edi
call   1070 <close@plt>
xor    %r13d,%r13d
mov    0x8(%rsp),%rbp
mov    %rbp,%rdi
call   1080 <closedir@plt>
mov    %r13d,%eax
add    $0x428,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.dirent = type { i8* }
@.str = [23 x i8] c"/proc/device-tree/cpus\00"
@.str.1 = [14 x i8] c"PowerPC,POWER\00"
@.str.2 = [43 x i8] c"/proc/device-tree/cpus/%s/ibm,my-drc-index\00"
@O_RDONLY = global i32 0
@stderr = global i32 0
@.str.3 = [22 x i8] c"Error opening %s:\0A%s\0A\00"
@errno = global i32 0
@.str.4 = [53 x i8] c"/proc/device-tree/cpus/%s/ibm,ppc-interrupt-server#s\00"
define i32 @cpu_drcindex_to_interruptserver(i32 %0, i32* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32*
%9 = alloca %struct.dirent*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca [1024 x i8]
%14 = alloca i32
store i32 %0, i32* %5
store i32* %1, i32** %6
store i32 %2, i32* %7
store i32 0, i32* %12
%15 = call i32* @opendir(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
store i32* %15, i32** %8
%16 = load i32*, i32** %8
%17 = icmp ne i32* %16, null
br i1 %17, label %19, label %18
18: ; preds = %3
store i32 0, i32* %4
br label %112
19: ; preds = %3
br label %20
20: ; preds = %107, %19
%21 = load i32, i32* %12
%22 = icmp ne i32 %21, 0
br i1 %22, label %27, label %23
23: ; preds = %20
%24 = load i32*, i32** %8
%25 = call %struct.dirent* @readdir(i32* %24)
store %struct.dirent* %25, %struct.dirent** %9
%26 = icmp ne %struct.dirent* %25, null
br label %27
27: ; preds = %23, %20
%28 = phi i1 [ false, %20 ], [ %26, %23 ]
br i1 %28, label %29, label %108
29: ; preds = %27
%30 = load %struct.dirent*, %struct.dirent** %9
%31 = getelementptr inbounds %struct.dirent, %struct.dirent* %30, i32 0, i32 0
%32 = load i8*, i8** %31
%33 = call i32 @strncmp(i8* %32, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 13)
%34 = icmp ne i32 %33, 0
br i1 %34, label %107, label %35
35: ; preds = %29
%36 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%37 = load %struct.dirent*, %struct.dirent** %9
%38 = getelementptr inbounds %struct.dirent, %struct.dirent* %37, i32 0, i32 0
%39 = load i8*, i8** %38
%40 = call i32 @snprintf(i8* %36, i32 1024, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0), i8* %39)
%41 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%42 = load i32, i32* @O_RDONLY
%43 = call i32 @open(i8* %41, i32 %42)
store i32 %43, i32* %11
%44 = icmp slt i32 %43, 0
br i1 %44, label %45, label %53
45: ; preds = %35
%46 = load i32, i32* @stderr
%47 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%48 = load i32, i32* @errno
%49 = call i8* @strerror(i32 %48)
%50 = call i32 @fprintf(i32 %46, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* %47, i8* %49)
%51 = load i32*, i32** %8
%52 = call i32 @closedir(i32* %51)
store i32 0, i32* %4
br label %112
53: ; preds = %35
br label %54
54: ; preds = %103, %53
%55 = load i32, i32* %11
%56 = call i64 @read_uint32(i32 %55, i32* %14)
%57 = icmp eq i64 %56, 0
br i1 %57, label %58, label %104
58: ; preds = %54
%59 = load i32, i32* %14
%60 = load i32, i32* %5
%61 = icmp eq i32 %59, %60
br i1 %61, label %62, label %103
62: ; preds = %58
%63 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%64 = load %struct.dirent*, %struct.dirent** %9
%65 = getelementptr inbounds %struct.dirent, %struct.dirent* %64, i32 0, i32 0
%66 = load i8*, i8** %65
%67 = call i32 @snprintf(i8* %63, i32 1024, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.4, i64 0, i64 0), i8* %66)
%68 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%69 = load i32, i32* @O_RDONLY
%70 = call i32 @open(i8* %68, i32 %69)
store i32 %70, i32* %10
%71 = icmp slt i32 %70, 0
br i1 %71, label %72, label %82
72: ; preds = %62
%73 = load i32, i32* @stderr
%74 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%75 = load i32, i32* @errno
%76 = call i8* @strerror(i32 %75)
%77 = call i32 @fprintf(i32 %73, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* %74, i8* %76)
%78 = load i32, i32* %11
%79 = call i32 @close(i32 %78)
%80 = load i32*, i32** %8
%81 = call i32 @closedir(i32* %80)
store i32 0, i32* %4
br label %112
82: ; preds = %62
br label %83
83: ; preds = %93, %82
%84 = load i32, i32* %12
%85 = load i32, i32* %7
%86 = icmp slt i32 %84, %85
br i1 %86, label %87, label %91
87: ; preds = %83
%88 = load i32, i32* %10
%89 = call i32 @read(i32 %88, i32* %14, i32 4)
%90 = icmp eq i32 %89, 4
br label %91
91: ; preds = %87, %83
%92 = phi i1 [ false, %83 ], [ %90, %87 ]
br i1 %92, label %93, label %100
93: ; preds = %91
%94 = load i32, i32* %14
%95 = load i32*, i32** %6
%96 = load i32, i32* %12
%97 = add nsw i32 %96, 1
store i32 %97, i32* %12
%98 = sext i32 %96 to i64
%99 = getelementptr inbounds i32, i32* %95, i64 %98
store i32 %94, i32* %99
br label %83
100: ; preds = %91
%101 = load i32, i32* %10
%102 = call i32 @close(i32 %101)
br label %104
103: ; preds = %58
br label %54
104: ; preds = %100, %54
%105 = load i32, i32* %11
%106 = call i32 @close(i32 %105)
br label %107
107: ; preds = %104, %29
br label %20
108: ; preds = %27
%109 = load i32*, i32** %8
%110 = call i32 @closedir(i32* %109)
%111 = load i32, i32* %12
store i32 %111, i32* %4
br label %112
112: ; preds = %108, %72, %45, %18
%113 = load i32, i32* %4
ret i32 %113
}

LLVM IR (-O2):
%struct.dirent = type { i8* }
@.str = [23 x i8] c"/proc/device-tree/cpus\00"
@.str.1 = [14 x i8] c"PowerPC,POWER\00"
@.str.2 = [43 x i8] c"/proc/device-tree/cpus/%s/ibm,my-drc-index\00"
@O_RDONLY = global i32 0
@stderr = global i32 0
@.str.3 = [22 x i8] c"Error opening %s:\0A%s\0A\00"
@errno = global i32 0
@.str.4 = [53 x i8] c"/proc/device-tree/cpus/%s/ibm,ppc-interrupt-server#s\00"
define i32 @cpu_drcindex_to_interruptserver(i32 %0, i32* nocapture writeonly %1, i32 %2) {
%4 = alloca [1024 x i8]
%5 = alloca i32
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%7 = bitcast i32* %5 to i8*
%8 = tail call i32* @opendir(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i32* %8, null
br i1 %9, label %74, label %10
10: ; preds = %3
%11 = icmp sgt i32 %2, 0
%12 = zext i32 %2 to i64
br label %13
13: ; preds = %10, %68
%14 = call %struct.dirent* @readdir(i32* %8)
%15 = icmp eq %struct.dirent* %14, null
br i1 %15, label %71, label %16
16: ; preds = %13
%17 = getelementptr inbounds %struct.dirent, %struct.dirent* %14, i64 0, i32 0
%18 = load i8*, i8** %17
%19 = call i32 @strncmp(i8* %18, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 13)
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %68
21: ; preds = %16
%22 = load i8*, i8** %17
%23 = call i32 @snprintf(i8* %6, i32 1024, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0), i8* %22)
%24 = load i32, i32* @O_RDONLY
%25 = call i32 @open(i8* %6, i32 %24)
%26 = icmp slt i32 %25, 0
br i1 %26, label %27, label %32
27: ; preds = %21
%28 = load i32, i32* @stderr
%29 = load i32, i32* @errno
%30 = call i8* @strerror(i32 %29)
%31 = call i32 @fprintf(i32 %28, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* %6, i8* %30)
br label %71
32: ; preds = %21, %35
%33 = call i64 @read_uint32(i32 %25, i32* %5)
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %65
35: ; preds = %32
%36 = load i32, i32* %5
%37 = icmp eq i32 %36, %0
br i1 %37, label %38, label %32
38: ; preds = %35
%39 = load i8*, i8** %17
%40 = call i32 @snprintf(i8* %6, i32 1024, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.4, i64 0, i64 0), i8* %39)
%41 = load i32, i32* @O_RDONLY
%42 = call i32 @open(i8* %6, i32 %41)
%43 = icmp slt i32 %42, 0
br i1 %43, label %45, label %44
44: ; preds = %38
br i1 %11, label %51, label %62
45: ; preds = %38
%46 = load i32, i32* @stderr
%47 = load i32, i32* @errno
%48 = call i8* @strerror(i32 %47)
%49 = call i32 @fprintf(i32 %46, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* %6, i8* %48)
%50 = call i32 @close(i32 %25)
br label %71
51: ; preds = %44, %55
%52 = phi i64 [ %57, %55 ], [ 0, %44 ]
%53 = call i32 @read(i32 %42, i32* %5, i32 4)
%54 = icmp eq i32 %53, 4
br i1 %54, label %55, label %60
55: ; preds = %51
%56 = load i32, i32* %5
%57 = add nuw nsw i64 %52, 1
%58 = getelementptr inbounds i32, i32* %1, i64 %52
store i32 %56, i32* %58
%59 = icmp eq i64 %57, %12
br i1 %59, label %62, label %51
60: ; preds = %51
%61 = trunc i64 %52 to i32
br label %62
62: ; preds = %55, %60, %44
%63 = phi i32 [ 0, %44 ], [ %61, %60 ], [ %2, %55 ]
%64 = call i32 @close(i32 %42)
br label %65
65: ; preds = %32, %62
%66 = phi i32 [ %63, %62 ], [ 0, %32 ]
%67 = call i32 @close(i32 %25)
br label %68
68: ; preds = %65, %16
%69 = phi i32 [ 0, %16 ], [ %66, %65 ]
%70 = icmp eq i32 %69, 0
br i1 %70, label %13, label %71
71: ; preds = %13, %68, %27, %45
%72 = phi i32 [ 0, %45 ], [ 0, %27 ], [ %69, %68 ], [ 0, %13 ]
%73 = call i32 @closedir(i32* %8)
br label %74
74: ; preds = %71, %3
%75 = phi i32 [ 0, %3 ], [ %72, %71 ]
ret i32 %75
}