#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*/ downcase(char *);
int /*<<< orphan*/ free(char *);
char *memcheck(int /*<<< orphan*/);
int /*<<< orphan*/ my_searchenv1(char *, char *, char *, int);
int /*<<< orphan*/ strdup(char *);
void my_searchenv(char *name, char *envname, char *hitfile, int hitlen) {
  my_searchenv1(name, envname, hitfile, hitlen);
  if (*hitfile) {
    return;
  }
  char *copy = memcheck(strdup(name));
  downcase(copy);
  my_searchenv1(copy, envname, hitfile, hitlen);
  free(copy);
}


x86 assembly (clang, -O0):
<my_searchenv>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%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_searchenv1@plt>
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
je     118d <my_searchenv+0x3d>
jmp    11c7 <my_searchenv+0x77>
mov    -0x8(%rbp),%rdi
call   1070 <strdup@plt>
mov    %eax,%edi
call   1060 <memcheck@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
call   1050 <downcase@plt>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
call   1040 <my_searchenv1@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<my_searchenv>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %ecx,%r14d
mov    %rdx,%rbx
mov    %rsi,%r15
mov    %rdi,%rbp
call   1040 <my_searchenv1@plt>
cmpb   $0x0,(%rbx)
je     1178 <my_searchenv+0x28>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rbp,%rdi
call   1070 <strdup@plt>
mov    %eax,%edi
call   1060 <memcheck@plt>
mov    %rax,%rbp
mov    %rax,%rdi
call   1050 <downcase@plt>
mov    %rbp,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
mov    %r14d,%ecx
call   1040 <my_searchenv1@plt>
mov    %rbp,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>

LLVM IR (-O0):
define void @my_searchenv(i8* %0, i8* %1, i8* %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i8*
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i32 %3, i32* %8
%10 = load i8*, i8** %5
%11 = load i8*, i8** %6
%12 = load i8*, i8** %7
%13 = load i32, i32* %8
%14 = call i32 @my_searchenv1(i8* %10, i8* %11, i8* %12, i32 %13)
%15 = load i8*, i8** %7
%16 = load i8, i8* %15
%17 = icmp ne i8 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %4
br label %32
19: ; preds = %4
%20 = load i8*, i8** %5
%21 = call i32 @strdup(i8* %20)
%22 = call i8* @memcheck(i32 %21)
store i8* %22, i8** %9
%23 = load i8*, i8** %9
%24 = call i32 @downcase(i8* %23)
%25 = load i8*, i8** %9
%26 = load i8*, i8** %6
%27 = load i8*, i8** %7
%28 = load i32, i32* %8
%29 = call i32 @my_searchenv1(i8* %25, i8* %26, i8* %27, i32 %28)
%30 = load i8*, i8** %9
%31 = call i32 @free(i8* %30)
br label %32
32: ; preds = %19, %18
ret void
}

LLVM IR (-O2):
define void @my_searchenv(i8* %0, i8* %1, i8* %2, i32 %3) {
%5 = tail call i32 @my_searchenv1(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 %14
8: ; preds = %4
%9 = tail call i32 @strdup(i8* %0)
%10 = tail call i8* @memcheck(i32 %9)
%11 = tail call i32 @downcase(i8* %10)
%12 = tail call i32 @my_searchenv1(i8* %10, i8* %1, i8* %2, i32 %3)
%13 = tail call i32 @free(i8* %10)
br label %14
14: ; preds = %4, %8
ret void
}