#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*/ fprintf(int /*<<< orphan*/, char *, char *);
int snprintf(char *, size_t, char *, char const *, char const *, char const *);
int /*<<< orphan*/ stderr;
bool createFilePath(char *file_path, size_t max_length,
                    const char *output_directory, const char *prefix,
                    const char *base_file_name) {
  int length = snprintf(file_path, max_length, "%s/%s%s", output_directory,
                        prefix, base_file_name);
  if (length > max_length) {
    fprintf(stderr, "Output file path too long: %s", file_path);
    return false;
  }
  return true;
}


x86 assembly (clang, -O0):
<createFilePath>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
mov    -0x30(%rbp),%r9
lea    0xea9(%rip),%rdx
call   1030 <snprintf@plt>
mov    %eax,-0x34(%rbp)
movslq -0x34(%rbp),%rax
cmp    -0x18(%rbp),%rax
jbe    1192 <createFilePath+0x72>
mov    0x2e6c(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe87(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1199 <createFilePath+0x79>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<createFilePath>:
push   %r14
push   %rbx
push   %rax
mov    %r8,%r9
mov    %rcx,%r8
mov    %rdx,%rcx
mov    %rsi,%rbx
mov    %rdi,%r14
lea    0xec6(%rip),%rdx
call   1030 <snprintf@plt>
movslq %eax,%rcx
mov    $0x1,%eax
cmp    %rbx,%rcx
jbe    1166 <createFilePath+0x46>
mov    0x2e8d(%rip),%rax
mov    (%rax),%edi
lea    0xeac(%rip),%rsi
mov    %r14,%rdx
call   1040 <fprintf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [8 x i8] c"%s/%s%s\00"
@stderr = global i32 0
@.str.1 = [30 x i8] c"Output file path too long: %s\00"
define i32 @createFilePath(i8* %0, i64 %1, i8* %2, i8* %3, i8* %4) {
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i32
store i8* %0, i8** %7
store i64 %1, i64* %8
store i8* %2, i8** %9
store i8* %3, i8** %10
store i8* %4, i8** %11
%13 = load i8*, i8** %7
%14 = load i64, i64* %8
%15 = load i8*, i8** %9
%16 = load i8*, i8** %10
%17 = load i8*, i8** %11
%18 = call i32 @snprintf(i8* %13, i64 %14, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %15, i8* %16, i8* %17)
store i32 %18, i32* %12
%19 = load i32, i32* %12
%20 = sext i32 %19 to i64
%21 = load i64, i64* %8
%22 = icmp ugt i64 %20, %21
br i1 %22, label %23, label %27
23: ; preds = %5
%24 = load i32, i32* @stderr
%25 = load i8*, i8** %7
%26 = call i32 @fprintf(i32 %24, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* %25)
store i32 0, i32* %6
br label %28
27: ; preds = %5
store i32 1, i32* %6
br label %28
28: ; preds = %27, %23
%29 = load i32, i32* %6
ret i32 %29
}

LLVM IR (-O2):
@.str = [8 x i8] c"%s/%s%s\00"
@stderr = global i32 0
@.str.1 = [30 x i8] c"Output file path too long: %s\00"
define i32 @createFilePath(i8* %0, i64 %1, i8* %2, i8* %3, i8* %4) {
%6 = tail call i32 @snprintf(i8* %0, i64 %1, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %2, i8* %3, i8* %4)
%7 = sext i32 %6 to i64
%8 = icmp ugt i64 %7, %1
br i1 %8, label %9, label %12
9: ; preds = %5
%10 = load i32, i32* @stderr
%11 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %12
12: ; preds = %5, %9
%13 = phi i32 [ 0, %9 ], [ 1, %5 ]
ret i32 %13
}