#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 */
unsigned int strlen(char const *);
int /*<<< orphan*/ strncpy(char *, char const *, unsigned int);
const char *syzygy_rsrc_root(char *buffer, unsigned int size) {
  static const char *path = "/usr/lib/syzygy";
  if (size <= strlen(path)) {
    return "buffer is too small";
  } else {
    strncpy(buffer, path, size);
    return "";
  }
}


x86 assembly (clang, -O0):
<syzygy_rsrc_root>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    0x2ef4(%rip),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
cmp    %ecx,%eax
ja     115e <syzygy_rsrc_root+0x3e>
lea    0xebb(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    117c <syzygy_rsrc_root+0x5c>
mov    -0x10(%rbp),%rdi
mov    0x2ec7(%rip),%rsi
mov    -0x14(%rbp),%edx
call   1030 <strncpy@plt>
lea    0xeab(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<syzygy_rsrc_root>:
push   %r14
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %rdi,%r14
lea    0xed0(%rip),%rdi
call   1040 <strlen@plt>
cmp    %ebx,%eax
jae    1153 <syzygy_rsrc_root+0x33>
lea    0xec0(%rip),%rsi
mov    %r14,%rdi
mov    %ebx,%edx
call   1030 <strncpy@plt>
lea    0xed2(%rip),%rax
jmp    115a <syzygy_rsrc_root+0x3a>
lea    0xeb6(%rip),%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@syzygy_rsrc_root.path = internal global i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i32 0, i32 0)
@.str = [16 x i8] c"/usr/lib/syzygy\00"
@.str.1 = [20 x i8] c"buffer is too small\00"
@.str.2 = [1 x i8] zeroinitializer
define i8* @syzygy_rsrc_root(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
%6 = load i32, i32* %5
%7 = load i8*, i8** @syzygy_rsrc_root.path
%8 = call i32 @strlen(i8* %7)
%9 = icmp ule i32 %6, %8
br i1 %9, label %10, label %11
10: ; preds = %2
store i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8** %3
br label %16
11: ; preds = %2
%12 = load i8*, i8** %4
%13 = load i8*, i8** @syzygy_rsrc_root.path
%14 = load i32, i32* %5
%15 = call i32 @strncpy(i8* %12, i8* %13, i32 %14)
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8** %3
br label %16
16: ; preds = %11, %10
%17 = load i8*, i8** %3
ret i8* %17
}

LLVM IR (-O2):
@.str = [16 x i8] c"/usr/lib/syzygy\00"
@.str.1 = [20 x i8] c"buffer is too small\00"
@.str.2 = [1 x i8] zeroinitializer
define i8* @syzygy_rsrc_root(i8* %0, i32 %1) {
%3 = tail call i32 @strlen(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%4 = icmp ult i32 %3, %1
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call i32 @strncpy(i8* %0, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %1)
br label %7
7: ; preds = %2, %5
%8 = phi i8* [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), %5 ], [ getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), %2 ]
ret i8* %8
}