#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*/ OPENSSL_strlcat(char *, char const *, size_t);
int /*<<< orphan*/ OPENSSL_strlcpy(char *, char const *, size_t);
char *OPENSSL_zalloc(size_t);
int strlen(char const *);
char *mk_file_path(const char *dir, const char *file) {
  char *full_file = NULL;
  size_t full_file_l = 0;
  const char *sep = "";
  sep = "/";
  full_file_l = strlen(dir) + strlen(sep) + strlen(file) + 1;
  full_file = OPENSSL_zalloc(full_file_l);
  if (full_file != NULL) {
    OPENSSL_strlcpy(full_file, dir, full_file_l);
    OPENSSL_strlcat(full_file, sep, full_file_l);
    OPENSSL_strlcat(full_file, file, full_file_l);
  }
  return full_file;
}


x86 assembly (clang, -O0):
<mk_file_path>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
lea    0xe9a(%rip),%rax
mov    %rax,-0x28(%rbp)
lea    0xe8e(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x30(%rbp)
mov    -0x28(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
add    %ecx,%eax
add    $0x1,%eax
cltq
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1060 <OPENSSL_zalloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11f9 <mk_file_path+0xb9>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1030 <OPENSSL_strlcpy@plt>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1050 <OPENSSL_strlcat@plt>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1050 <OPENSSL_strlcat@plt>
mov    -0x18(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mk_file_path>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
call   1040 <strlen@plt>
mov    %eax,%ebp
lea    0xea4(%rip),%rdi
call   1040 <strlen@plt>
mov    %eax,%ebx
mov    %r14,%rdi
call   1040 <strlen@plt>
add    %ebp,%ebx
add    %ebx,%eax
add    $0x1,%eax
movslq %eax,%r12
mov    %r12,%rdi
call   1060 <OPENSSL_zalloc@plt>
mov    %rax,%rbx
test   %rax,%rax
je     11b3 <mk_file_path+0x73>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1030 <OPENSSL_strlcpy@plt>
lea    0xe66(%rip),%rsi
mov    %rbx,%rdi
mov    %r12,%rdx
call   1050 <OPENSSL_strlcat@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r12,%rdx
call   1050 <OPENSSL_strlcat@plt>
mov    %rbx,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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