#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 stat {
  int st_mode;
};

/* Variables and functions */
int /*<<< orphan*/ R_OK;
int S_IFREG;
scalar_t__ access(char const *, int /*<<< orphan*/);
int /*<<< orphan*/ free(char *);
char *malloc(int);
scalar_t__ stat(char const *, struct stat *);
int /*<<< orphan*/ strcat(char *, char const *);
int /*<<< orphan*/ strcattoc_esc(char *, char const *, char);
scalar_t__ strchr(char const *, char);
int /*<<< orphan*/ strcpy(char *, char const *);
char *strdup(char const *);
int strlen(char const *);
char *find_in_path(const char *path, const char *filename) {
  struct stat statbuf;
  const char *home;
  char *buf;
  int buf_size;
  if (filename == NULL)
    return NULL;
  if (path == NULL || strchr(filename, '/')) {
    if (stat(filename, &statbuf) == 0)
      if (statbuf.st_mode & S_IFREG)
        if (access(filename, R_OK) == 0) {
          return strdup(filename);
        }
    return NULL;
  }
  home = (NULL);
  buf_size = strlen(path) + strlen(filename) + 3;
  if (home) {
    buf_size += strlen(home) - 1;
  }
  buf = malloc(buf_size);
  if (buf == NULL)
    return NULL;
  while (*path) {
    *buf = 0;
    if (home && *path == '~' && *(path + 1) == '/') {
      strcpy(buf, home);
      path += 2;
      if (buf[strlen(buf) - 1] != '/')
        strcat(buf, "/");
    }
    strcattoc_esc(buf, path, ':');
    if (*buf == 0)
      strcpy(buf, "./");
    else if (buf[strlen(buf) - 1] != '/')
      strcat(buf, "/");
    strcat(buf, filename);
    if (stat(buf, &statbuf) == 0)
      if (statbuf.st_mode & S_IFREG)
        if (access(buf, R_OK) == 0) {
          return buf;
        }
    while (*path && *path != ':') {
      if (*path == '\\' && *(path + 1) != 0)
        path++;
      path++;
    }
    if (*path == ':')
      path++;
  }
  free(buf);
  return NULL;
}


