#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 *calloc(int /*<<< orphan*/, int);
char *rindex(char *, char);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ strlen(char *);
void _splitpath(char *path, char **dir, char **file) {
  char *p = rindex(path, '/');
  *file = calloc(strlen(p), sizeof(char));
  strcpy(*file, p + 1);
  *p = '\0';
  *dir = calloc(strlen(path) + 1, sizeof(char));
  strcpy(*dir, path);
  return;
}


x86 assembly (clang, -O0):
<_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
mov    $0x2f,%esi
call   1060 <rindex@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%edi
mov    $0x1,%esi
call   1050 <calloc@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
mov    -0x20(%rbp),%rsi
add    $0x1,%rsi
call   1030 <strcpy@plt>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%edi
add    $0x1,%edi
mov    $0x1,%esi
call   1050 <calloc@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_splitpath>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%r12
mov    $0x2f,%esi
call   1060 <rindex@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <strlen@plt>
mov    %eax,%edi
mov    $0x1,%esi
call   1050 <calloc@plt>
mov    %rax,(%r15)
lea    0x1(%rbx),%rsi
mov    %rax,%rdi
call   1030 <strcpy@plt>
movb   $0x0,(%rbx)
mov    %r12,%rdi
call   1040 <strlen@plt>
lea    0x1(%rax),%edi
mov    $0x1,%esi
call   1050 <calloc@plt>
mov    %rax,(%r14)
mov    %rax,%rdi
mov    %r12,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <strcpy@plt>

LLVM IR (-O0):
define void @_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 i8* @rindex(i8* %8, i8 signext 47)
store i8* %9, i8** %7
%10 = load i8*, i8** %7
%11 = call i32 @strlen(i8* %10)
%12 = call i8* @calloc(i32 %11, i32 1)
%13 = load i8**, i8*** %6
store i8* %12, i8** %13
%14 = load i8**, i8*** %6
%15 = load i8*, i8** %14
%16 = load i8*, i8** %7
%17 = getelementptr inbounds i8, i8* %16, i64 1
%18 = call i32 @strcpy(i8* %15, i8* %17)
%19 = load i8*, i8** %7
store i8 0, i8* %19
%20 = load i8*, i8** %4
%21 = call i32 @strlen(i8* %20)
%22 = add nsw i32 %21, 1
%23 = call i8* @calloc(i32 %22, i32 1)
%24 = load i8**, i8*** %5
store i8* %23, i8** %24
%25 = load i8**, i8*** %5
%26 = load i8*, i8** %25
%27 = load i8*, i8** %4
%28 = call i32 @strcpy(i8* %26, i8* %27)
ret void
}

LLVM IR (-O2):
define void @_splitpath(i8* %0, i8** nocapture writeonly %1, i8** nocapture writeonly %2) {
%4 = tail call i8* @rindex(i8* %0, i8 signext 47)
%5 = tail call i32 @strlen(i8* %4)
%6 = tail call i8* @calloc(i32 %5, i32 1)
store i8* %6, i8** %2
%7 = getelementptr inbounds i8, i8* %4, i64 1
%8 = tail call i32 @strcpy(i8* %6, i8* %7)
store i8 0, i8* %4
%9 = tail call i32 @strlen(i8* %0)
%10 = add nsw i32 %9, 1
%11 = tail call i8* @calloc(i32 %10, i32 1)
store i8* %11, i8** %1
%12 = tail call i32 @strcpy(i8* %11, i8* %0)
ret void
}