#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*/ assert(int);
size_t strlen(char const *);
int /*<<< orphan*/ strncat(char *, char const *, size_t);
int /*<<< orphan*/ strncpy(char *, char const *, size_t);
char *build_full_file_path(const char *prefix, const char *file, char *buffer,
                           size_t length) {
  size_t prefix_length;
  prefix_length = strlen(prefix);
  assert(prefix_length < length);
  strncpy(buffer, prefix, length);
  strncat(buffer, file, length - prefix_length);
  return buffer;
}


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

x86 assembly (clang, -O2):
<build_full_file_path>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rcx,%r14
mov    %rdx,%r13
mov    %rsi,%r15
mov    %rdi,%r12
call   1040 <strlen@plt>
xor    %edi,%edi
mov    %r14,%rbx
sub    %rax,%rbx
seta   %dil
call   1060 <assert@plt>
mov    %r13,%rdi
mov    %r12,%rsi
mov    %r14,%rdx
call   1030 <strncpy@plt>
mov    %r13,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1050 <strncat@plt>
mov    %r13,%rax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define i8* @build_full_file_path(i8* %0, i8* %1, i8* returned %2, i64 %3) {
%5 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%6 = icmp ult i64 %5, %3
%7 = zext i1 %6 to i32
%8 = tail call i32 @assert(i32 %7)
%9 = tail call i32 @strncpy(i8* %2, i8* %0, i64 %3)
%10 = sub i64 %3, %5
%11 = tail call i32 @strncat(i8* %2, i8* %1, i64 %10)
ret i8* %2
}