#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 *getfext(char *);
char *getfname(char *);
int /*<<< orphan*/ strcpy(char *, char const *);
void _splitpath(const char *path, char *drive, char *dir, char *fname,
                char *ext) {
  char *p;
  ext[0] = 0;
  drive[0] = 0;
  strcpy(dir, path);
  p = getfname(dir);
  strcpy(fname, p);
  if (p == dir)
    dir[0] = 0;
  else
    *p = 0;
  p = getfext(fname);
  if (p != NULL) {
    strcpy(ext, p);
    *p = 0;
  }
}


x86 assembly (clang, -O0):
<_splitpath>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x18(%rbp),%rdi
call   1040 <getfname@plt>
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x30(%rbp),%rax
cmp    -0x18(%rbp),%rax
jne    119b <_splitpath+0x6b>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
jmp    11a2 <_splitpath+0x72>
mov    -0x30(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x20(%rbp),%rdi
call   1050 <getfext@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     11ce <_splitpath+0x9e>
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x30(%rbp),%rax
movb   $0x0,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_splitpath>:
push   %r15
push   %r14
push   %rbx
mov    %r8,%r14
mov    %rcx,%r15
mov    %rdx,%rbx
mov    %rdi,%rax
movb   $0x0,(%r8)
movb   $0x0,(%rsi)
mov    %rdx,%rdi
mov    %rax,%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
call   1040 <getfname@plt>
mov    %rax,%rbx
mov    %r15,%rdi
mov    %rax,%rsi
call   1030 <strcpy@plt>
movb   $0x0,(%rbx)
mov    %r15,%rdi
call   1050 <getfext@plt>
test   %rax,%rax
je     118a <_splitpath+0x5a>
mov    %rax,%rbx
mov    %r14,%rdi
mov    %rax,%rsi
call   1030 <strcpy@plt>
movb   $0x0,(%rbx)
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @_splitpath(i8* %0, i8* %1, i8* %2, i8* %3, i8* %4) {
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
store i8* %0, i8** %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i8* %3, i8** %9
store i8* %4, i8** %10
%12 = load i8*, i8** %10
%13 = getelementptr inbounds i8, i8* %12, i64 0
store i8 0, i8* %13
%14 = load i8*, i8** %7
%15 = getelementptr inbounds i8, i8* %14, i64 0
store i8 0, i8* %15
%16 = load i8*, i8** %8
%17 = load i8*, i8** %6
%18 = call i32 @strcpy(i8* %16, i8* %17)
%19 = load i8*, i8** %8
%20 = call i8* @getfname(i8* %19)
store i8* %20, i8** %11
%21 = load i8*, i8** %9
%22 = load i8*, i8** %11
%23 = call i32 @strcpy(i8* %21, i8* %22)
%24 = load i8*, i8** %11
%25 = load i8*, i8** %8
%26 = icmp eq i8* %24, %25
br i1 %26, label %27, label %30
27: ; preds = %5
%28 = load i8*, i8** %8
%29 = getelementptr inbounds i8, i8* %28, i64 0
store i8 0, i8* %29
br label %32
30: ; preds = %5
%31 = load i8*, i8** %11
store i8 0, i8* %31
br label %32
32: ; preds = %30, %27
%33 = load i8*, i8** %9
%34 = call i8* @getfext(i8* %33)
store i8* %34, i8** %11
%35 = load i8*, i8** %11
%36 = icmp ne i8* %35, null
br i1 %36, label %37, label %42
37: ; preds = %32
%38 = load i8*, i8** %10
%39 = load i8*, i8** %11
%40 = call i32 @strcpy(i8* %38, i8* %39)
%41 = load i8*, i8** %11
store i8 0, i8* %41
br label %42
42: ; preds = %37, %32
ret void
}

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