#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 *, char *, char *);
scalar_t__ strlen(char *);
char *svz_malloc(scalar_t__);
char *svz_file_path(char *path, char *file) {
  char *full;
  if (file == NULL)
    return NULL;
  full = svz_malloc((path ? strlen(path) + 1 : 0) + strlen(file) + 1);
  sprintf(full, "%s%s%s", path ? path : "", path ? "/" : "", file);
  return full;
}


x86 assembly (clang, -O0):
<svz_file_path>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1158 <svz_file_path+0x28>
movq   $0x0,-0x8(%rbp)
jmp    1213 <svz_file_path+0xe3>
cmpq   $0x0,-0x10(%rbp)
je     1179 <svz_file_path+0x49>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1184 <svz_file_path+0x54>
xor    %eax,%eax
mov    %rax,-0x28(%rbp)
jmp    1184 <svz_file_path+0x54>
mov    -0x28(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x38(%rbp),%rdi
add    %rax,%rdi
add    $0x1,%rdi
call   1040 <svz_malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11c9 <svz_file_path+0x99>
mov    -0x10(%rbp),%rax
mov    %rax,-0x40(%rbp)
jmp    11d9 <svz_file_path+0xa9>
lea    0xe38(%rip),%rax
mov    %rax,-0x40(%rbp)
jmp    11d9 <svz_file_path+0xa9>
mov    -0x30(%rbp),%rdi
mov    -0x40(%rbp),%rdx
mov    -0x10(%rbp),%rsi
lea    0xe1c(%rip),%rcx
lea    0xe14(%rip),%rax
cmp    $0x0,%rsi
cmovne %rax,%rcx
mov    -0x18(%rbp),%r8
lea    0xdfa(%rip),%rsi
call   1050 <sprintf@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<svz_file_path>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %rsi,%rsi
je     1160 <svz_file_path+0x30>
mov    %rsi,%r12
mov    %rdi,%r14
test   %rdi,%rdi
je     1164 <svz_file_path+0x34>
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    %rax,%rbx
add    $0x2,%rbx
lea    0xea9(%rip),%r15
jmp    1173 <svz_file_path+0x43>
xor    %ebx,%ebx
jmp    11a1 <svz_file_path+0x71>
mov    $0x1,%ebx
lea    0xe98(%rip),%r15
mov    %r15,%r14
mov    %r12,%rdi
call   1030 <strlen@plt>
add    %rax,%rbx
mov    %rbx,%rdi
call   1040 <svz_malloc@plt>
mov    %rax,%rbx
lea    0xe70(%rip),%rsi
mov    %rax,%rdi
mov    %r14,%rdx
mov    %r15,%rcx
mov    %r12,%r8
call   1050 <sprintf@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

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