#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 int /*<<< orphan*/ str;

/* Variables and functions */
int /*<<< orphan*/ Panic(char *);
int strlcpy(char *, char *, int);
int strlen(char *);
void Check_strlcpy(void) {
  char str[5];
  if (strlcpy(str, "1234567890", sizeof(str)) != 10)
    Panic("strlcpy return code");
  if (str[4] != '\0')
    Panic("strlcpy NULL byte");
  if (strlen(str) != 4)
    Panic("strlcpy string length");
}


x86 assembly (clang, -O0):
<Check_strlcpy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    -0x5(%rbp),%rdi
lea    0xebd(%rip),%rsi
mov    $0x5,%edx
call   1050 <strlcpy@plt>
cmp    $0xa,%eax
je     1162 <Check_strlcpy+0x32>
lea    0xeae(%rip),%rdi
call   1040 <Panic@plt>
movsbl -0x1(%rbp),%eax
cmp    $0x0,%eax
je     117b <Check_strlcpy+0x4b>
lea    0xea9(%rip),%rdi
call   1040 <Panic@plt>
lea    -0x5(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x4,%eax
je     1199 <Check_strlcpy+0x69>
lea    0xe9d(%rip),%rdi
call   1040 <Panic@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Check_strlcpy>:
push   %rax
lea    0xec8(%rip),%rsi
lea    0x3(%rsp),%rdi
mov    $0x5,%edx
call   1050 <strlcpy@plt>
cmp    $0xa,%eax
je     1158 <Check_strlcpy+0x28>
lea    0xeb8(%rip),%rdi
call   1040 <Panic@plt>
cmpb   $0x0,0x7(%rsp)
je     116b <Check_strlcpy+0x3b>
lea    0xeb9(%rip),%rdi
call   1040 <Panic@plt>
lea    0x3(%rsp),%rdi
call   1030 <strlen@plt>
cmp    $0x4,%eax
je     1186 <Check_strlcpy+0x56>
lea    0xeb0(%rip),%rdi
call   1040 <Panic@plt>
pop    %rax
ret

LLVM IR (-O0):
@.str = [11 x i8] c"1234567890\00"
@.str.1 = [20 x i8] c"strlcpy return code\00"
@.str.2 = [18 x i8] c"strlcpy NULL byte\00"
@.str.3 = [22 x i8] c"strlcpy string length\00"
define void @Check_strlcpy() {
%1 = alloca [5 x i8]
%2 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
%3 = call i32 @strlcpy(i8* %2, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 5)
%4 = icmp ne i32 %3, 10
br i1 %4, label %5, label %7
5: ; preds = %0
%6 = call i32 @Panic(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
br label %7
7: ; preds = %5, %0
%8 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 4
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %7
%13 = call i32 @Panic(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
br label %14
14: ; preds = %12, %7
%15 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
%16 = call i32 @strlen(i8* %15)
%17 = icmp ne i32 %16, 4
br i1 %17, label %18, label %20
18: ; preds = %14
%19 = call i32 @Panic(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
br label %20
20: ; preds = %18, %14
ret void
}

LLVM IR (-O2):
@.str = [11 x i8] c"1234567890\00"
@.str.1 = [20 x i8] c"strlcpy return code\00"
@.str.2 = [18 x i8] c"strlcpy NULL byte\00"
@.str.3 = [22 x i8] c"strlcpy string length\00"
define void @Check_strlcpy() {
%1 = alloca [5 x i8]
%2 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
%3 = call i32 @strlcpy(i8* %2, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 5)
%4 = icmp eq i32 %3, 10
br i1 %4, label %7, label %5
5: ; preds = %0
%6 = call i32 @Panic(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
br label %7
7: ; preds = %5, %0
%8 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 4
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 0
br i1 %10, label %13, label %11
11: ; preds = %7
%12 = call i32 @Panic(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
br label %13
13: ; preds = %11, %7
%14 = call i32 @strlen(i8* %2)
%15 = icmp eq i32 %14, 4
br i1 %15, label %18, label %16
16: ; preds = %13
%17 = call i32 @Panic(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
br label %18
18: ; preds = %16, %13
ret void
}