#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*/ small;
typedef int /*<<< orphan*/ dest1;

/* Variables and functions */
int EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ star_strappend(char *, char *, int);
scalar_t__ star_strellcpy(char *, char *, int);
size_t star_strlcat(char *, char *, int);
size_t star_strlcpy(char *, char *, int);
size_t strlen(char *);
int main(void) {
  size_t len;
  char src1[] = "0123456789";
  char src2[] = "01234567890123456789";
  char dest1[15];
  int exstat = EXIT_SUCCESS;
  char small[3];
  dest1[0] = '\0';
  small[0] = '\0';
  len = star_strlcpy(dest1, src1, 15);
  printf("Attempt to copy %d characters to destination\n", (int)len);
  if (len != strlen(src1)) {
    printf("Wrong number of characters copied\n");
    exstat = EXIT_FAILURE;
  }
  len = star_strlcpy(dest1, src2, 15);
  if (len >= sizeof(dest1)) {
    printf("Did truncate as expected\n");
  } else {
    printf("Should have truncated\n");
    exstat = EXIT_FAILURE;
  }
  len = star_strlcpy(dest1, src1, 15);
  len = star_strlcat(dest1, "XX", 15);
  if (len != strlen(dest1)) {
    printf("Did not append string correctly\n");
    exstat = EXIT_FAILURE;
  }
  len = star_strlcat(dest1, src2, 15);
  if (len >= sizeof(dest1)) {
    printf("Did get truncation correctly\n");
  } else {
    printf("Did not get truncation status. Copied %d characters\n", (int)len);
    exstat = EXIT_FAILURE;
  }
  dest1[0] = '\0';
  if (star_strappend(dest1, src1, 15)) {
    printf("No ellipsis - correct\n");
  } else {
    printf("Got ellipsis by mistake\n");
    exstat = EXIT_FAILURE;
  }
  if (!star_strappend(dest1, src1, 15)) {
    printf("Ellipsis: '%s'\n", dest1);
  } else {
    printf("Should have truncated\n");
    exstat = EXIT_FAILURE;
  }
  if (!star_strappend(small, src1, sizeof(small))) {
    printf("Got small ellipsis: '%s'\n", small);
  } else {
    printf("Did not truncate!\n");
    exstat = EXIT_FAILURE;
  }
  dest1[0] = '\0';
  if (star_strellcpy(dest1, src1, 15)) {
    printf("No ellipsis - correct\n");
  } else {
    printf("Got ellipsis by mistake\n");
    exstat = EXIT_FAILURE;
  }
  if (!star_strellcpy(dest1, src2, 15)) {
    printf("Truncation - correct\n");
  } else {
    printf("Got no truncation by mistake\n");
    exstat = EXIT_FAILURE;
  }
  return exstat;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xe8a(%rip),%rax
mov    %rax,-0x1b(%rbp)
mov    0xe87(%rip),%ax
mov    %ax,-0x13(%rbp)
mov    0xe7f(%rip),%al
mov    %al,-0x11(%rbp)
mov    0x101b(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0x1018(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0x1016(%rip),%eax
mov    %eax,-0x20(%rbp)
mov    0x1011(%rip),%al
mov    %al,-0x1c(%rbp)
mov    0x2e1b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x44(%rbp)
movb   $0x0,-0x3f(%rbp)
movb   $0x0,-0x47(%rbp)
lea    -0x3f(%rbp),%rdi
lea    -0x1b(%rbp),%rsi
mov    $0xf,%edx
call   1030 <star_strlcpy@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %eax,%esi
lea    0xe1e(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x50(%rbp)
lea    -0x1b(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,%rcx
mov    -0x50(%rbp),%rax
cmp    %rcx,%rax
je     122f <main+0xcf>
lea    0xe1d(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    0x2db6(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x44(%rbp)
lea    -0x3f(%rbp),%rdi
lea    -0x30(%rbp),%rsi
mov    $0xf,%edx
call   1030 <star_strlcpy@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0xf,-0x10(%rbp)
jb     1263 <main+0x103>
lea    0xe05(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    127d <main+0x11d>
lea    0xe0c(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    0x2d68(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x44(%rbp)
lea    -0x3f(%rbp),%rdi
lea    -0x1b(%rbp),%rsi
mov    $0xf,%edx
call   1030 <star_strlcpy@plt>
mov    %rax,-0x10(%rbp)
lea    -0x3f(%rbp),%rdi
lea    0xdef(%rip),%rsi
mov    $0xf,%edx
call   1080 <star_strlcat@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x58(%rbp)
lea    -0x3f(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,%rcx
mov    -0x58(%rbp),%rax
cmp    %rcx,%rax
je     12e7 <main+0x187>
lea    0xdbc(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    0x2cfe(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x44(%rbp)
lea    -0x3f(%rbp),%rdi
lea    -0x30(%rbp),%rsi
mov    $0xf,%edx
call   1080 <star_strlcat@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0xf,-0x10(%rbp)
jb     131b <main+0x1bb>
lea    0xda2(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    133b <main+0x1db>
mov    -0x10(%rbp),%rax
mov    %eax,%esi
lea    0xda7(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    0x2caa(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x44(%rbp)
movb   $0x0,-0x3f(%rbp)
lea    -0x3f(%rbp),%rdi
lea    -0x1b(%rbp),%rsi
mov    $0xf,%edx
call   1070 <star_strappend@plt>
cmp    $0x0,%rax
je     136e <main+0x20e>
lea    0xda2(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1388 <main+0x228>
lea    0xda6(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    0x2c5d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x44(%rbp)
lea    -0x3f(%rbp),%rdi
lea    -0x1b(%rbp),%rsi
mov    $0xf,%edx
call   1070 <star_strappend@plt>
cmp    $0x0,%rax
jne    13bb <main+0x25b>
lea    -0x3f(%rbp),%rsi
lea    0xd85(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    13d5 <main+0x275>
lea    0xcb4(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    0x2c10(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x44(%rbp)
lea    -0x47(%rbp),%rdi
lea    -0x1b(%rbp),%rsi
mov    $0x3,%edx
call   1070 <star_strappend@plt>
cmp    $0x0,%rax
jne    1408 <main+0x2a8>
lea    -0x47(%rbp),%rsi
lea    0xd48(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1422 <main+0x2c2>
lea    0xd4f(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    0x2bc3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x44(%rbp)
movb   $0x0,-0x3f(%rbp)
lea    -0x3f(%rbp),%rdi
lea    -0x1b(%rbp),%rsi
mov    $0xf,%edx
call   1040 <star_strellcpy@plt>
cmp    $0x0,%rax
je     1455 <main+0x2f5>
lea    0xcbb(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    146f <main+0x30f>
lea    0xcbf(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    0x2b76(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x44(%rbp)
lea    -0x3f(%rbp),%rdi
lea    -0x30(%rbp),%rsi
mov    $0xf,%edx
call   1040 <star_strellcpy@plt>
cmp    $0x0,%rax
jne    149e <main+0x33e>
lea    0xcdf(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    14b8 <main+0x358>
lea    0xce2(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    0x2b2d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x44(%rbp)
mov    -0x44(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x50,%rsp
movabs $0x3736353433323130,%rax
35 36 37
mov    %rax,0x20(%rsp)
movl   $0x393837,0x27(%rsp)
movaps 0x100a(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movabs $0x39383736353433,%rax
mov    %rax,0x3d(%rsp)
mov    0x2e27(%rip),%rax
mov    (%rax),%r14d
movb   $0x0,0x11(%rsp)
movb   $0x0,0xe(%rsp)
lea    0x11(%rsp),%rdi
lea    0x20(%rsp),%rbx
mov    %rbx,%rsi
mov    $0xf,%edx
call   1030 <star_strlcpy@plt>
mov    %rax,%rbp
lea    0xe2c(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %rbx,%rdi
call   1060 <strlen@plt>
cmp    %rax,%rbp
je     120b <main+0x9b>
lea    0xf7d(%rip),%rdi
call   1040 <puts@plt>
mov    0x2dd8(%rip),%rax
mov    (%rax),%r14d
lea    0x11(%rsp),%rdi
lea    0x30(%rsp),%rsi
mov    $0xf,%edx
call   1030 <star_strlcpy@plt>
cmp    $0xf,%rax
jb     1233 <main+0xc3>
lea    0xf34(%rip),%rdi
call   1040 <puts@plt>
jmp    1249 <main+0xd9>
lea    0xebd(%rip),%rdi
call   1040 <puts@plt>
mov    0x2d9a(%rip),%rax
mov    (%rax),%r14d
lea    0x11(%rsp),%rbx
lea    0x20(%rsp),%rsi
mov    %rbx,%rdi
mov    $0xf,%edx
call   1030 <star_strlcpy@plt>
lea    0xdd2(%rip),%rsi
mov    %rbx,%rdi
mov    $0xf,%edx
call   1090 <star_strlcat@plt>
mov    %rax,%rbp
mov    %rbx,%rdi
call   1060 <strlen@plt>
cmp    %rax,%rbp
je     129a <main+0x12a>
lea    0xeb5(%rip),%rdi
call   1040 <puts@plt>
mov    0x2d49(%rip),%rax
mov    (%rax),%r14d
lea    0x11(%rsp),%rdi
lea    0x30(%rsp),%rsi
mov    $0xf,%edx
call   1090 <star_strlcat@plt>
cmp    $0xf,%rax
jb     12c2 <main+0x152>
lea    0xe68(%rip),%rdi
call   1040 <puts@plt>
jmp    12dc <main+0x16c>
lea    0xd73(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x2d07(%rip),%rax
mov    (%rax),%r14d
movb   $0x0,0x11(%rsp)
lea    0x11(%rsp),%rdi
lea    0x20(%rsp),%rsi
mov    $0xf,%edx
call   1080 <star_strappend@plt>
test   %rax,%rax
je     1308 <main+0x198>
lea    0xe0c(%rip),%rdi
call   1040 <puts@plt>
jmp    131e <main+0x1ae>
lea    0xd8c(%rip),%rdi
call   1040 <puts@plt>
mov    0x2cc5(%rip),%rax
mov    (%rax),%r14d
lea    0x11(%rsp),%rdi
lea    0x20(%rsp),%rsi
mov    $0xf,%edx
call   1080 <star_strappend@plt>
test   %rax,%rax
je     134f <main+0x1df>
lea    0xdb9(%rip),%rdi
call   1040 <puts@plt>
mov    0x2c96(%rip),%rax
mov    (%rax),%r14d
jmp    1362 <main+0x1f2>
lea    0xd1b(%rip),%rdi
lea    0x11(%rsp),%rsi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xe(%rsp),%rdi
lea    0x20(%rsp),%rsi
mov    $0x3,%edx
call   1080 <star_strappend@plt>
test   %rax,%rax
je     1393 <main+0x223>
lea    0xd63(%rip),%rdi
call   1040 <puts@plt>
mov    0x2c52(%rip),%rax
mov    (%rax),%r14d
jmp    13a6 <main+0x236>
lea    0xce7(%rip),%rdi
lea    0xe(%rsp),%rsi
xor    %eax,%eax
call   1070 <printf@plt>
movb   $0x0,0x11(%rsp)
lea    0x11(%rsp),%rdi
lea    0x20(%rsp),%rsi
mov    $0xf,%edx
call   1050 <star_strellcpy@plt>
test   %rax,%rax
je     13d2 <main+0x262>
lea    0xd42(%rip),%rdi
call   1040 <puts@plt>
jmp    13e8 <main+0x278>
lea    0xcc2(%rip),%rdi
call   1040 <puts@plt>
mov    0x2bfb(%rip),%rax
mov    (%rax),%r14d
lea    0x11(%rsp),%rdi
lea    0x30(%rsp),%rsi
mov    $0xf,%edx
call   1050 <star_strellcpy@plt>
test   %rax,%rax
je     1419 <main+0x2a9>
lea    0xcc0(%rip),%rdi
call   1040 <puts@plt>
mov    0x2bcc(%rip),%rax
mov    (%rax),%r14d
jmp    1425 <main+0x2b5>
lea    0xc93(%rip),%rdi
call   1040 <puts@plt>
mov    %r14d,%eax
add    $0x50,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.src1 = [11 x i8] c"0123456789\00"
@__const.main.src2 = [21 x i8] c"01234567890123456789\00"
@EXIT_SUCCESS = global i32 0
@.str = [46 x i8] c"Attempt to copy %d characters to destination\0A\00"
@.str.1 = [35 x i8] c"Wrong number of characters copied\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [26 x i8] c"Did truncate as expected\0A\00"
@.str.3 = [23 x i8] c"Should have truncated\0A\00"
@.str.4 = [3 x i8] c"XX\00"
@.str.5 = [33 x i8] c"Did not append string correctly\0A\00"
@.str.6 = [30 x i8] c"Did get truncation correctly\0A\00"
@.str.7 = [53 x i8] c"Did not get truncation status. Copied %d characters\0A\00"
@.str.8 = [23 x i8] c"No ellipsis - correct\0A\00"
@.str.9 = [25 x i8] c"Got ellipsis by mistake\0A\00"
@.str.10 = [16 x i8] c"Ellipsis: '%s'\0A\00"
@.str.11 = [26 x i8] c"Got small ellipsis: '%s'\0A\00"
@.str.12 = [19 x i8] c"Did not truncate!\0A\00"
@.str.13 = [22 x i8] c"Truncation - correct\0A\00"
@.str.14 = [30 x i8] c"Got no truncation by mistake\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca [11 x i8]
%4 = alloca [21 x i8]
%5 = alloca [15 x i8]
%6 = alloca i32
%7 = alloca [3 x i8]
store i32 0, i32* %1
%8 = bitcast [11 x i8]* %3 to i8*
%9 = bitcast [21 x i8]* %4 to i8*
%10 = load i32, i32* @EXIT_SUCCESS
store i32 %10, i32* %6
%11 = getelementptr inbounds [15 x i8], [15 x i8]* %5, i64 0, i64 0
store i8 0, i8* %11
%12 = getelementptr inbounds [3 x i8], [3 x i8]* %7, i64 0, i64 0
store i8 0, i8* %12
%13 = getelementptr inbounds [15 x i8], [15 x i8]* %5, i64 0, i64 0
%14 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 0
%15 = call i64 @star_strlcpy(i8* %13, i8* %14, i32 15)
store i64 %15, i64* %2
%16 = load i64, i64* %2
%17 = trunc i64 %16 to i32
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i32 %17)
%19 = load i64, i64* %2
%20 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 0
%21 = call i64 @strlen(i8* %20)
%22 = icmp ne i64 %19, %21
br i1 %22, label %23, label %26
23: ; preds = %0
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
%25 = load i32, i32* @EXIT_FAILURE
store i32 %25, i32* %6
br label %26
26: ; preds = %23, %0
%27 = getelementptr inbounds [15 x i8], [15 x i8]* %5, i64 0, i64 0
%28 = getelementptr inbounds [21 x i8], [21 x i8]* %4, i64 0, i64 0
%29 = call i64 @star_strlcpy(i8* %27, i8* %28, i32 15)
store i64 %29, i64* %2
%30 = load i64, i64* %2
%31 = icmp uge i64 %30, 15
br i1 %31, label %32, label %34
32: ; preds = %26
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
br label %37
34: ; preds = %26
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
%36 = load i32, i32* @EXIT_FAILURE
store i32 %36, i32* %6
br label %37
37: ; preds = %34, %32
%38 = getelementptr inbounds [15 x i8], [15 x i8]* %5, i64 0, i64 0
%39 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 0
%40 = call i64 @star_strlcpy(i8* %38, i8* %39, i32 15)
store i64 %40, i64* %2
%41 = getelementptr inbounds [15 x i8], [15 x i8]* %5, i64 0, i64 0
%42 = call i64 @star_strlcat(i8* %41, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 15)
store i64 %42, i64* %2
%43 = load i64, i64* %2
%44 = getelementptr inbounds [15 x i8], [15 x i8]* %5, i64 0, i64 0
%45 = call i64 @strlen(i8* %44)
%46 = icmp ne i64 %43, %45
br i1 %46, label %47, label %50
47: ; preds = %37
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0))
%49 = load i32, i32* @EXIT_FAILURE
store i32 %49, i32* %6
br label %50
50: ; preds = %47, %37
%51 = getelementptr inbounds [15 x i8], [15 x i8]* %5, i64 0, i64 0
%52 = getelementptr inbounds [21 x i8], [21 x i8]* %4, i64 0, i64 0
%53 = call i64 @star_strlcat(i8* %51, i8* %52, i32 15)
store i64 %53, i64* %2
%54 = load i64, i64* %2
%55 = icmp uge i64 %54, 15
br i1 %55, label %56, label %58
56: ; preds = %50
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.6, i64 0, i64 0))
br label %63
58: ; preds = %50
%59 = load i64, i64* %2
%60 = trunc i64 %59 to i32
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.7, i64 0, i64 0), i32 %60)
%62 = load i32, i32* @EXIT_FAILURE
store i32 %62, i32* %6
br label %63
63: ; preds = %58, %56
%64 = getelementptr inbounds [15 x i8], [15 x i8]* %5, i64 0, i64 0
store i8 0, i8* %64
%65 = getelementptr inbounds [15 x i8], [15 x i8]* %5, i64 0, i64 0
%66 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 0
%67 = call i64 @star_strappend(i8* %65, i8* %66, i32 15)
%68 = icmp ne i64 %67, 0
br i1 %68, label %69, label %71
69: ; preds = %63
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0))
br label %74
71: ; preds = %63
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.9, i64 0, i64 0))
%73 = load i32, i32* @EXIT_FAILURE
store i32 %73, i32* %6
br label %74
74: ; preds = %71, %69
%75 = getelementptr inbounds [15 x i8], [15 x i8]* %5, i64 0, i64 0
%76 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 0
%77 = call i64 @star_strappend(i8* %75, i8* %76, i32 15)
%78 = icmp ne i64 %77, 0
br i1 %78, label %82, label %79
79: ; preds = %74
%80 = getelementptr inbounds [15 x i8], [15 x i8]* %5, i64 0, i64 0
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0), i8* %80)
br label %85
82: ; preds = %74
%83 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
%84 = load i32, i32* @EXIT_FAILURE
store i32 %84, i32* %6
br label %85
85: ; preds = %82, %79
%86 = getelementptr inbounds [3 x i8], [3 x i8]* %7, i64 0, i64 0
%87 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 0
%88 = call i64 @star_strappend(i8* %86, i8* %87, i32 3)
%89 = icmp ne i64 %88, 0
br i1 %89, label %93, label %90
90: ; preds = %85
%91 = getelementptr inbounds [3 x i8], [3 x i8]* %7, i64 0, i64 0
%92 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.11, i64 0, i64 0), i8* %91)
br label %96
93: ; preds = %85
%94 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.12, i64 0, i64 0))
%95 = load i32, i32* @EXIT_FAILURE
store i32 %95, i32* %6
br label %96
96: ; preds = %93, %90
%97 = getelementptr inbounds [15 x i8], [15 x i8]* %5, i64 0, i64 0
store i8 0, i8* %97
%98 = getelementptr inbounds [15 x i8], [15 x i8]* %5, i64 0, i64 0
%99 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 0
%100 = call i64 @star_strellcpy(i8* %98, i8* %99, i32 15)
%101 = icmp ne i64 %100, 0
br i1 %101, label %102, label %104
102: ; preds = %96
%103 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0))
br label %107
104: ; preds = %96
%105 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.9, i64 0, i64 0))
%106 = load i32, i32* @EXIT_FAILURE
store i32 %106, i32* %6
br label %107
107: ; preds = %104, %102
%108 = getelementptr inbounds [15 x i8], [15 x i8]* %5, i64 0, i64 0
%109 = getelementptr inbounds [21 x i8], [21 x i8]* %4, i64 0, i64 0
%110 = call i64 @star_strellcpy(i8* %108, i8* %109, i32 15)
%111 = icmp ne i64 %110, 0
br i1 %111, label %114, label %112
112: ; preds = %107
%113 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.13, i64 0, i64 0))
br label %117
114: ; preds = %107
%115 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.14, i64 0, i64 0))
%116 = load i32, i32* @EXIT_FAILURE
store i32 %116, i32* %6
br label %117
117: ; preds = %114, %112
%118 = load i32, i32* %6
ret i32 %118
}

LLVM IR (-O2):
@__const.main.src1 = [11 x i8] c"0123456789\00"
@__const.main.src2 = [21 x i8] c"01234567890123456789\00"
@EXIT_SUCCESS = global i32 0
@.str = [46 x i8] c"Attempt to copy %d characters to destination\0A\00"
@EXIT_FAILURE = global i32 0
@.str.4 = [3 x i8] c"XX\00"
@.str.7 = [53 x i8] c"Did not get truncation status. Copied %d characters\0A\00"
@.str.10 = [16 x i8] c"Ellipsis: '%s'\0A\00"
@.str.11 = [26 x i8] c"Got small ellipsis: '%s'\0A\00"
@str.16 = [24 x i8] c"Got ellipsis by mistake\00"
@str.17 = [21 x i8] c"Truncation - correct\00"
@str.18 = [29 x i8] c"Got no truncation by mistake\00"
@str.20 = [18 x i8] c"Did not truncate!\00"
@str.21 = [22 x i8] c"Should have truncated\00"
@str.22 = [22 x i8] c"No ellipsis - correct\00"
@str.23 = [29 x i8] c"Did get truncation correctly\00"
@str.24 = [32 x i8] c"Did not append string correctly\00"
@str.25 = [25 x i8] c"Did truncate as expected\00"
@str.26 = [34 x i8] c"Wrong number of characters copied\00"
define i32 @main() {
%1 = alloca [11 x i8]
%2 = alloca [21 x i8]
%3 = alloca [15 x i8]
%4 = alloca [3 x i8]
%5 = getelementptr inbounds [11 x i8], [11 x i8]* %1, i64 0, i64 0
%6 = getelementptr inbounds [21 x i8], [21 x i8]* %2, i64 0, i64 0
%7 = getelementptr inbounds [15 x i8], [15 x i8]* %3, i64 0, i64 0
%8 = load i32, i32* @EXIT_SUCCESS
%9 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 0
store i8 0, i8* %7
store i8 0, i8* %9
%10 = call i64 @star_strlcpy(i8* %7, i8* %5, i32 15)
%11 = trunc i64 %10 to i32
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = call i64 @strlen(i8* %5)
%14 = icmp eq i64 %10, %13
br i1 %14, label %18, label %15
15: ; preds = %0
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str.26, i64 0, i64 0))
%17 = load i32, i32* @EXIT_FAILURE
br label %18
18: ; preds = %15, %0
%19 = phi i32 [ %17, %15 ], [ %8, %0 ]
%20 = call i64 @star_strlcpy(i8* %7, i8* %6, i32 15)
%21 = icmp ugt i64 %20, 14
br i1 %21, label %22, label %24
22: ; preds = %18
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.25, i64 0, i64 0))
br label %27
24: ; preds = %18
%25 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.21, i64 0, i64 0))
%26 = load i32, i32* @EXIT_FAILURE
br label %27
27: ; preds = %24, %22
%28 = phi i32 [ %19, %22 ], [ %26, %24 ]
%29 = call i64 @star_strlcpy(i8* %7, i8* %5, i32 15)
%30 = call i64 @star_strlcat(i8* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 15)
%31 = call i64 @strlen(i8* %7)
%32 = icmp eq i64 %30, %31
br i1 %32, label %36, label %33
33: ; preds = %27
%34 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.24, i64 0, i64 0))
%35 = load i32, i32* @EXIT_FAILURE
br label %36
36: ; preds = %33, %27
%37 = phi i32 [ %35, %33 ], [ %28, %27 ]
%38 = call i64 @star_strlcat(i8* %7, i8* %6, i32 15)
%39 = icmp ugt i64 %38, 14
br i1 %39, label %40, label %42
40: ; preds = %36
%41 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.23, i64 0, i64 0))
br label %46
42: ; preds = %36
%43 = trunc i64 %38 to i32
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @.str.7, i64 0, i64 0), i32 %43)
%45 = load i32, i32* @EXIT_FAILURE
br label %46
46: ; preds = %42, %40
%47 = phi i32 [ %37, %40 ], [ %45, %42 ]
store i8 0, i8* %7
%48 = call i64 @star_strappend(i8* %7, i8* %5, i32 15)
%49 = icmp eq i64 %48, 0
br i1 %49, label %52, label %50
50: ; preds = %46
%51 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.22, i64 0, i64 0))
br label %55
52: ; preds = %46
%53 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.16, i64 0, i64 0))
%54 = load i32, i32* @EXIT_FAILURE
br label %55
55: ; preds = %52, %50
%56 = phi i32 [ %47, %50 ], [ %54, %52 ]
%57 = call i64 @star_strappend(i8* %7, i8* %5, i32 15)
%58 = icmp eq i64 %57, 0
br i1 %58, label %59, label %61
59: ; preds = %55
%60 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0), i8* %7)
br label %64
61: ; preds = %55
%62 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.21, i64 0, i64 0))
%63 = load i32, i32* @EXIT_FAILURE
br label %64
64: ; preds = %61, %59
%65 = phi i32 [ %63, %61 ], [ %56, %59 ]
%66 = call i64 @star_strappend(i8* %9, i8* %5, i32 3)
%67 = icmp eq i64 %66, 0
br i1 %67, label %68, label %70
68: ; preds = %64
%69 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.11, i64 0, i64 0), i8* %9)
br label %73
70: ; preds = %64
%71 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.20, i64 0, i64 0))
%72 = load i32, i32* @EXIT_FAILURE
br label %73
73: ; preds = %70, %68
%74 = phi i32 [ %72, %70 ], [ %65, %68 ]
store i8 0, i8* %7
%75 = call i64 @star_strellcpy(i8* %7, i8* %5, i32 15)
%76 = icmp eq i64 %75, 0
br i1 %76, label %79, label %77
77: ; preds = %73
%78 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.22, i64 0, i64 0))
br label %82
79: ; preds = %73
%80 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.16, i64 0, i64 0))
%81 = load i32, i32* @EXIT_FAILURE
br label %82
82: ; preds = %79, %77
%83 = phi i32 [ %74, %77 ], [ %81, %79 ]
%84 = call i64 @star_strellcpy(i8* %7, i8* %6, i32 15)
%85 = icmp eq i64 %84, 0
br i1 %85, label %86, label %88
86: ; preds = %82
%87 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.17, i64 0, i64 0))
br label %91
88: ; preds = %82
%89 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.18, i64 0, i64 0))
%90 = load i32, i32* @EXIT_FAILURE
br label %91
91: ; preds = %88, %86
%92 = phi i32 [ %90, %88 ], [ %83, %86 ]
ret i32 %92
}