#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 */
char *Malloc(int);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *);
int strlen(char *);
char *createFullPath(char *firsts, char *seconds) {
  char *fullPath;
  if (firsts == NULL || seconds == NULL) {
    ;
    fullPath = NULL;
  } else {
    fullPath =
        Malloc(sizeof(char) * (strlen(firsts) + 1 + strlen(seconds) + 1));
    sprintf(fullPath, "%s/%s", firsts, seconds);
  }
  return fullPath;
}


x86 assembly (clang, -O0):
<createFullPath>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1156 <createFullPath+0x26>
cmpq   $0x0,-0x10(%rbp)
jne    1163 <createFullPath+0x33>
movq   $0x0,-0x18(%rbp)
jmp    11ae <createFullPath+0x7e>
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
add    %ecx,%eax
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1030 <Malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rcx
lea    0xe57(%rip),%rsi
call   1050 <sprintf@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<createFullPath>:
push   %r15
push   %r14
push   %rbx
xor    %ebx,%ebx
test   %rdi,%rdi
je     1179 <createFullPath+0x49>
mov    %rsi,%r14
test   %rsi,%rsi
je     1179 <createFullPath+0x49>
mov    %rdi,%r15
call   1040 <strlen@plt>
mov    %eax,%ebx
mov    %r14,%rdi
call   1040 <strlen@plt>
lea    (%rbx,%rax,1),%edi
add    $0x2,%edi
call   1030 <Malloc@plt>
mov    %rax,%rbx
lea    0xe95(%rip),%rsi
mov    %rax,%rdi
mov    %r15,%rdx
mov    %r14,%rcx
call   1050 <sprintf@plt>
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [6 x i8] c"%s/%s\00"
define i8* @createFullPath(i8* %0, i8* %1) {
%3 = icmp eq i8* %0, null
%4 = icmp eq i8* %1, null
%5 = or i1 %3, %4
br i1 %5, label %13, label %6
6: ; preds = %2
%7 = tail call i32 @strlen(i8* %0)
%8 = tail call i32 @strlen(i8* %1)
%9 = add i32 %7, 2
%10 = add i32 %9, %8
%11 = tail call i8* @Malloc(i32 %10)
%12 = tail call i32 @sprintf(i8* dereferenceable(1) %11, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %1)
br label %13
13: ; preds = %2, %6
%14 = phi i8* [ %11, %6 ], [ null, %2 ]
ret i8* %14
}