#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 */
typedef scalar_t__ cl_bool;

/* Variables and functions */
int /*<<< orphan*/ snprintf(char *, int, char *, ...);
int /*<<< orphan*/ strcat(char *const, char *);
int strlen(char *);
int CL_create_compile_string(char *const options,
                             const char *const header_file_path, int local_size,
                             cl_bool is_atomic, cl_bool debug) {
  char tmp[1024];
  if (local_size > 0)
    snprintf(tmp, 1024, " -D __RND_WORKGROUP_SIZE=%d%s%s -I %s", local_size,
             is_atomic ? " -D __RND_ATOMIC" : "", debug ? " -D RND_DEBUG" : "",
             header_file_path);
  else
    snprintf(tmp, 1024, "%s%s -I %s", is_atomic ? " -D __RND_ATOMIC" : "",
             debug ? " -D RND_DEBUG" : "", header_file_path);
  if (options == NULL)
    return strlen(tmp) + 1;
  strcat(options, tmp);
  return 0;
}


x86 assembly (clang, -O0):
<CL_create_compile_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x440,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jle    11b6 <CL_create_compile_string+0x86>
lea    -0x430(%rbp),%rdi
mov    -0x1c(%rbp),%ecx
mov    -0x28(%rbp),%rdx
lea    0xec9(%rip),%r8
lea    0xeb2(%rip),%rax
cmp    $0x0,%rdx
cmovne %rax,%r8
mov    -0x30(%rbp),%rdx
lea    0xeaf(%rip),%r9
lea    0xea9(%rip),%rax
cmp    $0x0,%rdx
cmovne %rax,%r9
mov    -0x18(%rbp),%rax
mov    $0x400,%esi
lea    0xe5a(%rip),%rdx
mov    %rax,(%rsp)
mov    $0x0,%al
call   1040 <snprintf@plt>
jmp    1208 <CL_create_compile_string+0xd8>
lea    -0x430(%rbp),%rdi
mov    -0x28(%rbp),%rdx
lea    0xe6e(%rip),%rcx
lea    0xe57(%rip),%rax
cmp    $0x0,%rdx
cmovne %rax,%rcx
mov    -0x30(%rbp),%rdx
lea    0xe54(%rip),%r8
lea    0xe4e(%rip),%rax
cmp    $0x0,%rdx
cmovne %rax,%r8
mov    -0x18(%rbp),%r9
mov    $0x400,%esi
lea    0xe1a(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf@plt>
cmpq   $0x0,-0x10(%rbp)
jne    122a <CL_create_compile_string+0xfa>
lea    -0x430(%rbp),%rdi
call   1030 <strlen@plt>
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1241 <CL_create_compile_string+0x111>
mov    -0x10(%rbp),%rdi
lea    -0x430(%rbp),%rsi
call   1050 <strcat@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x440,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CL_create_compile_string>:
push   %r14
push   %rbx
sub    $0x418,%rsp
mov    %r8,%rbx
mov    %rsi,%r10
mov    %rdi,%r14
test   %rcx,%rcx
lea    0xee9(%rip),%rcx
lea    0xed2(%rip),%r8
cmove  %rcx,%r8
test   %rbx,%rbx
lea    0xed5(%rip),%r9
cmove  %rcx,%r9
test   %edx,%edx
jle    11a0 <CL_create_compile_string+0x70>
mov    %edx,%eax
mov    %r10,(%rsp)
lea    0xe89(%rip),%rdx
lea    0x10(%rsp),%rdi
mov    $0x400,%esi
mov    %eax,%ecx
xor    %eax,%eax
call   1040 <snprintf@plt>
test   %r14,%r14
je     11c6 <CL_create_compile_string+0x96>
lea    0x10(%rsp),%rsi
mov    %r14,%rdi
call   1050 <strcat@plt>
xor    %eax,%eax
jmp    11d3 <CL_create_compile_string+0xa3>
lea    0xe74(%rip),%rdx
lea    0x10(%rsp),%rdi
mov    $0x400,%esi
mov    %r8,%rcx
mov    %r9,%r8
mov    %r10,%r9
xor    %eax,%eax
call   1040 <snprintf@plt>
test   %r14,%r14
jne    118f <CL_create_compile_string+0x5f>
lea    0x10(%rsp),%rdi
call   1030 <strlen@plt>
add    $0x1,%eax
add    $0x418,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [38 x i8] c" -D __RND_WORKGROUP_SIZE=%d%s%s -I %s\00"
@.str.1 = [17 x i8] c" -D __RND_ATOMIC\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [14 x i8] c" -D RND_DEBUG\00"
@.str.4 = [11 x i8] c"%s%s -I %s\00"
define i32 @CL_create_compile_string(i8* %0, i8* %1, i32 %2, i64 %3, i64 %4) {
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i64
%11 = alloca i64
%12 = alloca [1024 x i8]
store i8* %0, i8** %7
store i8* %1, i8** %8
store i32 %2, i32* %9
store i64 %3, i64* %10
store i64 %4, i64* %11
%13 = load i32, i32* %9
%14 = icmp sgt i32 %13, 0
br i1 %14, label %15, label %28
15: ; preds = %5
%16 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%17 = load i32, i32* %9
%18 = load i64, i64* %10
%19 = icmp ne i64 %18, 0
%20 = zext i1 %19 to i64
%21 = select i1 %19, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0)
%22 = load i64, i64* %11
%23 = icmp ne i64 %22, 0
%24 = zext i1 %23 to i64
%25 = select i1 %23, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0)
%26 = load i8*, i8** %8
%27 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %16, i32 1024, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i32 %17, i8* %21, i8* %25, i8* %26)
br label %40
28: ; preds = %5
%29 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%30 = load i64, i64* %10
%31 = icmp ne i64 %30, 0
%32 = zext i1 %31 to i64
%33 = select i1 %31, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0)
%34 = load i64, i64* %11
%35 = icmp ne i64 %34, 0
%36 = zext i1 %35 to i64
%37 = select i1 %35, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0)
%38 = load i8*, i8** %8
%39 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %29, i32 1024, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i8* %33, i8* %37, i8* %38)
br label %40
40: ; preds = %28, %15
%41 = load i8*, i8** %7
%42 = icmp eq i8* %41, null
br i1 %42, label %43, label %47
43: ; preds = %40
%44 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%45 = call i32 @strlen(i8* %44)
%46 = add nsw i32 %45, 1
store i32 %46, i32* %6
br label %51
47: ; preds = %40
%48 = load i8*, i8** %7
%49 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%50 = call i32 @strcat(i8* %48, i8* %49)
store i32 0, i32* %6
br label %51
51: ; preds = %47, %43
%52 = load i32, i32* %6
ret i32 %52
}

