#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 */
scalar_t__ misc_malloc(size_t);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *);
int strlen(char *);
char *misc_make_path(char *dirname, char *filename) {
  char *result;
  size_t len;
  len = strlen(dirname) + strlen(filename) + 2;
  result = (char *)misc_malloc(len);
  if (result == NULL)
    return NULL;
  sprintf(result, "%s/%s", dirname, filename);
  return result;
}


x86 assembly (clang, -O0):
<misc_make_path>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
add    %ecx,%eax
add    $0x2,%eax
cltq
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
call   1040 <misc_malloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    118a <misc_make_path+0x5a>
movq   $0x0,-0x8(%rbp)
jmp    11aa <misc_make_path+0x7a>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
lea    0xe63(%rip),%rsi
call   1050 <sprintf@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<misc_make_path>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
call   1030 <strlen@plt>
mov    %eax,%ebx
mov    %r14,%rdi
call   1030 <strlen@plt>
add    %ebx,%eax
add    $0x2,%eax
movslq %eax,%rdi
call   1040 <misc_malloc@plt>
test   %rax,%rax
je     1176 <misc_make_path+0x46>
mov    %rax,%rbx
lea    0xe9a(%rip),%rsi
mov    %rax,%rdi
mov    %r15,%rdx
mov    %r14,%rcx
call   1050 <sprintf@plt>
jmp    1178 <misc_make_path+0x48>
xor    %ebx,%ebx
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [6 x i8] c"%s/%s\00"
define i8* @misc_make_path(i8* %0, i8* %1) {
%3 = tail call i32 @strlen(i8* %0)
%4 = tail call i32 @strlen(i8* %1)
%5 = add i32 %3, 2
%6 = add i32 %5, %4
%7 = sext i32 %6 to i64
%8 = tail call i64 @misc_malloc(i64 %7)
%9 = inttoptr i64 %8 to i8*
%10 = icmp eq i64 %8, 0
br i1 %10, label %13, label %11
11: ; preds = %2
%12 = tail call i32 @sprintf(i8* %9, 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, %11
%14 = phi i8* [ %9, %11 ], [ null, %2 ]
ret i8* %14
}