#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*/ test_dirname(char *, char *);
void test_path_dirname(void) {
  test_dirname("/a/b/c", "/a/b");
  test_dirname("/a/b/c/", "/a/b");
  test_dirname("/", "/");
  test_dirname("", "");
  test_dirname("a/b/derp.mp3", "a/b");
  test_dirname("/home", "/");
  test_dirname("/home/andy", "/home");
}


x86 assembly (clang, -O0):
<test_path_dirname>:
push   %rbp
mov    %rsp,%rbp
lea    0xee5(%rip),%rdi
lea    0xee5(%rip),%rsi
call   1030 <test_dirname@plt>
lea    0xede(%rip),%rdi
lea    0xed2(%rip),%rsi
call   1030 <test_dirname@plt>
lea    0xed1(%rip),%rsi
mov    %rsi,%rdi
call   1030 <test_dirname@plt>
lea    0xec3(%rip),%rsi
mov    %rsi,%rdi
call   1030 <test_dirname@plt>
lea    0xeb5(%rip),%rdi
lea    0xea2(%rip),%rsi
call   1030 <test_dirname@plt>
lea    0xeaf(%rip),%rdi
lea    0xe99(%rip),%rsi
call   1030 <test_dirname@plt>
lea    0xea2(%rip),%rdi
lea    0xe95(%rip),%rsi
call   1030 <test_dirname@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_path_dirname>:
push   %r14
push   %rbx
push   %rax
lea    0xee5(%rip),%rdi
lea    0xee5(%rip),%rbx
mov    %rbx,%rsi
call   1030 <test_dirname@plt>
lea    0xedb(%rip),%rdi
mov    %rbx,%rsi
call   1030 <test_dirname@plt>
lea    0xed2(%rip),%r14
mov    %r14,%rdi
mov    %r14,%rsi
call   1030 <test_dirname@plt>
lea    0xec1(%rip),%rdi
mov    %rdi,%rsi
call   1030 <test_dirname@plt>
lea    0xeb3(%rip),%rdi
lea    0xea0(%rip),%rsi
call   1030 <test_dirname@plt>
lea    0xead(%rip),%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <test_dirname@plt>
lea    0xea1(%rip),%rdi
mov    %rbx,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <test_dirname@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"/a/b/c\00"
@.str.1 = [5 x i8] c"/a/b\00"
@.str.2 = [8 x i8] c"/a/b/c/\00"
@.str.3 = [2 x i8] c"/\00"
@.str.4 = [1 x i8] zeroinitializer
@.str.5 = [13 x i8] c"a/b/derp.mp3\00"
@.str.6 = [4 x i8] c"a/b\00"
@.str.7 = [6 x i8] c"/home\00"
@.str.8 = [11 x i8] c"/home/andy\00"
define void @test_path_dirname() {
%1 = call i32 @test_dirname(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%2 = call i32 @test_dirname(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%3 = call i32 @test_dirname(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%4 = call i32 @test_dirname(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i64 0, i64 0))
%5 = call i32 @test_dirname(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%6 = call i32 @test_dirname(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%7 = call i32 @test_dirname(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"/a/b/c\00"
@.str.1 = [5 x i8] c"/a/b\00"
@.str.2 = [8 x i8] c"/a/b/c/\00"
@.str.3 = [2 x i8] c"/\00"
@.str.4 = [1 x i8] zeroinitializer
@.str.5 = [13 x i8] c"a/b/derp.mp3\00"
@.str.6 = [4 x i8] c"a/b\00"
@.str.7 = [6 x i8] c"/home\00"
@.str.8 = [11 x i8] c"/home/andy\00"
define void @test_path_dirname() {
%1 = tail call i32 @test_dirname(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%2 = tail call i32 @test_dirname(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%3 = tail call i32 @test_dirname(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%4 = tail call i32 @test_dirname(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i64 0, i64 0))
%5 = tail call i32 @test_dirname(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%6 = tail call i32 @test_dirname(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%7 = tail call i32 @test_dirname(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
ret void
}