LLVM IR (-O2):
@.str = [38 x i8] c" -D __RND_WORKGROUP_SIZE=%d%s%s -I %s\00"
@.str.1 = [17 x i8] c" -D __RND_ATOMIC\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [14 x i8] c" -D RND_DEBUG\00"
@.str.4 = [11 x i8] c"%s%s -I %s\00"
define i32 @CL_create_compile_string(i8* %0, i8* %1, i32 %2, i64 %3, i64 %4) {
%6 = alloca [1024 x i8]
%7 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%8 = icmp sgt i32 %2, 0
%9 = icmp eq i64 %3, 0
%10 = select i1 %9, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0)
%11 = icmp eq i64 %4, 0
%12 = select i1 %11, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0)
br i1 %8, label %13, label %15
13: ; preds = %5
%14 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %7, i32 1024, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i32 %2, i8* %10, i8* %12, i8* %1)
br label %17
15: ; preds = %5
%16 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %7, i32 1024, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i8* %10, i8* %12, i8* %1)
br label %17
17: ; preds = %15, %13
%18 = icmp eq i8* %0, null
br i1 %18, label %19, label %22
19: ; preds = %17
%20 = call i32 @strlen(i8* %7)
%21 = add nsw i32 %20, 1
br label %24
22: ; preds = %17
%23 = call i32 @strcat(i8* %0, i8* %7)
br label %24
24: ; preds = %22, %19
%25 = phi i32 [ %21, %19 ], [ 0, %22 ]
ret i32 %25
}