#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*/ PATH_MAX;
char *filepath_sfind(char **, char *, char const *);
int /*<<< orphan*/ free(char *);
char *malloc(int /*<<< orphan*/);
char *filepath_find(char **respathv, const char *filename) {
  char *ret;
  char *filepath;
  if ((respathv == NULL) || (respathv[0] == NULL))
    return NULL;
  filepath = malloc(PATH_MAX);
  if (filepath == NULL)
    return NULL;
  ret = filepath_sfind(respathv, filepath, filename);
  if (ret == NULL)
    free(filepath);
  return ret;
}


x86 assembly (clang, -O0):
<filepath_find>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1159 <filepath_find+0x29>
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
jne    1166 <filepath_find+0x36>
movq   $0x0,-0x8(%rbp)
jmp    11c1 <filepath_find+0x91>
mov    0x2e83(%rip),%rax
mov    (%rax),%edi
call   1050 <malloc@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1190 <filepath_find+0x60>
movq   $0x0,-0x8(%rbp)
jmp    11c1 <filepath_find+0x91>
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1040 <filepath_sfind@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11b9 <filepath_find+0x89>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<filepath_find>:
push   %r15
push   %r14
push   %rbx
test   %rdi,%rdi
je     1177 <filepath_find+0x47>
mov    %rdi,%rbx
cmpq   $0x0,(%rdi)
je     1177 <filepath_find+0x47>
mov    %rsi,%r14
mov    0x2ea3(%rip),%rax
mov    (%rax),%edi
call   1050 <malloc@plt>
test   %rax,%rax
je     1177 <filepath_find+0x47>
mov    %rax,%r15
mov    %rbx,%rdi
mov    %rax,%rsi
mov    %r14,%rdx
call   1040 <filepath_sfind@plt>
test   %rax,%rax
jne    1179 <filepath_find+0x49>
mov    %r15,%rdi
call   1030 <free@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@PATH_MAX = global i32 0
define i8* @filepath_find(i8** %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8**
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
store i8** %0, i8*** %4
store i8* %1, i8** %5
%8 = load i8**, i8*** %4
%9 = icmp eq i8** %8, null
br i1 %9, label %15, label %10
10: ; preds = %2
%11 = load i8**, i8*** %4
%12 = getelementptr inbounds i8*, i8** %11, i64 0
%13 = load i8*, i8** %12
%14 = icmp eq i8* %13, null
br i1 %14, label %15, label %16
15: ; preds = %10, %2
store i8* null, i8** %3
br label %34
16: ; preds = %10
%17 = load i32, i32* @PATH_MAX
%18 = call i8* @malloc(i32 %17)
store i8* %18, i8** %7
%19 = load i8*, i8** %7
%20 = icmp eq i8* %19, null
br i1 %20, label %21, label %22
21: ; preds = %16
store i8* null, i8** %3
br label %34
22: ; preds = %16
%23 = load i8**, i8*** %4
%24 = load i8*, i8** %7
%25 = load i8*, i8** %5
%26 = call i8* @filepath_sfind(i8** %23, i8* %24, i8* %25)
store i8* %26, i8** %6
%27 = load i8*, i8** %6
%28 = icmp eq i8* %27, null
br i1 %28, label %29, label %32
29: ; preds = %22
%30 = load i8*, i8** %7
%31 = call i32 @free(i8* %30)
br label %32
32: ; preds = %29, %22
%33 = load i8*, i8** %6
store i8* %33, i8** %3
br label %34
34: ; preds = %32, %21, %15
%35 = load i8*, i8** %3
ret i8* %35
}

LLVM IR (-O2):
@PATH_MAX = global i32 0
define i8* @filepath_find(i8** %0, i8* %1) {
%3 = icmp eq i8** %0, null
br i1 %3, label %16, label %4
4: ; preds = %2
%5 = load i8*, i8** %0
%6 = icmp eq i8* %5, null
br i1 %6, label %16, label %7
7: ; preds = %4
%8 = load i32, i32* @PATH_MAX
%9 = tail call i8* @malloc(i32 %8)
%10 = icmp eq i8* %9, null
br i1 %10, label %16, label %11
11: ; preds = %7
%12 = tail call i8* @filepath_sfind(i8** %0, i8* %9, i8* %1)
%13 = icmp eq i8* %12, null
br i1 %13, label %14, label %16
14: ; preds = %11
%15 = tail call i32 @free(i8* %9)
br label %16
16: ; preds = %11, %14, %7, %2, %4
%17 = phi i8* [ null, %4 ], [ null, %2 ], [ null, %7 ], [ null, %14 ], [ %12, %11 ]
ret i8* %17
}