#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*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
void Prepend(char *sPathname, char *sFilename) {
  char sTemp[256];
  if (sPathname[strlen(sPathname) - 1] != '/' && sFilename[0] != '/') {
    strcat(sPathname, "/");
  }
  strcpy(sTemp, sPathname);
  strcat(sTemp, sFilename);
  strcpy(sFilename, sTemp);
}


x86 assembly (clang, -O0):
<Prepend>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x118(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x118(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2f,%eax
je     1193 <Prepend+0x63>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
je     1193 <Prepend+0x63>
mov    -0x8(%rbp),%rdi
lea    0xe72(%rip),%rsi
call   1050 <strcat@plt>
lea    -0x110(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x110(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <strcat@plt>
mov    -0x10(%rbp),%rdi
lea    -0x110(%rbp),%rsi
call   1030 <strcpy@plt>
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Prepend>:
push   %r15
push   %r14
push   %rbx
sub    $0x100,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
call   1040 <strlen@plt>
cltq
cmpb   $0x2f,-0x1(%rax,%rbx,1)
je     1165 <Prepend+0x35>
cmpb   $0x2f,(%r14)
je     1165 <Prepend+0x35>
lea    0xea3(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcat@plt>
mov    %rsp,%r15
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    %r15,%rdi
mov    %r14,%rsi
call   1050 <strcat@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1030 <strcpy@plt>
add    $0x100,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c"/\00"
define void @Prepend(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [256 x i8]
store i8* %0, i8** %3
store i8* %1, i8** %4
%6 = load i8*, i8** %3
%7 = load i8*, i8** %3
%8 = call i32 @strlen(i8* %7)
%9 = sub nsw i32 %8, 1
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds i8, i8* %6, i64 %10
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp ne i32 %13, 47
br i1 %14, label %15, label %24
15: ; preds = %2
%16 = load i8*, i8** %4
%17 = getelementptr inbounds i8, i8* %16, i64 0
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp ne i32 %19, 47
br i1 %20, label %21, label %24
21: ; preds = %15
%22 = load i8*, i8** %3
%23 = call i32 @strcat(i8* %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %24
24: ; preds = %21, %15, %2
%25 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%26 = load i8*, i8** %3
%27 = call i32 @strcpy(i8* %25, i8* %26)
%28 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%29 = load i8*, i8** %4
%30 = call i32 @strcat(i8* %28, i8* %29)
%31 = load i8*, i8** %4
%32 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%33 = call i32 @strcpy(i8* %31, i8* %32)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"/\00"
define void @Prepend(i8* %0, i8* %1) {
%3 = alloca [256 x i8]
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%5 = tail call i32 @strlen(i8* %0)
%6 = add nsw i32 %5, -1
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds i8, i8* %0, i64 %7
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 47
br i1 %10, label %16, label %11
11: ; preds = %2
%12 = load i8, i8* %1
%13 = icmp eq i8 %12, 47
br i1 %13, label %16, label %14
14: ; preds = %11
%15 = tail call i32 @strcat(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %16
16: ; preds = %14, %11, %2
%17 = call i32 @strcpy(i8* %4, i8* %0)
%18 = call i32 @strcat(i8* %4, i8* %1)
%19 = call i32 @strcpy(i8* %1, i8* %4)
ret void
}