#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*/ split_filename(char const *, char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
void prepare_fname_for_opendir(const char *pathname, char *path, char *name) {
  split_filename(pathname, path, name);
  if (path && !*path)
    strcpy(path, "./");
  if (name && !*name)
    strcpy(name, "*");
}


x86 assembly (clang, -O0):
<prepare_fname_for_opendir>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1040 <split_filename@plt>
cmpq   $0x0,-0x10(%rbp)
je     116d <prepare_fname_for_opendir+0x4d>
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
jne    116d <prepare_fname_for_opendir+0x4d>
mov    -0x10(%rbp),%rdi
lea    0xe98(%rip),%rsi
call   1030 <strcpy@plt>
cmpq   $0x0,-0x18(%rbp)
je     1195 <prepare_fname_for_opendir+0x75>
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
jne    1195 <prepare_fname_for_opendir+0x75>
mov    -0x18(%rbp),%rdi
lea    0xe73(%rip),%rsi
call   1030 <strcpy@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<prepare_fname_for_opendir>:
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%rbx
call   1040 <split_filename@plt>
test   %rbx,%rbx
je     1139 <prepare_fname_for_opendir+0x19>
cmpb   $0x0,(%rbx)
je     115a <prepare_fname_for_opendir+0x3a>
test   %r14,%r14
je     116e <prepare_fname_for_opendir+0x4e>
cmpb   $0x0,(%r14)
jne    116e <prepare_fname_for_opendir+0x4e>
lea    0xeb8(%rip),%rsi
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <strcpy@plt>
lea    0xe9f(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcpy@plt>
test   %r14,%r14
jne    113e <prepare_fname_for_opendir+0x1e>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [3 x i8] c"./\00"
@.str.1 = [2 x i8] c"*\00"
define void @prepare_fname_for_opendir(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%7 = load i8*, i8** %4
%8 = load i8*, i8** %5
%9 = load i8*, i8** %6
%10 = call i32 @split_filename(i8* %7, i8* %8, i8* %9)
%11 = load i8*, i8** %5
%12 = icmp ne i8* %11, null
br i1 %12, label %13, label %20
13: ; preds = %3
%14 = load i8*, i8** %5
%15 = load i8, i8* %14
%16 = icmp ne i8 %15, 0
br i1 %16, label %20, label %17
17: ; preds = %13
%18 = load i8*, i8** %5
%19 = call i32 @strcpy(i8* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %20
20: ; preds = %17, %13, %3
%21 = load i8*, i8** %6
%22 = icmp ne i8* %21, null
br i1 %22, label %23, label %30
23: ; preds = %20
%24 = load i8*, i8** %6
%25 = load i8, i8* %24
%26 = icmp ne i8 %25, 0
br i1 %26, label %30, label %27
27: ; preds = %23
%28 = load i8*, i8** %6
%29 = call i32 @strcpy(i8* %28, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %30
30: ; preds = %27, %23, %20
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"./\00"
@.str.1 = [2 x i8] c"*\00"
define void @prepare_fname_for_opendir(i8* %0, i8* %1, i8* %2) {
%4 = tail call i32 @split_filename(i8* %0, i8* %1, i8* %2)
%5 = icmp eq i8* %1, null
br i1 %5, label %11, label %6
6: ; preds = %3
%7 = load i8, i8* %1
%8 = icmp eq i8 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %6
%10 = tail call i32 @strcpy(i8* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %11
11: ; preds = %9, %6, %3
%12 = icmp eq i8* %2, null
br i1 %12, label %18, label %13
13: ; preds = %11
%14 = load i8, i8* %2
%15 = icmp eq i8 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %13
%17 = tail call i32 @strcpy(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %18
18: ; preds = %16, %13, %11
ret void
}