#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 *checking_strdup(char const *);
char *strdupdelim(char const *, char *);
char *strrchr(char const *, char);
int /*<<< orphan*/ url_unescape(char *);
void split_path(const char *path, char **dir, char **file) {
  char *last_slash = strrchr(path, '/');
  if (!last_slash) {
    *dir = checking_strdup("");
    *file = checking_strdup(path);
  } else {
    *dir = strdupdelim(path, last_slash);
    *file = checking_strdup(last_slash + 1);
  }
  url_unescape(*dir);
  url_unescape(*file);
}


x86 assembly (clang, -O0):
<split_path>:
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    $0x2f,%esi
call   1040 <strrchr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    119f <split_path+0x5f>
lea    0xe88(%rip),%rdi
call   1060 <checking_strdup@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rdi
call   1060 <checking_strdup@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
jmp    11cd <split_path+0x8d>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1050 <strdupdelim@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x20(%rbp),%rdi
add    $0x1,%rdi
call   1060 <checking_strdup@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1030 <url_unescape@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
call   1030 <url_unescape@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<split_path>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r12
mov    $0x2f,%esi
call   1040 <strrchr@plt>
test   %rax,%rax
je     117a <split_path+0x3a>
mov    %rax,%rbx
mov    %r12,%rdi
mov    %rax,%rsi
call   1050 <strdupdelim@plt>
mov    %rax,(%r15)
add    $0x1,%rbx
mov    %rbx,%rdi
jmp    118c <split_path+0x4c>
lea    0xe7f(%rip),%rdi
call   1060 <checking_strdup@plt>
mov    %rax,(%r15)
mov    %r12,%rdi
call   1060 <checking_strdup@plt>
mov    %rax,(%r14)
mov    (%r15),%rdi
call   1030 <url_unescape@plt>
mov    (%r14),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <url_unescape@plt>

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
define void @split_path(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 i8* @strrchr(i8* %8, i8 signext 47)
store i8* %9, i8** %7
%10 = load i8*, i8** %7
%11 = icmp ne i8* %10, null
br i1 %11, label %18, label %12
12: ; preds = %3
%13 = call i8* @checking_strdup(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%14 = load i8**, i8*** %5
store i8* %13, i8** %14
%15 = load i8*, i8** %4
%16 = call i8* @checking_strdup(i8* %15)
%17 = load i8**, i8*** %6
store i8* %16, i8** %17
br label %27
18: ; preds = %3
%19 = load i8*, i8** %4
%20 = load i8*, i8** %7
%21 = call i8* @strdupdelim(i8* %19, i8* %20)
%22 = load i8**, i8*** %5
store i8* %21, i8** %22
%23 = load i8*, i8** %7
%24 = getelementptr inbounds i8, i8* %23, i64 1
%25 = call i8* @checking_strdup(i8* %24)
%26 = load i8**, i8*** %6
store i8* %25, i8** %26
br label %27
27: ; preds = %18, %12
%28 = load i8**, i8*** %5
%29 = load i8*, i8** %28
%30 = call i32 @url_unescape(i8* %29)
%31 = load i8**, i8*** %6
%32 = load i8*, i8** %31
%33 = call i32 @url_unescape(i8* %32)
ret void
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
define void @split_path(i8* %0, i8** nocapture %1, i8** nocapture %2) {
%4 = tail call i8* @strrchr(i8* dereferenceable(1) %0, i8 signext 47)
%5 = icmp eq i8* %4, null
br i1 %5, label %6, label %9
6: ; preds = %3
%7 = tail call i8* @checking_strdup(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
store i8* %7, i8** %1
%8 = tail call i8* @checking_strdup(i8* %0)
br label %13
9: ; preds = %3
%10 = tail call i8* @strdupdelim(i8* %0, i8* %4)
store i8* %10, i8** %1
%11 = getelementptr inbounds i8, i8* %4, i64 1
%12 = tail call i8* @checking_strdup(i8* %11)
br label %13
13: ; preds = %9, %6
%14 = phi i8* [ %8, %6 ], [ %12, %9 ]
store i8* %14, i8** %2
%15 = load i8*, i8** %1
%16 = tail call i32 @url_unescape(i8* %15)
%17 = load i8*, i8** %2
%18 = tail call i32 @url_unescape(i8* %17)
ret void
}