int test_ft_strncpy() {
  char *src;
  char dest[10];
  printf("%s\n", __func__ + 5);
  _it("should copy at most n characters from src into dst");
  src = "abcdef";
  memset(dest, 1, 10);
  ft_strncpy(dest, src, 0);
  do {
    _begin_assert();
    if (!(dest[0] == 1)) {
      _fail_test();
      do {
        _color(31);
        printf("\nfailure in %s() line %d\n", __func__, 114);
        _color(0);
      } while (0);
      return 1;
    }
  } while (0);
  ft_strncpy(dest, src, 4);
  do {
    _begin_assert();
    if (!(!memcmp(dest, src, 4))) {
      _fail_test();
      do {
        _color(31);
        printf("\nfailure in %s() line %d\n", __func__, 117);
        _color(0);
      } while (0);
      return 1;
    }
  } while (0);
  do {
    _begin_assert();
    if (!(dest[4] == 1)) {
      _fail_test();
      do {
        _color(31);
        printf("\nfailure in %s() line %d\n", __func__, 118);
        _color(0);
      } while (0);
      return 1;
    }
  } while (0);
  _it("should fill the remainder of dst is filled with \\0");
  src = "lol";
  memset(dest, 1, 10);
  ft_strncpy(dest, src, 5);
  do {
    _begin_assert();
    if (strcmp(dest, src)) {
      _fail_test();
      do {
        _color(31);
        printf("\nfailure in %s() line %d\n", __func__, 125);
        _color(0);
      } while (0);
      printf("expected \"%s\" to equal \"%s\"\n\n", (char *)dest, (char *)src);
      return 1;
    }
  } while (0);
  do {
    _begin_assert();
    if (!(!dest[3] && !dest[4] && dest[5])) {
      _fail_test();
      do {
        _color(31);
        printf("\nfailure in %s() line %d\n", __func__, 126);
        _color(0);
      } while (0);
      return 1;
    }
  } while (0);
  _it("should not terminate dst otherwise");
  src = "abcdef";
  memset(dest, 1, 10);
  ft_strncpy(dest, src, 0);
  do {
    _begin_assert();
    if (!(dest[0] != '\0')) {
      _fail_test();
      do {
        _color(31);
        printf("\nfailure in %s() line %d\n", __func__, 133);
        _color(0);
      } while (0);
      return 1;
    }
  } while (0);
  ft_strncpy(dest, src, 4);
  do {
    _begin_assert();
    if (!(dest[4] != '\0')) {
      _fail_test();
      do {
        _color(31);
        printf("\nfailure in %s() line %d\n", __func__, 136);
        _color(0);
      } while (0);
      return 1;
    }
  } while (0);
  _it("should return dst");
  do {
    _begin_assert();
    if (ft_strncpy(dest, src, 4) != dest) {
      _fail_test();
      do {
        _color(31);
        printf("\nfailure in %s() line %d\n", __func__, 139);
        _color(0);
      } while (0);
      printf("expected %p to equal %p\n\n", ft_strncpy(dest, src, 4), dest);
      return 1;
    }
  } while (0);
  do {
    _close_pending();
    printf("\n");
    return (0);
  } while (0);
}


