#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 *strdup(char *);
char *strndup(char *, int);
char *strpbrk(char *, char *);
void gf_split_path_file(char **p, char **f, char *pf) {
  char *slash = pf, *next;
  while ((next = strpbrk(slash + 1, "\\/")))
    slash = next;
  if (pf != slash)
    slash++;
  *p = strndup(pf, slash - pf);
  *f = strdup(slash);
}


x86 assembly (clang, -O0):
<gf_split_path_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
add    $0x1,%rdi
lea    0xea5(%rip),%rsi
call   1040 <strpbrk@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
je     117b <gf_split_path_file+0x4b>
mov    -0x28(%rbp),%rax
mov    %rax,-0x20(%rbp)
jmp    114c <gf_split_path_file+0x1c>
mov    -0x18(%rbp),%rax
cmp    -0x20(%rbp),%rax
je     1195 <gf_split_path_file+0x65>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rax
mov    -0x18(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%esi
call   1030 <strndup@plt>
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x20(%rbp),%rdi
call   1050 <strdup@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gf_split_path_file>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r12
mov    %rsi,%r14
mov    %rdi,%r15
lea    0xeb5(%rip),%r13
mov    %rdx,%rax
xchg   %ax,%ax
mov    %rax,%rbp
lea    0x1(%rax),%rbx
mov    %rbx,%rdi
mov    %r13,%rsi
call   1040 <strpbrk@plt>
test   %rax,%rax
jne    1150 <gf_split_path_file+0x20>
cmp    %r12,%rbp
cmove  %rbp,%rbx
mov    %ebx,%esi
sub    %r12d,%esi
mov    %r12,%rdi
call   1030 <strndup@plt>
mov    %rax,(%r15)
mov    %rbx,%rdi
call   1050 <strdup@plt>
mov    %rax,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"\\/\00"
define void @gf_split_path_file(i8** nocapture writeonly %0, i8** nocapture writeonly %1, i8* %2) {
br label %4
4: ; preds = %4, %3
%5 = phi i8* [ %2, %3 ], [ %7, %4 ]
%6 = getelementptr inbounds i8, i8* %5, i64 1
%7 = tail call i8* @strpbrk(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i8* %7, null
br i1 %8, label %9, label %4
9: ; preds = %4
%10 = icmp eq i8* %5, %2
%11 = select i1 %10, i8* %5, i8* %6
%12 = ptrtoint i8* %11 to i64
%13 = ptrtoint i8* %2 to i64
%14 = sub i64 %12, %13
%15 = trunc i64 %14 to i32
%16 = tail call i8* @strndup(i8* %2, i32 %15)
store i8* %16, i8** %0
%17 = tail call i8* @strdup(i8* %11)
store i8* %17, i8** %1
ret void
}