#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 */

/* Variables and functions */
int /*<<< orphan*/ ENOENT;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int, char *, int, ...);
int /*<<< orphan*/ free(char *);
char *getenv(char *);
int getpid();
scalar_t__ isfile(char const *);
scalar_t__ malloc(size_t);
int /*<<< orphan*/ stderr;
char *strdup(char const *);
char *strerror(int /*<<< orphan*/);
int strlen(char const *);
int /*<<< orphan*/ strncat(char *, char const *, size_t);
int /*<<< orphan*/ strncpy(char *, char *, size_t);
char *strtok(char *, char *);
char *pathfind(const char *fn) {
  if (fn == NULL || *fn == '\0') {
    errno = ENOENT;
    return NULL;
  }
  if (fn[0] == '/') {
    if (isfile(fn)) {
      char *exe = strdup(fn);
      if (exe == NULL) {
        fprintf(stderr,
                "kickstart[%d]: %s[%d]: "
                "strdup: %s\n",
                getpid(),
                "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                "outputs/2022-01-22/02-19-57/repos/pegasus-isi/pegasus/refs/"
                "heads/master/src/tools/pegasus-kickstart/jobinfo.c",
                109, strerror(errno));
        return NULL;
      }
      return exe;
    } else {
      return NULL;
    }
  }
  if (isfile(fn)) {
    char *exe = strdup(fn);
    if (exe == NULL) {
      fprintf(stderr,
              "kickstart[%d]: %s[%d]: "
              "strdup: %s\n",
              getpid(),
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/pegasus-isi/pegasus/refs/heads/master/"
              "src/tools/pegasus-kickstart/jobinfo.c",
              122, strerror(errno));
      return NULL;
    }
    return exe;
  }
  char *s = getenv("PATH");
  if (s == NULL) {
    fprintf(stderr,
            "kickstart[%d]: %s[%d]: "
            "PATH not set\n",
            getpid(),
            "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
            "2022-01-22/02-19-57/repos/pegasus-isi/pegasus/refs/heads/master/"
            "src/tools/pegasus-kickstart/jobinfo.c",
            131);
    return NULL;
  }
  char *path = strdup(s);
  if (path == NULL) {
    fprintf(stderr,
            "kickstart[%d]: %s[%d]: "
            "strdup: %s\n",
            getpid(),
            "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
            "2022-01-22/02-19-57/repos/pegasus-isi/pegasus/refs/heads/master/"
            "src/tools/pegasus-kickstart/jobinfo.c",
            137, strerror(errno));
    return NULL;
  }
  char *t = NULL;
  for (s = strtok(path, ":"); s; s = strtok(NULL, ":")) {
    size_t len = strlen(fn) + strlen(s) + 2;
    t = (char *)malloc(len);
    if (t == NULL) {
      fprintf(stderr,
              "kickstart[%d]: %s[%d]: "
              "malloc: %s\n",
              getpid(),
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/pegasus-isi/pegasus/refs/heads/master/"
              "src/tools/pegasus-kickstart/jobinfo.c",
              148, strerror(errno));
      return NULL;
    }
    strncpy(t, s, len);
    strncat(t, "/", len);
    strncat(t, fn, len);
    if (isfile(t)) {
      break;
    } else {
      free(t);
      t = NULL;
    }
  }
  free(path);
  return t;
}


