#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*/ free(char *);
char *strdup(char const *);
char *ybed95943699743390_br_build_path(char *, char *);
char *ybed95943699743390_br_find_prefix(char const *);
char *ybed95943699743390_br_find_lib_dir(const char *default_lib_dir) {
  char *prefix, *dir;
  prefix = ybed95943699743390_br_find_prefix((const char *)((void *)0));
  if (prefix == (char *)((void *)0)) {
    if (default_lib_dir != (const char *)((void *)0))
      return strdup(default_lib_dir);
    else
      return (char *)((void *)0);
  }
  dir = ybed95943699743390_br_build_path(prefix, "lib");
  free(prefix);
  return dir;
}


x86 assembly (clang, -O0):
<ybed95943699743390_br_find_lib_dir>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1040 <ybed95943699743390_br_find_prefix@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    118e <ybed95943699743390_br_find_lib_dir+0x4e>
cmpq   $0x0,-0x10(%rbp)
je     1181 <ybed95943699743390_br_find_lib_dir+0x41>
mov    -0x10(%rbp),%rdi
call   1050 <strdup@plt>
mov    %rax,-0x8(%rbp)
jmp    11b3 <ybed95943699743390_br_find_lib_dir+0x73>
movq   $0x0,-0x8(%rbp)
jmp    11b3 <ybed95943699743390_br_find_lib_dir+0x73>
mov    -0x18(%rbp),%rdi
lea    0xe67(%rip),%rsi
call   1060 <ybed95943699743390_br_build_path@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ybed95943699743390_br_find_lib_dir>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
xor    %edi,%edi
call   1040 <ybed95943699743390_br_find_prefix@plt>
test   %rax,%rax
je     117b <ybed95943699743390_br_find_lib_dir+0x3b>
mov    %rax,%rbx
lea    0xea3(%rip),%rsi
mov    %rax,%rdi
call   1060 <ybed95943699743390_br_build_path@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
test   %r14,%r14
je     118f <ybed95943699743390_br_find_lib_dir+0x4f>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1050 <strdup@plt>
xor    %eax,%eax
jmp    1173 <ybed95943699743390_br_find_lib_dir+0x33>

LLVM IR (-O0):
@.str = [4 x i8] c"lib\00"
define i8* @ybed95943699743390_br_find_lib_dir(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %3
%6 = call i8* @ybed95943699743390_br_find_prefix(i8* null)
store i8* %6, i8** %4
%7 = load i8*, i8** %4
%8 = icmp eq i8* %7, null
br i1 %8, label %9, label %16
9: ; preds = %1
%10 = load i8*, i8** %3
%11 = icmp ne i8* %10, null
br i1 %11, label %12, label %15
12: ; preds = %9
%13 = load i8*, i8** %3
%14 = call i8* @strdup(i8* %13)
store i8* %14, i8** %2
br label %22
15: ; preds = %9
store i8* null, i8** %2
br label %22
16: ; preds = %1
%17 = load i8*, i8** %4
%18 = call i8* @ybed95943699743390_br_build_path(i8* %17, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i8* %18, i8** %5
%19 = load i8*, i8** %4
%20 = call i32 @free(i8* %19)
%21 = load i8*, i8** %5
store i8* %21, i8** %2
br label %22
22: ; preds = %16, %15, %12
%23 = load i8*, i8** %2
ret i8* %23
}

LLVM IR (-O2):
@.str = [4 x i8] c"lib\00"
define i8* @ybed95943699743390_br_find_lib_dir(i8* %0) {
%2 = tail call i8* @ybed95943699743390_br_find_prefix(i8* null)
%3 = icmp eq i8* %2, null
br i1 %3, label %4, label %8
4: ; preds = %1
%5 = icmp eq i8* %0, null
br i1 %5, label %11, label %6
6: ; preds = %4
%7 = tail call i8* @strdup(i8* %0)
br label %11
8: ; preds = %1
%9 = tail call i8* @ybed95943699743390_br_build_path(i8* %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%10 = tail call i32 @free(i8* %2)
br label %11
11: ; preds = %4, %8, %6
%12 = phi i8* [ %7, %6 ], [ %9, %8 ], [ null, %4 ]
ret i8* %12
}