#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 dirent {
  char *d_name;
};
typedef int /*<<< orphan*/ link;
typedef int /*<<< orphan*/ executable;
typedef int /*<<< orphan*/ exePath;
typedef int /*<<< orphan*/ cmdlinePath;
typedef int /*<<< orphan*/ FILE;
typedef int /*<<< orphan*/ DIR;

/* Variables and functions */
int atoi(char *);
int /*<<< orphan*/ closedir(int /*<<< orphan*/ *);
scalar_t__ doesMatch(char *, char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ *opendir(char *);
int /*<<< orphan*/ printf(char *);
struct dirent *readdir(int /*<<< orphan*/ *);
int readlink(char *, char *, int);
int /*<<< orphan*/ snprintf(char *, int, char *, char *);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
int isAppRunning(char *pzName, char *pzCommandPattern) {
  DIR *proc_fd = opendir("/proc");
  if (proc_fd != NULL) {
    struct dirent *procEntry;
    while ((procEntry = readdir(proc_fd)) != NULL) {
      if (doesMatch("^[0-9][0-9]*$", procEntry->d_name)) {
        char exePath[384] = {
            0,
        };
        char link[256] = {
            0,
        };
        char cmdlinePath[384] = {
            0,
        };
        char buffer[1024] = {
            0,
        };
        int len;
        snprintf(exePath, sizeof(exePath), "/proc/%s/exe", procEntry->d_name);
        snprintf(cmdlinePath, sizeof(cmdlinePath), "/proc/%s/cmdline",
                 procEntry->d_name);
        if ((len = readlink(exePath, link, sizeof(link) - 1)) != -1) {
          char executable[256] = {
              0,
          };
          strncpy(executable, pzName, sizeof(executable) - 2);
          strcat(executable, "$");
          if (!doesMatch(executable, link)) {
            continue;
          }
        } else
          continue;
        if (pzCommandPattern != NULL) {
          FILE *cmdline = fopen(cmdlinePath, "r");
          if (!cmdline) {
            continue;
          }
          if (fgets(buffer, 1024, cmdline) == NULL) {
            fclose(cmdline);
            continue;
          }
          fclose(cmdline);
          if (!doesMatch(pzCommandPattern, buffer)) {
            continue;
          }
        }
        int d_name = atoi(procEntry->d_name);
        closedir(proc_fd);
        return d_name;
      }
    }
    closedir(proc_fd);
  } else {
    printf("/proc failed to open\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<isAppRunning>:
push   %rbp
mov    %rsp,%rbp
sub    $0x950,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
lea    0xe06(%rip),%rdi
call   1060 <opendir@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1436 <isAppRunning+0x256>
jmp    1213 <isAppRunning+0x33>
mov    -0x20(%rbp),%rdi
call   10d0 <readdir@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
je     1428 <isAppRunning+0x248>
mov    -0x28(%rbp),%rax
mov    (%rax),%rsi
lea    0xdce(%rip),%rdi
call   1080 <doesMatch@plt>
cmp    $0x0,%rax
je     1423 <isAppRunning+0x243>
lea    -0x1b0(%rbp),%rdi
xor    %esi,%esi
mov    $0x180,%edx
call   10a0 <memset@plt>
lea    -0x2b0(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   10a0 <memset@plt>
lea    -0x430(%rbp),%rdi
xor    %esi,%esi
mov    $0x180,%edx
call   10a0 <memset@plt>
lea    -0x830(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   10a0 <memset@plt>
lea    -0x1b0(%rbp),%rdi
mov    -0x28(%rbp),%rax
mov    (%rax),%rcx
mov    $0x180,%esi
lea    0xd67(%rip),%rdx
call   1090 <snprintf@plt>
lea    -0x430(%rbp),%rdi
mov    -0x28(%rbp),%rax
mov    (%rax),%rcx
mov    $0x180,%esi
lea    0xd55(%rip),%rdx
call   1090 <snprintf@plt>
lea    -0x1b0(%rbp),%rdi
lea    -0x2b0(%rbp),%rsi
mov    $0xff,%edx
call   1040 <readlink@plt>
mov    %eax,-0x834(%rbp)
cmp    $0xffffffff,%eax
je     135a <isAppRunning+0x17a>
lea    -0x940(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   10a0 <memset@plt>
lea    -0x940(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0xfe,%edx
call   1030 <strncpy@plt>
lea    -0x940(%rbp),%rdi
lea    0xce4(%rip),%rsi
call   1100 <strcat@plt>
lea    -0x940(%rbp),%rdi
lea    -0x2b0(%rbp),%rsi
call   1080 <doesMatch@plt>
cmp    $0x0,%rax
jne    1355 <isAppRunning+0x175>
jmp    1213 <isAppRunning+0x33>
jmp    135f <isAppRunning+0x17f>
jmp    1213 <isAppRunning+0x33>
cmpq   $0x0,-0x18(%rbp)
je     13fa <isAppRunning+0x21a>
lea    -0x430(%rbp),%rdi
lea    0xcba(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,-0x948(%rbp)
cmpq   $0x0,-0x948(%rbp)
jne    1397 <isAppRunning+0x1b7>
jmp    1213 <isAppRunning+0x33>
lea    -0x830(%rbp),%rdi
mov    -0x948(%rbp),%rdx
mov    $0x400,%esi
call   10c0 <fgets@plt>
cmp    $0x0,%rax
jne    13ca <isAppRunning+0x1ea>
mov    -0x948(%rbp),%rdi
call   1050 <fclose@plt>
jmp    1213 <isAppRunning+0x33>
mov    -0x948(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x18(%rbp),%rdi
lea    -0x830(%rbp),%rsi
call   1080 <doesMatch@plt>
cmp    $0x0,%rax
jne    13f5 <isAppRunning+0x215>
jmp    1213 <isAppRunning+0x33>
jmp    13fa <isAppRunning+0x21a>
mov    -0x28(%rbp),%rax
mov    (%rax),%rdi
call   10f0 <atoi@plt>
mov    %eax,-0x94c(%rbp)
mov    -0x20(%rbp),%rdi
call   10b0 <closedir@plt>
mov    -0x94c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1449 <isAppRunning+0x269>
jmp    1213 <isAppRunning+0x33>
mov    -0x20(%rbp),%rdi
call   10b0 <closedir@plt>
jmp    1442 <isAppRunning+0x262>
lea    0xbf7(%rip),%rdi
call   1070 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x950,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isAppRunning>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x918,%rsp
mov    %rsi,0x8(%rsp)
mov    %rdi,%r14
lea    0xe00(%rip),%rdi
call   1070 <opendir@plt>
test   %rax,%rax
je     14a2 <isAppRunning+0x2c2>
mov    %rax,%r13
mov    %rax,%rdi
call   10d0 <readdir@plt>
test   %rax,%rax
je     1498 <isAppRunning+0x2b8>
mov    %rax,%rbp
lea    0xdda(%rip),%r12
jmp    1244 <isAppRunning+0x64>
xchg   %ax,%ax
mov    %r13,%rdi
call   10d0 <readdir@plt>
mov    %rax,%rbp
test   %rax,%rax
je     1498 <isAppRunning+0x2b8>
mov    0x0(%rbp),%rsi
mov    %r12,%rdi
call   1080 <doesMatch@plt>
test   %rax,%rax
je     1230 <isAppRunning+0x50>
mov    $0x180,%edx
lea    0x790(%rsp),%r15
mov    %r15,%rdi
xor    %esi,%esi
call   10a0 <memset@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,0x100(%rsp)
movaps %xmm0,0xf0(%rsp)
movaps %xmm0,0xe0(%rsp)
movaps %xmm0,0xd0(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
mov    $0x180,%edx
lea    0x210(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
call   10a0 <memset@plt>
mov    $0x400,%edx
lea    0x390(%rsp),%rdi
xor    %esi,%esi
call   10a0 <memset@plt>
mov    0x0(%rbp),%rcx
mov    %r15,%rdi
mov    $0x180,%esi
lea    0xcfc(%rip),%rdx
call   1090 <snprintf@plt>
mov    0x0(%rbp),%rcx
mov    %rbx,%rdi
mov    $0x180,%esi
lea    0xcf1(%rip),%rdx
call   1090 <snprintf@plt>
mov    %r15,%rdi
lea    0x10(%rsp),%rsi
mov    $0xff,%edx
call   1050 <readlink@plt>
cmp    $0xffffffff,%eax
je     1230 <isAppRunning+0x50>
xorps  %xmm0,%xmm0
movaps %xmm0,0x200(%rsp)
movaps %xmm0,0x1f0(%rsp)
movaps %xmm0,0x1e0(%rsp)
movaps %xmm0,0x1d0(%rsp)
movaps %xmm0,0x1c0(%rsp)
movaps %xmm0,0x1b0(%rsp)
movaps %xmm0,0x1a0(%rsp)
movaps %xmm0,0x190(%rsp)
movaps %xmm0,0x180(%rsp)
movaps %xmm0,0x170(%rsp)
movaps %xmm0,0x160(%rsp)
movaps %xmm0,0x150(%rsp)
movaps %xmm0,0x140(%rsp)
movaps %xmm0,0x130(%rsp)
movaps %xmm0,0x120(%rsp)
movaps %xmm0,0x110(%rsp)
lea    0x110(%rsp),%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0xfe,%edx
call   1030 <strncpy@plt>
mov    %rbx,%rdi
lea    0xc1d(%rip),%rsi
call   1100 <strcat@plt>
mov    %rbx,%rdi
lea    0x10(%rsp),%rsi
call   1080 <doesMatch@plt>
test   %rax,%rax
je     1230 <isAppRunning+0x50>
cmpq   $0x0,0x8(%rsp)
je     1483 <isAppRunning+0x2a3>
lea    0x210(%rsp),%rdi
lea    0xc0b(%rip),%rsi
call   10e0 <fopen@plt>
test   %rax,%rax
je     1230 <isAppRunning+0x50>
mov    %rax,%r15
lea    0x390(%rsp),%rdi
mov    $0x400,%esi
mov    %rax,%rdx
call   10c0 <fgets@plt>
mov    %rax,%r12
mov    %r15,%rdi
call   1060 <fclose@plt>
test   %r12,%r12
lea    0xba4(%rip),%r12
je     1230 <isAppRunning+0x50>
mov    0x8(%rsp),%rdi
lea    0x390(%rsp),%rsi
call   1080 <doesMatch@plt>
test   %rax,%rax
je     1230 <isAppRunning+0x50>
mov    0x0(%rbp),%rdi
call   10f0 <atoi@plt>
mov    %eax,%ebp
mov    %r13,%rdi
call   10b0 <closedir@plt>
jmp    14b0 <isAppRunning+0x2d0>
mov    %r13,%rdi
call   10b0 <closedir@plt>
jmp    14ae <isAppRunning+0x2ce>
lea    0xb8b(%rip),%rdi
call   1040 <puts@plt>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x918,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.dirent = type { i8* }
@.str = [6 x i8] c"/proc\00"
@.str.1 = [14 x i8] c"^[0-9][0-9]*$\00"
@.str.2 = [13 x i8] c"/proc/%s/exe\00"
@.str.3 = [17 x i8] c"/proc/%s/cmdline\00"
@.str.4 = [2 x i8] c"$\00"
@.str.5 = [2 x i8] c"r\00"
@.str.6 = [22 x i8] c"/proc failed to open\0A\00"
define i32 @isAppRunning(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca %struct.dirent*
%8 = alloca [384 x i8]
%9 = alloca [256 x i8]
%10 = alloca [384 x i8]
%11 = alloca [1024 x i8]
%12 = alloca i32
%13 = alloca [256 x i8]
%14 = alloca i32*
%15 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
%16 = call i32* @opendir(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
store i32* %16, i32** %6
%17 = load i32*, i32** %6
%18 = icmp ne i32* %17, null
br i1 %18, label %19, label %101
19: ; preds = %2
br label %20
20: ; preds = %97, %87, %77, %71, %62, %60, %19
%21 = load i32*, i32** %6
%22 = call %struct.dirent* @readdir(i32* %21)
store %struct.dirent* %22, %struct.dirent** %7
%23 = icmp ne %struct.dirent* %22, null
br i1 %23, label %24, label %98
24: ; preds = %20
%25 = load %struct.dirent*, %struct.dirent** %7
%26 = getelementptr inbounds %struct.dirent, %struct.dirent* %25, i32 0, i32 0
%27 = load i8*, i8** %26
%28 = call i64 @doesMatch(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %27)
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %97
30: ; preds = %24
%31 = bitcast [384 x i8]* %8 to i8*
%32 = bitcast [256 x i8]* %9 to i8*
%33 = bitcast [384 x i8]* %10 to i8*
%34 = bitcast [1024 x i8]* %11 to i8*
%35 = getelementptr inbounds [384 x i8], [384 x i8]* %8, i64 0, i64 0
%36 = load %struct.dirent*, %struct.dirent** %7
%37 = getelementptr inbounds %struct.dirent, %struct.dirent* %36, i32 0, i32 0
%38 = load i8*, i8** %37
%39 = call i32 @snprintf(i8* %35, i32 384, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %38)
%40 = getelementptr inbounds [384 x i8], [384 x i8]* %10, i64 0, i64 0
%41 = load %struct.dirent*, %struct.dirent** %7
%42 = getelementptr inbounds %struct.dirent, %struct.dirent* %41, i32 0, i32 0
%43 = load i8*, i8** %42
%44 = call i32 @snprintf(i8* %40, i32 384, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i8* %43)
%45 = getelementptr inbounds [384 x i8], [384 x i8]* %8, i64 0, i64 0
%46 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%47 = call i32 @readlink(i8* %45, i8* %46, i32 255)
store i32 %47, i32* %12
%48 = icmp ne i32 %47, -1
br i1 %48, label %49, label %62
49: ; preds = %30
%50 = bitcast [256 x i8]* %13 to i8*
%51 = getelementptr inbounds [256 x i8], [256 x i8]* %13, i64 0, i64 0
%52 = load i8*, i8** %4
%53 = call i32 @strncpy(i8* %51, i8* %52, i32 254)
%54 = getelementptr inbounds [256 x i8], [256 x i8]* %13, i64 0, i64 0
%55 = call i32 @strcat(i8* %54, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%56 = getelementptr inbounds [256 x i8], [256 x i8]* %13, i64 0, i64 0
%57 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%58 = call i64 @doesMatch(i8* %56, i8* %57)
%59 = icmp ne i64 %58, 0
br i1 %59, label %61, label %60
60: ; preds = %49
br label %20
61: ; preds = %49
br label %63
62: ; preds = %30
br label %20
63: ; preds = %61
%64 = load i8*, i8** %5
%65 = icmp ne i8* %64, null
br i1 %65, label %66, label %89
66: ; preds = %63
%67 = getelementptr inbounds [384 x i8], [384 x i8]* %10, i64 0, i64 0
%68 = call i32* @fopen(i8* %67, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i32* %68, i32** %14
%69 = load i32*, i32** %14
%70 = icmp ne i32* %69, null
br i1 %70, label %72, label %71
71: ; preds = %66
br label %20
72: ; preds = %66
%73 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%74 = load i32*, i32** %14
%75 = call i32* @fgets(i8* %73, i32 1024, i32* %74)
%76 = icmp eq i32* %75, null
br i1 %76, label %77, label %80
77: ; preds = %72
%78 = load i32*, i32** %14
%79 = call i32 @fclose(i32* %78)
br label %20
80: ; preds = %72
%81 = load i32*, i32** %14
%82 = call i32 @fclose(i32* %81)
%83 = load i8*, i8** %5
%84 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%85 = call i64 @doesMatch(i8* %83, i8* %84)
%86 = icmp ne i64 %85, 0
br i1 %86, label %88, label %87
87: ; preds = %80
br label %20
88: ; preds = %80
br label %89
89: ; preds = %88, %63
%90 = load %struct.dirent*, %struct.dirent** %7
%91 = getelementptr inbounds %struct.dirent, %struct.dirent* %90, i32 0, i32 0
%92 = load i8*, i8** %91
%93 = call i32 @atoi(i8* %92)
store i32 %93, i32* %15
%94 = load i32*, i32** %6
%95 = call i32 @closedir(i32* %94)
%96 = load i32, i32* %15
store i32 %96, i32* %3
br label %104
97: ; preds = %24
br label %20
98: ; preds = %20
%99 = load i32*, i32** %6
%100 = call i32 @closedir(i32* %99)
br label %103
101: ; preds = %2
%102 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0))
br label %103
103: ; preds = %101, %98
store i32 0, i32* %3
br label %104
104: ; preds = %103, %89
%105 = load i32, i32* %3
ret i32 %105
}

LLVM IR (-O2):
%struct.dirent = type { i8* }
@.str = [6 x i8] c"/proc\00"
@.str.1 = [14 x i8] c"^[0-9][0-9]*$\00"
@.str.2 = [13 x i8] c"/proc/%s/exe\00"
@.str.3 = [17 x i8] c"/proc/%s/cmdline\00"
@.str.4 = [2 x i8] c"$\00"
@.str.5 = [2 x i8] c"r\00"
@str = [21 x i8] c"/proc failed to open\00"
define i32 @isAppRunning(i8* %0, i8* %1) {
%3 = alloca [384 x i8]
%4 = alloca [256 x i8]
%5 = alloca [384 x i8]
%6 = alloca [1024 x i8]
%7 = alloca [256 x i8]
%8 = tail call i32* @opendir(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i32* %8, null
br i1 %9, label %60, label %10
10: ; preds = %2
%11 = call %struct.dirent* @readdir(i32* %8)
%12 = icmp eq %struct.dirent* %11, null
br i1 %12, label %58, label %13
13: ; preds = %10
%14 = getelementptr inbounds [384 x i8], [384 x i8]* %3, i64 0, i64 0
%15 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%16 = getelementptr inbounds [384 x i8], [384 x i8]* %5, i64 0, i64 0
%17 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%18 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%19 = icmp eq i8* %1, null
br label %20
20: ; preds = %13, %55
%21 = phi %struct.dirent* [ %11, %13 ], [ %56, %55 ]
%22 = getelementptr inbounds %struct.dirent, %struct.dirent* %21, i64 0, i32 0
%23 = load i8*, i8** %22
%24 = call i64 @doesMatch(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %23)
%25 = icmp eq i64 %24, 0
br i1 %25, label %55, label %26
26: ; preds = %20
%27 = load i8*, i8** %22
%28 = call i32 @snprintf(i8* %14, i32 384, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %27)
%29 = load i8*, i8** %22
%30 = call i32 @snprintf(i8* %16, i32 384, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i8* %29)
%31 = call i32 @readlink(i8* %14, i8* %15, i32 255)
%32 = icmp eq i32 %31, -1
br i1 %32, label %53, label %33
33: ; preds = %26
%34 = call i32 @strncpy(i8* %18, i8* %0, i32 254)
%35 = call i32 @strcat(i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%36 = call i64 @doesMatch(i8* %18, i8* %15)
%37 = icmp eq i64 %36, 0
br i1 %37, label %53, label %38
38: ; preds = %33
br i1 %19, label %49, label %39
39: ; preds = %38
%40 = call i32* @fopen(i8* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%41 = icmp eq i32* %40, null
br i1 %41, label %53, label %42
42: ; preds = %39
%43 = call i32* @fgets(i8* %17, i32 1024, i32* %40)
%44 = icmp eq i32* %43, null
%45 = call i32 @fclose(i32* %40)
br i1 %44, label %53, label %46
46: ; preds = %42
%47 = call i64 @doesMatch(i8* %1, i8* %17)
%48 = icmp eq i64 %47, 0
br i1 %48, label %54, label %49
49: ; preds = %38, %46
%50 = load i8*, i8** %22
%51 = call i32 @atoi(i8* %50)
%52 = call i32 @closedir(i32* %8)
br label %62
53: ; preds = %42, %33, %26, %39
br label %55
54: ; preds = %46
br label %55
55: ; preds = %54, %53, %20
%56 = call %struct.dirent* @readdir(i32* %8)
%57 = icmp eq %struct.dirent* %56, null
br i1 %57, label %58, label %20
58: ; preds = %55, %10
%59 = call i32 @closedir(i32* %8)
br label %62
60: ; preds = %2
%61 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
br label %62
62: ; preds = %49, %60, %58
%63 = phi i32 [ 0, %58 ], [ 0, %60 ], [ %51, %49 ]
ret i32 %63
}