x86 assembly (clang, -O0):
<test_ft_strncpy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xe61(%rip),%rdi
lea    0xe5e(%rip),%rsi
add    $0x5,%rsi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe5c(%rip),%rdi
mov    $0x0,%al
call   1090 <_it@plt>
lea    0xe81(%rip),%rax
mov    %rax,-0x10(%rbp)
lea    -0x1a(%rbp),%rdi
mov    $0x1,%esi
mov    $0xa,%edx
call   1060 <memset@plt>
lea    -0x1a(%rbp),%rdi
mov    -0x10(%rbp),%rsi
xor    %edx,%edx
mov    $0x0,%al
call   10b0 <ft_strncpy@plt>
mov    $0x0,%al
call   1030 <_begin_assert@plt>
movsbl -0x1a(%rbp),%eax
cmp    $0x1,%eax
je     1244 <test_ft_strncpy+0xb4>
mov    $0x0,%al
call   10a0 <_fail_test@plt>
mov    $0x1f,%edi
mov    $0x0,%al
call   1080 <_color@plt>
lea    0xe32(%rip),%rdi
lea    0xde1(%rip),%rsi
mov    $0x72,%edx
mov    $0x0,%al
call   1050 <printf@plt>
xor    %edi,%edi
mov    $0x0,%al
call   1080 <_color@plt>
movl   $0x1,-0x4(%rbp)
jmp    1625 <test_ft_strncpy+0x495>
jmp    1249 <test_ft_strncpy+0xb9>
lea    -0x1a(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x4,%edx
mov    $0x0,%al
call   10b0 <ft_strncpy@plt>
mov    $0x0,%al
call   1030 <_begin_assert@plt>
lea    -0x1a(%rbp),%rax
mov    -0x10(%rbp),%rcx
mov    (%rcx),%ecx
mov    (%rax),%eax
sub    %ecx,%eax
setne  %al
movzbl %al,%eax
cmp    $0x0,%eax
je     12c3 <test_ft_strncpy+0x133>
mov    $0x0,%al
call   10a0 <_fail_test@plt>
mov    $0x1f,%edi
mov    $0x0,%al
call   1080 <_color@plt>
lea    0xdb3(%rip),%rdi
lea    0xd62(%rip),%rsi
mov    $0x75,%edx
mov    $0x0,%al
call   1050 <printf@plt>
xor    %edi,%edi
mov    $0x0,%al
call   1080 <_color@plt>
movl   $0x1,-0x4(%rbp)
jmp    1625 <test_ft_strncpy+0x495>
jmp    12c8 <test_ft_strncpy+0x138>
jmp    12cd <test_ft_strncpy+0x13d>
mov    $0x0,%al
call   1030 <_begin_assert@plt>
movsbl -0x16(%rbp),%eax
cmp    $0x1,%eax
je     1323 <test_ft_strncpy+0x193>
mov    $0x0,%al
call   10a0 <_fail_test@plt>
mov    $0x1f,%edi
mov    $0x0,%al
call   1080 <_color@plt>
lea    0xd53(%rip),%rdi
lea    0xd02(%rip),%rsi
mov    $0x76,%edx
mov    $0x0,%al
call   1050 <printf@plt>
xor    %edi,%edi
mov    $0x0,%al
call   1080 <_color@plt>
movl   $0x1,-0x4(%rbp)
jmp    1625 <test_ft_strncpy+0x495>
jmp    1328 <test_ft_strncpy+0x198>
lea    0xd39(%rip),%rdi
mov    $0x0,%al
call   1090 <_it@plt>
lea    0xd5e(%rip),%rax
mov    %rax,-0x10(%rbp)
lea    -0x1a(%rbp),%rdi
mov    $0x1,%esi
mov    $0xa,%edx
call   1060 <memset@plt>
lea    -0x1a(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x5,%edx
mov    $0x0,%al
call   10b0 <ft_strncpy@plt>
mov    $0x0,%al
call   1030 <_begin_assert@plt>
lea    -0x1a(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
je     13dd <test_ft_strncpy+0x24d>
mov    $0x0,%al
call   10a0 <_fail_test@plt>
mov    $0x1f,%edi
mov    $0x0,%al
call   1080 <_color@plt>
lea    0xcaf(%rip),%rdi
lea    0xc5e(%rip),%rsi
mov    $0x7d,%edx
mov    $0x0,%al
call   1050 <printf@plt>
xor    %edi,%edi
mov    $0x0,%al
call   1080 <_color@plt>
lea    -0x1a(%rbp),%rsi
mov    -0x10(%rbp),%rdx
lea    0xcd5(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1625 <test_ft_strncpy+0x495>
jmp    13e2 <test_ft_strncpy+0x252>
jmp    13e7 <test_ft_strncpy+0x257>
mov    $0x0,%al
call   1030 <_begin_assert@plt>
cmpb   $0x0,-0x17(%rbp)
jne    140f <test_ft_strncpy+0x27f>
cmpb   $0x0,-0x16(%rbp)
jne    140f <test_ft_strncpy+0x27f>
movsbl -0x15(%rbp),%eax
cmp    $0x0,%eax
jne    1451 <test_ft_strncpy+0x2c1>
mov    $0x0,%al
call   10a0 <_fail_test@plt>
mov    $0x1f,%edi
mov    $0x0,%al
call   1080 <_color@plt>
lea    0xc25(%rip),%rdi
lea    0xbd4(%rip),%rsi
mov    $0x7e,%edx
mov    $0x0,%al
call   1050 <printf@plt>
xor    %edi,%edi
mov    $0x0,%al
call   1080 <_color@plt>
movl   $0x1,-0x4(%rbp)
jmp    1625 <test_ft_strncpy+0x495>
jmp    1456 <test_ft_strncpy+0x2c6>
lea    0xc60(%rip),%rdi
mov    $0x0,%al
call   1090 <_it@plt>
lea    0xbdc(%rip),%rax
mov    %rax,-0x10(%rbp)
lea    -0x1a(%rbp),%rdi
mov    $0x1,%esi
mov    $0xa,%edx
call   1060 <memset@plt>
lea    -0x1a(%rbp),%rdi
mov    -0x10(%rbp),%rsi
xor    %edx,%edx
mov    $0x0,%al
call   10b0 <ft_strncpy@plt>
mov    $0x0,%al
call   1030 <_begin_assert@plt>
movsbl -0x1a(%rbp),%eax
cmp    $0x0,%eax
jne    14e9 <test_ft_strncpy+0x359>
mov    $0x0,%al
call   10a0 <_fail_test@plt>
mov    $0x1f,%edi
mov    $0x0,%al
call   1080 <_color@plt>
lea    0xb8d(%rip),%rdi
lea    0xb3c(%rip),%rsi
mov    $0x85,%edx
mov    $0x0,%al
call   1050 <printf@plt>
xor    %edi,%edi
mov    $0x0,%al
call   1080 <_color@plt>
movl   $0x1,-0x4(%rbp)
jmp    1625 <test_ft_strncpy+0x495>
jmp    14ee <test_ft_strncpy+0x35e>
lea    -0x1a(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x4,%edx
mov    $0x0,%al
call   10b0 <ft_strncpy@plt>
mov    $0x0,%al
call   1030 <_begin_assert@plt>
movsbl -0x16(%rbp),%eax
cmp    $0x0,%eax
jne    1558 <test_ft_strncpy+0x3c8>
mov    $0x0,%al
call   10a0 <_fail_test@plt>
mov    $0x1f,%edi
mov    $0x0,%al
call   1080 <_color@plt>
lea    0xb1e(%rip),%rdi
lea    0xacd(%rip),%rsi
mov    $0x88,%edx
mov    $0x0,%al
call   1050 <printf@plt>
xor    %edi,%edi
mov    $0x0,%al
call   1080 <_color@plt>
movl   $0x1,-0x4(%rbp)
jmp    1625 <test_ft_strncpy+0x495>
jmp    155d <test_ft_strncpy+0x3cd>
lea    0xb7c(%rip),%rdi
mov    $0x0,%al
call   1090 <_it@plt>
mov    $0x0,%al
call   1030 <_begin_assert@plt>
lea    -0x1a(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x4,%edx
mov    $0x0,%al
call   10b0 <ft_strncpy@plt>
cltq
lea    -0x1a(%rbp),%rcx
cmp    %rcx,%rax
je     15ff <test_ft_strncpy+0x46f>
mov    $0x0,%al
call   10a0 <_fail_test@plt>
mov    $0x1f,%edi
mov    $0x0,%al
call   1080 <_color@plt>
lea    0xa9f(%rip),%rdi
lea    0xa4e(%rip),%rsi
mov    $0x8b,%edx
mov    $0x0,%al
call   1050 <printf@plt>
xor    %edi,%edi
mov    $0x0,%al
call   1080 <_color@plt>
lea    -0x1a(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x4,%edx
mov    $0x0,%al
call   10b0 <ft_strncpy@plt>
mov    %eax,%esi
lea    -0x1a(%rbp),%rdx
lea    0xb06(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1625 <test_ft_strncpy+0x495>
jmp    1604 <test_ft_strncpy+0x474>
jmp    1609 <test_ft_strncpy+0x479>
mov    $0x0,%al
call   1040 <_close_pending@plt>
lea    0xaa4(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_ft_strncpy>:
push   %r14
push   %rbx
sub    $0x18,%rsp
lea    0xe67(%rip),%rdi
call   1050 <puts@plt>
lea    0xe66(%rip),%rdi
xor    %eax,%eax
call   1090 <_it@plt>
movabs $0x101010101010101,%rbx
01 01 01
mov    %rbx,0x8(%rsp)
movw   $0x101,0x10(%rsp)
lea    0xe75(%rip),%rsi
lea    0x8(%rsp),%rdi
xor    %edx,%edx
xor    %eax,%eax
call   10b0 <ft_strncpy@plt>
xor    %eax,%eax
call   1040 <_begin_assert@plt>
cmpb   $0x1,0x8(%rsp)
jne    123b <test_ft_strncpy+0xab>
lea    0xe52(%rip),%rsi
lea    0x8(%rsp),%rdi
mov    $0x4,%edx
xor    %eax,%eax
call   10b0 <ft_strncpy@plt>
xor    %eax,%eax
call   1040 <_begin_assert@plt>
cmpl   $0x64636261,0x8(%rsp)
64
je     1280 <test_ft_strncpy+0xf0>
xor    %eax,%eax
call   10a0 <_fail_test@plt>
mov    $0x1f,%edi
xor    %eax,%eax
call   1080 <_color@plt>
lea    0xe1d(%rip),%rdi
lea    0xdcc(%rip),%rsi
mov    $0x75,%edx
jmp    1261 <test_ft_strncpy+0xd1>
xor    %eax,%eax
call   10a0 <_fail_test@plt>
mov    $0x1f,%edi
xor    %eax,%eax
call   1080 <_color@plt>
lea    0xdf5(%rip),%rdi
lea    0xda4(%rip),%rsi
mov    $0x72,%edx
xor    %eax,%eax
call   1070 <printf@plt>
xor    %edi,%edi
xor    %eax,%eax
call   1080 <_color@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret
xor    %eax,%eax
call   1040 <_begin_assert@plt>
cmpb   $0x1,0xc(%rsp)
jne    132e <test_ft_strncpy+0x19e>
lea    0xdcb(%rip),%rdi
xor    %eax,%eax
call   1090 <_it@plt>
mov    %rbx,0x8(%rsp)
movw   $0x101,0x10(%rsp)
lea    0xde4(%rip),%rsi
lea    0x8(%rsp),%rdi
mov    $0x5,%edx
xor    %eax,%eax
call   10b0 <ft_strncpy@plt>
xor    %eax,%eax
call   1040 <_begin_assert@plt>
cmpl   $0x6c6f6c,0x8(%rsp)
je     1359 <test_ft_strncpy+0x1c9>
xor    %eax,%eax
call   10a0 <_fail_test@plt>
mov    $0x1f,%edi
xor    %eax,%eax
call   1080 <_color@plt>
lea    0xd57(%rip),%rdi
lea    0xd06(%rip),%rsi
mov    $0x7d,%edx
xor    %eax,%eax
call   1070 <printf@plt>
xor    %edi,%edi
xor    %eax,%eax
call   1080 <_color@plt>
lea    0xd85(%rip),%rdi
lea    0xd7a(%rip),%rdx
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   1070 <printf@plt>
jmp    1271 <test_ft_strncpy+0xe1>
xor    %eax,%eax
call   10a0 <_fail_test@plt>
mov    $0x1f,%edi
xor    %eax,%eax
call   1080 <_color@plt>
lea    0xd02(%rip),%rdi
lea    0xcb1(%rip),%rsi
mov    $0x76,%edx
jmp    1261 <test_ft_strncpy+0xd1>
xor    %eax,%eax
call   1040 <_begin_assert@plt>
cmpb   $0x0,0xb(%rsp)
jne    1490 <test_ft_strncpy+0x300>
cmpb   $0x0,0xc(%rsp)
jne    1490 <test_ft_strncpy+0x300>
cmpb   $0x0,0xd(%rsp)
je     1490 <test_ft_strncpy+0x300>
lea    0xd31(%rip),%rdi
xor    %eax,%eax
call   1090 <_it@plt>
mov    %rbx,0x8(%rsp)
movw   $0x101,0x10(%rsp)
lea    0xca1(%rip),%rsi
lea    0x8(%rsp),%rdi
xor    %edx,%edx
xor    %eax,%eax
call   10b0 <ft_strncpy@plt>
xor    %eax,%eax
call   1040 <_begin_assert@plt>
cmpb   $0x0,0x8(%rsp)
je     14bb <test_ft_strncpy+0x32b>
lea    0xc7a(%rip),%rsi
lea    0x8(%rsp),%r14
mov    %r14,%rdi
mov    $0x4,%edx
xor    %eax,%eax
call   10b0 <ft_strncpy@plt>
xor    %eax,%eax
call   1040 <_begin_assert@plt>
cmpb   $0x0,0xc(%rsp)
je     14e6 <test_ft_strncpy+0x356>
lea    0xce6(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1090 <_it@plt>
xor    %eax,%eax
call   1040 <_begin_assert@plt>
lea    0xc36(%rip),%rsi
mov    %r14,%rdi
mov    $0x4,%edx
xor    %eax,%eax
call   10b0 <ft_strncpy@plt>
cltq
cmp    %rax,%r14
je     1511 <test_ft_strncpy+0x381>
xor    %eax,%eax
call   10a0 <_fail_test@plt>
mov    $0x1f,%edi
xor    %eax,%eax
call   1080 <_color@plt>
lea    0xc09(%rip),%rdi
lea    0xbb8(%rip),%rsi
mov    $0x8b,%edx
xor    %eax,%eax
call   1070 <printf@plt>
xor    %edi,%edi
xor    %eax,%eax
call   1080 <_color@plt>
lea    0xbdf(%rip),%rsi
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x4,%edx
xor    %eax,%eax
call   10b0 <ft_strncpy@plt>
lea    0xc6f(%rip),%rdi
mov    %eax,%esi
mov    %rbx,%rdx
xor    %eax,%eax
call   1070 <printf@plt>
jmp    1271 <test_ft_strncpy+0xe1>
xor    %eax,%eax
call   10a0 <_fail_test@plt>
mov    $0x1f,%edi
xor    %eax,%eax
call   1080 <_color@plt>
lea    0xba0(%rip),%rdi
lea    0xb4f(%rip),%rsi
mov    $0x7e,%edx
jmp    1261 <test_ft_strncpy+0xd1>
xor    %eax,%eax
call   10a0 <_fail_test@plt>
mov    $0x1f,%edi
xor    %eax,%eax
call   1080 <_color@plt>
lea    0xb75(%rip),%rdi
lea    0xb24(%rip),%rsi
mov    $0x85,%edx
jmp    1261 <test_ft_strncpy+0xd1>
xor    %eax,%eax
call   10a0 <_fail_test@plt>
mov    $0x1f,%edi
xor    %eax,%eax
call   1080 <_color@plt>
lea    0xb4a(%rip),%rdi
lea    0xaf9(%rip),%rsi
mov    $0x88,%edx
jmp    1261 <test_ft_strncpy+0xd1>
xor    %eax,%eax
call   1060 <_close_pending@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    1276 <test_ft_strncpy+0xe6>

LLVM IR (-O0):
@.str = [4 x i8] c"%s\0A\00"
@__func__.test_ft_strncpy = [16 x i8] c"test_ft_strncpy\00"
@.str.1 = [51 x i8] c"should copy at most n characters from src into dst\00"
@.str.2 = [7 x i8] c"abcdef\00"
@.str.3 = [26 x i8] c"\0Afailure in %s() line %d\0A\00"
@.str.4 = [51 x i8] c"should fill the remainder of dst is filled with \\0\00"
@.str.5 = [4 x i8] c"lol\00"
@.str.6 = [30 x i8] c"expected \22%s\22 to equal \22%s\22\0A\0A\00"
@.str.7 = [35 x i8] c"should not terminate dst otherwise\00"
@.str.8 = [18 x i8] c"should return dst\00"
@.str.9 = [26 x i8] c"expected %p to equal %p\0A\0A\00"
@.str.10 = [2 x i8] c"\0A\00"
define i32 @test_ft_strncpy() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca [10 x i8]
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @__func__.test_ft_strncpy, i64 0, i64 5))
%5 = call i32 (i8*, ...) bitcast (i32 (...)* @_it to i32 (i8*, ...)*)(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0))
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8** %2
%6 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%8 = load i8*, i8** %2
%9 = call i32 (i8*, i8*, i32, ...) bitcast (i32 (...)* @ft_strncpy to i32 (i8*, i8*, i32, ...)*)(i8* %7, i8* %8, i32 0)
br label %10
10: ; preds = %0
%11 = call i32 (...) @_begin_assert()
%12 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp eq i32 %14, 1
br i1 %15, label %23, label %16
16: ; preds = %10
%17 = call i32 (...) @_fail_test()
br label %18
18: ; preds = %16
%19 = call i32 (i32, ...) bitcast (i32 (...)* @_color to i32 (i32, ...)*)(i32 31)
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @__func__.test_ft_strncpy, i64 0, i64 0), i32 114)
%21 = call i32 (i32, ...) bitcast (i32 (...)* @_color to i32 (i32, ...)*)(i32 0)
br label %22
22: ; preds = %18
store i32 1, i32* %1
br label %169
23: ; preds = %10
br label %24
24: ; preds = %23
%25 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%26 = load i8*, i8** %2
%27 = call i32 (i8*, i8*, i32, ...) bitcast (i32 (...)* @ft_strncpy to i32 (i8*, i8*, i32, ...)*)(i8* %25, i8* %26, i32 4)
br label %28
28: ; preds = %24
%29 = call i32 (...) @_begin_assert()
%30 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%31 = load i8*, i8** %2
%32 = call i32 @memcmp(i8* %30, i8* %31, i64 4)
%33 = icmp ne i32 %32, 0
br i1 %33, label %34, label %41
34: ; preds = %28
%35 = call i32 (...) @_fail_test()
br label %36
36: ; preds = %34
%37 = call i32 (i32, ...) bitcast (i32 (...)* @_color to i32 (i32, ...)*)(i32 31)
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @__func__.test_ft_strncpy, i64 0, i64 0), i32 117)
%39 = call i32 (i32, ...) bitcast (i32 (...)* @_color to i32 (i32, ...)*)(i32 0)
br label %40
40: ; preds = %36
store i32 1, i32* %1
br label %169
41: ; preds = %28
br label %42
42: ; preds = %41
br label %43
43: ; preds = %42
%44 = call i32 (...) @_begin_assert()
%45 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 4
%46 = load i8, i8* %45
%47 = sext i8 %46 to i32
%48 = icmp eq i32 %47, 1
br i1 %48, label %56, label %49
49: ; preds = %43
%50 = call i32 (...) @_fail_test()
br label %51
51: ; preds = %49
%52 = call i32 (i32, ...) bitcast (i32 (...)* @_color to i32 (i32, ...)*)(i32 31)
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @__func__.test_ft_strncpy, i64 0, i64 0), i32 118)
%54 = call i32 (i32, ...) bitcast (i32 (...)* @_color to i32 (i32, ...)*)(i32 0)
br label %55
55: ; preds = %51
store i32 1, i32* %1
br label %169
56: ; preds = %43
br label %57
57: ; preds = %56
%58 = call i32 (i8*, ...) bitcast (i32 (...)* @_it to i32 (i8*, ...)*)(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.4, i64 0, i64 0))
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8** %2
%59 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%60 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%61 = load i8*, i8** %2
%62 = call i32 (i8*, i8*, i32, ...) bitcast (i32 (...)* @ft_strncpy to i32 (i8*, i8*, i32, ...)*)(i8* %60, i8* %61, i32 5)
br label %63
63: ; preds = %57
%64 = call i32 (...) @_begin_assert()
%65 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%66 = load i8*, i8** %2
%67 = call i32 @strcmp(i8* %65, i8* %66)
%68 = icmp ne i32 %67, 0
br i1 %68, label %69, label %79
69: ; preds = %63
%70 = call i32 (...) @_fail_test()
br label %71
71: ; preds = %69
%72 = call i32 (i32, ...) bitcast (i32 (...)* @_color to i32 (i32, ...)*)(i32 31)
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @__func__.test_ft_strncpy, i64 0, i64 0), i32 125)
%74 = call i32 (i32, ...) bitcast (i32 (...)* @_color to i32 (i32, ...)*)(i32 0)
br label %75
75: ; preds = %71
%76 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%77 = load i8*, i8** %2
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.6, i64 0, i64 0), i8* %76, i8* %77)
store i32 1, i32* %1
br label %169
79: ; preds = %63
br label %80
80: ; preds = %79
br label %81
81: ; preds = %80
%82 = call i32 (...) @_begin_assert()
%83 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 3
%84 = load i8, i8* %83
%85 = icmp ne i8 %84, 0
br i1 %85, label %95, label %86
86: ; preds = %81
%87 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 4
%88 = load i8, i8* %87
%89 = icmp ne i8 %88, 0
br i1 %89, label %95, label %90
90: ; preds = %86
%91 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 5
%92 = load i8, i8* %91
%93 = sext i8 %92 to i32
%94 = icmp ne i32 %93, 0
br i1 %94, label %102, label %95
95: ; preds = %90, %86, %81
%96 = call i32 (...) @_fail_test()
br label %97
97: ; preds = %95
%98 = call i32 (i32, ...) bitcast (i32 (...)* @_color to i32 (i32, ...)*)(i32 31)
%99 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @__func__.test_ft_strncpy, i64 0, i64 0), i32 126)
%100 = call i32 (i32, ...) bitcast (i32 (...)* @_color to i32 (i32, ...)*)(i32 0)
br label %101
101: ; preds = %97
store i32 1, i32* %1
br label %169
102: ; preds = %90
br label %103
103: ; preds = %102
%104 = call i32 (i8*, ...) bitcast (i32 (...)* @_it to i32 (i8*, ...)*)(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.7, i64 0, i64 0))
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8** %2
%105 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%106 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%107 = load i8*, i8** %2
%108 = call i32 (i8*, i8*, i32, ...) bitcast (i32 (...)* @ft_strncpy to i32 (i8*, i8*, i32, ...)*)(i8* %106, i8* %107, i32 0)
br label %109
109: ; preds = %103
%110 = call i32 (...) @_begin_assert()
%111 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%112 = load i8, i8* %111
%113 = sext i8 %112 to i32
%114 = icmp ne i32 %113, 0
br i1 %114, label %122, label %115
115: ; preds = %109
%116 = call i32 (...) @_fail_test()
br label %117
117: ; preds = %115
%118 = call i32 (i32, ...) bitcast (i32 (...)* @_color to i32 (i32, ...)*)(i32 31)
%119 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @__func__.test_ft_strncpy, i64 0, i64 0), i32 133)
%120 = call i32 (i32, ...) bitcast (i32 (...)* @_color to i32 (i32, ...)*)(i32 0)
br label %121
121: ; preds = %117
store i32 1, i32* %1
br label %169
122: ; preds = %109
br label %123
123: ; preds = %122
%124 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%125 = load i8*, i8** %2
%126 = call i32 (i8*, i8*, i32, ...) bitcast (i32 (...)* @ft_strncpy to i32 (i8*, i8*, i32, ...)*)(i8* %124, i8* %125, i32 4)
br label %127
127: ; preds = %123
%128 = call i32 (...) @_begin_assert()
%129 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 4
%130 = load i8, i8* %129
%131 = sext i8 %130 to i32
%132 = icmp ne i32 %131, 0
br i1 %132, label %140, label %133
133: ; preds = %127
%134 = call i32 (...) @_fail_test()
br label %135
135: ; preds = %133
%136 = call i32 (i32, ...) bitcast (i32 (...)* @_color to i32 (i32, ...)*)(i32 31)
%137 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @__func__.test_ft_strncpy, i64 0, i64 0), i32 136)
%138 = call i32 (i32, ...) bitcast (i32 (...)* @_color to i32 (i32, ...)*)(i32 0)
br label %139
139: ; preds = %135
store i32 1, i32* %1
br label %169
140: ; preds = %127
br label %141
141: ; preds = %140
%142 = call i32 (i8*, ...) bitcast (i32 (...)* @_it to i32 (i8*, ...)*)(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i64 0, i64 0))
br label %143
143: ; preds = %141
%144 = call i32 (...) @_begin_assert()
%145 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%146 = load i8*, i8** %2
%147 = call i32 (i8*, i8*, i32, ...) bitcast (i32 (...)* @ft_strncpy to i32 (i8*, i8*, i32, ...)*)(i8* %145, i8* %146, i32 4)
%148 = sext i32 %147 to i64
%149 = inttoptr i64 %148 to i8*
%150 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%151 = icmp ne i8* %149, %150
br i1 %151, label %152, label %164
152: ; preds = %143
%153 = call i32 (...) @_fail_test()
br label %154
154: ; preds = %152
%155 = call i32 (i32, ...) bitcast (i32 (...)* @_color to i32 (i32, ...)*)(i32 31)
%156 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @__func__.test_ft_strncpy, i64 0, i64 0), i32 139)
%157 = call i32 (i32, ...) bitcast (i32 (...)* @_color to i32 (i32, ...)*)(i32 0)
br label %158
158: ; preds = %154
%159 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%160 = load i8*, i8** %2
%161 = call i32 (i8*, i8*, i32, ...) bitcast (i32 (...)* @ft_strncpy to i32 (i8*, i8*, i32, ...)*)(i8* %159, i8* %160, i32 4)
%162 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%163 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.9, i64 0, i64 0), i32 %161, i8* %162)
store i32 1, i32* %1
br label %169
164: ; preds = %143
br label %165
165: ; preds = %164
br label %166
166: ; preds = %165
%167 = call i32 (...) @_close_pending()
%168 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
store i32 0, i32* %1
br label %169
169: ; preds = %22, %40, %55, %75, %101, %121, %139, %158, %166
%170 = load i32, i32* %1
ret i32 %170
}

