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

/* Variables and functions */
int PATH_MAX;
char *basename(char *);
int /*<<< orphan*/ closedir(int /*<<< orphan*/ *);
scalar_t__ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *const);
int /*<<< orphan*/ isdigit(char);
int /*<<< orphan*/ *opendir(char *);
scalar_t__ read_buf(char *, char *, int);
struct dirent *readdir(int /*<<< orphan*/ *);
int /*<<< orphan*/ snprintf(char *, int, char *, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcmp(char *const, char *);
scalar_t__ strtol(char *const, int /*<<< orphan*/ *, int);
pid_t proc_name_to_pid(char *const name) {
  char *ptr;
  bool isnum = true;
  DIR *dir;
  struct dirent *d;
  pid_t pid = 0;
  for (ptr = name; *ptr; ptr++) {
    if (!isdigit(*ptr)) {
      isnum = false;
      break;
    }
  }
  if (isnum) {
    pid = (pid_t)strtol(name, NULL, 10);
    if (errno || (pid < 1)) {
      (void)fprintf(stderr, "Invalid pid value '%s'\n", name);
      return 0;
    }
    return pid;
  }
  dir = opendir("/proc");
  if (!dir)
    return pid;
  while ((d = readdir(dir)) != NULL) {
    char path[PATH_MAX], buf[4096], *bn;
    if (!isdigit(d->d_name[0]))
      continue;
    (void)snprintf(path, sizeof(path), "/proc/%s/cmdline", d->d_name);
    if (read_buf(path, buf, sizeof(buf)) < 0)
      continue;
    bn = basename(buf);
    if (!bn)
      continue;
    if (!strcmp(name, bn)) {
      pid = (pid_t)strtol(d->d_name, NULL, 10);
      if ((errno == 0) && (pid > 0))
        break;
    }
  }
  (void)closedir(dir);
  if (!pid)
    (void)fprintf(stderr, "Cannot find process '%s'\n", name);
  return pid;
}


x86 assembly (clang, -O0):
<proc_name_to_pid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1080,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x1,-0x1c(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
je     1209 <proc_name_to_pid+0x69>
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
jne    11f3 <proc_name_to_pid+0x53>
movl   $0x0,-0x1c(%rbp)
jmp    1209 <proc_name_to_pid+0x69>
jmp    11f8 <proc_name_to_pid+0x58>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    11c5 <proc_name_to_pid+0x25>
cmpl   $0x0,-0x1c(%rbp)
je     1273 <proc_name_to_pid+0xd3>
mov    -0x10(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   10b0 <strtol@plt>
mov    %eax,-0x34(%rbp)
mov    0x2da1(%rip),%rax
cmpq   $0x0,(%rax)
jne    1243 <proc_name_to_pid+0xa3>
cmpl   $0x1,-0x34(%rbp)
jge    1268 <proc_name_to_pid+0xc8>
mov    0x2d8e(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xda9(%rip),%rsi
call   1090 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1470 <proc_name_to_pid+0x2d0>
mov    -0x34(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1470 <proc_name_to_pid+0x2d0>
lea    0xd9e(%rip),%rdi
call   1040 <opendir@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1299 <proc_name_to_pid+0xf9>
mov    -0x34(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1470 <proc_name_to_pid+0x2d0>
jmp    129e <proc_name_to_pid+0xfe>
mov    -0x28(%rbp),%rdi
call   10c0 <readdir@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
je     143e <proc_name_to_pid+0x29e>
mov    0x2d34(%rip),%rax
mov    (%rax),%eax
mov    %rax,-0x1070(%rbp)
mov    %rsp,%rcx
mov    %rcx,-0x40(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x1068(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x48(%rbp)
mov    -0x30(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
jne    1312 <proc_name_to_pid+0x172>
movl   $0x5,-0x105c(%rbp)
jmp    1400 <proc_name_to_pid+0x260>
mov    -0x1068(%rbp),%rdi
mov    -0x1070(%rbp),%rax
mov    %eax,%esi
mov    -0x30(%rbp),%rax
mov    (%rax),%rcx
lea    0xcee(%rip),%rdx
call   1060 <snprintf@plt>
mov    -0x1068(%rbp),%rdi
lea    -0x1050(%rbp),%rsi
mov    $0x1000,%edx
call   1050 <read_buf@plt>
cmp    $0x0,%rax
jge    1366 <proc_name_to_pid+0x1c6>
movl   $0x5,-0x105c(%rbp)
jmp    1400 <proc_name_to_pid+0x260>
lea    -0x1050(%rbp),%rdi
call   10a0 <basename@plt>
mov    %rax,-0x1058(%rbp)
cmpq   $0x0,-0x1058(%rbp)
jne    1396 <proc_name_to_pid+0x1f6>
movl   $0x5,-0x105c(%rbp)
jmp    1400 <proc_name_to_pid+0x260>
mov    -0x10(%rbp),%rdi
mov    -0x1058(%rbp),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%eax
jne    13f6 <proc_name_to_pid+0x256>
mov    -0x30(%rbp),%rax
mov    (%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   10b0 <strtol@plt>
mov    %eax,-0x34(%rbp)
mov    0x2c02(%rip),%rax
cmpq   $0x0,(%rax)
jne    13f1 <proc_name_to_pid+0x251>
cmpl   $0x0,-0x34(%rbp)
jle    13f1 <proc_name_to_pid+0x251>
movl   $0x6,-0x105c(%rbp)
jmp    1400 <proc_name_to_pid+0x260>
jmp    13f6 <proc_name_to_pid+0x256>
movl   $0x0,-0x105c(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,%rsp
mov    -0x105c(%rbp),%eax
mov    %eax,-0x1074(%rbp)
test   %eax,%eax
je     1439 <proc_name_to_pid+0x299>
jmp    1420 <proc_name_to_pid+0x280>
mov    -0x1074(%rbp),%eax
sub    $0x5,%eax
je     129e <proc_name_to_pid+0xfe>
jmp    1434 <proc_name_to_pid+0x294>
jmp    143e <proc_name_to_pid+0x29e>
jmp    129e <proc_name_to_pid+0xfe>
mov    -0x28(%rbp),%rdi
call   1070 <closedir@plt>
cmpl   $0x0,-0x34(%rbp)
jne    146a <proc_name_to_pid+0x2ca>
mov    0x2b80(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xbca(%rip),%rsi
call   1090 <fprintf@plt>
mov    -0x34(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<proc_name_to_pid>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1018,%rsp
mov    %rdi,%r14
mov    (%rdi),%al
test   %al,%al
je     11e7 <proc_name_to_pid+0x47>
lea    0x1(%r14),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsbl %al,%edi
call   1030 <isdigit@plt>
test   %eax,%eax
je     1220 <proc_name_to_pid+0x80>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    11d0 <proc_name_to_pid+0x30>
mov    %r14,%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   10b0 <strtol@plt>
mov    0x2dd3(%rip),%rcx
cmpq   $0x0,(%rcx)
jne    120b <proc_name_to_pid+0x6b>
test   %eax,%eax
jg     1389 <proc_name_to_pid+0x1e9>
mov    0x2dc6(%rip),%rax
mov    (%rax),%edi
lea    0xde5(%rip),%rsi
jmp    137f <proc_name_to_pid+0x1df>
lea    0xdf1(%rip),%rdi
call   1040 <opendir@plt>
mov    %rax,%rbx
xor    %eax,%eax
test   %rbx,%rbx
je     1389 <proc_name_to_pid+0x1e9>
mov    %rbx,%rdi
call   10c0 <readdir@plt>
test   %rax,%rax
je     1367 <proc_name_to_pid+0x1c7>
mov    %rax,%r12
mov    %r14,-0x38(%rbp)
xor    %eax,%eax
mov    %rax,-0x30(%rbp)
lea    -0x1040(%rbp),%r14
mov    %rbx,-0x40(%rbp)
jmp    128e <proc_name_to_pid+0xee>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%r14
mov    %r15,%rsp
mov    -0x40(%rbp),%rbx
mov    %rbx,%rdi
call   10c0 <readdir@plt>
mov    %rax,%r12
test   %rax,%rax
je     1351 <proc_name_to_pid+0x1b1>
mov    %r14,%rbx
mov    %rsp,%r15
mov    0x2d55(%rip),%rax
mov    (%rax),%r14d
mov    %rsp,%r13
lea    0xf(%r14),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r13
mov    %r13,%rsp
mov    (%r12),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
test   %eax,%eax
je     1270 <proc_name_to_pid+0xd0>
mov    (%r12),%rcx
mov    %r13,%rdi
mov    %r14d,%esi
lea    0xd4e(%rip),%rdx
call   1060 <snprintf@plt>
mov    %r13,%rdi
mov    %rbx,%r14
mov    %rbx,%rsi
mov    $0x1000,%edx
call   1050 <read_buf@plt>
test   %rax,%rax
js     1273 <proc_name_to_pid+0xd3>
mov    %r14,%rdi
call   10a0 <basename@plt>
test   %rax,%rax
je     1273 <proc_name_to_pid+0xd3>
mov    -0x38(%rbp),%rdi
mov    %rax,%rsi
call   1080 <strcmp@plt>
test   %eax,%eax
jne    1273 <proc_name_to_pid+0xd3>
mov    (%r12),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   10b0 <strtol@plt>
mov    0x2ca7(%rip),%rcx
cmpq   $0x0,(%rcx)
mov    %rax,-0x30(%rbp)
jne    1273 <proc_name_to_pid+0xd3>
test   %eax,%eax
jle    1273 <proc_name_to_pid+0xd3>
mov    %r15,%rsp
mov    -0x40(%rbp),%rdi
call   1070 <closedir@plt>
mov    -0x30(%rbp),%rax
jmp    1389 <proc_name_to_pid+0x1e9>
mov    %rbx,%rdi
call   1070 <closedir@plt>
mov    -0x30(%rbp),%rax
test   %eax,%eax
mov    -0x38(%rbp),%r14
jne    1389 <proc_name_to_pid+0x1e9>
jmp    136f <proc_name_to_pid+0x1cf>
mov    %rbx,%rdi
call   1070 <closedir@plt>
mov    0x2c62(%rip),%rax
mov    (%rax),%edi
lea    0xcb0(%rip),%rsi
mov    %r14,%rdx
call   1090 <fprintf@plt>
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.dirent = type { i8* }
@errno = global i64 0
@stderr = global i32 0
@.str = [24 x i8] c"Invalid pid value '%s'\0A\00"
@.str.1 = [6 x i8] c"/proc\00"
@PATH_MAX = global i32 0
@.str.2 = [17 x i8] c"/proc/%s/cmdline\00"
@.str.3 = [26 x i8] c"Cannot find process '%s'\0A\00"
define i32 @proc_name_to_pid(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32*
%7 = alloca %struct.dirent*
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i64
%11 = alloca [4096 x i8]
%12 = alloca i8*
%13 = alloca i32
store i8* %0, i8** %3
store i32 1, i32* %5
store i32 0, i32* %8
%14 = load i8*, i8** %3
store i8* %14, i8** %4
br label %15
15: ; preds = %26, %1
%16 = load i8*, i8** %4
%17 = load i8, i8* %16
%18 = icmp ne i8 %17, 0
br i1 %18, label %19, label %29
19: ; preds = %15
%20 = load i8*, i8** %4
%21 = load i8, i8* %20
%22 = call i32 @isdigit(i8 signext %21)
%23 = icmp ne i32 %22, 0
br i1 %23, label %25, label %24
24: ; preds = %19
store i32 0, i32* %5
br label %29
25: ; preds = %19
br label %26
26: ; preds = %25
%27 = load i8*, i8** %4
%28 = getelementptr inbounds i8, i8* %27, i32 1
store i8* %28, i8** %4
br label %15
29: ; preds = %24, %15
%30 = load i32, i32* %5
%31 = icmp ne i32 %30, 0
br i1 %31, label %32, label %47
32: ; preds = %29
%33 = load i8*, i8** %3
%34 = call i64 @strtol(i8* %33, i32* null, i32 10)
%35 = trunc i64 %34 to i32
store i32 %35, i32* %8
%36 = load i64, i64* @errno
%37 = icmp ne i64 %36, 0
br i1 %37, label %41, label %38
38: ; preds = %32
%39 = load i32, i32* %8
%40 = icmp slt i32 %39, 1
br i1 %40, label %41, label %45
41: ; preds = %38, %32
%42 = load i32, i32* @stderr
%43 = load i8*, i8** %3
%44 = call i32 @fprintf(i32 %42, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %43)
store i32 0, i32* %2
br label %121
45: ; preds = %38
%46 = load i32, i32* %8
store i32 %46, i32* %2
br label %121
47: ; preds = %29
%48 = call i32* @opendir(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
store i32* %48, i32** %6
%49 = load i32*, i32** %6
%50 = icmp ne i32* %49, null
br i1 %50, label %53, label %51
51: ; preds = %47
%52 = load i32, i32* %8
store i32 %52, i32* %2
br label %121
53: ; preds = %47
br label %54
54: ; preds = %109, %106, %53
%55 = load i32*, i32** %6
%56 = call %struct.dirent* @readdir(i32* %55)
store %struct.dirent* %56, %struct.dirent** %7
%57 = icmp ne %struct.dirent* %56, null
br i1 %57, label %58, label %110
58: ; preds = %54
%59 = load i32, i32* @PATH_MAX
%60 = zext i32 %59 to i64
%61 = call i8* @llvm.stacksave()
store i8* %61, i8** %9
%62 = alloca i8, i64 %60
store i64 %60, i64* %10
%63 = load %struct.dirent*, %struct.dirent** %7
%64 = getelementptr inbounds %struct.dirent, %struct.dirent* %63, i32 0, i32 0
%65 = load i8*, i8** %64
%66 = getelementptr inbounds i8, i8* %65, i64 0
%67 = load i8, i8* %66
%68 = call i32 @isdigit(i8 signext %67)
%69 = icmp ne i32 %68, 0
br i1 %69, label %71, label %70
70: ; preds = %58
store i32 5, i32* %13
br label %106
71: ; preds = %58
%72 = trunc i64 %60 to i32
%73 = load %struct.dirent*, %struct.dirent** %7
%74 = getelementptr inbounds %struct.dirent, %struct.dirent* %73, i32 0, i32 0
%75 = load i8*, i8** %74
%76 = call i32 @snprintf(i8* %62, i32 %72, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* %75)
%77 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%78 = call i64 @read_buf(i8* %62, i8* %77, i32 4096)
%79 = icmp slt i64 %78, 0
br i1 %79, label %80, label %81
80: ; preds = %71
store i32 5, i32* %13
br label %106
81: ; preds = %71
%82 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%83 = call i8* @basename(i8* %82)
store i8* %83, i8** %12
%84 = load i8*, i8** %12
%85 = icmp ne i8* %84, null
br i1 %85, label %87, label %86
86: ; preds = %81
store i32 5, i32* %13
br label %106
87: ; preds = %81
%88 = load i8*, i8** %3
%89 = load i8*, i8** %12
%90 = call i32 @strcmp(i8* %88, i8* %89)
%91 = icmp ne i32 %90, 0
br i1 %91, label %105, label %92
92: ; preds = %87
%93 = load %struct.dirent*, %struct.dirent** %7
%94 = getelementptr inbounds %struct.dirent, %struct.dirent* %93, i32 0, i32 0
%95 = load i8*, i8** %94
%96 = call i64 @strtol(i8* %95, i32* null, i32 10)
%97 = trunc i64 %96 to i32
store i32 %97, i32* %8
%98 = load i64, i64* @errno
%99 = icmp eq i64 %98, 0
br i1 %99, label %100, label %104
100: ; preds = %92
%101 = load i32, i32* %8
%102 = icmp sgt i32 %101, 0
br i1 %102, label %103, label %104
103: ; preds = %100
store i32 6, i32* %13
br label %106
104: ; preds = %100, %92
br label %105
105: ; preds = %104, %87
store i32 0, i32* %13
br label %106
106: ; preds = %105, %103, %86, %80, %70
%107 = load i8*, i8** %9
%108 = load i32, i32* %13
switch i32 %108, label %123 [
i32 0, label %109
i32 5, label %54
i32 6, label %110
]
109: ; preds = %106
br label %54
110: ; preds = %106, %54
%111 = load i32*, i32** %6
%112 = call i32 @closedir(i32* %111)
%113 = load i32, i32* %8
%114 = icmp ne i32 %113, 0
br i1 %114, label %119, label %115
115: ; preds = %110
%116 = load i32, i32* @stderr
%117 = load i8*, i8** %3
%118 = call i32 @fprintf(i32 %116, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8* %117)
br label %119
119: ; preds = %115, %110
%120 = load i32, i32* %8
store i32 %120, i32* %2
br label %121
121: ; preds = %119, %51, %45, %41
%122 = load i32, i32* %2
ret i32 %122
123: ; preds = %106
unreachable
}

LLVM IR (-O2):
%struct.dirent = type { i8* }
@errno = global i64 0
@stderr = global i32 0
@.str = [24 x i8] c"Invalid pid value '%s'\0A\00"
@.str.1 = [6 x i8] c"/proc\00"
@PATH_MAX = global i32 0
@.str.2 = [17 x i8] c"/proc/%s/cmdline\00"
@.str.3 = [26 x i8] c"Cannot find process '%s'\0A\00"
define i32 @proc_name_to_pid(i8* %0) {
%2 = alloca [4096 x i8]
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 0
br i1 %4, label %14, label %8
5: ; preds = %8
%6 = load i8, i8* %13
%7 = icmp eq i8 %6, 0
br i1 %7, label %14, label %8
8: ; preds = %1, %5
%9 = phi i8 [ %6, %5 ], [ %3, %1 ]
%10 = phi i8* [ %13, %5 ], [ %0, %1 ]
%11 = tail call i32 @isdigit(i8 signext %9)
%12 = icmp eq i32 %11, 0
%13 = getelementptr inbounds i8, i8* %10, i64 1
br i1 %12, label %24, label %5
14: ; preds = %5, %1
%15 = tail call i64 @strtol(i8* nocapture %0, i32* null, i32 10)
%16 = trunc i64 %15 to i32
%17 = load i64, i64* @errno
%18 = icmp ne i64 %17, 0
%19 = icmp slt i32 %16, 1
%20 = select i1 %18, i1 true, i1 %19
br i1 %20, label %21, label %78
21: ; preds = %14
%22 = load i32, i32* @stderr
%23 = tail call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %78
24: ; preds = %8
%25 = tail call i32* @opendir(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%26 = icmp eq i32* %25, null
br i1 %26, label %78, label %27
27: ; preds = %24
%28 = call %struct.dirent* @readdir(i32* %25)
%29 = icmp eq %struct.dirent* %28, null
br i1 %29, label %30, label %32
30: ; preds = %27
%31 = call i32 @closedir(i32* %25)
br label %75
32: ; preds = %27
%33 = getelementptr inbounds [4096 x i8], [4096 x i8]* %2, i64 0, i64 0
br label %34
34: ; preds = %32, %68
%35 = phi %struct.dirent* [ %28, %32 ], [ %70, %68 ]
%36 = phi i32 [ 0, %32 ], [ %69, %68 ]
%37 = load i32, i32* @PATH_MAX
%38 = zext i32 %37 to i64
%39 = call i8* @llvm.stacksave()
%40 = alloca i8, i64 %38
%41 = getelementptr inbounds %struct.dirent, %struct.dirent* %35, i64 0, i32 0
%42 = load i8*, i8** %41
%43 = load i8, i8* %42
%44 = call i32 @isdigit(i8 signext %43)
%45 = icmp eq i32 %44, 0
br i1 %45, label %68, label %46
46: ; preds = %34
%47 = load i8*, i8** %41
%48 = call i32 @snprintf(i8* %40, i32 %37, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* %47)
%49 = call i64 @read_buf(i8* %40, i8* %33, i32 4096)
%50 = icmp slt i64 %49, 0
br i1 %50, label %68, label %51
51: ; preds = %46
%52 = call i8* @basename(i8* %33)
%53 = icmp eq i8* %52, null
br i1 %53, label %68, label %54
54: ; preds = %51
%55 = call i32 @strcmp(i8* dereferenceable(1) %0, i8* %52)
%56 = icmp eq i32 %55, 0
br i1 %56, label %57, label %68
57: ; preds = %54
%58 = load i8*, i8** %41
%59 = call i64 @strtol(i8* nocapture %58, i32* null, i32 10)
%60 = trunc i64 %59 to i32
%61 = load i64, i64* @errno
%62 = icmp eq i64 %61, 0
%63 = icmp sgt i32 %60, 0
%64 = select i1 %62, i1 %63, i1 false
br i1 %64, label %65, label %68
65: ; preds = %57
%66 = trunc i64 %59 to i32
%67 = call i32 @closedir(i32* %25)
br label %78
68: ; preds = %54, %57, %51, %46, %34
%69 = phi i32 [ %36, %34 ], [ %36, %46 ], [ %36, %51 ], [ %36, %54 ], [ %60, %57 ]
%70 = call %struct.dirent* @readdir(i32* %25)
%71 = icmp eq %struct.dirent* %70, null
br i1 %71, label %72, label %34
72: ; preds = %68
%73 = call i32 @closedir(i32* %25)
%74 = icmp eq i32 %69, 0
br i1 %74, label %75, label %78
75: ; preds = %30, %72
%76 = load i32, i32* @stderr
%77 = call i32 @fprintf(i32 %76, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8* %0)
br label %78
78: ; preds = %65, %72, %75, %24, %14, %21
%79 = phi i32 [ 0, %21 ], [ %16, %14 ], [ 0, %24 ], [ 0, %75 ], [ %69, %72 ], [ %66, %65 ]
ret i32 %79
}