#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*/ exit(int);
scalar_t__ malloc(int);
int /*<<< orphan*/ perror(char *);
char *strdup(char const *);
char *strrchr(char *, char);
void dirAndFil(const char *full, char **dir, char **fil) {
  *dir = strdup(full);
  *fil = strrchr(*dir, '/');
  if (*fil) {
    **fil = '\0';
    (*fil)++;
    *fil = strdup(*fil);
  } else {
    *fil = (char *)malloc(1);
    if (!(*fil)) {
      perror("malloc");
      exit(1);
    }
    **fil = '\0';
  }
}


x86 assembly (clang, -O0):
<dirAndFil>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1070 <strdup@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    $0x2f,%esi
call   1030 <strrchr@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
cmpq   $0x0,(%rax)
je     11d3 <dirAndFil+0x83>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
movb   $0x0,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%rcx
add    $0x1,%rcx
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
call   1070 <strdup@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
jmp    1215 <dirAndFil+0xc5>
mov    $0x1,%edi
call   1040 <malloc@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
cmpq   $0x0,(%rax)
jne    120b <dirAndFil+0xbb>
lea    0xe04(%rip),%rdi
call   1050 <perror@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
movb   $0x0,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dirAndFil>:
push   %r14
push   %rbx
push   %rax
mov    %rdx,%rbx
mov    %rsi,%r14
call   1070 <strdup@plt>
mov    %rax,(%r14)
mov    %rax,%rdi
mov    $0x2f,%esi
call   1030 <strrchr@plt>
mov    %rax,(%rbx)
test   %rax,%rax
je     118e <dirAndFil+0x3e>
movb   $0x0,(%rax)
mov    (%rbx),%rdi
add    $0x1,%rdi
mov    %rdi,(%rbx)
call   1070 <strdup@plt>
mov    %rax,(%rbx)
jmp    11a3 <dirAndFil+0x53>
mov    $0x1,%edi
call   1040 <malloc@plt>
mov    %rax,(%rbx)
test   %rax,%rax
je     11ab <dirAndFil+0x5b>
movb   $0x0,(%rax)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe4e(%rip),%rdi
call   1050 <perror@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

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

LLVM IR (-O2):
@.str = [7 x i8] c"malloc\00"
define void @dirAndFil(i8* nocapture %0, i8** nocapture writeonly %1, i8** nocapture %2) {
%4 = tail call i8* @strdup(i8* %0)
store i8* %4, i8** %1
%5 = tail call i8* @strrchr(i8* dereferenceable(1) %4, i8 signext 47)
store i8* %5, i8** %2
%6 = icmp eq i8* %5, null
br i1 %6, label %11, label %7
7: ; preds = %3
store i8 0, i8* %5
%8 = load i8*, i8** %2
%9 = getelementptr inbounds i8, i8* %8, i64 1
store i8* %9, i8** %2
%10 = tail call i8* @strdup(i8* %9)
store i8* %10, i8** %2
br label %19
11: ; preds = %3
%12 = tail call i64 @malloc(i32 1)
%13 = inttoptr i64 %12 to i8*
store i8* %13, i8** %2
%14 = icmp eq i64 %12, 0
br i1 %14, label %15, label %18
15: ; preds = %11
%16 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%17 = tail call i32 @exit(i32 1)
unreachable
18: ; preds = %11
store i8 0, i8* %13
br label %19
19: ; preds = %18, %7
ret void
}