LLVM IR (-O2):
@__func__.test_ft_strncpy = [16 x i8] c"test_ft_strncpy\00"
@.str.1 = [51 x i8] c"should copy at most n characters from src into dst\00"
@.str.2 = [7 x i8] c"abcdef\00"
@.str.3 = [26 x i8] c"\0Afailure in %s() line %d\0A\00"
@.str.4 = [51 x i8] c"should fill the remainder of dst is filled with \\0\00"
@.str.5 = [4 x i8] c"lol\00"
@.str.6 = [30 x i8] c"expected \22%s\22 to equal \22%s\22\0A\0A\00"
@.str.7 = [35 x i8] c"should not terminate dst otherwise\00"
@.str.8 = [18 x i8] c"should return dst\00"
@.str.9 = [26 x i8] c"expected %p to equal %p\0A\0A\00"
define i32 @test_ft_strncpy() {
%1 = alloca [10 x i8]
%2 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @__func__.test_ft_strncpy, i64 0, i64 5))
%4 = tail call i32 (i8*, ...) bitcast (i32 (...)* @_it to i32 (i8*, ...)*)(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 (i8*, i8*, i32, ...) bitcast (i32 (...)* @ft_strncpy to i32 (i8*, i8*, i32, ...)*)(i8* %2, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 0)
%6 = call i32 (...) @_begin_assert()
%7 = load i8, i8* %2
%8 = icmp eq i8 %7, 1
br i1 %8, label %14, label %9
9: ; preds = %0
%10 = call i32 (...) @_fail_test()
%11 = call i32 (i32, ...) bitcast (i32 (...)* @_color to i32 (i32, ...)*)(i32 31)
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @__func__.test_ft_strncpy, i64 0, i64 0), i32 114)
%13 = call i32 (i32, ...) bitcast (i32 (...)* @_color to i32 (i32, ...)*)(i32 0)
br label %101
14: ; preds = %0
%15 = call i32 (i8*, i8*, i32, ...) bitcast (i32 (...)* @ft_strncpy to i32 (i8*, i8*, i32, ...)*)(i8* %2, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 4)
%16 = call i32 (...) @_begin_assert()
%17 = call i32 @bcmp(i8* dereferenceable(4) %2, i8* dereferenceable(4) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i64 4)
%18 = icmp eq i32 %17, 0
br i1 %18, label %24, label %19
19: ; preds = %14
%20 = call i32 (...) @_fail_test()
%21 = call i32 (i32, ...) bitcast (i32 (...)* @_color to i32 (i32, ...)*)(i32 31)
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @__func__.test_ft_strncpy, i64 0, i64 0), i32 117)
%23 = call i32 (i32, ...) bitcast (i32 (...)* @_color to i32 (i32, ...)*)(i32 0)
br label %101
24: ; preds = %14
%25 = call i32 (...) @_begin_assert()
%26 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 4
%27 = load i8, i8* %26
%28 = icmp eq i8 %27, 1
br i1 %28, label %34, label %29
29: ; preds = %24
%30 = call i32 (...) @_fail_test()
%31 = call i32 (i32, ...) bitcast (i32 (...)* @_color to i32 (i32, ...)*)(i32 31)
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @__func__.test_ft_strncpy, i64 0, i64 0), i32 118)
%33 = call i32 (i32, ...) bitcast (i32 (...)* @_color to i32 (i32, ...)*)(i32 0)
br label %101
34: ; preds = %24
%35 = call i32 (i8*, ...) bitcast (i32 (...)* @_it to i32 (i8*, ...)*)(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.4, i64 0, i64 0))
%36 = call i32 (i8*, i8*, i32, ...) bitcast (i32 (...)* @ft_strncpy to i32 (i8*, i8*, i32, ...)*)(i8* %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 5)
%37 = call i32 (...) @_begin_assert()
%38 = call i32 @bcmp(i8* dereferenceable(4) %2, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i64 4)
%39 = icmp eq i32 %38, 0
br i1 %39, label %46, label %40
40: ; preds = %34
%41 = call i32 (...) @_fail_test()
%42 = call i32 (i32, ...) bitcast (i32 (...)* @_color to i32 (i32, ...)*)(i32 31)
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @__func__.test_ft_strncpy, i64 0, i64 0), i32 125)
%44 = call i32 (i32, ...) bitcast (i32 (...)* @_color to i32 (i32, ...)*)(i32 0)
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.6, i64 0, i64 0), i8* %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
br label %101
46: ; preds = %34
%47 = call i32 (...) @_begin_assert()
%48 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 3
%49 = load i8, i8* %48
%50 = icmp eq i8 %49, 0
%51 = load i8, i8* %26
%52 = icmp eq i8 %51, 0
%53 = select i1 %50, i1 %52, i1 false
%54 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 5
%55 = load i8, i8* %54
%56 = icmp ne i8 %55, 0
%57 = select i1 %53, i1 %56, i1 false
br i1 %57, label %63, label %58
58: ; preds = %46
%59 = call i32 (...) @_fail_test()
%60 = call i32 (i32, ...) bitcast (i32 (...)* @_color to i32 (i32, ...)*)(i32 31)
%61 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @__func__.test_ft_strncpy, i64 0, i64 0), i32 126)
%62 = call i32 (i32, ...) bitcast (i32 (...)* @_color to i32 (i32, ...)*)(i32 0)
br label %101
63: ; preds = %46
%64 = call i32 (i8*, ...) bitcast (i32 (...)* @_it to i32 (i8*, ...)*)(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.7, i64 0, i64 0))
%65 = call i32 (i8*, i8*, i32, ...) bitcast (i32 (...)* @ft_strncpy to i32 (i8*, i8*, i32, ...)*)(i8* %2, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 0)
%66 = call i32 (...) @_begin_assert()
%67 = load i8, i8* %2
%68 = icmp eq i8 %67, 0
br i1 %68, label %69, label %74
69: ; preds = %63
%70 = call i32 (...) @_fail_test()
%71 = call i32 (i32, ...) bitcast (i32 (...)* @_color to i32 (i32, ...)*)(i32 31)
%72 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @__func__.test_ft_strncpy, i64 0, i64 0), i32 133)
%73 = call i32 (i32, ...) bitcast (i32 (...)* @_color to i32 (i32, ...)*)(i32 0)
br label %101
74: ; preds = %63
%75 = call i32 (i8*, i8*, i32, ...) bitcast (i32 (...)* @ft_strncpy to i32 (i8*, i8*, i32, ...)*)(i8* %2, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 4)
%76 = call i32 (...) @_begin_assert()
%77 = load i8, i8* %26
%78 = icmp eq i8 %77, 0
br i1 %78, label %79, label %84
79: ; preds = %74
%80 = call i32 (...) @_fail_test()
%81 = call i32 (i32, ...) bitcast (i32 (...)* @_color to i32 (i32, ...)*)(i32 31)
%82 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @__func__.test_ft_strncpy, i64 0, i64 0), i32 136)
%83 = call i32 (i32, ...) bitcast (i32 (...)* @_color to i32 (i32, ...)*)(i32 0)
br label %101
84: ; preds = %74
%85 = call i32 (i8*, ...) bitcast (i32 (...)* @_it to i32 (i8*, ...)*)(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i64 0, i64 0))
%86 = call i32 (...) @_begin_assert()
%87 = call i32 (i8*, i8*, i32, ...) bitcast (i32 (...)* @ft_strncpy to i32 (i8*, i8*, i32, ...)*)(i8* %2, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 4)
%88 = sext i32 %87 to i64
%89 = inttoptr i64 %88 to i8*
%90 = icmp eq i8* %2, %89
br i1 %90, label %98, label %91
91: ; preds = %84
%92 = call i32 (...) @_fail_test()
%93 = call i32 (i32, ...) bitcast (i32 (...)* @_color to i32 (i32, ...)*)(i32 31)
%94 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @__func__.test_ft_strncpy, i64 0, i64 0), i32 139)
%95 = call i32 (i32, ...) bitcast (i32 (...)* @_color to i32 (i32, ...)*)(i32 0)
%96 = call i32 (i8*, i8*, i32, ...) bitcast (i32 (...)* @ft_strncpy to i32 (i8*, i8*, i32, ...)*)(i8* %2, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 4)
%97 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.9, i64 0, i64 0), i32 %96, i8* %2)
br label %101
98: ; preds = %84
%99 = call i32 (...) @_close_pending()
%100 = call i32 @putchar(i32 10)
br label %101
101: ; preds = %98, %91, %79, %69, %58, %40, %29, %19, %9
%102 = phi i32 [ 1, %19 ], [ 1, %40 ], [ 1, %91 ], [ 0, %98 ], [ 1, %79 ], [ 1, %69 ], [ 1, %58 ], [ 1, %29 ], [ 1, %9 ]
ret i32 %102
}