#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*/ my_searchenv2(char *, char *, char *, int);
char *strchr(char *, char);
void my_searchenv1(char *name, char *envname, char *hitfile, int hitlen) {
  my_searchenv2(name, envname, hitfile, hitlen);
  if (*hitfile) {
    return;
  }
  char *p = name;
  char c;
  while ((c = *p++)) {
    if (c == ':') {
      my_searchenv2(p, envname, hitfile, hitlen);
      if (*hitfile) {
        return;
      }
    }
    if (c == '[') {
      char *enddir = strchr(p, ']');
      if (enddir == NULL) {
        return;
      }
      p = enddir + 1;
      my_searchenv2(p, envname, hitfile, hitlen);
      return;
    }
  }
  return;
}


x86 assembly (clang, -O0):
<my_searchenv1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
call   1040 <my_searchenv2@plt>
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
je     115d <my_searchenv1+0x3d>
jmp    1217 <my_searchenv1+0xf7>
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x28(%rbp)
mov    (%rax),%al
mov    %al,-0x29(%rbp)
cmp    $0x0,%al
je     1212 <my_searchenv1+0xf2>
movsbl -0x29(%rbp),%eax
cmp    $0x3a,%eax
jne    11b9 <my_searchenv1+0x99>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
call   1040 <my_searchenv2@plt>
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
je     11b4 <my_searchenv1+0x94>
jmp    1217 <my_searchenv1+0xf7>
jmp    11b9 <my_searchenv1+0x99>
movsbl -0x29(%rbp),%eax
cmp    $0x5b,%eax
jne    120d <my_searchenv1+0xed>
mov    -0x28(%rbp),%rdi
mov    $0x5d,%esi
call   1030 <strchr@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    11e8 <my_searchenv1+0xc8>
jmp    1217 <my_searchenv1+0xf7>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
call   1040 <my_searchenv2@plt>
jmp    1217 <my_searchenv1+0xf7>
jmp    1165 <my_searchenv1+0x45>
jmp    1217 <my_searchenv1+0xf7>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<my_searchenv1>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %ecx,%r14d
mov    %rdx,%rbx
mov    %rsi,%r15
mov    %rdi,%rbp
jmp    114c <my_searchenv1+0x2c>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbp,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
mov    %r14d,%ecx
call   1040 <my_searchenv2@plt>
cmpb   $0x0,(%rbx)
jne    119b <my_searchenv1+0x7b>
add    $0x1,%rbp
movzbl -0x1(%rbp),%eax
cmp    $0x3a,%al
je     1140 <my_searchenv1+0x20>
test   %al,%al
je     119b <my_searchenv1+0x7b>
cmp    $0x5b,%al
jne    1156 <my_searchenv1+0x36>
mov    %rbp,%rdi
mov    $0x5d,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     119b <my_searchenv1+0x7b>
add    $0x1,%rax
mov    %rax,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
mov    %r14d,%ecx
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <my_searchenv2@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @my_searchenv1(i8* %0, i8* %1, i8* %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i8
%11 = alloca i8*
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i32 %3, i32* %8
%12 = load i8*, i8** %5
%13 = load i8*, i8** %6
%14 = load i8*, i8** %7
%15 = load i32, i32* %8
%16 = call i32 @my_searchenv2(i8* %12, i8* %13, i8* %14, i32 %15)
%17 = load i8*, i8** %7
%18 = load i8, i8* %17
%19 = icmp ne i8 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %4
br label %63
21: ; preds = %4
%22 = load i8*, i8** %5
store i8* %22, i8** %9
br label %23
23: ; preds = %61, %21
%24 = load i8*, i8** %9
%25 = getelementptr inbounds i8, i8* %24, i32 1
store i8* %25, i8** %9
%26 = load i8, i8* %24
store i8 %26, i8* %10
%27 = icmp ne i8 %26, 0
br i1 %27, label %28, label %62
28: ; preds = %23
%29 = load i8, i8* %10
%30 = sext i8 %29 to i32
%31 = icmp eq i32 %30, 58
br i1 %31, label %32, label %43
32: ; preds = %28
%33 = load i8*, i8** %9
%34 = load i8*, i8** %6
%35 = load i8*, i8** %7
%36 = load i32, i32* %8
%37 = call i32 @my_searchenv2(i8* %33, i8* %34, i8* %35, i32 %36)
%38 = load i8*, i8** %7
%39 = load i8, i8* %38
%40 = icmp ne i8 %39, 0
br i1 %40, label %41, label %42
41: ; preds = %32
br label %63
42: ; preds = %32
br label %43
43: ; preds = %42, %28
%44 = load i8, i8* %10
%45 = sext i8 %44 to i32
%46 = icmp eq i32 %45, 91
br i1 %46, label %47, label %61
47: ; preds = %43
%48 = load i8*, i8** %9
%49 = call i8* @strchr(i8* %48, i8 signext 93)
store i8* %49, i8** %11
%50 = load i8*, i8** %11
%51 = icmp eq i8* %50, null
br i1 %51, label %52, label %53
52: ; preds = %47
br label %63
53: ; preds = %47
%54 = load i8*, i8** %11
%55 = getelementptr inbounds i8, i8* %54, i64 1
store i8* %55, i8** %9
%56 = load i8*, i8** %9
%57 = load i8*, i8** %6
%58 = load i8*, i8** %7
%59 = load i32, i32* %8
%60 = call i32 @my_searchenv2(i8* %56, i8* %57, i8* %58, i32 %59)
br label %63
61: ; preds = %43
br label %23
62: ; preds = %23
br label %63
63: ; preds = %62, %53, %52, %41, %20
ret void
}

LLVM IR (-O2):
define void @my_searchenv1(i8* %0, i8* %1, i8* %2, i32 %3) {
%5 = tail call i32 @my_searchenv2(i8* %0, i8* %1, i8* %2, i32 %3)
%6 = load i8, i8* %2
%7 = icmp eq i8 %6, 0
br i1 %7, label %8, label %23
8: ; preds = %4, %12
%9 = phi i8* [ %10, %12 ], [ %0, %4 ]
%10 = getelementptr inbounds i8, i8* %9, i64 1
%11 = load i8, i8* %9
switch i8 %11, label %12 [
i8 0, label %23
i8 58, label %13
i8 91, label %17
]
12: ; preds = %8, %13
br label %8
13: ; preds = %8
%14 = tail call i32 @my_searchenv2(i8* %10, i8* %1, i8* %2, i32 %3)
%15 = load i8, i8* %2
%16 = icmp eq i8 %15, 0
br i1 %16, label %12, label %23
17: ; preds = %8
%18 = tail call i8* @strchr(i8* %10, i8 signext 93)
%19 = icmp eq i8* %18, null
br i1 %19, label %23, label %20
20: ; preds = %17
%21 = getelementptr inbounds i8, i8* %18, i64 1
%22 = tail call i32 @my_searchenv2(i8* %21, i8* %1, i8* %2, i32 %3)
br label %23
23: ; preds = %13, %8, %17, %20, %4
ret void
}