#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*/ append_file_name(char *, char const *);
int /*<<< orphan*/ assert(int);
size_t strlen(char const *);
char *create_path(char *path, const char *dirname, const char *fname) {
  const size_t dirname_len = strlen(dirname), fname_len = strlen(fname);
  assert((dirname_len + fname_len) < 1024);
  path[0] = '\0';
  append_file_name(path, dirname);
  append_file_name(path, fname);
  return path;
}


x86 assembly (clang, -O0):
<create_path>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
add    -0x28(%rbp),%rax
cmp    $0x400,%rax
setb   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x8(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <append_file_name@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <append_file_name@plt>
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_path>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
mov    %rsi,%rdi
call   1030 <strlen@plt>
mov    %rax,%r12
mov    %r14,%rdi
call   1030 <strlen@plt>
add    %r12,%rax
xor    %edi,%edi
cmp    $0x400,%rax
setb   %dil
call   1050 <assert@plt>
movb   $0x0,(%rbx)
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <append_file_name@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <append_file_name@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i8* @create_path(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i64
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%9 = load i8*, i8** %5
%10 = call i64 @strlen(i8* %9)
store i64 %10, i64* %7
%11 = load i8*, i8** %6
%12 = call i64 @strlen(i8* %11)
store i64 %12, i64* %8
%13 = load i64, i64* %7
%14 = load i64, i64* %8
%15 = add i64 %13, %14
%16 = icmp ult i64 %15, 1024
%17 = zext i1 %16 to i32
%18 = call i32 @assert(i32 %17)
%19 = load i8*, i8** %4
%20 = getelementptr inbounds i8, i8* %19, i64 0
store i8 0, i8* %20
%21 = load i8*, i8** %4
%22 = load i8*, i8** %5
%23 = call i32 @append_file_name(i8* %21, i8* %22)
%24 = load i8*, i8** %4
%25 = load i8*, i8** %6
%26 = call i32 @append_file_name(i8* %24, i8* %25)
%27 = load i8*, i8** %4
ret i8* %27
}

LLVM IR (-O2):
define i8* @create_path(i8* returned %0, i8* %1, i8* %2) {
%4 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%5 = tail call i64 @strlen(i8* dereferenceable(1) %2)
%6 = add i64 %5, %4
%7 = icmp ult i64 %6, 1024
%8 = zext i1 %7 to i32
%9 = tail call i32 @assert(i32 %8)
store i8 0, i8* %0
%10 = tail call i32 @append_file_name(i8* %0, i8* %1)
%11 = tail call i32 @append_file_name(i8* %0, i8* %2)
ret i8* %0
}