#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*/ strcpy(char *, char *);
int /*<<< orphan*/ test_my_dirname(char *, char *);
void my_dirname_suite() {
  char buf[256];
  strcpy(buf, "/foo/bar/baz");
  test_my_dirname(buf, "/foo/bar");
  strcpy(buf, "/foo/bar");
  test_my_dirname(buf, "/foo");
  strcpy(buf, "/foo");
  test_my_dirname(buf, "/");
  strcpy(buf, "/foo/");
  test_my_dirname(buf, "/foo");
  strcpy(buf, "/");
  test_my_dirname(buf, "/");
  strcpy(buf, "foo");
  test_my_dirname(buf, ".");
  strcpy(buf, "foo/bar");
  test_my_dirname(buf, "foo");
  strcpy(buf, "./foo/bar");
  test_my_dirname(buf, "./foo");
  strcpy(buf, "./foo");
  test_my_dirname(buf, ".");
  strcpy(buf, ".");
  test_my_dirname(buf, "..");
}


x86 assembly (clang, -O0):
<my_dirname_suite>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
lea    -0x100(%rbp),%rdi
lea    0xec7(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x100(%rbp),%rdi
lea    0xec8(%rip),%rsi
call   1040 <test_my_dirname@plt>
lea    -0x100(%rbp),%rdi
lea    0xeb5(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x100(%rbp),%rdi
lea    0xeac(%rip),%rsi
call   1040 <test_my_dirname@plt>
lea    -0x100(%rbp),%rdi
lea    0xe99(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x100(%rbp),%rdi
lea    0xe79(%rip),%rsi
call   1040 <test_my_dirname@plt>
lea    -0x100(%rbp),%rdi
lea    0xe62(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x100(%rbp),%rdi
lea    0xe60(%rip),%rsi
call   1040 <test_my_dirname@plt>
lea    -0x100(%rbp),%rdi
lea    0xe40(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x100(%rbp),%rdi
lea    0xe2d(%rip),%rsi
call   1040 <test_my_dirname@plt>
lea    -0x100(%rbp),%rdi
lea    0xe28(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x100(%rbp),%rdi
lea    0xe1a(%rip),%rsi
call   1040 <test_my_dirname@plt>
lea    -0x100(%rbp),%rdi
lea    0xdf8(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x100(%rbp),%rdi
lea    0xdef(%rip),%rsi
call   1040 <test_my_dirname@plt>
lea    -0x100(%rbp),%rdi
lea    0xdd0(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x100(%rbp),%rdi
lea    0xdc7(%rip),%rsi
call   1040 <test_my_dirname@plt>
lea    -0x100(%rbp),%rdi
lea    0xdb4(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x100(%rbp),%rdi
lea    0xda8(%rip),%rsi
call   1040 <test_my_dirname@plt>
lea    -0x100(%rbp),%rdi
lea    0xd95(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x100(%rbp),%rdi
lea    0xd81(%rip),%rsi
call   1040 <test_my_dirname@plt>
add    $0x100,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<my_dirname_suite>:
push   %r15
push   %r14
push   %rbx
sub    $0x100,%rsp
lea    0xecd(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1030 <strcpy@plt>
lea    0xecf(%rip),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <test_my_dirname@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
lea    0xebc(%rip),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <test_my_dirname@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
lea    0xe92(%rip),%r15
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <test_my_dirname@plt>
lea    0xe7c(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <test_my_dirname@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <test_my_dirname@plt>
lea    0xe5e(%rip),%r15
mov    %rbx,%rdi
mov    %r15,%rsi
call   1030 <strcpy@plt>
lea    0xe51(%rip),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <test_my_dirname@plt>
lea    0xe30(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <test_my_dirname@plt>
lea    0xe14(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcpy@plt>
lea    0xe0f(%rip),%r15
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <test_my_dirname@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <test_my_dirname@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
lea    0xde2(%rip),%rsi
mov    %rbx,%rdi
call   1040 <test_my_dirname@plt>
add    $0x100,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [13 x i8] c"/foo/bar/baz\00"
@.str.1 = [9 x i8] c"/foo/bar\00"
@.str.2 = [5 x i8] c"/foo\00"
@.str.3 = [2 x i8] c"/\00"
@.str.4 = [6 x i8] c"/foo/\00"
@.str.5 = [4 x i8] c"foo\00"
@.str.6 = [2 x i8] c".\00"
@.str.7 = [8 x i8] c"foo/bar\00"
@.str.8 = [10 x i8] c"./foo/bar\00"
@.str.9 = [6 x i8] c"./foo\00"
@.str.10 = [3 x i8] c"..\00"
define void @my_dirname_suite() {
%1 = alloca [256 x i8]
%2 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%3 = call i32 @strcpy(i8* %2, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%5 = call i32 @test_my_dirname(i8* %4, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%6 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%7 = call i32 @strcpy(i8* %6, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%8 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%9 = call i32 @test_my_dirname(i8* %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%10 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%11 = call i32 @strcpy(i8* %10, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%12 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%13 = call i32 @test_my_dirname(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%14 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%15 = call i32 @strcpy(i8* %14, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%16 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%17 = call i32 @test_my_dirname(i8* %16, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%18 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%19 = call i32 @strcpy(i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%20 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%21 = call i32 @test_my_dirname(i8* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%22 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%23 = call i32 @strcpy(i8* %22, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%24 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%25 = call i32 @test_my_dirname(i8* %24, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%26 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%27 = call i32 @strcpy(i8* %26, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0))
%28 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%29 = call i32 @test_my_dirname(i8* %28, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%30 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%31 = call i32 @strcpy(i8* %30, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0))
%32 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%33 = call i32 @test_my_dirname(i8* %32, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0))
%34 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%35 = call i32 @strcpy(i8* %34, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0))
%36 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%37 = call i32 @test_my_dirname(i8* %36, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%38 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%39 = call i32 @strcpy(i8* %38, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%40 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%41 = call i32 @test_my_dirname(i8* %40, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [13 x i8] c"/foo/bar/baz\00"
@.str.1 = [9 x i8] c"/foo/bar\00"
@.str.2 = [5 x i8] c"/foo\00"
@.str.3 = [2 x i8] c"/\00"
@.str.4 = [6 x i8] c"/foo/\00"
@.str.5 = [4 x i8] c"foo\00"
@.str.6 = [2 x i8] c".\00"
@.str.7 = [8 x i8] c"foo/bar\00"
@.str.8 = [10 x i8] c"./foo/bar\00"
@.str.9 = [6 x i8] c"./foo\00"
@.str.10 = [3 x i8] c"..\00"
define void @my_dirname_suite() {
%1 = alloca [256 x i8]
%2 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%3 = call i32 @strcpy(i8* %2, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @test_my_dirname(i8* %2, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 @strcpy(i8* %2, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 @test_my_dirname(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%7 = call i32 @strcpy(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 @test_my_dirname(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%9 = call i32 @strcpy(i8* %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%10 = call i32 @test_my_dirname(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 @strcpy(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%12 = call i32 @test_my_dirname(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%13 = call i32 @strcpy(i8* %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%14 = call i32 @test_my_dirname(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%15 = call i32 @strcpy(i8* %2, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0))
%16 = call i32 @test_my_dirname(i8* %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%17 = call i32 @strcpy(i8* %2, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0))
%18 = call i32 @test_my_dirname(i8* %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0))
%19 = call i32 @strcpy(i8* %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0))
%20 = call i32 @test_my_dirname(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%21 = call i32 @strcpy(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%22 = call i32 @test_my_dirname(i8* %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0))
ret void
}