#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*/ printf(char *, char *, char *);
char *strdup(char const *);
void parseName(const char *path) {
  char *p, *dir, *fn;
  if (path == NULL)
    return;
  p = strdup(path);
  dir = p;
  fn = p;
  while (*p != '\0') {
    if (*p == '/') {
      fn = p;
    }
    ++p;
  }
  if (dir != fn) {
    *fn++ = '\0';
  } else {
    dir = ".";
  }
  printf("\tp: %s\n\tf: %s\n", dir, fn);
}


x86 assembly (clang, -O0):
<parseName>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    113c <parseName+0x1c>
jmp    11d6 <parseName+0xb6>
mov    -0x8(%rbp),%rdi
call   1040 <strdup@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1192 <parseName+0x72>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
jne    1181 <parseName+0x61>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1159 <parseName+0x39>
mov    -0x18(%rbp),%rax
cmp    -0x20(%rbp),%rax
je     11b7 <parseName+0x97>
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20(%rbp)
movb   $0x0,(%rax)
jmp    11c2 <parseName+0xa2>
lea    0xe42(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
lea    0xe31(%rip),%rdi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parseName>:
test   %rdi,%rdi
je     1167 <parseName+0x47>
push   %rax
call   1040 <strdup@plt>
mov    %rax,%rdx
mov    %rax,%rdi
jmp    1147 <parseName+0x27>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rdx,%rdi
add    $0x1,%rdx
movzbl (%rdx),%ecx
cmp    $0x2f,%cl
je     1140 <parseName+0x20>
test   %cl,%cl
jne    1143 <parseName+0x23>
cmp    %rdi,%rax
je     1168 <parseName+0x48>
movb   $0x0,(%rdi)
add    $0x1,%rdi
mov    %rax,%rsi
mov    %rdi,%rax
jmp    116f <parseName+0x4f>
ret
lea    0xe91(%rip),%rsi
lea    0xe8c(%rip),%rdi
mov    %rax,%rdx
pop    %rax
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [2 x i8] c".\00"
@.str.1 = [15 x i8] c"\09p: %s\0A\09f: %s\0A\00"
define void @parseName(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = icmp eq i8* %6, null
br i1 %7, label %8, label %9
8: ; preds = %1
br label %41
9: ; preds = %1
%10 = load i8*, i8** %2
%11 = call i8* @strdup(i8* %10)
store i8* %11, i8** %3
%12 = load i8*, i8** %3
store i8* %12, i8** %4
%13 = load i8*, i8** %3
store i8* %13, i8** %5
br label %14
14: ; preds = %26, %9
%15 = load i8*, i8** %3
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %29
19: ; preds = %14
%20 = load i8*, i8** %3
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 47
br i1 %23, label %24, label %26
24: ; preds = %19
%25 = load i8*, i8** %3
store i8* %25, i8** %5
br label %26
26: ; preds = %24, %19
%27 = load i8*, i8** %3
%28 = getelementptr inbounds i8, i8* %27, i32 1
store i8* %28, i8** %3
br label %14
29: ; preds = %14
%30 = load i8*, i8** %4
%31 = load i8*, i8** %5
%32 = icmp ne i8* %30, %31
br i1 %32, label %33, label %36
33: ; preds = %29
%34 = load i8*, i8** %5
%35 = getelementptr inbounds i8, i8* %34, i32 1
store i8* %35, i8** %5
store i8 0, i8* %34
br label %37
36: ; preds = %29
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %4
br label %37
37: ; preds = %36, %33
%38 = load i8*, i8** %4
%39 = load i8*, i8** %5
%40 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %38, i8* %39)
br label %41
41: ; preds = %37, %8
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c".\00"
@.str.1 = [15 x i8] c"\09p: %s\0A\09f: %s\0A\00"
define void @parseName(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %21, label %3
3: ; preds = %1
%4 = tail call i8* @strdup(i8* %0)
br label %5
5: ; preds = %10, %3
%6 = phi i8* [ %4, %3 ], [ %12, %10 ]
%7 = phi i8* [ %4, %3 ], [ %11, %10 ]
%8 = load i8, i8* %6
switch i8 %8, label %10 [
i8 0, label %13
i8 47, label %9
]
9: ; preds = %5
br label %10
10: ; preds = %5, %9
%11 = phi i8* [ %6, %9 ], [ %7, %5 ]
%12 = getelementptr inbounds i8, i8* %6, i64 1
br label %5
13: ; preds = %5
%14 = icmp eq i8* %4, %7
br i1 %14, label %17, label %15
15: ; preds = %13
%16 = getelementptr inbounds i8, i8* %7, i64 1
store i8 0, i8* %7
br label %17
17: ; preds = %13, %15
%18 = phi i8* [ %4, %15 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), %13 ]
%19 = phi i8* [ %16, %15 ], [ %4, %13 ]
%20 = tail call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %18, i8* %19)
br label %21
21: ; preds = %1, %17
ret void
}