#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 */
int /*<<< orphan*/ sprintf(char *, char *, ...);
int strlen(char *);
void stripPath(char *full, char **path, char **fileName) {
  int i;
  int pos = -1;
  for (i = strlen(full) - 1; i >= 0; i--) {
    if (full[i] == '/') {
      pos = i;
      break;
    }
  }
  if (pos != -1) {
    sprintf(*fileName, "%s%c", (full + pos + 1), '\0');
    full[pos + 1] = '\0';
    sprintf(*path, "%s%c", full, '\0');
  } else {
    sprintf(*fileName, "%s%c", full, '\0');
    sprintf(*path, "%c", '\0');
  }
}


x86 assembly (clang, -O0):
<stripPath>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0xffffffff,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
sub    $0x1,%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jl     1187 <stripPath+0x67>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2f,%eax
jne    1174 <stripPath+0x54>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
jmp    1187 <stripPath+0x67>
jmp    1179 <stripPath+0x59>
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
jmp    114a <stripPath+0x2a>
cmpl   $0xffffffff,-0x20(%rbp)
je     11e8 <stripPath+0xc8>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
mov    -0x8(%rbp),%rdx
movslq -0x20(%rbp),%rax
add    %rax,%rdx
add    $0x1,%rdx
lea    0xe52(%rip),%rsi
xor    %ecx,%ecx
mov    $0x0,%al
call   1040 <sprintf@plt>
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0x8(%rbp),%rdx
lea    0xe26(%rip),%rsi
xor    %ecx,%ecx
mov    $0x0,%al
call   1040 <sprintf@plt>
jmp    121a <stripPath+0xfa>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
mov    -0x8(%rbp),%rdx
lea    0xe06(%rip),%rsi
xor    %ecx,%ecx
mov    $0x0,%al
call   1040 <sprintf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xdf1(%rip),%rsi
xor    %edx,%edx
mov    $0x0,%al
call   1040 <sprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stripPath>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%r12
call   1030 <strlen@plt>
mov    %eax,%eax
nopl   0x0(%rax,%rax,1)
test   %eax,%eax
jle    1196 <stripPath+0x76>
lea    -0x1(%rax),%rbx
cmpb   $0x2f,-0x1(%r12,%rax,1)
mov    %rbx,%rax
jne    1140 <stripPath+0x20>
mov    (%r15),%rdi
mov    %ebx,%eax
lea    (%r12,%rax,1),%rdx
add    $0x1,%rdx
lea    0xe99(%rip),%r15
mov    %r15,%rsi
xor    %ecx,%ecx
xor    %eax,%eax
call   1040 <sprintf@plt>
movb   $0x0,0x1(%r12,%rbx,1)
mov    (%r14),%rdi
mov    %r15,%rsi
mov    %r12,%rdx
xor    %ecx,%ecx
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1040 <sprintf@plt>
mov    (%r15),%rdi
lea    0xe60(%rip),%rsi
mov    %r12,%rdx
xor    %ecx,%ecx
xor    %eax,%eax
call   1040 <sprintf@plt>
mov    (%r14),%rax
movw   $0x0,(%rax)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%s%c\00"
@.str.1 = [3 x i8] c"%c\00"
define void @stripPath(i8* %0, i8** %1, i8** %2) {
%4 = alloca i8*
%5 = alloca i8**
%6 = alloca i8**
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %4
store i8** %1, i8*** %5
store i8** %2, i8*** %6
store i32 -1, i32* %8
%9 = load i8*, i8** %4
%10 = call i32 @strlen(i8* %9)
%11 = sub nsw i32 %10, 1
store i32 %11, i32* %7
br label %12
12: ; preds = %26, %3
%13 = load i32, i32* %7
%14 = icmp sge i32 %13, 0
br i1 %14, label %15, label %29
15: ; preds = %12
%16 = load i8*, i8** %4
%17 = load i32, i32* %7
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %16, i64 %18
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %21, 47
br i1 %22, label %23, label %25
23: ; preds = %15
%24 = load i32, i32* %7
store i32 %24, i32* %8
br label %29
25: ; preds = %15
br label %26
26: ; preds = %25
%27 = load i32, i32* %7
%28 = add nsw i32 %27, -1
store i32 %28, i32* %7
br label %12
29: ; preds = %23, %12
%30 = load i32, i32* %8
%31 = icmp ne i32 %30, -1
br i1 %31, label %32, label %50
32: ; preds = %29
%33 = load i8**, i8*** %6
%34 = load i8*, i8** %33
%35 = load i8*, i8** %4
%36 = load i32, i32* %8
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8, i8* %35, i64 %37
%39 = getelementptr inbounds i8, i8* %38, i64 1
%40 = call i32 (i8*, i8*, ...) @sprintf(i8* %34, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %39, i32 0)
%41 = load i8*, i8** %4
%42 = load i32, i32* %8
%43 = add nsw i32 %42, 1
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i8, i8* %41, i64 %44
store i8 0, i8* %45
%46 = load i8**, i8*** %5
%47 = load i8*, i8** %46
%48 = load i8*, i8** %4
%49 = call i32 (i8*, i8*, ...) @sprintf(i8* %47, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %48, i32 0)
br label %58
50: ; preds = %29
%51 = load i8**, i8*** %6
%52 = load i8*, i8** %51
%53 = load i8*, i8** %4
%54 = call i32 (i8*, i8*, ...) @sprintf(i8* %52, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %53, i32 0)
%55 = load i8**, i8*** %5
%56 = load i8*, i8** %55
%57 = call i32 (i8*, i8*, ...) @sprintf(i8* %56, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 0)
br label %58
58: ; preds = %50, %32
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"%s%c\00"
define void @stripPath(i8* %0, i8** nocapture %1, i8** nocapture %2) {
%4 = tail call i32 @strlen(i8* %0)
%5 = zext i32 %4 to i64
br label %6
6: ; preds = %11, %3
%7 = phi i64 [ %8, %11 ], [ %5, %3 ]
%8 = add nsw i64 %7, -1
%9 = trunc i64 %7 to i32
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %25
11: ; preds = %6
%12 = getelementptr inbounds i8, i8* %0, i64 %8
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 47
br i1 %14, label %15, label %6
15: ; preds = %11
%16 = load i8*, i8** %2
%17 = and i64 %8, 4294967295
%18 = getelementptr inbounds i8, i8* %0, i64 %17
%19 = getelementptr inbounds i8, i8* %18, i64 1
%20 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %16, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %19, i32 0)
%21 = and i64 %7, 4294967295
%22 = getelementptr inbounds i8, i8* %0, i64 %21
store i8 0, i8* %22
%23 = load i8*, i8** %1
%24 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %23, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %0, i32 0)
br label %30
25: ; preds = %6
%26 = load i8*, i8** %2
%27 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %26, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %0, i32 0)
%28 = load i8*, i8** %1
store i8 0, i8* %28
%29 = getelementptr i8, i8* %28, i64 1
store i8 0, i8* %29
br label %30
30: ; preds = %25, %15
ret void
}