#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 *alloca(scalar_t__);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strlen(char *);
char *strrchr(char *, char);
void split_fname(char *_fname, char *path, char *name, char *ext) {
  char *fname = alloca(strlen(_fname) + 1);
  char *tmp;
  strcpy(fname, _fname);
  tmp = strrchr(fname, '.');
  if (!tmp)
    *ext = 0;
  else {
    strcpy(ext, tmp);
    *tmp = 0;
  }
  tmp = strrchr(fname, '/');
  if (!tmp) {
    strcpy(name, fname);
    *fname = 0;
  } else {
    strcpy(name, tmp + 1);
    tmp[1] = 0;
  }
  if (!*fname)
    strcpy(path, "./");
  else
    strcpy(path, fname);
}


x86 assembly (clang, -O0):
<split_fname>:
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    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rdi
add    $0x1,%rdi
call   1060 <alloca@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x28(%rbp),%rdi
mov    $0x2e,%esi
call   1050 <strrchr@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    11a7 <split_fname+0x67>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
jmp    11bb <split_fname+0x7b>
mov    -0x20(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x30(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x28(%rbp),%rdi
mov    $0x2f,%esi
call   1050 <strrchr@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    11f1 <split_fname+0xb1>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x28(%rbp),%rax
movb   $0x0,(%rax)
jmp    120a <split_fname+0xca>
mov    -0x18(%rbp),%rdi
mov    -0x30(%rbp),%rsi
add    $0x1,%rsi
call   1030 <strcpy@plt>
mov    -0x30(%rbp),%rax
movb   $0x0,0x1(%rax)
mov    -0x28(%rbp),%rax
cmpb   $0x0,(%rax)
jne    122c <split_fname+0xec>
mov    -0x10(%rbp),%rdi
lea    0xdde(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1239 <split_fname+0xf9>
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1030 <strcpy@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<split_fname>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rcx,%r12
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%rbx
call   1040 <strlen@plt>
lea    0x1(%rax),%rdi
call   1060 <alloca@plt>
mov    %rax,%r13
mov    %rax,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    %r13,%rdi
mov    $0x2e,%esi
call   1050 <strrchr@plt>
test   %rax,%rax
je     1194 <split_fname+0x54>
mov    %rax,%rbx
mov    %r12,%rdi
mov    %rax,%rsi
call   1030 <strcpy@plt>
mov    %rbx,%r12
movb   $0x0,(%r12)
mov    %r13,%rdi
mov    $0x2f,%esi
call   1050 <strrchr@plt>
test   %rax,%rax
je     11d0 <split_fname+0x90>
mov    %rax,%rbx
mov    %rax,%rsi
add    $0x1,%rsi
mov    %r15,%rdi
call   1030 <strcpy@plt>
movb   $0x0,0x1(%rbx)
cmpb   $0x0,0x0(%r13)
je     11e0 <split_fname+0xa0>
mov    %r14,%rdi
mov    %r13,%rsi
jmp    11ea <split_fname+0xaa>
mov    %r15,%rdi
mov    %r13,%rsi
call   1030 <strcpy@plt>
movb   $0x0,0x0(%r13)
lea    0xe19(%rip),%rsi
mov    %r14,%rdi
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1030 <strcpy@plt>

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

LLVM IR (-O2):
@.str = [3 x i8] c"./\00"
define void @split_fname(i8* %0, i8* %1, i8* %2, i8* %3) {
%5 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%6 = add nsw i64 %5, 1
%7 = tail call i8* @alloca(i64 %6)
%8 = tail call i32 @strcpy(i8* %7, i8* %0)
%9 = tail call i8* @strrchr(i8* dereferenceable(1) %7, i8 signext 46)
%10 = icmp eq i8* %9, null
br i1 %10, label %13, label %11
11: ; preds = %4
%12 = tail call i32 @strcpy(i8* %3, i8* %9)
br label %13
13: ; preds = %4, %11
%14 = phi i8* [ %9, %11 ], [ %3, %4 ]
store i8 0, i8* %14
%15 = tail call i8* @strrchr(i8* dereferenceable(1) %7, i8 signext 47)
%16 = icmp eq i8* %15, null
br i1 %16, label %17, label %19
17: ; preds = %13
%18 = tail call i32 @strcpy(i8* %2, i8* %7)
store i8 0, i8* %7
br label %24
19: ; preds = %13
%20 = getelementptr inbounds i8, i8* %15, i64 1
%21 = tail call i32 @strcpy(i8* %2, i8* %20)
store i8 0, i8* %20
%22 = load i8, i8* %7
%23 = icmp eq i8 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %17, %19
%25 = tail call i32 @strcpy(i8* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %28
26: ; preds = %19
%27 = tail call i32 @strcpy(i8* %1, i8* %7)
br label %28
28: ; preds = %26, %24
ret void
}