#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*/ sprintf(char *, char *, char const *, ...);
int strlen(char const *);
char *make_path(char *dest, const char *frt, const char *snd) {
  if (NULL == frt || strlen(frt) == 0) {
    sprintf(dest, "%s", snd);
  } else if (NULL == snd || strlen(snd) == 0) {
    sprintf(dest, "%s", frt);
  } else {
    if (frt[strlen(frt) - 1] == '/') {
      sprintf(dest, "%s%s", frt, snd);
    } else {
      sprintf(dest, "%s/%s", frt, snd);
    }
  }
  return dest;
}


x86 assembly (clang, -O0):
<make_path>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
xor    %eax,%eax
cmp    -0x10(%rbp),%rax
je     1152 <make_path+0x32>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x0,%eax
jne    116d <make_path+0x4d>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xea7(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
jmp    1213 <make_path+0xf3>
xor    %eax,%eax
cmp    -0x18(%rbp),%rax
je     118b <make_path+0x6b>
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x0,%eax
jne    11a6 <make_path+0x86>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xe6e(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
jmp    120e <make_path+0xee>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2f,%eax
jne    11ef <make_path+0xcf>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
lea    0xe1d(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
jmp    1209 <make_path+0xe9>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
lea    0xe03(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
jmp    120e <make_path+0xee>
jmp    1213 <make_path+0xf3>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<make_path>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rdi,%r15
test   %rsi,%rsi
je     117a <make_path+0x4a>
mov    %rsi,%rbx
mov    %rsi,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
je     117a <make_path+0x4a>
test   %r14,%r14
je     1187 <make_path+0x57>
mov    %r14,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
je     1187 <make_path+0x57>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
cmpb   $0x2f,-0x1(%rax,%rbx,1)
jne    1194 <make_path+0x64>
lea    0xe88(%rip),%rsi
jmp    119b <make_path+0x6b>
mov    %r15,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
jmp    11ab <make_path+0x7b>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
jmp    11ab <make_path+0x7b>
lea    0xe6a(%rip),%rsi
mov    %r15,%rdi
mov    %rbx,%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1050 <sprintf@plt>
mov    %r15,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [5 x i8] c"%s%s\00"
@.str.2 = [6 x i8] c"%s/%s\00"
define i8* @make_path(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%7 = load i8*, i8** %5
%8 = icmp eq i8* null, %7
br i1 %8, label %13, label %9
9: ; preds = %3
%10 = load i8*, i8** %5
%11 = call i32 @strlen(i8* %10)
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %17
13: ; preds = %9, %3
%14 = load i8*, i8** %4
%15 = load i8*, i8** %6
%16 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %15)
br label %50
17: ; preds = %9
%18 = load i8*, i8** %6
%19 = icmp eq i8* null, %18
br i1 %19, label %24, label %20
20: ; preds = %17
%21 = load i8*, i8** %6
%22 = call i32 @strlen(i8* %21)
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %28
24: ; preds = %20, %17
%25 = load i8*, i8** %4
%26 = load i8*, i8** %5
%27 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %25, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %26)
br label %49
28: ; preds = %20
%29 = load i8*, i8** %5
%30 = load i8*, i8** %5
%31 = call i32 @strlen(i8* %30)
%32 = sub nsw i32 %31, 1
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8, i8* %29, i64 %33
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = icmp eq i32 %36, 47
br i1 %37, label %38, label %43
38: ; preds = %28
%39 = load i8*, i8** %4
%40 = load i8*, i8** %5
%41 = load i8*, i8** %6
%42 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %39, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %40, i8* %41)
br label %48
43: ; preds = %28
%44 = load i8*, i8** %4
%45 = load i8*, i8** %5
%46 = load i8*, i8** %6
%47 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %44, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %45, i8* %46)
br label %48
48: ; preds = %43, %38
br label %49
49: ; preds = %48, %24
br label %50
50: ; preds = %49, %13
%51 = load i8*, i8** %4
ret i8* %51
}

LLVM IR (-O2):
@.str.1 = [5 x i8] c"%s%s\00"
@.str.2 = [6 x i8] c"%s/%s\00"
define i8* @make_path(i8* returned %0, i8* %1, i8* %2) {
%4 = icmp eq i8* %1, null
br i1 %4, label %8, label %5
5: ; preds = %3
%6 = tail call i32 @strlen(i8* %1)
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %5, %3
%9 = tail call i8* @strcpy(i8* dereferenceable(1) %0, i8* dereferenceable(1) %2)
br label %28
10: ; preds = %5
%11 = icmp eq i8* %2, null
br i1 %11, label %15, label %12
12: ; preds = %10
%13 = tail call i32 @strlen(i8* %2)
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %12, %10
%16 = tail call i8* @strcpy(i8* dereferenceable(1) %0, i8* %1)
br label %28
17: ; preds = %12
%18 = tail call i32 @strlen(i8* %1)
%19 = add nsw i32 %18, -1
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %1, i64 %20
%22 = load i8, i8* %21
%23 = icmp eq i8 %22, 47
br i1 %23, label %24, label %26
24: ; preds = %17
%25 = tail call i32 (i8*, i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %1, i8* %2)
br label %28
26: ; preds = %17
%27 = tail call i32 (i8*, i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %1, i8* %2)
br label %28
28: ; preds = %15, %26, %24, %8
ret i8* %0
}