#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*/ assert(int);
int /*<<< orphan*/ get_subdirectory(char *, char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sprintf(char *, char *, ...);
scalar_t__ strcmp(char *, char *);
void test_subdirectory() {
  char directory[512];
  char subdirectory[512];
  char reference[512];
  printf("test_subdirectory...");
  subdirectory[0] = 0;
  sprintf(directory, "%s", "/home/username/develop/myproject");
  get_subdirectory(directory, subdirectory);
  sprintf(reference, "myproject");
  assert(strcmp(subdirectory, reference) == 0);
  subdirectory[0] = 0;
  sprintf(directory, "%s", "/home/username/develop/myproject/");
  get_subdirectory(directory, subdirectory);
  sprintf(reference, "myproject");
  assert(strcmp(subdirectory, reference) == 0);
  subdirectory[0] = 0;
  sprintf(directory, "%s", "myproject");
  get_subdirectory(directory, subdirectory);
  sprintf(reference, "myproject");
  assert(strcmp(subdirectory, reference) == 0);
  printf("Ok\n");
}


x86 assembly (clang, -O0):
<test_subdirectory>:
push   %rbp
mov    %rsp,%rbp
sub    $0x600,%rsp
lea    0xe9e(%rip),%rdi
call   1040 <printf@plt>
movb   $0x0,-0x400(%rbp)
lea    -0x200(%rbp),%rdi
lea    0xe99(%rip),%rsi
lea    0xe95(%rip),%rdx
mov    $0x0,%al
call   1070 <sprintf@plt>
lea    -0x200(%rbp),%rdi
lea    -0x400(%rbp),%rsi
call   1030 <get_subdirectory@plt>
lea    -0x600(%rbp),%rdi
lea    0xe84(%rip),%rsi
mov    $0x0,%al
call   1070 <sprintf@plt>
lea    -0x400(%rbp),%rdi
lea    -0x600(%rbp),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
movb   $0x0,-0x400(%rbp)
lea    -0x200(%rbp),%rdi
lea    0xe2a(%rip),%rsi
lea    0xe47(%rip),%rdx
mov    $0x0,%al
call   1070 <sprintf@plt>
lea    -0x200(%rbp),%rdi
lea    -0x400(%rbp),%rsi
call   1030 <get_subdirectory@plt>
lea    -0x600(%rbp),%rdi
lea    0xe15(%rip),%rsi
mov    $0x0,%al
call   1070 <sprintf@plt>
lea    -0x400(%rbp),%rdi
lea    -0x600(%rbp),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
movb   $0x0,-0x400(%rbp)
lea    -0x200(%rbp),%rdi
lea    0xdbb(%rip),%rsi
lea    0xdce(%rip),%rdx
mov    $0x0,%al
call   1070 <sprintf@plt>
lea    -0x200(%rbp),%rdi
lea    -0x400(%rbp),%rsi
call   1030 <get_subdirectory@plt>
lea    -0x600(%rbp),%rdi
lea    0xda6(%rip),%rsi
mov    $0x0,%al
call   1070 <sprintf@plt>
lea    -0x400(%rbp),%rdi
lea    -0x600(%rbp),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
lea    0xda0(%rip),%rdi
call   1040 <printf@plt>
add    $0x600,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_subdirectory>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x608,%rsp
lea    0xe9b(%rip),%rdi
call   1050 <printf@plt>
movb   $0x0,0x400(%rsp)
movups 0xe9c(%rip),%xmm0
movaps %xmm0,(%rsp)
movups 0xea1(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movb   $0x0,0x20(%rsp)
mov    %rsp,%r14
lea    0x400(%rsp),%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <get_subdirectory@plt>
movabs $0x63656a6f7270796d,%r12
6a 65 63
mov    %r12,0x200(%rsp)
movw   $0x74,0x208(%rsp)
lea    0x200(%rsp),%r15
mov    %rbx,%rdi
mov    %r15,%rsi
call   1060 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1070 <assert@plt>
movb   $0x0,0x400(%rsp)
movups 0xe46(%rip),%xmm0
movaps %xmm0,(%rsp)
movups 0xe4b(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movw   $0x2f,0x20(%rsp)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <get_subdirectory@plt>
mov    %r12,0x200(%rsp)
movw   $0x74,0x208(%rsp)
mov    %rbx,%rdi
mov    %r15,%rsi
call   1060 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1070 <assert@plt>
movb   $0x0,0x400(%rsp)
mov    %r12,(%rsp)
movw   $0x74,0x8(%rsp)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <get_subdirectory@plt>
mov    %r12,0x200(%rsp)
movw   $0x74,0x208(%rsp)
mov    %rbx,%rdi
mov    %r15,%rsi
call   1060 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1070 <assert@plt>
lea    0xdcb(%rip),%rdi
call   1030 <puts@plt>
add    $0x608,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [21 x i8] c"test_subdirectory...\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [33 x i8] c"/home/username/develop/myproject\00"
@.str.3 = [10 x i8] c"myproject\00"
@.str.4 = [34 x i8] c"/home/username/develop/myproject/\00"
@.str.5 = [4 x i8] c"Ok\0A\00"
define void @test_subdirectory() {
%1 = alloca [512 x i8]
%2 = alloca [512 x i8]
%3 = alloca [512 x i8]
%4 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%5 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
store i8 0, i8* %5
%6 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%7 = call i32 (i8*, i8*, ...) @sprintf(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
%8 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%9 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%10 = call i32 @get_subdirectory(i8* %8, i8* %9)
%11 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%12 = call i32 (i8*, i8*, ...) @sprintf(i8* %11, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%13 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%14 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%15 = call i64 @strcmp(i8* %13, i8* %14)
%16 = icmp eq i64 %15, 0
%17 = zext i1 %16 to i32
%18 = call i32 @assert(i32 %17)
%19 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
store i8 0, i8* %19
%20 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%21 = call i32 (i8*, i8*, ...) @sprintf(i8* %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0))
%22 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%23 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%24 = call i32 @get_subdirectory(i8* %22, i8* %23)
%25 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%26 = call i32 (i8*, i8*, ...) @sprintf(i8* %25, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%27 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%28 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%29 = call i64 @strcmp(i8* %27, i8* %28)
%30 = icmp eq i64 %29, 0
%31 = zext i1 %30 to i32
%32 = call i32 @assert(i32 %31)
%33 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
store i8 0, i8* %33
%34 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%35 = call i32 (i8*, i8*, ...) @sprintf(i8* %34, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%36 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%37 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%38 = call i32 @get_subdirectory(i8* %36, i8* %37)
%39 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%40 = call i32 (i8*, i8*, ...) @sprintf(i8* %39, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%41 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%42 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%43 = call i64 @strcmp(i8* %41, i8* %42)
%44 = icmp eq i64 %43, 0
%45 = zext i1 %44 to i32
%46 = call i32 @assert(i32 %45)
%47 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [21 x i8] c"test_subdirectory...\00"
@.str.2 = [33 x i8] c"/home/username/develop/myproject\00"
@.str.3 = [10 x i8] c"myproject\00"
@.str.4 = [34 x i8] c"/home/username/develop/myproject/\00"
@str = [3 x i8] c"Ok\00"
define void @test_subdirectory() {
%1 = alloca [512 x i8]
%2 = alloca [512 x i8]
%3 = alloca [512 x i8]
%4 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%7 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
store i8 0, i8* %5
%8 = call i32 @get_subdirectory(i8* %4, i8* %5)
%9 = call i64 @strcmp(i8* %5, i8* %6)
%10 = icmp eq i64 %9, 0
%11 = zext i1 %10 to i32
%12 = call i32 @assert(i32 %11)
store i8 0, i8* %5
%13 = call i32 @get_subdirectory(i8* %4, i8* %5)
%14 = call i64 @strcmp(i8* %5, i8* %6)
%15 = icmp eq i64 %14, 0
%16 = zext i1 %15 to i32
%17 = call i32 @assert(i32 %16)
store i8 0, i8* %5
%18 = call i32 @get_subdirectory(i8* %4, i8* %5)
%19 = call i64 @strcmp(i8* %5, i8* %6)
%20 = icmp eq i64 %19, 0
%21 = zext i1 %20 to i32
%22 = call i32 @assert(i32 %21)
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str, i64 0, i64 0))
ret void
}