#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 */
char *ftg_get_filename_from_path(char const *);
scalar_t__ ftg_is_dir(char const *);
void NFDi_SplitPath(const char *path, const char **out_dir,
                    const char **out_filename) {
  if (ftg_is_dir(path)) {
    *out_dir = path;
    *out_filename = NULL;
    return;
  }
  const char *filename = ftg_get_filename_from_path(path);
  if (filename[0]) {
    *out_filename = filename;
  }
  *out_dir = path;
}


x86 assembly (clang, -O0):
<NFDi_SplitPath>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <ftg_is_dir@plt>
cmp    $0x0,%rax
je     1162 <NFDi_SplitPath+0x42>
mov    -0x8(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
movq   $0x0,(%rax)
jmp    1192 <NFDi_SplitPath+0x72>
mov    -0x8(%rbp),%rdi
call   1030 <ftg_get_filename_from_path@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmpb   $0x0,(%rax)
je     1187 <NFDi_SplitPath+0x67>
mov    -0x20(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<NFDi_SplitPath>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
call   1040 <ftg_is_dir@plt>
test   %rax,%rax
je     1144 <NFDi_SplitPath+0x24>
mov    %rbx,(%r15)
movq   $0x0,(%r14)
jmp    1157 <NFDi_SplitPath+0x37>
mov    %rbx,%rdi
call   1030 <ftg_get_filename_from_path@plt>
cmpb   $0x0,(%rax)
je     1154 <NFDi_SplitPath+0x34>
mov    %rax,(%r14)
mov    %rbx,(%r15)
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @NFDi_SplitPath(i8* %0, i8** %1, i8** %2) {
%4 = alloca i8*
%5 = alloca i8**
%6 = alloca i8**
%7 = alloca i8*
store i8* %0, i8** %4
store i8** %1, i8*** %5
store i8** %2, i8*** %6
%8 = load i8*, i8** %4
%9 = call i64 @ftg_is_dir(i8* %8)
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %15
11: ; preds = %3
%12 = load i8*, i8** %4
%13 = load i8**, i8*** %5
store i8* %12, i8** %13
%14 = load i8**, i8*** %6
store i8* null, i8** %14
br label %28
15: ; preds = %3
%16 = load i8*, i8** %4
%17 = call i8* @ftg_get_filename_from_path(i8* %16)
store i8* %17, i8** %7
%18 = load i8*, i8** %7
%19 = getelementptr inbounds i8, i8* %18, i64 0
%20 = load i8, i8* %19
%21 = icmp ne i8 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %15
%23 = load i8*, i8** %7
%24 = load i8**, i8*** %6
store i8* %23, i8** %24
br label %25
25: ; preds = %22, %15
%26 = load i8*, i8** %4
%27 = load i8**, i8*** %5
store i8* %26, i8** %27
br label %28
28: ; preds = %25, %11
ret void
}

LLVM IR (-O2):
define void @NFDi_SplitPath(i8* %0, i8** nocapture writeonly %1, i8** nocapture writeonly %2) {
%4 = tail call i64 @ftg_is_dir(i8* %0)
%5 = icmp eq i64 %4, 0
br i1 %5, label %7, label %6
6: ; preds = %3
store i8* %0, i8** %1
store i8* null, i8** %2
br label %13
7: ; preds = %3
%8 = tail call i8* @ftg_get_filename_from_path(i8* %0)
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 0
br i1 %10, label %12, label %11
11: ; preds = %7
store i8* %8, i8** %2
br label %12
12: ; preds = %11, %7
store i8* %0, i8** %1
br label %13
13: ; preds = %12, %6
ret void
}