x86 assembly (clang, -O0):
<pathfind>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11e7 <pathfind+0x27>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1206 <pathfind+0x46>
mov    0x2dda(%rip),%rax
mov    (%rax),%ecx
mov    0x2de1(%rip),%rax
mov    %ecx,(%rax)
movq   $0x0,-0x8(%rbp)
jmp    154c <pathfind+0x38c>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
jne    12b0 <pathfind+0xf0>
mov    -0x10(%rbp),%rdi
call   10b0 <isfile@plt>
cmp    $0x0,%rax
je     12a3 <pathfind+0xe3>
mov    -0x10(%rbp),%rdi
call   10d0 <strdup@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1296 <pathfind+0xd6>
mov    0x2d98(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x48(%rbp)
mov    $0x0,%al
call   1060 <getpid@plt>
mov    %eax,-0x44(%rbp)
mov    0x2d7a(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
mov    -0x48(%rbp),%edi
mov    -0x44(%rbp),%edx
mov    %rax,%r9
lea    0xd8b(%rip),%rsi
lea    0xda7(%rip),%rcx
mov    $0x6d,%r8d
mov    $0x0,%al
call   1090 <fprintf@plt>
movq   $0x0,-0x8(%rbp)
jmp    154c <pathfind+0x38c>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    154c <pathfind+0x38c>
movq   $0x0,-0x8(%rbp)
jmp    154c <pathfind+0x38c>
mov    -0x10(%rbp),%rdi
call   10b0 <isfile@plt>
cmp    $0x0,%rax
je     133d <pathfind+0x17d>
mov    -0x10(%rbp),%rdi
call   10d0 <strdup@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1330 <pathfind+0x170>
mov    0x2cfe(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x50(%rbp)
mov    $0x0,%al
call   1060 <getpid@plt>
mov    %eax,-0x4c(%rbp)
mov    0x2ce0(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
mov    -0x50(%rbp),%edi
mov    -0x4c(%rbp),%edx
mov    %rax,%r9
lea    0xcf1(%rip),%rsi
lea    0xd0d(%rip),%rcx
mov    $0x7a,%r8d
mov    $0x0,%al
call   1090 <fprintf@plt>
movq   $0x0,-0x8(%rbp)
jmp    154c <pathfind+0x38c>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    154c <pathfind+0x38c>
lea    0xd85(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1398 <pathfind+0x1d8>
mov    0x2c81(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x54(%rbp)
mov    $0x0,%al
call   1060 <getpid@plt>
mov    -0x54(%rbp),%edi
mov    %eax,%edx
lea    0xd57(%rip),%rsi
lea    0xca5(%rip),%rcx
mov    $0x83,%r8d
mov    $0x0,%al
call   1090 <fprintf@plt>
movq   $0x0,-0x8(%rbp)
jmp    154c <pathfind+0x38c>
mov    -0x28(%rbp),%rdi
call   10d0 <strdup@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1405 <pathfind+0x245>
mov    0x2c29(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x5c(%rbp)
mov    $0x0,%al
call   1060 <getpid@plt>
mov    %eax,-0x58(%rbp)
mov    0x2c0b(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
mov    -0x5c(%rbp),%edi
mov    -0x58(%rbp),%edx
mov    %rax,%r9
lea    0xc1c(%rip),%rsi
lea    0xc38(%rip),%rcx
mov    $0x89,%r8d
mov    $0x0,%al
call   1090 <fprintf@plt>
movq   $0x0,-0x8(%rbp)
jmp    154c <pathfind+0x38c>
movq   $0x0,-0x38(%rbp)
mov    -0x30(%rbp),%rdi
lea    0xcdb(%rip),%rsi
call   10c0 <strtok@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     153b <pathfind+0x37b>
mov    -0x10(%rbp),%rdi
call   1070 <strlen@plt>
mov    %eax,-0x60(%rbp)
mov    -0x28(%rbp),%rdi
call   1070 <strlen@plt>
mov    %eax,%ecx
mov    -0x60(%rbp),%eax
add    %ecx,%eax
add    $0x2,%eax
cltq
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rdi
call   10a0 <malloc@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    14be <pathfind+0x2fe>
mov    0x2b70(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x68(%rbp)
mov    $0x0,%al
call   1060 <getpid@plt>
mov    %eax,-0x64(%rbp)
mov    0x2b52(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
mov    -0x68(%rbp),%edi
mov    -0x64(%rbp),%edx
mov    %rax,%r9
lea    0xc58(%rip),%rsi
lea    0xb7f(%rip),%rcx
mov    $0x94,%r8d
mov    $0x0,%al
call   1090 <fprintf@plt>
movq   $0x0,-0x8(%rbp)
jmp    154c <pathfind+0x38c>
mov    -0x38(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x40(%rbp),%rdx
call   1050 <strncpy@plt>
mov    -0x38(%rbp),%rdi
mov    -0x40(%rbp),%rdx
lea    0xc3a(%rip),%rsi
call   1080 <strncat@plt>
mov    -0x38(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x40(%rbp),%rdx
call   1080 <strncat@plt>
mov    -0x38(%rbp),%rdi
call   10b0 <isfile@plt>
cmp    $0x0,%rax
je     150c <pathfind+0x34c>
jmp    153b <pathfind+0x37b>
mov    -0x38(%rbp),%rdi
call   1040 <free@plt>
movq   $0x0,-0x38(%rbp)
jmp    1522 <pathfind+0x362>
xor    %eax,%eax
mov    %eax,%edi
lea    0xbc6(%rip),%rsi
call   10c0 <strtok@plt>
mov    %rax,-0x28(%rbp)
jmp    1421 <pathfind+0x261>
mov    -0x30(%rbp),%rdi
call   1040 <free@plt>
mov    -0x38(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pathfind>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %rdi,%rdi
je     11e1 <pathfind+0x21>
mov    %rdi,%rbx
mov    (%rdi),%al
cmp    $0x2f,%al
je     1208 <pathfind+0x48>
test   %al,%al
jne    1265 <pathfind+0xa5>
mov    0x2de0(%rip),%rax
mov    (%rax),%eax
mov    0x2de7(%rip),%rcx
mov    %eax,(%rcx)
xor    %r13d,%r13d
mov    %r13,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rbx,%rdi
call   10b0 <isfile@plt>
test   %rax,%rax
je     11f3 <pathfind+0x33>
mov    %rbx,%rdi
call   10d0 <strdup@plt>
mov    %rax,%r13
test   %rax,%rax
jne    11f6 <pathfind+0x36>
mov    0x2db4(%rip),%rax
mov    (%rax),%ebx
xor    %r13d,%r13d
xor    %eax,%eax
call   1060 <getpid@plt>
mov    %eax,%ebp
mov    0x2d97(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
lea    0xdb1(%rip),%rsi
lea    0xdcd(%rip),%rcx
mov    %ebx,%edi
mov    %ebp,%edx
mov    $0x6d,%r8d
jmp    145a <pathfind+0x29a>
mov    %rbx,%rdi
call   10b0 <isfile@plt>
test   %rax,%rax
je     12c6 <pathfind+0x106>
mov    %rbx,%rdi
call   10d0 <strdup@plt>
mov    %rax,%r13
test   %rax,%rax
jne    11f6 <pathfind+0x36>
mov    0x2d53(%rip),%rax
mov    (%rax),%ebx
xor    %r13d,%r13d
xor    %eax,%eax
call   1060 <getpid@plt>
mov    %eax,%ebp
mov    0x2d36(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
lea    0xd50(%rip),%rsi
lea    0xd6c(%rip),%rcx
mov    %ebx,%edi
mov    %ebp,%edx
mov    $0x7a,%r8d
jmp    145a <pathfind+0x29a>
lea    0xdfc(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     13a6 <pathfind+0x1e6>
mov    %rax,%rdi
call   10d0 <strdup@plt>
test   %rax,%rax
je     13dd <pathfind+0x21d>
mov    %rax,%r15
lea    0xdfd(%rip),%rsi
mov    %rax,%rdi
call   10c0 <strtok@plt>
test   %rax,%rax
je     141a <pathfind+0x25a>
mov    %rax,%rbp
xor    %r13d,%r13d
nopl   (%rax)
mov    %rbx,%rdi
call   1070 <strlen@plt>
mov    %eax,%r14d
mov    %rbp,%rdi
call   1070 <strlen@plt>
add    %r14d,%eax
add    $0x2,%eax
movslq %eax,%r12
mov    %r12,%rdi
call   10a0 <malloc@plt>
test   %rax,%rax
je     141f <pathfind+0x25f>
mov    %rax,%r14
mov    %rax,%rdi
mov    %rbp,%rsi
mov    %r12,%rdx
call   1050 <strncpy@plt>
mov    %r14,%rdi
lea    0xdc0(%rip),%rsi
mov    %r12,%rdx
call   1080 <strncat@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %r12,%rdx
call   1080 <strncat@plt>
mov    %r14,%rdi
call   10b0 <isfile@plt>
test   %rax,%rax
jne    1469 <pathfind+0x2a9>
mov    %r14,%rdi
call   1040 <free@plt>
xor    %edi,%edi
lea    0xd63(%rip),%rsi
call   10c0 <strtok@plt>
mov    %rax,%rbp
test   %rax,%rax
jne    1310 <pathfind+0x150>
jmp    146c <pathfind+0x2ac>
mov    0x2c33(%rip),%rax
mov    (%rax),%ebx
xor    %r13d,%r13d
xor    %eax,%eax
call   1060 <getpid@plt>
lea    0xd0e(%rip),%rsi
lea    0xc5c(%rip),%rcx
mov    %ebx,%edi
mov    %eax,%edx
mov    $0x83,%r8d
xor    %eax,%eax
call   1090 <fprintf@plt>
jmp    11f6 <pathfind+0x36>
mov    0x2bfc(%rip),%rax
mov    (%rax),%ebx
xor    %r13d,%r13d
xor    %eax,%eax
call   1060 <getpid@plt>
mov    %eax,%ebp
mov    0x2bdf(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
lea    0xbf9(%rip),%rsi
lea    0xc15(%rip),%rcx
mov    %ebx,%edi
mov    %ebp,%edx
mov    $0x89,%r8d
jmp    145a <pathfind+0x29a>
xor    %r13d,%r13d
jmp    146c <pathfind+0x2ac>
mov    0x2bba(%rip),%rax
mov    (%rax),%ebx
xor    %r13d,%r13d
xor    %eax,%eax
call   1060 <getpid@plt>
mov    %eax,%ebp
mov    0x2b9d(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
lea    0xcac(%rip),%rsi
lea    0xbd3(%rip),%rcx
mov    %ebx,%edi
mov    %ebp,%edx
mov    $0x94,%r8d
mov    %rax,%r9
xor    %eax,%eax
call   1090 <fprintf@plt>
jmp    11f6 <pathfind+0x36>
mov    %r14,%r13
mov    %r15,%rdi
call   1040 <free@plt>
jmp    11f6 <pathfind+0x36>

LLVM IR (-O0):
@ENOENT = global i32 0
@errno = global i32 0
@stderr = global i32 0
@.str = [35 x i8] c"kickstart[%d]: %s[%d]: strdup: %s\0A\00"
@.str.1 = [166 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/pegasus-isi/pegasus/refs/heads/master/src/tools/pegasus-kickstart/jobinfo.c\00"
@.str.2 = [5 x i8] c"PATH\00"
@.str.3 = [37 x i8] c"kickstart[%d]: %s[%d]: PATH not set\0A\00"
@.str.4 = [2 x i8] c":\00"
@.str.5 = [35 x i8] c"kickstart[%d]: %s[%d]: malloc: %s\0A\00"
@.str.6 = [2 x i8] c"/\00"
define i8* @pathfind(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i64
store i8* %0, i8** %3
%10 = load i8*, i8** %3
%11 = icmp eq i8* %10, null
br i1 %11, label %17, label %12
12: ; preds = %1
%13 = load i8*, i8** %3
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %12, %1
%18 = load i32, i32* @ENOENT
store i32 %18, i32* @errno
store i8* null, i8** %2
br label %130
19: ; preds = %12
%20 = load i8*, i8** %3
%21 = getelementptr inbounds i8, i8* %20, i64 0
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %23, 47
br i1 %24, label %25, label %43
25: ; preds = %19
%26 = load i8*, i8** %3
%27 = call i64 @isfile(i8* %26)
%28 = icmp ne i64 %27, 0
br i1 %28, label %29, label %42
29: ; preds = %25
%30 = load i8*, i8** %3
%31 = call i8* @strdup(i8* %30)
store i8* %31, i8** %4
%32 = load i8*, i8** %4
%33 = icmp eq i8* %32, null
br i1 %33, label %34, label %40
34: ; preds = %29
%35 = load i32, i32* @stderr
%36 = call i32 (...) @getpid()
%37 = load i32, i32* @errno
%38 = call i8* @strerror(i32 %37)
%39 = call i32 (i32, i8*, i32, i8*, i32, ...) @fprintf(i32 %35, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 %36, i8* getelementptr inbounds ([166 x i8], [166 x i8]* @.str.1, i64 0, i64 0), i32 109, i8* %38)
store i8* null, i8** %2
br label %130
40: ; preds = %29
%41 = load i8*, i8** %4
store i8* %41, i8** %2
br label %130
42: ; preds = %25
store i8* null, i8** %2
br label %130
43: ; preds = %19
%44 = load i8*, i8** %3
%45 = call i64 @isfile(i8* %44)
%46 = icmp ne i64 %45, 0
br i1 %46, label %47, label %60
47: ; preds = %43
%48 = load i8*, i8** %3
%49 = call i8* @strdup(i8* %48)
store i8* %49, i8** %5
%50 = load i8*, i8** %5
%51 = icmp eq i8* %50, null
br i1 %51, label %52, label %58
52: ; preds = %47
%53 = load i32, i32* @stderr
%54 = call i32 (...) @getpid()
%55 = load i32, i32* @errno
%56 = call i8* @strerror(i32 %55)
%57 = call i32 (i32, i8*, i32, i8*, i32, ...) @fprintf(i32 %53, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 %54, i8* getelementptr inbounds ([166 x i8], [166 x i8]* @.str.1, i64 0, i64 0), i32 122, i8* %56)
store i8* null, i8** %2
br label %130
58: ; preds = %47
%59 = load i8*, i8** %5
store i8* %59, i8** %2
br label %130
60: ; preds = %43
%61 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
store i8* %61, i8** %6
%62 = load i8*, i8** %6
%63 = icmp eq i8* %62, null
br i1 %63, label %64, label %68
64: ; preds = %60
%65 = load i32, i32* @stderr
%66 = call i32 (...) @getpid()
%67 = call i32 (i32, i8*, i32, i8*, i32, ...) @fprintf(i32 %65, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i32 %66, i8* getelementptr inbounds ([166 x i8], [166 x i8]* @.str.1, i64 0, i64 0), i32 131)
store i8* null, i8** %2
br label %130
68: ; preds = %60
%69 = load i8*, i8** %6
%70 = call i8* @strdup(i8* %69)
store i8* %70, i8** %7
%71 = load i8*, i8** %7
%72 = icmp eq i8* %71, null
br i1 %72, label %73, label %79
73: ; preds = %68
%74 = load i32, i32* @stderr
%75 = call i32 (...) @getpid()
%76 = load i32, i32* @errno
%77 = call i8* @strerror(i32 %76)
%78 = call i32 (i32, i8*, i32, i8*, i32, ...) @fprintf(i32 %74, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 %75, i8* getelementptr inbounds ([166 x i8], [166 x i8]* @.str.1, i64 0, i64 0), i32 137, i8* %77)
store i8* null, i8** %2
br label %130
79: ; preds = %68
store i8* null, i8** %8
%80 = load i8*, i8** %7
%81 = call i8* @strtok(i8* %80, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i8* %81, i8** %6
br label %82
82: ; preds = %124, %79
%83 = load i8*, i8** %6
%84 = icmp ne i8* %83, null
br i1 %84, label %85, label %126
85: ; preds = %82
%86 = load i8*, i8** %3
%87 = call i32 @strlen(i8* %86)
%88 = load i8*, i8** %6
%89 = call i32 @strlen(i8* %88)
%90 = add nsw i32 %87, %89
%91 = add nsw i32 %90, 2
%92 = sext i32 %91 to i64
store i64 %92, i64* %9
%93 = load i64, i64* %9
%94 = call i64 @malloc(i64 %93)
%95 = inttoptr i64 %94 to i8*
store i8* %95, i8** %8
%96 = load i8*, i8** %8
%97 = icmp eq i8* %96, null
br i1 %97, label %98, label %104
98: ; preds = %85
%99 = load i32, i32* @stderr
%100 = call i32 (...) @getpid()
%101 = load i32, i32* @errno
%102 = call i8* @strerror(i32 %101)
%103 = call i32 (i32, i8*, i32, i8*, i32, ...) @fprintf(i32 %99, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.5, i64 0, i64 0), i32 %100, i8* getelementptr inbounds ([166 x i8], [166 x i8]* @.str.1, i64 0, i64 0), i32 148, i8* %102)
store i8* null, i8** %2
br label %130
104: ; preds = %85
%105 = load i8*, i8** %8
%106 = load i8*, i8** %6
%107 = load i64, i64* %9
%108 = call i32 @strncpy(i8* %105, i8* %106, i64 %107)
%109 = load i8*, i8** %8
%110 = load i64, i64* %9
%111 = call i32 @strncat(i8* %109, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), i64 %110)
%112 = load i8*, i8** %8
%113 = load i8*, i8** %3
%114 = load i64, i64* %9
%115 = call i32 @strncat(i8* %112, i8* %113, i64 %114)
%116 = load i8*, i8** %8
%117 = call i64 @isfile(i8* %116)
%118 = icmp ne i64 %117, 0
br i1 %118, label %119, label %120
119: ; preds = %104
br label %126
120: ; preds = %104
%121 = load i8*, i8** %8
%122 = call i32 @free(i8* %121)
store i8* null, i8** %8
br label %123
123: ; preds = %120
br label %124
124: ; preds = %123
%125 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i8* %125, i8** %6
br label %82
126: ; preds = %119, %82
%127 = load i8*, i8** %7
%128 = call i32 @free(i8* %127)
%129 = load i8*, i8** %8
store i8* %129, i8** %2
br label %130
130: ; preds = %126, %98, %73, %64, %58, %52, %42, %40, %34, %17
%131 = load i8*, i8** %2
ret i8* %131
}

LLVM IR (-O2):
@ENOENT = global i32 0
@errno = global i32 0
@stderr = global i32 0
@.str = [35 x i8] c"kickstart[%d]: %s[%d]: strdup: %s\0A\00"
@.str.1 = [166 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/pegasus-isi/pegasus/refs/heads/master/src/tools/pegasus-kickstart/jobinfo.c\00"
@.str.2 = [5 x i8] c"PATH\00"
@.str.3 = [37 x i8] c"kickstart[%d]: %s[%d]: PATH not set\0A\00"
@.str.4 = [2 x i8] c":\00"
@.str.5 = [35 x i8] c"kickstart[%d]: %s[%d]: malloc: %s\0A\00"
@.str.6 = [2 x i8] c"/\00"
define i8* @pathfind(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %5, label %3
3: ; preds = %1
%4 = load i8, i8* %0
switch i8 %4, label %19 [
i8 0, label %5
i8 47, label %7
]
5: ; preds = %3, %1
%6 = load i32, i32* @ENOENT
store i32 %6, i32* @errno
br label %81
7: ; preds = %3
%8 = tail call i64 @isfile(i8* %0)
%9 = icmp eq i64 %8, 0
br i1 %9, label %81, label %10
10: ; preds = %7
%11 = tail call i8* @strdup(i8* %0)
%12 = icmp eq i8* %11, null
br i1 %12, label %13, label %81
13: ; preds = %10
%14 = load i32, i32* @stderr
%15 = tail call i32 (...) @getpid()
%16 = load i32, i32* @errno
%17 = tail call i8* @strerror(i32 %16)
%18 = tail call i32 (i32, i8*, i32, i8*, i32, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 %15, i8* getelementptr inbounds ([166 x i8], [166 x i8]* @.str.1, i64 0, i64 0), i32 109, i8* %17)
br label %81
19: ; preds = %3
%20 = tail call i64 @isfile(i8* %0)
%21 = icmp eq i64 %20, 0
br i1 %21, label %31, label %22
22: ; preds = %19
%23 = tail call i8* @strdup(i8* %0)
%24 = icmp eq i8* %23, null
br i1 %24, label %25, label %81
25: ; preds = %22
%26 = load i32, i32* @stderr
%27 = tail call i32 (...) @getpid()
%28 = load i32, i32* @errno
%29 = tail call i8* @strerror(i32 %28)
%30 = tail call i32 (i32, i8*, i32, i8*, i32, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 %27, i8* getelementptr inbounds ([166 x i8], [166 x i8]* @.str.1, i64 0, i64 0), i32 122, i8* %29)
br label %81
31: ; preds = %19
%32 = tail call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%33 = icmp eq i8* %32, null
br i1 %33, label %34, label %38
34: ; preds = %31
%35 = load i32, i32* @stderr
%36 = tail call i32 (...) @getpid()
%37 = tail call i32 (i32, i8*, i32, i8*, i32, ...) @fprintf(i32 %35, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i32 %36, i8* getelementptr inbounds ([166 x i8], [166 x i8]* @.str.1, i64 0, i64 0), i32 131)
br label %81
38: ; preds = %31
%39 = tail call i8* @strdup(i8* %32)
%40 = icmp eq i8* %39, null
br i1 %40, label %41, label %47
41: ; preds = %38
%42 = load i32, i32* @stderr
%43 = tail call i32 (...) @getpid()
%44 = load i32, i32* @errno
%45 = tail call i8* @strerror(i32 %44)
%46 = tail call i32 (i32, i8*, i32, i8*, i32, ...) @fprintf(i32 %42, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 %43, i8* getelementptr inbounds ([166 x i8], [166 x i8]* @.str.1, i64 0, i64 0), i32 137, i8* %45)
br label %81
47: ; preds = %38
%48 = tail call i8* @strtok(i8* %39, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%49 = icmp eq i8* %48, null
br i1 %49, label %78, label %50
50: ; preds = %47, %72
%51 = phi i8* [ %74, %72 ], [ %48, %47 ]
%52 = tail call i32 @strlen(i8* %0)
%53 = tail call i32 @strlen(i8* %51)
%54 = add i32 %52, 2
%55 = add i32 %54, %53
%56 = sext i32 %55 to i64
%57 = tail call i64 @malloc(i64 %56)
%58 = inttoptr i64 %57 to i8*
%59 = icmp eq i64 %57, 0
br i1 %59, label %60, label %66
60: ; preds = %50
%61 = load i32, i32* @stderr
%62 = tail call i32 (...) @getpid()
%63 = load i32, i32* @errno
%64 = tail call i8* @strerror(i32 %63)
%65 = tail call i32 (i32, i8*, i32, i8*, i32, ...) @fprintf(i32 %61, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.5, i64 0, i64 0), i32 %62, i8* getelementptr inbounds ([166 x i8], [166 x i8]* @.str.1, i64 0, i64 0), i32 148, i8* %64)
br label %81
66: ; preds = %50
%67 = tail call i32 @strncpy(i8* %58, i8* %51, i64 %56)
%68 = tail call i32 @strncat(i8* %58, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), i64 %56)
%69 = tail call i32 @strncat(i8* %58, i8* %0, i64 %56)
%70 = tail call i64 @isfile(i8* %58)
%71 = icmp eq i64 %70, 0
br i1 %71, label %72, label %76
72: ; preds = %66
%73 = tail call i32 @free(i8* %58)
%74 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%75 = icmp eq i8* %74, null
br i1 %75, label %78, label %50
76: ; preds = %66
%77 = inttoptr i64 %57 to i8*
br label %78
78: ; preds = %72, %76, %47
%79 = phi i8* [ null, %47 ], [ %77, %76 ], [ null, %72 ]
%80 = tail call i32 @free(i8* %39)
br label %81
81: ; preds = %60, %34, %78, %41, %25, %22, %7, %13, %10, %5
%82 = phi i8* [ null, %5 ], [ null, %13 ], [ %11, %10 ], [ null, %7 ], [ null, %25 ], [ %23, %22 ], [ null, %34 ], [ null, %41 ], [ %79, %78 ], [ null, %60 ]
ret i8* %82
}