#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 pid_t;
typedef int /*<<< orphan*/ FILE;
typedef int /*<<< orphan*/ DIR;

/* Variables and functions */
int EOF;
int /*<<< orphan*/ LOG_ERR;
int atoi(char *);
int /*<<< orphan*/ closedir(int /*<<< orphan*/ *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ *opendir(char *);
struct dirent *readdir(int /*<<< orphan*/ *);
int /*<<< orphan*/ sprintf(char *, char *, char *);
scalar_t__ strcmp(char *, char *);
char *strrchr(char *, char);
int /*<<< orphan*/ syslog(int /*<<< orphan*/, char *);
pid_t libamg_process_get_pid(char *progname) {
  DIR *dir;
  struct dirent *d;
  FILE *fp;
  int pid = 0, found = 0, f, c;
  char *s, *q;
  char path[256];
  char buf[256];
  char cmdline[256];
  if ((dir = opendir("/proc")) == NULL) {
    syslog(LOG_ERR, "cannot opendir(/proc)");
    return (0);
  }
  while (((d = readdir(dir)) != NULL) && (!found)) {
    if ((pid = atoi(d->d_name)) == 0)
      continue;
    sprintf(path, "/proc/%s/stat", d->d_name);
    if ((fp = fopen(path, "r")) != NULL) {
      buf[0] = 0;
      fgets(buf, 256, fp);
      fclose(fp);
      s = buf;
      while (*s != ' ')
        s++;
      s++;
      if (*s == '(') {
        q = strrchr(buf, ')');
        if (q == NULL)
          continue;
        *q = 0;
        s++;
        if (strcmp(s, progname) == 0) {
          sprintf(path, "/proc/%s/cmdline", d->d_name);
          if ((fp = fopen(path, "r")) != NULL) {
            f = 0;
            while (f < (256 - 1) && (c = fgetc(fp)) != EOF) {
              cmdline[f++] = c ? c : ' ';
            }
            cmdline[f++] = 0;
            fclose(fp);
          } else {
            continue;
          }
          found = 1;
        }
      }
    } else {
      continue;
    }
  }
  closedir(dir);
  return (found ? pid : 0);
}


x86 assembly (clang, -O0):
<libamg_process_get_pid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x360,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
lea    0xe1c(%rip),%rdi
call   1040 <opendir@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    1218 <libamg_process_get_pid+0x58>
mov    0x2dd2(%rip),%rax
mov    (%rax),%edi
lea    0xdff(%rip),%rsi
call   10b0 <syslog@plt>
movl   $0x0,-0x4(%rbp)
jmp    14c0 <libamg_process_get_pid+0x300>
jmp    121d <libamg_process_get_pid+0x5d>
mov    -0x18(%rbp),%rdi
call   10a0 <readdir@plt>
mov    %rax,%rcx
mov    %rcx,-0x20(%rbp)
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x351(%rbp)
je     124e <libamg_process_get_pid+0x8e>
cmpl   $0x0,-0x30(%rbp)
setne  %al
xor    $0xff,%al
mov    %al,-0x351(%rbp)
mov    -0x351(%rbp),%al
test   $0x1,%al
jne    1261 <libamg_process_get_pid+0xa1>
jmp    1489 <libamg_process_get_pid+0x2c9>
mov    -0x20(%rbp),%rax
mov    (%rax),%rdi
call   10d0 <atoi@plt>
mov    %eax,-0x2c(%rbp)
cmp    $0x0,%eax
jne    127e <libamg_process_get_pid+0xbe>
jmp    121d <libamg_process_get_pid+0x5d>
lea    -0x150(%rbp),%rdi
mov    -0x20(%rbp),%rax
mov    (%rax),%rdx
lea    0xd89(%rip),%rsi
call   10e0 <sprintf@plt>
lea    -0x150(%rbp),%rdi
lea    0xd84(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
je     147f <libamg_process_get_pid+0x2bf>
movb   $0x0,-0x250(%rbp)
lea    -0x250(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    $0x100,%esi
call   1080 <fgets@plt>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
lea    -0x250(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
je     130a <libamg_process_get_pid+0x14a>
mov    -0x40(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x40(%rbp)
jmp    12e9 <libamg_process_get_pid+0x129>
mov    -0x40(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x28,%eax
jne    147a <libamg_process_get_pid+0x2ba>
lea    -0x250(%rbp),%rdi
mov    $0x29,%esi
call   1050 <strrchr@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
jne    134b <libamg_process_get_pid+0x18b>
jmp    121d <libamg_process_get_pid+0x5d>
mov    -0x48(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x40(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    1475 <libamg_process_get_pid+0x2b5>
lea    -0x150(%rbp),%rdi
mov    -0x20(%rbp),%rax
mov    (%rax),%rdx
lea    0xca2(%rip),%rsi
call   10e0 <sprintf@plt>
lea    -0x150(%rbp),%rdi
lea    0xc8d(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
je     1469 <libamg_process_get_pid+0x2a9>
movl   $0x0,-0x34(%rbp)
xor    %eax,%eax
cmpl   $0xff,-0x34(%rbp)
mov    %al,-0x352(%rbp)
jge    13ea <libamg_process_get_pid+0x22a>
mov    -0x28(%rbp),%rdi
call   1060 <fgetc@plt>
mov    %eax,-0x38(%rbp)
mov    0x2c09(%rip),%rcx
cmp    (%rcx),%eax
setne  %al
mov    %al,-0x352(%rbp)
mov    -0x352(%rbp),%al
test   $0x1,%al
jne    13fd <libamg_process_get_pid+0x23d>
jmp    1446 <libamg_process_get_pid+0x286>
cmpl   $0x0,-0x38(%rbp)
je     1415 <libamg_process_get_pid+0x255>
mov    -0x38(%rbp),%eax
mov    %eax,-0x358(%rbp)
jmp    1425 <libamg_process_get_pid+0x265>
mov    $0x20,%eax
mov    %eax,-0x358(%rbp)
jmp    1425 <libamg_process_get_pid+0x265>
mov    -0x358(%rbp),%eax
mov    %al,%cl
mov    -0x34(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x34(%rbp)
cltq
mov    %cl,-0x350(%rbp,%rax,1)
jmp    13b7 <libamg_process_get_pid+0x1f7>
mov    -0x34(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x34(%rbp)
cltq
movb   $0x0,-0x350(%rbp,%rax,1)
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
jmp    146e <libamg_process_get_pid+0x2ae>
jmp    121d <libamg_process_get_pid+0x5d>
movl   $0x1,-0x30(%rbp)
jmp    147a <libamg_process_get_pid+0x2ba>
jmp    1484 <libamg_process_get_pid+0x2c4>
jmp    121d <libamg_process_get_pid+0x5d>
jmp    121d <libamg_process_get_pid+0x5d>
mov    -0x18(%rbp),%rdi
call   1070 <closedir@plt>
cmpl   $0x0,-0x30(%rbp)
je     14aa <libamg_process_get_pid+0x2ea>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x35c(%rbp)
jmp    14b7 <libamg_process_get_pid+0x2f7>
xor    %eax,%eax
mov    %eax,-0x35c(%rbp)
jmp    14b7 <libamg_process_get_pid+0x2f7>
mov    -0x35c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x360,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<libamg_process_get_pid>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x218,%rsp
mov    %rdi,0x8(%rsp)
lea    0xe23(%rip),%rdi
call   1040 <opendir@plt>
test   %rax,%rax
je     134e <libamg_process_get_pid+0x18e>
mov    %rax,%r13
mov    %rax,%rdi
call   10a0 <readdir@plt>
test   %rax,%rax
je     1344 <libamg_process_get_pid+0x184>
mov    %rax,%r14
lea    0x110(%rsp),%r12
jmp    1224 <libamg_process_get_pid+0x64>
nopl   0x0(%rax)
mov    %r13,%rdi
call   10a0 <readdir@plt>
mov    %rax,%r14
test   %rax,%rax
je     1344 <libamg_process_get_pid+0x184>
mov    (%r14),%rbx
mov    %rbx,%rdi
call   10d0 <atoi@plt>
test   %eax,%eax
je     1210 <libamg_process_get_pid+0x50>
mov    %eax,%ebp
mov    %r12,%rdi
lea    0xddd(%rip),%rsi
mov    %rbx,%rdx
call   10e0 <sprintf@plt>
mov    %r12,%rdi
lea    0xdd9(%rip),%rsi
call   10c0 <fopen@plt>
test   %rax,%rax
je     1210 <libamg_process_get_pid+0x50>
mov    %rax,%rbx
movb   $0x0,0x10(%rsp)
lea    0x10(%rsp),%rdi
mov    $0x100,%esi
mov    %rax,%rdx
call   1080 <fgets@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
lea    0x11(%rsp),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
cmpb   $0x20,-0x1(%r15)
lea    0x1(%r15),%r15
jne    1290 <libamg_process_get_pid+0xd0>
cmpb   $0x28,-0x1(%r15)
jne    1210 <libamg_process_get_pid+0x50>
lea    0x10(%rsp),%rdi
mov    $0x29,%esi
call   1050 <strrchr@plt>
test   %rax,%rax
je     1210 <libamg_process_get_pid+0x50>
movb   $0x0,(%rax)
mov    %r15,%rdi
mov    0x8(%rsp),%rsi
call   1090 <strcmp@plt>
test   %rax,%rax
jne    1210 <libamg_process_get_pid+0x50>
mov    (%r14),%rdx
mov    %r12,%rdi
lea    0xd48(%rip),%rsi
call   10e0 <sprintf@plt>
mov    %r12,%rdi
lea    0xd37(%rip),%rsi
call   10c0 <fopen@plt>
test   %rax,%rax
je     1210 <libamg_process_get_pid+0x50>
mov    %rax,%r14
xor    %ebx,%ebx
mov    0x2cdb(%rip),%r15
nopl   (%rax)
mov    %r14,%rdi
call   1060 <fgetc@plt>
cmp    (%r15),%eax
je     132a <libamg_process_get_pid+0x16a>
lea    0x1(%rbx),%eax
cmp    $0xfe,%ebx
mov    %eax,%ebx
jb     1310 <libamg_process_get_pid+0x150>
mov    %r14,%rdi
call   1030 <fclose@plt>
mov    %r13,%rdi
call   10a0 <readdir@plt>
mov    %r13,%rdi
call   1070 <closedir@plt>
jmp    1365 <libamg_process_get_pid+0x1a5>
mov    %r13,%rdi
call   1070 <closedir@plt>
jmp    1363 <libamg_process_get_pid+0x1a3>
mov    0x2c7b(%rip),%rax
mov    (%rax),%edi
lea    0xca8(%rip),%rsi
call   10b0 <syslog@plt>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x218,%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"
@LOG_ERR = global i32 0
@.str.1 = [22 x i8] c"cannot opendir(/proc)\00"
@.str.2 = [14 x i8] c"/proc/%s/stat\00"
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [17 x i8] c"/proc/%s/cmdline\00"
@EOF = global i32 0
define i32 @libamg_process_get_pid(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca %struct.dirent*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca [256 x i8]
%14 = alloca [256 x i8]
%15 = alloca [256 x i8]
store i8* %0, i8** %3
store i32 0, i32* %7
store i32 0, i32* %8
%16 = call i32* @opendir(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
store i32* %16, i32** %4
%17 = icmp eq i32* %16, null
br i1 %17, label %18, label %21
18: ; preds = %1
%19 = load i32, i32* @LOG_ERR
%20 = call i32 @syslog(i32 %19, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %2
br label %141
21: ; preds = %1
br label %22
22: ; preds = %130, %129, %125, %76, %38, %21
%23 = load i32*, i32** %4
%24 = call %struct.dirent* @readdir(i32* %23)
store %struct.dirent* %24, %struct.dirent** %5
%25 = icmp ne %struct.dirent* %24, null
br i1 %25, label %26, label %30
26: ; preds = %22
%27 = load i32, i32* %8
%28 = icmp ne i32 %27, 0
%29 = xor i1 %28, true
br label %30
30: ; preds = %26, %22
%31 = phi i1 [ false, %22 ], [ %29, %26 ]
br i1 %31, label %32, label %131
32: ; preds = %30
%33 = load %struct.dirent*, %struct.dirent** %5
%34 = getelementptr inbounds %struct.dirent, %struct.dirent* %33, i32 0, i32 0
%35 = load i8*, i8** %34
%36 = call i32 @atoi(i8* %35)
store i32 %36, i32* %7
%37 = icmp eq i32 %36, 0
br i1 %37, label %38, label %39
38: ; preds = %32
br label %22
39: ; preds = %32
%40 = getelementptr inbounds [256 x i8], [256 x i8]* %13, i64 0, i64 0
%41 = load %struct.dirent*, %struct.dirent** %5
%42 = getelementptr inbounds %struct.dirent, %struct.dirent* %41, i32 0, i32 0
%43 = load i8*, i8** %42
%44 = call i32 @sprintf(i8* %40, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %43)
%45 = getelementptr inbounds [256 x i8], [256 x i8]* %13, i64 0, i64 0
%46 = call i32* @fopen(i8* %45, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %46, i32** %6
%47 = icmp ne i32* %46, null
br i1 %47, label %48, label %129
48: ; preds = %39
%49 = getelementptr inbounds [256 x i8], [256 x i8]* %14, i64 0, i64 0
store i8 0, i8* %49
%50 = getelementptr inbounds [256 x i8], [256 x i8]* %14, i64 0, i64 0
%51 = load i32*, i32** %6
%52 = call i32 @fgets(i8* %50, i32 256, i32* %51)
%53 = load i32*, i32** %6
%54 = call i32 @fclose(i32* %53)
%55 = getelementptr inbounds [256 x i8], [256 x i8]* %14, i64 0, i64 0
store i8* %55, i8** %11
br label %56
56: ; preds = %61, %48
%57 = load i8*, i8** %11
%58 = load i8, i8* %57
%59 = sext i8 %58 to i32
%60 = icmp ne i32 %59, 32
br i1 %60, label %61, label %64
61: ; preds = %56
%62 = load i8*, i8** %11
%63 = getelementptr inbounds i8, i8* %62, i32 1
store i8* %63, i8** %11
br label %56
64: ; preds = %56
%65 = load i8*, i8** %11
%66 = getelementptr inbounds i8, i8* %65, i32 1
store i8* %66, i8** %11
%67 = load i8*, i8** %11
%68 = load i8, i8* %67
%69 = sext i8 %68 to i32
%70 = icmp eq i32 %69, 40
br i1 %70, label %71, label %128
71: ; preds = %64
%72 = getelementptr inbounds [256 x i8], [256 x i8]* %14, i64 0, i64 0
%73 = call i8* @strrchr(i8* %72, i8 signext 41)
store i8* %73, i8** %12
%74 = load i8*, i8** %12
%75 = icmp eq i8* %74, null
br i1 %75, label %76, label %77
76: ; preds = %71
br label %22
77: ; preds = %71
%78 = load i8*, i8** %12
store i8 0, i8* %78
%79 = load i8*, i8** %11
%80 = getelementptr inbounds i8, i8* %79, i32 1
store i8* %80, i8** %11
%81 = load i8*, i8** %11
%82 = load i8*, i8** %3
%83 = call i64 @strcmp(i8* %81, i8* %82)
%84 = icmp eq i64 %83, 0
br i1 %84, label %85, label %127
85: ; preds = %77
%86 = getelementptr inbounds [256 x i8], [256 x i8]* %13, i64 0, i64 0
%87 = load %struct.dirent*, %struct.dirent** %5
%88 = getelementptr inbounds %struct.dirent, %struct.dirent* %87, i32 0, i32 0
%89 = load i8*, i8** %88
%90 = call i32 @sprintf(i8* %86, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i8* %89)
%91 = getelementptr inbounds [256 x i8], [256 x i8]* %13, i64 0, i64 0
%92 = call i32* @fopen(i8* %91, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %92, i32** %6
%93 = icmp ne i32* %92, null
br i1 %93, label %94, label %125
94: ; preds = %85
store i32 0, i32* %9
br label %95
95: ; preds = %111, %94
%96 = load i32, i32* %9
%97 = icmp slt i32 %96, 255
br i1 %97, label %98, label %103
98: ; preds = %95
%99 = load i32*, i32** %6
%100 = call i32 @fgetc(i32* %99)
store i32 %100, i32* %10
%101 = load i32, i32* @EOF
%102 = icmp ne i32 %100, %101
br label %103
103: ; preds = %98, %95
%104 = phi i1 [ false, %95 ], [ %102, %98 ]
br i1 %104, label %105, label %118
105: ; preds = %103
%106 = load i32, i32* %10
%107 = icmp ne i32 %106, 0
br i1 %107, label %108, label %110
108: ; preds = %105
%109 = load i32, i32* %10
br label %111
110: ; preds = %105
br label %111
111: ; preds = %110, %108
%112 = phi i32 [ %109, %108 ], [ 32, %110 ]
%113 = trunc i32 %112 to i8
%114 = load i32, i32* %9
%115 = add nsw i32 %114, 1
store i32 %115, i32* %9
%116 = sext i32 %114 to i64
%117 = getelementptr inbounds [256 x i8], [256 x i8]* %15, i64 0, i64 %116
store i8 %113, i8* %117
br label %95
118: ; preds = %103
%119 = load i32, i32* %9
%120 = add nsw i32 %119, 1
store i32 %120, i32* %9
%121 = sext i32 %119 to i64
%122 = getelementptr inbounds [256 x i8], [256 x i8]* %15, i64 0, i64 %121
store i8 0, i8* %122
%123 = load i32*, i32** %6
%124 = call i32 @fclose(i32* %123)
br label %126
125: ; preds = %85
br label %22
126: ; preds = %118
store i32 1, i32* %8
br label %127
127: ; preds = %126, %77
br label %128
128: ; preds = %127, %64
br label %130
129: ; preds = %39
br label %22
130: ; preds = %128
br label %22
131: ; preds = %30
%132 = load i32*, i32** %4
%133 = call i32 @closedir(i32* %132)
%134 = load i32, i32* %8
%135 = icmp ne i32 %134, 0
br i1 %135, label %136, label %138
136: ; preds = %131
%137 = load i32, i32* %7
br label %139
138: ; preds = %131
br label %139
139: ; preds = %138, %136
%140 = phi i32 [ %137, %136 ], [ 0, %138 ]
store i32 %140, i32* %2
br label %141
141: ; preds = %139, %18
%142 = load i32, i32* %2
ret i32 %142
}

LLVM IR (-O2):
%struct.dirent = type { i8* }
@.str = [6 x i8] c"/proc\00"
@LOG_ERR = global i32 0
@.str.1 = [22 x i8] c"cannot opendir(/proc)\00"
@.str.2 = [14 x i8] c"/proc/%s/stat\00"
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [17 x i8] c"/proc/%s/cmdline\00"
@EOF = global i32 0
define i32 @libamg_process_get_pid(i8* %0) {
%2 = alloca [256 x i8]
%3 = alloca [256 x i8]
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%6 = tail call i32* @opendir(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i32* %6, null
br i1 %7, label %11, label %8
8: ; preds = %1
%9 = call %struct.dirent* @readdir(i32* %6)
%10 = icmp eq %struct.dirent* %9, null
br i1 %10, label %67, label %14
11: ; preds = %1
%12 = load i32, i32* @LOG_ERR
%13 = tail call i32 @syslog(i32 %12, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
br label %69
14: ; preds = %8, %41
%15 = phi %struct.dirent* [ %42, %41 ], [ %9, %8 ]
%16 = getelementptr inbounds %struct.dirent, %struct.dirent* %15, i64 0, i32 0
%17 = load i8*, i8** %16
%18 = call i32 @atoi(i8* %17)
%19 = icmp eq i32 %18, 0
br i1 %19, label %60, label %20
20: ; preds = %14
%21 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %17)
%22 = call i32* @fopen(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%23 = icmp eq i32* %22, null
br i1 %23, label %60, label %24
24: ; preds = %20
store i8 0, i8* %5
%25 = call i32 @fgets(i8* %5, i32 256, i32* %22)
%26 = call i32 @fclose(i32* %22)
br label %27
27: ; preds = %27, %24
%28 = phi i8* [ %5, %24 ], [ %31, %27 ]
%29 = load i8, i8* %28
%30 = icmp eq i8 %29, 32
%31 = getelementptr inbounds i8, i8* %28, i64 1
br i1 %30, label %32, label %27
32: ; preds = %27
%33 = load i8, i8* %31
%34 = icmp eq i8 %33, 40
br i1 %34, label %35, label %60
35: ; preds = %32
%36 = call i8* @strrchr(i8* %5, i8 signext 41)
%37 = icmp eq i8* %36, null
br i1 %37, label %38, label %43
38: ; preds = %35, %47
%39 = call %struct.dirent* @readdir(i32* %6)
%40 = icmp eq %struct.dirent* %39, null
br i1 %40, label %67, label %41
41: ; preds = %38, %60
%42 = phi %struct.dirent* [ %39, %38 ], [ %61, %60 ]
br label %14
43: ; preds = %35
store i8 0, i8* %36
%44 = getelementptr inbounds i8, i8* %28, i64 2
%45 = call i64 @strcmp(i8* %44, i8* %0)
%46 = icmp eq i64 %45, 0
br i1 %46, label %47, label %60
47: ; preds = %43
%48 = load i8*, i8** %16
%49 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i8* %48)
%50 = call i32* @fopen(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%51 = icmp eq i32* %50, null
br i1 %51, label %38, label %52
52: ; preds = %47, %52
%53 = phi i32 [ %57, %52 ], [ 0, %47 ]
%54 = call i32 @fgetc(i32* %50)
%55 = load i32, i32* @EOF
%56 = icmp ne i32 %54, %55
%57 = add nuw nsw i32 %53, 1
%58 = icmp ult i32 %53, 254
%59 = select i1 %56, i1 %58, i1 false
br i1 %59, label %52, label %63
60: ; preds = %43, %32, %20, %14
%61 = call %struct.dirent* @readdir(i32* %6)
%62 = icmp eq %struct.dirent* %61, null
br i1 %62, label %67, label %41
63: ; preds = %52
%64 = call i32 @fclose(i32* %50)
%65 = call %struct.dirent* @readdir(i32* %6)
%66 = call i32 @closedir(i32* %6)
br label %69
67: ; preds = %60, %38, %8
%68 = call i32 @closedir(i32* %6)
br label %69
69: ; preds = %67, %63, %11
%70 = phi i32 [ 0, %11 ], [ 0, %67 ], [ %18, %63 ]
ret i32 %70
}