#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 const *);
size_t strlen(char *);
void SCE_String_MergePaths(char *dst, const char *a, const char *b) {
  size_t len;
  strcpy(dst, a);
  len = strlen(dst);
  if (len > 0) {
    if (dst[len - 1] != '/')
      dst[len++] = '/';
  }
  strcpy(&dst[len], b);
}


x86 assembly (clang, -O0):
<SCE_String_MergePaths>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jbe    118e <SCE_String_MergePaths+0x6e>
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rcx
sub    $0x1,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2f,%eax
je     1189 <SCE_String_MergePaths+0x69>
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    %rcx,%rdx
add    $0x1,%rdx
mov    %rdx,-0x20(%rbp)
movb   $0x2f,(%rax,%rcx,1)
jmp    118e <SCE_String_MergePaths+0x6e>
mov    -0x8(%rbp),%rdi
add    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcpy@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SCE_String_MergePaths>:
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rdi,%rbx
call   1030 <strcpy@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
test   %rax,%rax
je     114d <SCE_String_MergePaths+0x2d>
cmpb   $0x2f,-0x1(%rax,%rbx,1)
je     114f <SCE_String_MergePaths+0x2f>
movb   $0x2f,(%rbx,%rax,1)
add    $0x1,%rax
jmp    114f <SCE_String_MergePaths+0x2f>
xor    %eax,%eax
add    %rax,%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <strcpy@plt>

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

LLVM IR (-O2):
define void @SCE_String_MergePaths(i8* %0, i8* %1, i8* %2) {
%4 = tail call i32 @strcpy(i8* %0, i8* %1)
%5 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%6 = icmp eq i64 %5, 0
br i1 %6, label %15, label %7
7: ; preds = %3
%8 = add i64 %5, -1
%9 = getelementptr inbounds i8, i8* %0, i64 %8
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 47
br i1 %11, label %15, label %12
12: ; preds = %7
%13 = add i64 %5, 1
%14 = getelementptr inbounds i8, i8* %0, i64 %5
store i8 47, i8* %14
br label %15
15: ; preds = %7, %12, %3
%16 = phi i64 [ %13, %12 ], [ %5, %7 ], [ 0, %3 ]
%17 = getelementptr inbounds i8, i8* %0, i64 %16
%18 = tail call i32 @strcpy(i8* %17, i8* %2)
ret void
}