#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*/ printf(char *);
int /*<<< orphan*/ relative_install_path(char *, char *, char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, char *);
scalar_t__ strcmp(char *, char *);
scalar_t__ strlen(char *);
void test_relative_install_path() {
  char filename[512];
  char relative[512];
  printf("test_relative_install_path...");
  sprintf(filename, "%s",
          "/home/username/develop/projectname/desktop/somefile.png");
  relative_install_path(filename, relative, "install", "projectname");
  assert(strlen(relative) < strlen(filename));
  assert(strcmp(relative, "desktop/somefile.png") == 0);
  sprintf(filename, "%s",
          "/home/username/develop/projectname/install/somefile.png");
  relative_install_path(filename, relative, "install", "projectname");
  assert(strlen(relative) < strlen(filename));
  assert(strcmp(relative, "install/somefile.png") == 0);
  printf("Ok\n");
}


x86 assembly (clang, -O0):
<test_relative_install_path>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
lea    0xe8e(%rip),%rdi
call   1050 <printf@plt>
lea    -0x200(%rbp),%rdi
lea    0xe99(%rip),%rsi
lea    0xe95(%rip),%rdx
call   1080 <sprintf@plt>
lea    -0x200(%rbp),%rdi
lea    -0x400(%rbp),%rsi
lea    0xeb3(%rip),%rdx
lea    0xeb4(%rip),%rcx
call   1040 <relative_install_path@plt>
lea    -0x400(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x410(%rbp)
lea    -0x200(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    -0x410(%rbp),%rax
cmp    %rcx,%rax
setl   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
lea    -0x400(%rbp),%rdi
lea    0xe4b(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
lea    -0x200(%rbp),%rdi
lea    0xe01(%rip),%rsi
lea    0xe49(%rip),%rdx
call   1080 <sprintf@plt>
lea    -0x200(%rbp),%rdi
lea    -0x400(%rbp),%rsi
lea    0xe1b(%rip),%rdx
lea    0xe1c(%rip),%rcx
call   1040 <relative_install_path@plt>
lea    -0x400(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x408(%rbp)
lea    -0x200(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    -0x408(%rbp),%rax
cmp    %rcx,%rax
setl   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
lea    -0x400(%rbp),%rdi
lea    0xdff(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
lea    0xdf7(%rip),%rdi
call   1050 <printf@plt>
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_relative_install_path>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x408,%rsp
lea    0xe88(%rip),%rdi
call   1060 <printf@plt>
movabs $0x676e702e656c69,%rbp
mov    %rbp,0x30(%rsp)
movups 0xe8b(%rip),%xmm0
movaps %xmm0,(%rsp)
movups 0xe90(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movups 0xe94(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
lea    0xea0(%rip),%r15
lea    0xea1(%rip),%r12
mov    %rsp,%r14
lea    0x200(%rsp),%r13
mov    %r14,%rdi
mov    %r13,%rsi
mov    %r15,%rdx
mov    %r12,%rcx
call   1050 <relative_install_path@plt>
mov    %r13,%rdi
call   1040 <strlen@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1040 <strlen@plt>
xor    %edi,%edi
cmp    %rax,%rbx
setl   %dil
call   1080 <assert@plt>
lea    0xe40(%rip),%rsi
mov    %r13,%rdi
call   1070 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1080 <assert@plt>
mov    %rbp,0x30(%rsp)
movups 0xe47(%rip),%xmm0
movaps %xmm0,(%rsp)
movups 0xe4c(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movups 0xe50(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
mov    %r14,%rdi
mov    %r13,%rsi
mov    %r15,%rdx
mov    %r12,%rcx
call   1050 <relative_install_path@plt>
mov    %r13,%rdi
call   1040 <strlen@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1040 <strlen@plt>
xor    %edi,%edi
cmp    %rax,%rbx
setl   %dil
call   1080 <assert@plt>
lea    0xe15(%rip),%rsi
mov    %r13,%rdi
call   1070 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1080 <assert@plt>
lea    0xe0d(%rip),%rdi
call   1030 <puts@plt>
add    $0x408,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [30 x i8] c"test_relative_install_path...\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [56 x i8] c"/home/username/develop/projectname/desktop/somefile.png\00"
@.str.3 = [8 x i8] c"install\00"
@.str.4 = [12 x i8] c"projectname\00"
@.str.5 = [21 x i8] c"desktop/somefile.png\00"
@.str.6 = [56 x i8] c"/home/username/develop/projectname/install/somefile.png\00"
@.str.7 = [21 x i8] c"install/somefile.png\00"
@.str.8 = [4 x i8] c"Ok\0A\00"
define void @test_relative_install_path() {
%1 = alloca [512 x i8]
%2 = alloca [512 x i8]
%3 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%4 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%5 = call i32 @sprintf(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.2, i64 0, i64 0))
%6 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%7 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%8 = call i32 @relative_install_path(i8* %6, i8* %7, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
%9 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%10 = call i64 @strlen(i8* %9)
%11 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%12 = call i64 @strlen(i8* %11)
%13 = icmp slt i64 %10, %12
%14 = zext i1 %13 to i32
%15 = call i32 @assert(i32 %14)
%16 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%17 = call i64 @strcmp(i8* %16, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
%19 = zext i1 %18 to i32
%20 = call i32 @assert(i32 %19)
%21 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%22 = call i32 @sprintf(i8* %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.6, i64 0, i64 0))
%23 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%24 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%25 = call i32 @relative_install_path(i8* %23, i8* %24, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
%26 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%27 = call i64 @strlen(i8* %26)
%28 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%29 = call i64 @strlen(i8* %28)
%30 = icmp slt i64 %27, %29
%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
%34 = call i64 @strcmp(i8* %33, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0))
%35 = icmp eq i64 %34, 0
%36 = zext i1 %35 to i32
%37 = call i32 @assert(i32 %36)
%38 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [30 x i8] c"test_relative_install_path...\00"
@.str.2 = [56 x i8] c"/home/username/develop/projectname/desktop/somefile.png\00"
@.str.3 = [8 x i8] c"install\00"
@.str.4 = [12 x i8] c"projectname\00"
@.str.5 = [21 x i8] c"desktop/somefile.png\00"
@.str.6 = [56 x i8] c"/home/username/develop/projectname/install/somefile.png\00"
@.str.7 = [21 x i8] c"install/somefile.png\00"
@str = [3 x i8] c"Ok\00"
define void @test_relative_install_path() {
%1 = alloca [512 x i8]
%2 = alloca [512 x i8]
%3 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%5 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @relative_install_path(i8* %3, i8* %4, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
%7 = call i64 @strlen(i8* %4)
%8 = call i64 @strlen(i8* %3)
%9 = icmp slt i64 %7, %8
%10 = zext i1 %9 to i32
%11 = call i32 @assert(i32 %10)
%12 = call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
%14 = zext i1 %13 to i32
%15 = call i32 @assert(i32 %14)
%16 = call i32 @relative_install_path(i8* %3, i8* %4, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
%17 = call i64 @strlen(i8* %4)
%18 = call i64 @strlen(i8* %3)
%19 = icmp slt i64 %17, %18
%20 = zext i1 %19 to i32
%21 = call i32 @assert(i32 %20)
%22 = call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
%24 = zext i1 %23 to i32
%25 = call i32 @assert(i32 %24)
%26 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str, i64 0, i64 0))
ret void
}