x86 assembly (clang, -O0):
<find_in_path>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11c8 <find_in_path+0x28>
movq   $0x0,-0x8(%rbp)
jmp    14f0 <find_in_path+0x350>
cmpq   $0x0,-0x10(%rbp)
je     11eb <find_in_path+0x4b>
mov    -0x18(%rbp),%rdi
mov    $0x2f,%esi
call   1060 <strchr@plt>
cmp    $0x0,%rax
je     125c <find_in_path+0xbc>
mov    -0x18(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1070 <stat@plt>
cmp    $0x0,%rax
jne    124f <find_in_path+0xaf>
mov    -0x20(%rbp),%eax
mov    0x2ddc(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     124a <find_in_path+0xaa>
mov    -0x18(%rbp),%rdi
mov    0x2db6(%rip),%rax
mov    (%rax),%esi
call   1090 <access@plt>
cmp    $0x0,%rax
jne    1245 <find_in_path+0xa5>
mov    -0x18(%rbp),%rdi
call   10c0 <strdup@plt>
mov    %rax,-0x8(%rbp)
jmp    14f0 <find_in_path+0x350>
jmp    124a <find_in_path+0xaa>
jmp    124f <find_in_path+0xaf>
movq   $0x0,-0x8(%rbp)
jmp    14f0 <find_in_path+0x350>
movq   $0x0,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x38(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x38(%rbp),%eax
add    %ecx,%eax
add    $0x3,%eax
mov    %eax,-0x34(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     12a3 <find_in_path+0x103>
mov    -0x28(%rbp),%rdi
call   1050 <strlen@plt>
sub    $0x1,%eax
add    -0x34(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%edi
call   1080 <malloc@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    12c7 <find_in_path+0x127>
movq   $0x0,-0x8(%rbp)
jmp    14f0 <find_in_path+0x350>
jmp    12cc <find_in_path+0x12c>
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     14df <find_in_path+0x33f>
mov    -0x30(%rbp),%rax
movb   $0x0,(%rax)
cmpq   $0x0,-0x28(%rbp)
je     1364 <find_in_path+0x1c4>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x7e,%eax
jne    1364 <find_in_path+0x1c4>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x2f,%eax
jne    1364 <find_in_path+0x1c4>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x10(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x10(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x30(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x40(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2f,%eax
je     135f <find_in_path+0x1bf>
mov    -0x30(%rbp),%rdi
lea    0xca7(%rip),%rsi
call   10b0 <strcat@plt>
jmp    1364 <find_in_path+0x1c4>
mov    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x3a,%edx
call   10a0 <strcattoc_esc@plt>
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    139b <find_in_path+0x1fb>
mov    -0x30(%rbp),%rdi
lea    0xc6f(%rip),%rsi
call   1040 <strcpy@plt>
jmp    13da <find_in_path+0x23a>
mov    -0x30(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x30(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x48(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2f,%eax
je     13d5 <find_in_path+0x235>
mov    -0x30(%rbp),%rdi
lea    0xc31(%rip),%rsi
call   10b0 <strcat@plt>
jmp    13da <find_in_path+0x23a>
mov    -0x30(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   10b0 <strcat@plt>
mov    -0x30(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1070 <stat@plt>
cmp    $0x0,%rax
jne    1446 <find_in_path+0x2a6>
mov    -0x20(%rbp),%eax
mov    0x2be0(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1441 <find_in_path+0x2a1>
mov    -0x30(%rbp),%rdi
mov    0x2bba(%rip),%rax
mov    (%rax),%esi
call   1090 <access@plt>
cmp    $0x0,%rax
jne    143c <find_in_path+0x29c>
mov    -0x30(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    14f0 <find_in_path+0x350>
jmp    1441 <find_in_path+0x2a1>
jmp    1446 <find_in_path+0x2a6>
jmp    144b <find_in_path+0x2ab>
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x49(%rbp)
je     1470 <find_in_path+0x2d0>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3a,%eax
setne  %al
mov    %al,-0x49(%rbp)
mov    -0x49(%rbp),%al
test   $0x1,%al
jne    1480 <find_in_path+0x2e0>
jmp    14be <find_in_path+0x31e>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5c,%eax
jne    14ad <find_in_path+0x30d>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x0,%eax
je     14ad <find_in_path+0x30d>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    144b <find_in_path+0x2ab>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3a,%eax
jne    14da <find_in_path+0x33a>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    12cc <find_in_path+0x12c>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_in_path>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %rsi,%rsi
je     1354 <find_in_path+0x1b4>
mov    %rsi,%r14
mov    %rdi,%rbx
test   %rdi,%rdi
je     11d1 <find_in_path+0x31>
mov    %r14,%rdi
mov    $0x2f,%esi
call   1060 <strchr@plt>
test   %rax,%rax
je     1221 <find_in_path+0x81>
mov    %rsp,%rsi
mov    %r14,%rdi
call   1070 <stat@plt>
test   %rax,%rax
jne    1354 <find_in_path+0x1b4>
mov    0x2dfc(%rip),%rax
mov    (%rax),%eax
test   %eax,(%rsp)
je     1354 <find_in_path+0x1b4>
mov    0x2dda(%rip),%rax
mov    (%rax),%esi
mov    %r14,%rdi
call   1090 <access@plt>
test   %rax,%rax
jne    1354 <find_in_path+0x1b4>
mov    %r14,%rdi
call   10c0 <strdup@plt>
mov    %rax,%r15
jmp    1357 <find_in_path+0x1b7>
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %eax,%ebp
mov    %r14,%rdi
call   1050 <strlen@plt>
lea    (%rax,%rbp,1),%edi
add    $0x3,%edi
call   1080 <malloc@plt>
test   %rax,%rax
je     1354 <find_in_path+0x1b4>
mov    %rax,%r15
cmpb   $0x0,(%rbx)
je     134c <find_in_path+0x1ac>
lea    0xda6(%rip),%r12
mov    %rsp,%r13
mov    0x2d84(%rip),%rbp
jmp    1285 <find_in_path+0xe5>
cs nopw 0x0(%rax,%rax,1)
xor    %ecx,%ecx
cmp    $0x3a,%al
sete   %cl
cmpb   $0x0,(%rbx,%rcx,1)
lea    (%rbx,%rcx,1),%rbx
je     134c <find_in_path+0x1ac>
movb   $0x0,(%r15)
mov    %r15,%rdi
mov    %rbx,%rsi
mov    $0x3a,%edx
call   10a0 <strcattoc_esc@plt>
cmpb   $0x0,(%r15)
je     12d0 <find_in_path+0x130>
mov    %r15,%rdi
call   1050 <strlen@plt>
cltq
cmpb   $0x2f,-0x1(%rax,%r15,1)
je     12db <find_in_path+0x13b>
mov    %r15,%rdi
lea    0xd46(%rip),%rsi
call   10b0 <strcat@plt>
jmp    12db <find_in_path+0x13b>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r15,%rdi
mov    %r12,%rsi
call   1040 <strcpy@plt>
mov    %r15,%rdi
mov    %r14,%rsi
call   10b0 <strcat@plt>
mov    %r15,%rdi
mov    %r13,%rsi
call   1070 <stat@plt>
test   %rax,%rax
jne    1324 <find_in_path+0x184>
mov    0x0(%rbp),%eax
test   %eax,(%rsp)
je     1324 <find_in_path+0x184>
mov    0x2cd3(%rip),%rax
mov    (%rax),%esi
mov    %r15,%rdi
call   1090 <access@plt>
test   %rax,%rax
jne    1324 <find_in_path+0x184>
jmp    1357 <find_in_path+0x1b7>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%rbx
movzbl (%rbx),%eax
cmp    $0x5c,%al
je     1340 <find_in_path+0x1a0>
test   %al,%al
je     1270 <find_in_path+0xd0>
cmp    $0x3a,%al
jne    1320 <find_in_path+0x180>
jmp    1270 <find_in_path+0xd0>
nopl   0x0(%rax)
cmpb   $0x0,0x1(%rbx)
je     1320 <find_in_path+0x180>
add    $0x1,%rbx
jmp    1320 <find_in_path+0x180>
mov    %r15,%rdi
call   1030 <free@plt>
xor    %r15d,%r15d
mov    %r15,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.stat = type { i32 }
@S_IFREG = global i32 0
@R_OK = global i32 0
@.str = [2 x i8] c"/\00"
@.str.1 = [3 x i8] c"./\00"
define i8* @find_in_path(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca %struct.stat
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
%10 = load i8*, i8** %5
%11 = icmp eq i8* %10, null
br i1 %11, label %12, label %13
12: ; preds = %2
store i8* null, i8** %3
br label %190
13: ; preds = %2
%14 = load i8*, i8** %4
%15 = icmp eq i8* %14, null
br i1 %15, label %20, label %16
16: ; preds = %13
%17 = load i8*, i8** %5
%18 = call i64 @strchr(i8* %17, i8 signext 47)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %41
20: ; preds = %16, %13
%21 = load i8*, i8** %5
%22 = call i64 @stat(i8* %21, %struct.stat* %6)
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %40
24: ; preds = %20
%25 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 0
%26 = load i32, i32* %25
%27 = load i32, i32* @S_IFREG
%28 = and i32 %26, %27
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %39
30: ; preds = %24
%31 = load i8*, i8** %5
%32 = load i32, i32* @R_OK
%33 = call i64 @access(i8* %31, i32 %32)
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %38
35: ; preds = %30
%36 = load i8*, i8** %5
%37 = call i8* @strdup(i8* %36)
store i8* %37, i8** %3
br label %190
38: ; preds = %30
br label %39
39: ; preds = %38, %24
br label %40
40: ; preds = %39, %20
store i8* null, i8** %3
br label %190
41: ; preds = %16
store i8* null, i8** %7
%42 = load i8*, i8** %4
%43 = call i32 @strlen(i8* %42)
%44 = load i8*, i8** %5
%45 = call i32 @strlen(i8* %44)
%46 = add nsw i32 %43, %45
%47 = add nsw i32 %46, 3
store i32 %47, i32* %9
%48 = load i8*, i8** %7
%49 = icmp ne i8* %48, null
br i1 %49, label %50, label %56
50: ; preds = %41
%51 = load i8*, i8** %7
%52 = call i32 @strlen(i8* %51)
%53 = sub nsw i32 %52, 1
%54 = load i32, i32* %9
%55 = add nsw i32 %54, %53
store i32 %55, i32* %9
br label %56
56: ; preds = %50, %41
%57 = load i32, i32* %9
%58 = call i8* @malloc(i32 %57)
store i8* %58, i8** %8
%59 = load i8*, i8** %8
%60 = icmp eq i8* %59, null
br i1 %60, label %61, label %62
61: ; preds = %56
store i8* null, i8** %3
br label %190
62: ; preds = %56
br label %63
63: ; preds = %186, %62
%64 = load i8*, i8** %4
%65 = load i8, i8* %64
%66 = icmp ne i8 %65, 0
br i1 %66, label %67, label %187
67: ; preds = %63
%68 = load i8*, i8** %8
store i8 0, i8* %68
%69 = load i8*, i8** %7
%70 = icmp ne i8* %69, null
br i1 %70, label %71, label %101
71: ; preds = %67
%72 = load i8*, i8** %4
%73 = load i8, i8* %72
%74 = sext i8 %73 to i32
%75 = icmp eq i32 %74, 126
br i1 %75, label %76, label %101
76: ; preds = %71
%77 = load i8*, i8** %4
%78 = getelementptr inbounds i8, i8* %77, i64 1
%79 = load i8, i8* %78
%80 = sext i8 %79 to i32
%81 = icmp eq i32 %80, 47
br i1 %81, label %82, label %101
82: ; preds = %76
%83 = load i8*, i8** %8
%84 = load i8*, i8** %7
%85 = call i32 @strcpy(i8* %83, i8* %84)
%86 = load i8*, i8** %4
%87 = getelementptr inbounds i8, i8* %86, i64 2
store i8* %87, i8** %4
%88 = load i8*, i8** %8
%89 = load i8*, i8** %8
%90 = call i32 @strlen(i8* %89)
%91 = sub nsw i32 %90, 1
%92 = sext i32 %91 to i64
%93 = getelementptr inbounds i8, i8* %88, i64 %92
%94 = load i8, i8* %93
%95 = sext i8 %94 to i32
%96 = icmp ne i32 %95, 47
br i1 %96, label %97, label %100
97: ; preds = %82
%98 = load i8*, i8** %8
%99 = call i32 @strcat(i8* %98, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %100
100: ; preds = %97, %82
br label %101
101: ; preds = %100, %76, %71, %67
%102 = load i8*, i8** %8
%103 = load i8*, i8** %4
%104 = call i32 @strcattoc_esc(i8* %102, i8* %103, i8 signext 58)
%105 = load i8*, i8** %8
%106 = load i8, i8* %105
%107 = sext i8 %106 to i32
%108 = icmp eq i32 %107, 0
br i1 %108, label %109, label %112
109: ; preds = %101
%110 = load i8*, i8** %8
%111 = call i32 @strcpy(i8* %110, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %126
112: ; preds = %101
%113 = load i8*, i8** %8
%114 = load i8*, i8** %8
%115 = call i32 @strlen(i8* %114)
%116 = sub nsw i32 %115, 1
%117 = sext i32 %116 to i64
%118 = getelementptr inbounds i8, i8* %113, i64 %117
%119 = load i8, i8* %118
%120 = sext i8 %119 to i32
%121 = icmp ne i32 %120, 47
br i1 %121, label %122, label %125
122: ; preds = %112
%123 = load i8*, i8** %8
%124 = call i32 @strcat(i8* %123, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %125
125: ; preds = %122, %112
br label %126
126: ; preds = %125, %109
%127 = load i8*, i8** %8
%128 = load i8*, i8** %5
%129 = call i32 @strcat(i8* %127, i8* %128)
%130 = load i8*, i8** %8
%131 = call i64 @stat(i8* %130, %struct.stat* %6)
%132 = icmp eq i64 %131, 0
br i1 %132, label %133, label %148
133: ; preds = %126
%134 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 0
%135 = load i32, i32* %134
%136 = load i32, i32* @S_IFREG
%137 = and i32 %135, %136
%138 = icmp ne i32 %137, 0
br i1 %138, label %139, label %147
139: ; preds = %133
%140 = load i8*, i8** %8
%141 = load i32, i32* @R_OK
%142 = call i64 @access(i8* %140, i32 %141)
%143 = icmp eq i64 %142, 0
br i1 %143, label %144, label %146
144: ; preds = %139
%145 = load i8*, i8** %8
store i8* %145, i8** %3
br label %190
146: ; preds = %139
br label %147
147: ; preds = %146, %133
br label %148
148: ; preds = %147, %126
br label %149
149: ; preds = %175, %148
%150 = load i8*, i8** %4
%151 = load i8, i8* %150
%152 = sext i8 %151 to i32
%153 = icmp ne i32 %152, 0
br i1 %153, label %154, label %159
154: ; preds = %149
%155 = load i8*, i8** %4
%156 = load i8, i8* %155
%157 = sext i8 %156 to i32
%158 = icmp ne i32 %157, 58
br label %159
159: ; preds = %154, %149
%160 = phi i1 [ false, %149 ], [ %158, %154 ]
br i1 %160, label %161, label %178
161: ; preds = %159
%162 = load i8*, i8** %4
%163 = load i8, i8* %162
%164 = sext i8 %163 to i32
%165 = icmp eq i32 %164, 92
br i1 %165, label %166, label %175
166: ; preds = %161
%167 = load i8*, i8** %4
%168 = getelementptr inbounds i8, i8* %167, i64 1
%169 = load i8, i8* %168
%170 = sext i8 %169 to i32
%171 = icmp ne i32 %170, 0
br i1 %171, label %172, label %175
172: ; preds = %166
%173 = load i8*, i8** %4
%174 = getelementptr inbounds i8, i8* %173, i32 1
store i8* %174, i8** %4
br label %175
175: ; preds = %172, %166, %161
%176 = load i8*, i8** %4
%177 = getelementptr inbounds i8, i8* %176, i32 1
store i8* %177, i8** %4
br label %149
178: ; preds = %159
%179 = load i8*, i8** %4
%180 = load i8, i8* %179
%181 = sext i8 %180 to i32
%182 = icmp eq i32 %181, 58
br i1 %182, label %183, label %186
183: ; preds = %178
%184 = load i8*, i8** %4
%185 = getelementptr inbounds i8, i8* %184, i32 1
store i8* %185, i8** %4
br label %186
186: ; preds = %183, %178
br label %63
187: ; preds = %63
%188 = load i8*, i8** %8
%189 = call i32 @free(i8* %188)
store i8* null, i8** %3
br label %190
190: ; preds = %187, %144, %61, %40, %35, %12
%191 = load i8*, i8** %3
ret i8* %191
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@S_IFREG = global i32 0
@R_OK = global i32 0
@.str = [2 x i8] c"/\00"
@.str.1 = [3 x i8] c"./\00"
define i8* @find_in_path(i8* %0, i8* %1) {
%3 = alloca %struct.stat
%4 = bitcast %struct.stat* %3 to i8*
%5 = icmp eq i8* %1, null
br i1 %5, label %87, label %6
6: ; preds = %2
%7 = icmp eq i8* %0, null
br i1 %7, label %11, label %8
8: ; preds = %6
%9 = tail call i64 @strchr(i8* %1, i8 signext 47)
%10 = icmp eq i64 %9, 0
br i1 %10, label %26, label %11
11: ; preds = %8, %6
%12 = call i64 @stat(i8* %1, %struct.stat* %3)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %87
14: ; preds = %11
%15 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%16 = load i32, i32* %15
%17 = load i32, i32* @S_IFREG
%18 = and i32 %17, %16
%19 = icmp eq i32 %18, 0
br i1 %19, label %87, label %20
20: ; preds = %14
%21 = load i32, i32* @R_OK
%22 = call i64 @access(i8* %1, i32 %21)
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %87
24: ; preds = %20
%25 = call i8* @strdup(i8* %1)
br label %87
26: ; preds = %8
%27 = tail call i32 @strlen(i8* %0)
%28 = tail call i32 @strlen(i8* %1)
%29 = add i32 %27, 3
%30 = add i32 %29, %28
%31 = tail call i8* @malloc(i32 %30)
%32 = icmp eq i8* %31, null
br i1 %32, label %87, label %33
33: ; preds = %26
%34 = load i8, i8* %0
%35 = icmp eq i8 %34, 0
br i1 %35, label %85, label %36
36: ; preds = %33
%37 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
br label %38
38: ; preds = %36, %79
%39 = phi i8* [ %0, %36 ], [ %82, %79 ]
store i8 0, i8* %31
%40 = call i32 @strcattoc_esc(i8* %31, i8* %39, i8 signext 58)
%41 = load i8, i8* %31
%42 = icmp eq i8 %41, 0
br i1 %42, label %43, label %45
43: ; preds = %38
%44 = call i32 @strcpy(i8* %31, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %54
45: ; preds = %38
%46 = call i32 @strlen(i8* %31)
%47 = add nsw i32 %46, -1
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i8, i8* %31, i64 %48
%50 = load i8, i8* %49
%51 = icmp eq i8 %50, 47
br i1 %51, label %54, label %52
52: ; preds = %45
%53 = call i32 @strcat(i8* %31, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %54
54: ; preds = %45, %52, %43
%55 = call i32 @strcat(i8* %31, i8* %1)
%56 = call i64 @stat(i8* %31, %struct.stat* %3)
%57 = icmp eq i64 %56, 0
br i1 %57, label %58, label %67
58: ; preds = %54
%59 = load i32, i32* %37
%60 = load i32, i32* @S_IFREG
%61 = and i32 %60, %59
%62 = icmp eq i32 %61, 0
br i1 %62, label %67, label %63
63: ; preds = %58
%64 = load i32, i32* @R_OK
%65 = call i64 @access(i8* %31, i32 %64)
%66 = icmp eq i64 %65, 0
br i1 %66, label %87, label %67
67: ; preds = %58, %63, %54
br label %68
68: ; preds = %67, %76
%69 = phi i8* [ %78, %76 ], [ %39, %67 ]
%70 = load i8, i8* %69
switch i8 %70, label %76 [
i8 0, label %79
i8 58, label %79
i8 92, label %71
]
71: ; preds = %68
%72 = getelementptr inbounds i8, i8* %69, i64 1
%73 = load i8, i8* %72
%74 = icmp eq i8 %73, 0
%75 = select i1 %74, i8* %69, i8* %72
br label %76
76: ; preds = %71, %68
%77 = phi i8* [ %69, %68 ], [ %75, %71 ]
%78 = getelementptr inbounds i8, i8* %77, i64 1
br label %68
79: ; preds = %68, %68
%80 = icmp eq i8 %70, 58
%81 = zext i1 %80 to i64
%82 = getelementptr i8, i8* %69, i64 %81
%83 = load i8, i8* %82
%84 = icmp eq i8 %83, 0
br i1 %84, label %85, label %38
85: ; preds = %79, %33
%86 = call i32 @free(i8* %31)
br label %87
87: ; preds = %63, %26, %11, %20, %14, %2, %85, %24
%88 = phi i8* [ %25, %24 ], [ null, %85 ], [ null, %2 ], [ null, %14 ], [ null, %20 ], [ null, %11 ], [ null, %26 ], [ %31, %63 ]
ret i8* %88
}