#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 */
typedef int /*<<< orphan*/ cFilename;
typedef int /*<<< orphan*/ cDirectory;

/* Variables and functions */
int /*<<< orphan*/ strncpyz(char *, char *, size_t);
char *strrchr(char *, char);
char *parsePath(char *pcPath, size_t iDirSize, char **ppcDirectory,
                size_t iFnamSize, char **ppcFilename) {
  char cDirectory[256], cFilename[256];
  char *pcSep;
  if (ppcDirectory && *ppcDirectory) {
    *(*ppcDirectory) = '\0';
    if (pcPath && *pcPath)
      ;
    {
      if ((pcSep = strrchr(pcPath, '/'))) {
        strncpyz(cDirectory, pcPath,
                 ((pcSep - pcPath) < sizeof(cDirectory) - 1
                      ? (pcSep - pcPath)
                      : sizeof(cDirectory) - 1));
        strncpyz(cFilename, ++pcSep, sizeof(cFilename) - 1);
      } else {
        strncpyz(cFilename, ++pcSep, sizeof(cFilename) - 1);
      }
    }
    strncpyz(*ppcDirectory, cDirectory, iDirSize);
    if (ppcFilename && *ppcFilename) {
      strncpyz(*ppcFilename, cFilename, iFnamSize);
    }
    return *ppcDirectory;
  }
  return NULL;
}


