#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*/ clean_line(char *);
scalar_t__ wfile_eitherslash(char);
int /*<<< orphan*/ wfile_fullname(char *, char *, char *);
int wfile_status(char *);
int wfile_find_in_path(char *dest, char *src, char *path) {
  static char dir[512];
  int i, j;
  if (wfile_eitherslash(src[0]) || src[1] == ':')
    return (wfile_status(src) == 1 ? -1 : 0);
  for (i = 0; 1; i++) {
    for (j = 0; path[i] != '\0' && path[i] != ':' && path[i] != ';'; i++) {
      dir[j++] = path[i];
      if (j == 1 && path[i + 1] == ':') {
        i++;
        dir[j++] = path[i];
        continue;
      }
    }
    dir[j] = '\0';
    clean_line(dir);
    wfile_fullname(dest, dir, src);
    if (wfile_status(dest) == 1)
      return (-1);
    if (path[i] == '\0')
      break;
  }
  return (0);
}


x86 assembly (clang, -O0):
<wfile_find_in_path>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1030 <wfile_eitherslash@plt>
cmp    $0x0,%rax
jne    117b <wfile_find_in_path+0x3b>
mov    -0x18(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x3a,%eax
jne    119b <wfile_find_in_path+0x5b>
mov    -0x18(%rbp),%rdi
call   1040 <wfile_status@plt>
mov    %eax,%edx
xor    %eax,%eax
mov    $0xffffffff,%ecx
cmp    $0x1,%edx
cmove  %ecx,%eax
mov    %eax,-0x4(%rbp)
jmp    131d <wfile_find_in_path+0x1dd>
movl   $0x0,-0x24(%rbp)
mov    $0x1,%al
test   $0x1,%al
jne    11b1 <wfile_find_in_path+0x71>
jmp    1316 <wfile_find_in_path+0x1d6>
movl   $0x0,-0x28(%rbp)
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x29(%rbp)
je     1201 <wfile_find_in_path+0xc1>
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
xor    %eax,%eax
cmp    $0x3a,%ecx
mov    %al,-0x29(%rbp)
je     1201 <wfile_find_in_path+0xc1>
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x3b,%eax
setne  %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
test   $0x1,%al
jne    1211 <wfile_find_in_path+0xd1>
jmp    129c <wfile_find_in_path+0x15c>
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x28(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x28(%rbp)
movslq %eax,%rcx
lea    0x2e1f(%rip),%rax
mov    %dl,(%rax,%rcx,1)
cmpl   $0x1,-0x28(%rbp)
jne    1289 <wfile_find_in_path+0x149>
mov    -0x20(%rbp),%rax
mov    -0x24(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x3a,%eax
jne    1289 <wfile_find_in_path+0x149>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x28(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x28(%rbp)
movslq %eax,%rcx
lea    0x2dcf(%rip),%rax
mov    %dl,(%rax,%rcx,1)
jmp    128e <wfile_find_in_path+0x14e>
jmp    128e <wfile_find_in_path+0x14e>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11b8 <wfile_find_in_path+0x78>
movslq -0x28(%rbp),%rcx
lea    0x2da9(%rip),%rax
movb   $0x0,(%rax,%rcx,1)
lea    0x2d9e(%rip),%rdi
call   1060 <clean_line@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0x2d8a(%rip),%rsi
call   1050 <wfile_fullname@plt>
mov    -0x10(%rbp),%rdi
call   1040 <wfile_status@plt>
cmp    $0x1,%eax
jne    12e9 <wfile_find_in_path+0x1a9>
movl   $0xffffffff,-0x4(%rbp)
jmp    131d <wfile_find_in_path+0x1dd>
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
jne    1303 <wfile_find_in_path+0x1c3>
jmp    1316 <wfile_find_in_path+0x1d6>
jmp    1308 <wfile_find_in_path+0x1c8>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11a2 <wfile_find_in_path+0x62>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wfile_find_in_path>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %rdi,%r15
movsbl (%rsi),%edi
call   1030 <wfile_eitherslash@plt>
test   %rax,%rax
jne    1168 <wfile_find_in_path+0x28>
cmpb   $0x3a,0x1(%r14)
jne    118b <wfile_find_in_path+0x4b>
mov    %r14,%rdi
call   1040 <wfile_status@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x1,%ecx
sete   %al
neg    %eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %ebp,%ebp
lea    0x2ebc(%rip),%r12
xor    %eax,%eax
jmp    11a3 <wfile_find_in_path+0x63>
nopl   0x0(%rax,%rax,1)
add    $0x1,%ebp
movslq %ebp,%r13
movzbl (%rbx,%r13,1),%ecx
movslq %eax,%rdx
cmp    $0x3b,%rcx
ja     1200 <wfile_find_in_path+0xc0>
movabs $0xc00000000000001,%rsi
bt     %rcx,%rsi
jae    1200 <wfile_find_in_path+0xc0>
movb   $0x0,(%rdx,%r12,1)
mov    %r12,%rdi
call   1060 <clean_line@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %r14,%rdx
call   1050 <wfile_fullname@plt>
mov    %r15,%rdi
call   1040 <wfile_status@plt>
cmp    $0x1,%eax
je     1235 <wfile_find_in_path+0xf5>
xor    %eax,%eax
cmpb   $0x0,(%rbx,%r13,1)
jne    11a0 <wfile_find_in_path+0x60>
jmp    117c <wfile_find_in_path+0x3c>
nopw   0x0(%rax,%rax,1)
mov    %cl,(%rdx,%r12,1)
test   %eax,%eax
je     1210 <wfile_find_in_path+0xd0>
add    $0x1,%eax
add    $0x1,%ebp
jmp    11a3 <wfile_find_in_path+0x63>
mov    $0x1,%eax
cmpb   $0x3a,0x1(%rbx,%r13,1)
jne    11a0 <wfile_find_in_path+0x60>
add    $0x1,%r13
movb   $0x3a,0x2e29(%rip)
mov    $0x2,%eax
mov    %r13d,%ebp
jmp    11a0 <wfile_find_in_path+0x60>
mov    $0xffffffff,%eax
jmp    117c <wfile_find_in_path+0x3c>

LLVM IR (-O0):
@wfile_find_in_path.dir = internal global [512 x i8] zeroinitializer
define i32 @wfile_find_in_path(i8* %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
%10 = load i8*, i8** %6
%11 = getelementptr inbounds i8, i8* %10, i64 0
%12 = load i8, i8* %11
%13 = call i64 @wfile_eitherslash(i8 signext %12)
%14 = icmp ne i64 %13, 0
br i1 %14, label %21, label %15
15: ; preds = %3
%16 = load i8*, i8** %6
%17 = getelementptr inbounds i8, i8* %16, i64 1
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 58
br i1 %20, label %21, label %27
21: ; preds = %15, %3
%22 = load i8*, i8** %6
%23 = call i32 @wfile_status(i8* %22)
%24 = icmp eq i32 %23, 1
%25 = zext i1 %24 to i64
%26 = select i1 %24, i32 -1, i32 0
store i32 %26, i32* %4
br label %119
27: ; preds = %15
store i32 0, i32* %8
br label %28
28: ; preds = %115, %27
br i1 true, label %29, label %118
29: ; preds = %28
store i32 0, i32* %9
br label %30
30: ; preds = %90, %29
%31 = load i8*, i8** %7
%32 = load i32, i32* %8
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8, i8* %31, i64 %33
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = icmp ne i32 %36, 0
br i1 %37, label %38, label %54
38: ; preds = %30
%39 = load i8*, i8** %7
%40 = load i32, i32* %8
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i8, i8* %39, i64 %41
%43 = load i8, i8* %42
%44 = sext i8 %43 to i32
%45 = icmp ne i32 %44, 58
br i1 %45, label %46, label %54
46: ; preds = %38
%47 = load i8*, i8** %7
%48 = load i32, i32* %8
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds i8, i8* %47, i64 %49
%51 = load i8, i8* %50
%52 = sext i8 %51 to i32
%53 = icmp ne i32 %52, 59
br label %54
54: ; preds = %46, %38, %30
%55 = phi i1 [ false, %38 ], [ false, %30 ], [ %53, %46 ]
br i1 %55, label %56, label %93
56: ; preds = %54
%57 = load i8*, i8** %7
%58 = load i32, i32* %8
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds i8, i8* %57, i64 %59
%61 = load i8, i8* %60
%62 = load i32, i32* %9
%63 = add nsw i32 %62, 1
store i32 %63, i32* %9
%64 = sext i32 %62 to i64
%65 = getelementptr inbounds [512 x i8], [512 x i8]* @wfile_find_in_path.dir, i64 0, i64 %64
store i8 %61, i8* %65
%66 = load i32, i32* %9
%67 = icmp eq i32 %66, 1
br i1 %67, label %68, label %89
68: ; preds = %56
%69 = load i8*, i8** %7
%70 = load i32, i32* %8
%71 = add nsw i32 %70, 1
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds i8, i8* %69, i64 %72
%74 = load i8, i8* %73
%75 = sext i8 %74 to i32
%76 = icmp eq i32 %75, 58
br i1 %76, label %77, label %89
77: ; preds = %68
%78 = load i32, i32* %8
%79 = add nsw i32 %78, 1
store i32 %79, i32* %8
%80 = load i8*, i8** %7
%81 = load i32, i32* %8
%82 = sext i32 %81 to i64
%83 = getelementptr inbounds i8, i8* %80, i64 %82
%84 = load i8, i8* %83
%85 = load i32, i32* %9
%86 = add nsw i32 %85, 1
store i32 %86, i32* %9
%87 = sext i32 %85 to i64
%88 = getelementptr inbounds [512 x i8], [512 x i8]* @wfile_find_in_path.dir, i64 0, i64 %87
store i8 %84, i8* %88
br label %90
89: ; preds = %68, %56
br label %90
90: ; preds = %89, %77
%91 = load i32, i32* %8
%92 = add nsw i32 %91, 1
store i32 %92, i32* %8
br label %30
93: ; preds = %54
%94 = load i32, i32* %9
%95 = sext i32 %94 to i64
%96 = getelementptr inbounds [512 x i8], [512 x i8]* @wfile_find_in_path.dir, i64 0, i64 %95
store i8 0, i8* %96
%97 = call i32 @clean_line(i8* getelementptr inbounds ([512 x i8], [512 x i8]* @wfile_find_in_path.dir, i64 0, i64 0))
%98 = load i8*, i8** %5
%99 = load i8*, i8** %6
%100 = call i32 @wfile_fullname(i8* %98, i8* getelementptr inbounds ([512 x i8], [512 x i8]* @wfile_find_in_path.dir, i64 0, i64 0), i8* %99)
%101 = load i8*, i8** %5
%102 = call i32 @wfile_status(i8* %101)
%103 = icmp eq i32 %102, 1
br i1 %103, label %104, label %105
104: ; preds = %93
store i32 -1, i32* %4
br label %119
105: ; preds = %93
%106 = load i8*, i8** %7
%107 = load i32, i32* %8
%108 = sext i32 %107 to i64
%109 = getelementptr inbounds i8, i8* %106, i64 %108
%110 = load i8, i8* %109
%111 = sext i8 %110 to i32
%112 = icmp eq i32 %111, 0
br i1 %112, label %113, label %114
113: ; preds = %105
br label %118
114: ; preds = %105
br label %115
115: ; preds = %114
%116 = load i32, i32* %8
%117 = add nsw i32 %116, 1
store i32 %117, i32* %8
br label %28
118: ; preds = %113, %28
store i32 0, i32* %4
br label %119
119: ; preds = %118, %104, %21
%120 = load i32, i32* %4
ret i32 %120
}

LLVM IR (-O2):
@wfile_find_in_path.dir = internal global [512 x i8] zeroinitializer
define i32 @wfile_find_in_path(i8* %0, i8* %1, i8* nocapture %2) {
%4 = load i8, i8* %1
%5 = tail call i64 @wfile_eitherslash(i8 signext %4)
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %11
7: ; preds = %3
%8 = getelementptr inbounds i8, i8* %1, i64 1
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 58
br i1 %10, label %11, label %15
11: ; preds = %7, %3
%12 = tail call i32 @wfile_status(i8* %1)
%13 = icmp eq i32 %12, 1
%14 = sext i1 %13 to i32
br label %48
15: ; preds = %7, %33
%16 = phi i32 [ %36, %33 ], [ 0, %7 ]
%17 = phi i32 [ %35, %33 ], [ 0, %7 ]
%18 = sext i32 %16 to i64
%19 = getelementptr inbounds i8, i8* %2, i64 %18
%20 = load i8, i8* %19
switch i8 %20, label %21 [
i8 0, label %37
i8 58, label %37
i8 59, label %37
]
21: ; preds = %15
%22 = add nsw i32 %17, 1
%23 = sext i32 %17 to i64
%24 = getelementptr inbounds [512 x i8], [512 x i8]* @wfile_find_in_path.dir, i64 0, i64 %23
store i8 %20, i8* %24
%25 = icmp eq i32 %17, 0
br i1 %25, label %26, label %33
26: ; preds = %21
%27 = add nsw i32 %16, 1
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %2, i64 %28
%30 = load i8, i8* %29
%31 = icmp eq i8 %30, 58
br i1 %31, label %32, label %33
32: ; preds = %26
store i8 58, i8* getelementptr inbounds ([512 x i8], [512 x i8]* @wfile_find_in_path.dir, i64 0, i64 1)
br label %33
33: ; preds = %32, %26, %21, %44
%34 = phi i32 [ %16, %44 ], [ %27, %32 ], [ %16, %26 ], [ %16, %21 ]
%35 = phi i32 [ 0, %44 ], [ 2, %32 ], [ 1, %26 ], [ %22, %21 ]
%36 = add nsw i32 %34, 1
br label %15
37: ; preds = %15, %15, %15
%38 = sext i32 %17 to i64
%39 = getelementptr inbounds [512 x i8], [512 x i8]* @wfile_find_in_path.dir, i64 0, i64 %38
store i8 0, i8* %39
%40 = tail call i32 @clean_line(i8* getelementptr inbounds ([512 x i8], [512 x i8]* @wfile_find_in_path.dir, i64 0, i64 0))
%41 = tail call i32 @wfile_fullname(i8* %0, i8* getelementptr inbounds ([512 x i8], [512 x i8]* @wfile_find_in_path.dir, i64 0, i64 0), i8* %1)
%42 = tail call i32 @wfile_status(i8* %0)
%43 = icmp eq i32 %42, 1
br i1 %43, label %48, label %44
44: ; preds = %37
%45 = getelementptr inbounds i8, i8* %2, i64 %18
%46 = load i8, i8* %45
%47 = icmp eq i8 %46, 0
br i1 %47, label %48, label %33
48: ; preds = %44, %37, %11
%49 = phi i32 [ %14, %11 ], [ 0, %44 ], [ -1, %37 ]
ret i32 %49
}