#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 */
scalar_t__ isalpha(char);
int /*<<< orphan*/ strcat(char *, char *);
char *strchr(char *, char);
char *strcpy(char *, char const *);
int /*<<< orphan*/ strncpy(char *, char *, int);
char *strrchr(char *, char);
void split_filename(const char *pathname, char *path, char *name) {
  char pname[260], *x;
  x = strcpy(pname, pathname);
  ;
  if (isalpha(x[0]) && x[1] == ':' && x[2] == '\\') {
    while ((x = strchr(x, '\\')) != NULL)
      *x = '/';
  }
  if ((x = strrchr(pname, '/')) != NULL) {
    *x = 0;
    if (path)
      strcpy(path, pname);
    if (name)
      strcpy(name, ++x);
  } else {
    if (path)
      *path = 0;
    if (name) {
      strncpy(name, pname, 100);
      name[100 - 1] = 0;
    }
  }
  if (path && *path)
    strcat(path, "/");
  if (path)
    ;
  if (name)
    ;
}


x86 assembly (clang, -O0):
<split_filename>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    -0x120(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1040 <strcpy@plt>
mov    %rax,-0x128(%rbp)
mov    -0x128(%rbp),%rax
movsbl (%rax),%edi
call   1070 <isalpha@plt>
cmp    $0x0,%rax
je     120a <split_filename+0xaa>
mov    -0x128(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x3a,%eax
jne    120a <split_filename+0xaa>
mov    -0x128(%rbp),%rax
movsbl 0x2(%rax),%eax
cmp    $0x5c,%eax
jne    120a <split_filename+0xaa>
jmp    11d4 <split_filename+0x74>
mov    -0x128(%rbp),%rdi
mov    $0x5c,%esi
call   1050 <strchr@plt>
mov    %rax,-0x128(%rbp)
cmp    $0x0,%rax
je     1205 <split_filename+0xa5>
mov    -0x128(%rbp),%rax
movb   $0x2f,(%rax)
jmp    11d4 <split_filename+0x74>
jmp    120a <split_filename+0xaa>
lea    -0x120(%rbp),%rdi
mov    $0x2f,%esi
call   1060 <strrchr@plt>
mov    %rax,-0x128(%rbp)
cmp    $0x0,%rax
je     127c <split_filename+0x11c>
mov    -0x128(%rbp),%rax
movb   $0x0,(%rax)
cmpq   $0x0,-0x10(%rbp)
je     1251 <split_filename+0xf1>
mov    -0x10(%rbp),%rdi
lea    -0x120(%rbp),%rsi
call   1040 <strcpy@plt>
cmpq   $0x0,-0x18(%rbp)
je     1277 <split_filename+0x117>
mov    -0x18(%rbp),%rdi
mov    -0x128(%rbp),%rsi
add    $0x1,%rsi
mov    %rsi,-0x128(%rbp)
call   1040 <strcpy@plt>
jmp    12bb <split_filename+0x15b>
cmpq   $0x0,-0x10(%rbp)
je     128e <split_filename+0x12e>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
cmpq   $0x0,-0x18(%rbp)
je     12b6 <split_filename+0x156>
mov    -0x18(%rbp),%rdi
lea    -0x120(%rbp),%rsi
mov    $0x64,%edx
call   1030 <strncpy@plt>
mov    -0x18(%rbp),%rax
movb   $0x0,0x63(%rax)
jmp    12bb <split_filename+0x15b>
cmpq   $0x0,-0x10(%rbp)
je     12e6 <split_filename+0x186>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     12e6 <split_filename+0x186>
mov    -0x10(%rbp),%rdi
lea    0xd1f(%rip),%rsi
call   1080 <strcat@plt>
cmpq   $0x0,-0x10(%rbp)
je     12f6 <split_filename+0x196>
jmp    12f6 <split_filename+0x196>
cmpq   $0x0,-0x18(%rbp)
je     1306 <split_filename+0x1a6>
jmp    1306 <split_filename+0x1a6>
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<split_filename>:
push   %r15
push   %r14
push   %rbx
sub    $0x110,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rsi
mov    %rsp,%rdi
call   1040 <strcpy@plt>
movsbl (%rsp),%edi
call   1070 <isalpha@plt>
test   %rax,%rax
je     11b7 <split_filename+0x57>
cmpb   $0x3a,0x1(%rsp)
jne    11b7 <split_filename+0x57>
cmpb   $0x5c,0x2(%rsp)
jne    11b7 <split_filename+0x57>
mov    %rsp,%rdi
nopl   0x0(%rax)
mov    $0x5c,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     11b7 <split_filename+0x57>
movb   $0x2f,(%rax)
mov    %rax,%rdi
jmp    11a0 <split_filename+0x40>
mov    %rsp,%rdi
mov    $0x2f,%esi
call   1060 <strrchr@plt>
test   %rax,%rax
je     11f5 <split_filename+0x95>
mov    %rax,%rbx
movb   $0x0,(%rax)
test   %r15,%r15
je     11df <split_filename+0x7f>
mov    %rsp,%rsi
mov    %r15,%rdi
call   1040 <strcpy@plt>
test   %r14,%r14
je     1218 <split_filename+0xb8>
add    $0x1,%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <strcpy@plt>
jmp    1218 <split_filename+0xb8>
test   %r15,%r15
je     11fe <split_filename+0x9e>
movb   $0x0,(%r15)
test   %r14,%r14
je     1218 <split_filename+0xb8>
mov    %rsp,%rsi
mov    %r14,%rdi
mov    $0x64,%edx
call   1030 <strncpy@plt>
movb   $0x0,0x63(%r14)
test   %r15,%r15
je     1232 <split_filename+0xd2>
cmpb   $0x0,(%r15)
je     1232 <split_filename+0xd2>
lea    0xdd6(%rip),%rsi
mov    %r15,%rdi
call   1080 <strcat@plt>
add    $0x110,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [2 x i8] c"/\00"
define void @split_filename(i8* nocapture %0, i8* %1, i8* %2) {
%4 = alloca [260 x i8]
%5 = getelementptr inbounds [260 x i8], [260 x i8]* %4, i64 0, i64 0
%6 = call i8* @strcpy(i8* %5, i8* dereferenceable(1) %0)
%7 = load i8, i8* %5
%8 = call i64 @isalpha(i8 signext %7)
%9 = icmp ne i64 %8, 0
%10 = getelementptr inbounds [260 x i8], [260 x i8]* %4, i64 0, i64 1
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 58
%13 = select i1 %9, i1 %12, i1 false
%14 = getelementptr inbounds [260 x i8], [260 x i8]* %4, i64 0, i64 2
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 92
%17 = select i1 %13, i1 %16, i1 false
br i1 %17, label %18, label %25
18: ; preds = %3
%19 = call i8* @strchr(i8* %5, i8 signext 92)
%20 = icmp eq i8* %19, null
br i1 %20, label %25, label %21
21: ; preds = %18, %21
%22 = phi i8* [ %23, %21 ], [ %19, %18 ]
store i8 47, i8* %22
%23 = call i8* @strchr(i8* %22, i8 signext 92)
%24 = icmp eq i8* %23, null
br i1 %24, label %25, label %21
25: ; preds = %21, %18, %3
%26 = call i8* @strrchr(i8* %5, i8 signext 47)
%27 = icmp eq i8* %26, null
br i1 %27, label %37, label %28
28: ; preds = %25
store i8 0, i8* %26
%29 = icmp eq i8* %1, null
br i1 %29, label %32, label %30
30: ; preds = %28
%31 = call i8* @strcpy(i8* %1, i8* %5)
br label %32
32: ; preds = %30, %28
%33 = icmp eq i8* %2, null
br i1 %33, label %45, label %34
34: ; preds = %32
%35 = getelementptr inbounds i8, i8* %26, i64 1
%36 = call i8* @strcpy(i8* %2, i8* %35)
br label %45
37: ; preds = %25
%38 = icmp eq i8* %1, null
br i1 %38, label %40, label %39
39: ; preds = %37
store i8 0, i8* %1
br label %40
40: ; preds = %39, %37
%41 = icmp eq i8* %2, null
br i1 %41, label %45, label %42
42: ; preds = %40
%43 = call i32 @strncpy(i8* %2, i8* %5, i32 100)
%44 = getelementptr inbounds i8, i8* %2, i64 99
store i8 0, i8* %44
br label %45
45: ; preds = %40, %42, %32, %34
%46 = icmp eq i8* %1, null
br i1 %46, label %52, label %47
47: ; preds = %45
%48 = load i8, i8* %1
%49 = icmp eq i8 %48, 0
br i1 %49, label %52, label %50
50: ; preds = %47
%51 = call i32 @strcat(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %52
52: ; preds = %50, %47, %45
ret void
}