x86 assembly (clang, -O0):
<parsePath>:
push   %rbp
mov    %rsp,%rbp
sub    $0x250,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     12bb <parsePath+0x19b>
mov    -0x20(%rbp),%rax
cmpq   $0x0,(%rax)
je     12bb <parsePath+0x19b>
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
movb   $0x0,(%rax)
cmpq   $0x0,-0x10(%rbp)
je     1182 <parsePath+0x62>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1182 <parsePath+0x62>
jmp    1182 <parsePath+0x62>
mov    -0x10(%rbp),%rdi
mov    $0x2f,%esi
call   1040 <strrchr@plt>
mov    %rax,-0x238(%rbp)
cmp    $0x0,%rax
je     1241 <parsePath+0x121>
lea    -0x130(%rbp),%rax
mov    %rax,-0x248(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x240(%rbp)
mov    -0x238(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
cmp    $0xff,%rax
jae    11ee <parsePath+0xce>
mov    -0x238(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
mov    %rax,-0x250(%rbp)
jmp    11ff <parsePath+0xdf>
mov    $0xff,%eax
mov    %rax,-0x250(%rbp)
jmp    11ff <parsePath+0xdf>
mov    -0x240(%rbp),%rsi
mov    -0x248(%rbp),%rdi
mov    -0x250(%rbp),%rdx
call   1030 <strncpyz@plt>
lea    -0x230(%rbp),%rdi
mov    -0x238(%rbp),%rsi
add    $0x1,%rsi
mov    %rsi,-0x238(%rbp)
mov    $0xff,%edx
call   1030 <strncpyz@plt>
jmp    1264 <parsePath+0x144>
lea    -0x230(%rbp),%rdi
mov    -0x238(%rbp),%rsi
add    $0x1,%rsi
mov    %rsi,-0x238(%rbp)
mov    $0xff,%edx
call   1030 <strncpyz@plt>
mov    -0x20(%rbp),%rax
mov    (%rax),%rdi
lea    -0x130(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1030 <strncpyz@plt>
cmpq   $0x0,-0x30(%rbp)
je     12ab <parsePath+0x18b>
mov    -0x30(%rbp),%rax
cmpq   $0x0,(%rax)
je     12ab <parsePath+0x18b>
mov    -0x30(%rbp),%rax
mov    (%rax),%rdi
lea    -0x230(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1030 <strncpyz@plt>
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x8(%rbp)
jmp    12c3 <parsePath+0x1a3>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x250,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parsePath>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x208,%rsp
test   %rdx,%rdx
je     118a <parsePath+0x6a>
mov    %rdx,%r13
mov    (%rdx),%rax
test   %rax,%rax
je     118a <parsePath+0x6a>
mov    %r8,%r15
mov    %rcx,%r14
mov    %rsi,%r12
mov    %rdi,%rbp
movb   $0x0,(%rax)
mov    $0x2f,%esi
call   1040 <strrchr@plt>
test   %rax,%rax
je     118e <parsePath+0x6e>
mov    %rax,%rbx
sub    %rbp,%rax
cmp    $0xff,%rax
mov    $0xff,%edx
cmovb  %rax,%rdx
lea    0x100(%rsp),%rdi
mov    %rbp,%rsi
call   1030 <strncpyz@plt>
add    $0x1,%rbx
jmp    1193 <parsePath+0x73>
xor    %eax,%eax
jmp    11d3 <parsePath+0xb3>
mov    $0x1,%ebx
mov    %rsp,%rdi
mov    $0xff,%edx
mov    %rbx,%rsi
call   1030 <strncpyz@plt>
mov    0x0(%r13),%rdi
lea    0x100(%rsp),%rsi
mov    %r12,%rdx
call   1030 <strncpyz@plt>
test   %r15,%r15
je     11cf <parsePath+0xaf>
mov    (%r15),%rdi
test   %rdi,%rdi
je     11cf <parsePath+0xaf>
mov    %rsp,%rsi
mov    %r14,%rdx
call   1030 <strncpyz@plt>
mov    0x0(%r13),%rax
add    $0x208,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i8* @parsePath(i8* %0, i64 %1, i8** %2, i64 %3, i8** %4) {
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i8**
%10 = alloca i64
%11 = alloca i8**
%12 = alloca [256 x i8]
%13 = alloca [256 x i8]
%14 = alloca i8*
store i8* %0, i8** %7
store i64 %1, i64* %8
store i8** %2, i8*** %9
store i64 %3, i64* %10
store i8** %4, i8*** %11
%15 = load i8**, i8*** %9
%16 = icmp ne i8** %15, null
br i1 %16, label %17, label %85
17: ; preds = %5
%18 = load i8**, i8*** %9
%19 = load i8*, i8** %18
%20 = icmp ne i8* %19, null
br i1 %20, label %21, label %85
21: ; preds = %17
%22 = load i8**, i8*** %9
%23 = load i8*, i8** %22
store i8 0, i8* %23
%24 = load i8*, i8** %7
%25 = icmp ne i8* %24, null
br i1 %25, label %26, label %32
26: ; preds = %21
%27 = load i8*, i8** %7
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %32
31: ; preds = %26
br label %32
32: ; preds = %31, %26, %21
%33 = load i8*, i8** %7
%34 = call i8* @strrchr(i8* %33, i8 signext 47)
store i8* %34, i8** %14
%35 = icmp ne i8* %34, null
br i1 %35, label %36, label %59
36: ; preds = %32
%37 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%38 = load i8*, i8** %7
%39 = load i8*, i8** %14
%40 = load i8*, i8** %7
%41 = ptrtoint i8* %39 to i64
%42 = ptrtoint i8* %40 to i64
%43 = sub i64 %41, %42
%44 = icmp ult i64 %43, 255
br i1 %44, label %45, label %51
45: ; preds = %36
%46 = load i8*, i8** %14
%47 = load i8*, i8** %7
%48 = ptrtoint i8* %46 to i64
%49 = ptrtoint i8* %47 to i64
%50 = sub i64 %48, %49
br label %52
51: ; preds = %36
br label %52
52: ; preds = %51, %45
%53 = phi i64 [ %50, %45 ], [ 255, %51 ]
%54 = call i32 @strncpyz(i8* %37, i8* %38, i64 %53)
%55 = getelementptr inbounds [256 x i8], [256 x i8]* %13, i64 0, i64 0
%56 = load i8*, i8** %14
%57 = getelementptr inbounds i8, i8* %56, i32 1
store i8* %57, i8** %14
%58 = call i32 @strncpyz(i8* %55, i8* %57, i64 255)
br label %64
59: ; preds = %32
%60 = getelementptr inbounds [256 x i8], [256 x i8]* %13, i64 0, i64 0
%61 = load i8*, i8** %14
%62 = getelementptr inbounds i8, i8* %61, i32 1
store i8* %62, i8** %14
%63 = call i32 @strncpyz(i8* %60, i8* %62, i64 255)
br label %64
64: ; preds = %59, %52
%65 = load i8**, i8*** %9
%66 = load i8*, i8** %65
%67 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%68 = load i64, i64* %8
%69 = call i32 @strncpyz(i8* %66, i8* %67, i64 %68)
%70 = load i8**, i8*** %11
%71 = icmp ne i8** %70, null
br i1 %71, label %72, label %82
72: ; preds = %64
%73 = load i8**, i8*** %11
%74 = load i8*, i8** %73
%75 = icmp ne i8* %74, null
br i1 %75, label %76, label %82
76: ; preds = %72
%77 = load i8**, i8*** %11
%78 = load i8*, i8** %77
%79 = getelementptr inbounds [256 x i8], [256 x i8]* %13, i64 0, i64 0
%80 = load i64, i64* %10
%81 = call i32 @strncpyz(i8* %78, i8* %79, i64 %80)
br label %82
82: ; preds = %76, %72, %64
%83 = load i8**, i8*** %9
%84 = load i8*, i8** %83
store i8* %84, i8** %6
br label %86
85: ; preds = %17, %5
store i8* null, i8** %6
br label %86
86: ; preds = %85, %82
%87 = load i8*, i8** %6
ret i8* %87
}

LLVM IR (-O2):
define i8* @parsePath(i8* %0, i64 %1, i8** %2, i64 %3, i8** %4) {
%6 = alloca [256 x i8]
%7 = alloca [256 x i8]
%8 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%9 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%10 = icmp eq i8** %2, null
br i1 %10, label %38, label %11
11: ; preds = %5
%12 = load i8*, i8** %2
%13 = icmp eq i8* %12, null
br i1 %13, label %38, label %14
14: ; preds = %11
store i8 0, i8* %12
%15 = tail call i8* @strrchr(i8* dereferenceable(1) %0, i8 signext 47)
%16 = icmp eq i8* %15, null
br i1 %16, label %25, label %17
17: ; preds = %14
%18 = ptrtoint i8* %15 to i64
%19 = ptrtoint i8* %0 to i64
%20 = sub i64 %18, %19
%21 = icmp ult i64 %20, 255
%22 = select i1 %21, i64 %20, i64 255
%23 = call i32 @strncpyz(i8* %8, i8* %0, i64 %22)
%24 = getelementptr inbounds i8, i8* %15, i64 1
br label %25
25: ; preds = %14, %17
%26 = phi i8* [ %24, %17 ], [ inttoptr (i64 1 to i8*), %14 ]
%27 = call i32 @strncpyz(i8* %9, i8* %26, i64 255)
%28 = load i8*, i8** %2
%29 = call i32 @strncpyz(i8* %28, i8* %8, i64 %1)
%30 = icmp eq i8** %4, null
br i1 %30, label %36, label %31
31: ; preds = %25
%32 = load i8*, i8** %4
%33 = icmp eq i8* %32, null
br i1 %33, label %36, label %34
34: ; preds = %31
%35 = call i32 @strncpyz(i8* %32, i8* %9, i64 %3)
br label %36
36: ; preds = %34, %31, %25
%37 = load i8*, i8** %2
br label %38
38: ; preds = %5, %11, %36
%39 = phi i8* [ %37, %36 ], [ null, %11 ], [ null, %5 ]
ret i8* %39
}