#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 *get_basename(char const *);
int /*<<< orphan*/ qe_pstrcpy(char *, int, char const *);
int /*<<< orphan*/ qe_pstrncpy(char *, int, char const *, int);
void splitpath(char *dirname, int dirname_size, char *filename,
               int filename_size, const char *pathname) {
  const char *base;
  base = get_basename(pathname);
  if (dirname)
    qe_pstrncpy(dirname, dirname_size, pathname, base - pathname);
  if (filename)
    qe_pstrcpy(filename, filename_size, base);
}


x86 assembly (clang, -O0):
<splitpath>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
call   1050 <get_basename@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     117f <splitpath+0x4f>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x28(%rbp),%rdx
mov    -0x30(%rbp),%rax
mov    -0x28(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%ecx
call   1040 <qe_pstrncpy@plt>
cmpq   $0x0,-0x18(%rbp)
je     119a <splitpath+0x6a>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x30(%rbp),%rdx
call   1030 <qe_pstrcpy@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<splitpath>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8,%rbp
mov    %ecx,%r14d
mov    %rdx,%r13
mov    %esi,%r12d
mov    %rdi,%rbx
mov    %r8,%rdi
call   1050 <get_basename@plt>
mov    %rax,%r15
test   %rbx,%rbx
je     116d <splitpath+0x3d>
mov    %r15d,%ecx
sub    %ebp,%ecx
mov    %rbx,%rdi
mov    %r12d,%esi
mov    %rbp,%rdx
call   1040 <qe_pstrncpy@plt>
test   %r13,%r13
je     118e <splitpath+0x5e>
mov    %r13,%rdi
mov    %r14d,%esi
mov    %r15,%rdx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <qe_pstrcpy@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @splitpath(i8* %0, i32 %1, i8* %2, i32 %3, i8* %4) {
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i8*
store i8* %0, i8** %6
store i32 %1, i32* %7
store i8* %2, i8** %8
store i32 %3, i32* %9
store i8* %4, i8** %10
%12 = load i8*, i8** %10
%13 = call i8* @get_basename(i8* %12)
store i8* %13, i8** %11
%14 = load i8*, i8** %6
%15 = icmp ne i8* %14, null
br i1 %15, label %16, label %27
16: ; preds = %5
%17 = load i8*, i8** %6
%18 = load i32, i32* %7
%19 = load i8*, i8** %10
%20 = load i8*, i8** %11
%21 = load i8*, i8** %10
%22 = ptrtoint i8* %20 to i64
%23 = ptrtoint i8* %21 to i64
%24 = sub i64 %22, %23
%25 = trunc i64 %24 to i32
%26 = call i32 @qe_pstrncpy(i8* %17, i32 %18, i8* %19, i32 %25)
br label %27
27: ; preds = %16, %5
%28 = load i8*, i8** %8
%29 = icmp ne i8* %28, null
br i1 %29, label %30, label %35
30: ; preds = %27
%31 = load i8*, i8** %8
%32 = load i32, i32* %9
%33 = load i8*, i8** %11
%34 = call i32 @qe_pstrcpy(i8* %31, i32 %32, i8* %33)
br label %35
35: ; preds = %30, %27
ret void
}

LLVM IR (-O2):
define void @splitpath(i8* %0, i32 %1, i8* %2, i32 %3, i8* %4) {
%6 = tail call i8* @get_basename(i8* %4)
%7 = icmp eq i8* %0, null
br i1 %7, label %14, label %8
8: ; preds = %5
%9 = ptrtoint i8* %6 to i64
%10 = ptrtoint i8* %4 to i64
%11 = sub i64 %9, %10
%12 = trunc i64 %11 to i32
%13 = tail call i32 @qe_pstrncpy(i8* %0, i32 %1, i8* %4, i32 %12)
br label %14
14: ; preds = %8, %5
%15 = icmp eq i8* %2, null
br i1 %15, label %18, label %16
16: ; preds = %14
%17 = tail call i32 @qe_pstrcpy(i8* %2, i32 %3, i8* %6)
br label %18
18: ; preds = %16, %14
ret void
}