int test_ft_strdup() {
  char *s;
  printf("%s\n", __func__ + 5);
  _it("should return a pointer to the copy of the string s1");
  s = "";
  do {
    _begin_assert();
    if (strcmp(ft_strdup(s), strdup(s))) {
      _fail_test();
      do {
        _color(31);
        printf("\nfailure in %s() line %d\n", __func__, 67);
        _color(0);
      } while (0);
      printf("expected \"%s\" to equal \"%s\"\n\n", (char *)ft_strdup(s),
             (char *)strdup(s));
      return 1;
    }
  } while (0);
  s = ";nh[wERNO;";
  do {
    _begin_assert();
    if (strcmp(ft_strdup(s), strdup(s))) {
      _fail_test();
      do {
        _color(31);
        printf("\nfailure in %s() line %d\n", __func__, 69);
        _color(0);
      } while (0);
      printf("expected \"%s\" to equal \"%s\"\n\n", (char *)ft_strdup(s),
             (char *)strdup(s));
      return 1;
    }
  } while (0);
  _itx("should return NULL on malloc fail");
  do {
    _close_pending();
    printf("\n");
    return (0);
  } while (0);
}


x86 assembly (clang, -O0):
<test_ft_strdup>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
lea    0xe51(%rip),%rdi
lea    0xe4e(%rip),%rsi
add    $0x5,%rsi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe4b(%rip),%rdi
mov    $0x0,%al
call   10a0 <_it@plt>
lea    0xea9(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    $0x0,%al
call   1030 <_begin_assert@plt>
mov    -0x10(%rbp),%rdi
mov    $0x0,%al
call   1070 <ft_strdup@plt>
cltq
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   10c0 <strdup@plt>
mov    -0x18(%rbp),%rdi
mov    %rax,%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
je     1281 <test_ft_strdup+0xe1>
mov    $0x0,%al
call   10b0 <_fail_test@plt>
mov    $0x1f,%edi
mov    $0x0,%al
call   1080 <_color@plt>
lea    0xe1e(%rip),%rdi
lea    0xdd3(%rip),%rsi
mov    $0x43,%edx
mov    $0x0,%al
call   1050 <printf@plt>
xor    %edi,%edi
mov    $0x0,%al
call   1080 <_color@plt>
mov    -0x10(%rbp),%rdi
mov    $0x0,%al
call   1070 <ft_strdup@plt>
cltq
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   10c0 <strdup@plt>
mov    -0x20(%rbp),%rsi
mov    %rax,%rdx
lea    0xdf4(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1367 <test_ft_strdup+0x1c7>
jmp    1286 <test_ft_strdup+0xe6>
lea    0xdf3(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    $0x0,%al
call   1030 <_begin_assert@plt>
mov    -0x10(%rbp),%rdi
mov    $0x0,%al
call   1070 <ft_strdup@plt>
cltq
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   10c0 <strdup@plt>
mov    -0x28(%rbp),%rdi
mov    %rax,%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
je     1338 <test_ft_strdup+0x198>
mov    $0x0,%al
call   10b0 <_fail_test@plt>
mov    $0x1f,%edi
mov    $0x0,%al
call   1080 <_color@plt>
lea    0xd67(%rip),%rdi
lea    0xd1c(%rip),%rsi
mov    $0x45,%edx
mov    $0x0,%al
call   1050 <printf@plt>
xor    %edi,%edi
mov    $0x0,%al
call   1080 <_color@plt>
mov    -0x10(%rbp),%rdi
mov    $0x0,%al
call   1070 <ft_strdup@plt>
cltq
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
call   10c0 <strdup@plt>
mov    -0x30(%rbp),%rsi
mov    %rax,%rdx
lea    0xd3d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1367 <test_ft_strdup+0x1c7>
jmp    133d <test_ft_strdup+0x19d>
lea    0xd47(%rip),%rdi
mov    $0x0,%al
call   1090 <_itx@plt>
mov    $0x0,%al
call   1040 <_close_pending@plt>
lea    0xd25(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_ft_strdup>:
push   %r15
push   %r14
push   %rbx
lea    0xe39(%rip),%rdi
call   1050 <puts@plt>
lea    0xe37(%rip),%rdi
xor    %eax,%eax
call   10c0 <_it@plt>
xor    %eax,%eax
call   1040 <_begin_assert@plt>
lea    0xe8e(%rip),%r14
mov    %r14,%rdi
xor    %eax,%eax
call   1090 <ft_strdup@plt>
movslq %eax,%rbx
mov    %r14,%rdi
call   10e0 <strdup@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
call   1080 <strcmp@plt>
test   %eax,%eax
je     1250 <test_ft_strdup+0x90>
xor    %eax,%eax
call   10d0 <_fail_test@plt>
mov    $0x1f,%edi
xor    %eax,%eax
call   10a0 <_color@plt>
lea    0xe19(%rip),%rdi
lea    0xdce(%rip),%rsi
mov    $0x43,%edx
xor    %eax,%eax
call   1070 <printf@plt>
xor    %edi,%edi
xor    %eax,%eax
call   10a0 <_color@plt>
lea    0xe2d(%rip),%r14
jmp    12c1 <test_ft_strdup+0x101>
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <_begin_assert@plt>
lea    0xe1c(%rip),%r14
mov    %r14,%rdi
xor    %eax,%eax
call   1090 <ft_strdup@plt>
movslq %eax,%r15
mov    %r14,%rdi
call   10e0 <strdup@plt>
mov    %r15,%rdi
mov    %rax,%rsi
call   1080 <strcmp@plt>
test   %eax,%eax
je     12f7 <test_ft_strdup+0x137>
xor    %eax,%eax
call   10d0 <_fail_test@plt>
mov    $0x1f,%edi
xor    %eax,%eax
call   10a0 <_color@plt>
lea    0xda6(%rip),%rdi
lea    0xd5b(%rip),%rsi
mov    $0x45,%edx
xor    %eax,%eax
call   1070 <printf@plt>
xor    %edi,%edi
xor    %eax,%eax
call   10a0 <_color@plt>
lea    0xdbb(%rip),%r14
mov    %r14,%rdi
xor    %eax,%eax
call   1090 <ft_strdup@plt>
movslq %eax,%rbx
mov    %r14,%rdi
call   10e0 <strdup@plt>
lea    0xd81(%rip),%rdi
mov    %rbx,%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xd89(%rip),%rdi
xor    %eax,%eax
call   10b0 <_itx@plt>
xor    %eax,%eax
call   1060 <_close_pending@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    12ef <test_ft_strdup+0x12f>

LLVM IR (-O0):
@.str = [4 x i8] c"%s\0A\00"
@__func__.test_ft_strdup = [15 x i8] c"test_ft_strdup\00"
@.str.1 = [53 x i8] c"should return a pointer to the copy of the string s1\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [26 x i8] c"\0Afailure in %s() line %d\0A\00"
@.str.4 = [30 x i8] c"expected \22%s\22 to equal \22%s\22\0A\0A\00"
@.str.5 = [11 x i8] c";nh[wERNO;\00"
@.str.6 = [34 x i8] c"should return NULL on malloc fail\00"
@.str.7 = [2 x i8] c"\0A\00"
define i32 @test_ft_strdup() {
%1 = alloca i32
%2 = alloca i8*
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @__func__.test_ft_strdup, i64 0, i64 5))
%4 = call i32 (i8*, ...) bitcast (i32 (...)* @_it to i32 (i8*, ...)*)(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.1, i64 0, i64 0))
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %5
5: ; preds = %0
%6 = call i32 (...) @_begin_assert()
%7 = load i8*, i8** %2
%8 = call i32 (i8*, ...) bitcast (i32 (...)* @ft_strdup to i32 (i8*, ...)*)(i8* %7)
%9 = sext i32 %8 to i64
%10 = inttoptr i64 %9 to i8*
%11 = load i8*, i8** %2
%12 = call i8* @strdup(i8* %11)
%13 = call i32 @strcmp(i8* %10, i8* %12)
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %29
15: ; preds = %5
%16 = call i32 (...) @_fail_test()
br label %17
17: ; preds = %15
%18 = call i32 (i32, ...) bitcast (i32 (...)* @_color to i32 (i32, ...)*)(i32 31)
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @__func__.test_ft_strdup, i64 0, i64 0), i32 67)
%20 = call i32 (i32, ...) bitcast (i32 (...)* @_color to i32 (i32, ...)*)(i32 0)
br label %21
21: ; preds = %17
%22 = load i8*, i8** %2
%23 = call i32 (i8*, ...) bitcast (i32 (...)* @ft_strdup to i32 (i8*, ...)*)(i8* %22)
%24 = sext i32 %23 to i64
%25 = inttoptr i64 %24 to i8*
%26 = load i8*, i8** %2
%27 = call i8* @strdup(i8* %26)
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i8* %25, i8* %27)
store i32 1, i32* %1
br label %61
29: ; preds = %5
br label %30
30: ; preds = %29
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i8** %2
br label %31
31: ; preds = %30
%32 = call i32 (...) @_begin_assert()
%33 = load i8*, i8** %2
%34 = call i32 (i8*, ...) bitcast (i32 (...)* @ft_strdup to i32 (i8*, ...)*)(i8* %33)
%35 = sext i32 %34 to i64
%36 = inttoptr i64 %35 to i8*
%37 = load i8*, i8** %2
%38 = call i8* @strdup(i8* %37)
%39 = call i32 @strcmp(i8* %36, i8* %38)
%40 = icmp ne i32 %39, 0
br i1 %40, label %41, label %55
41: ; preds = %31
%42 = call i32 (...) @_fail_test()
br label %43
43: ; preds = %41
%44 = call i32 (i32, ...) bitcast (i32 (...)* @_color to i32 (i32, ...)*)(i32 31)
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @__func__.test_ft_strdup, i64 0, i64 0), i32 69)
%46 = call i32 (i32, ...) bitcast (i32 (...)* @_color to i32 (i32, ...)*)(i32 0)
br label %47
47: ; preds = %43
%48 = load i8*, i8** %2
%49 = call i32 (i8*, ...) bitcast (i32 (...)* @ft_strdup to i32 (i8*, ...)*)(i8* %48)
%50 = sext i32 %49 to i64
%51 = inttoptr i64 %50 to i8*
%52 = load i8*, i8** %2
%53 = call i8* @strdup(i8* %52)
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i8* %51, i8* %53)
store i32 1, i32* %1
br label %61
55: ; preds = %31
br label %56
56: ; preds = %55
%57 = call i32 (i8*, ...) bitcast (i32 (...)* @_itx to i32 (i8*, ...)*)(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.6, i64 0, i64 0))
br label %58
58: ; preds = %56
%59 = call i32 (...) @_close_pending()
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
store i32 0, i32* %1
br label %61
61: ; preds = %21, %47, %58
%62 = load i32, i32* %1
ret i32 %62
}

LLVM IR (-O2):
@__func__.test_ft_strdup = [15 x i8] c"test_ft_strdup\00"
@.str.1 = [53 x i8] c"should return a pointer to the copy of the string s1\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [26 x i8] c"\0Afailure in %s() line %d\0A\00"
@.str.4 = [30 x i8] c"expected \22%s\22 to equal \22%s\22\0A\0A\00"
@.str.5 = [11 x i8] c";nh[wERNO;\00"
@.str.6 = [34 x i8] c"should return NULL on malloc fail\00"
define i32 @test_ft_strdup() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @__func__.test_ft_strdup, i64 0, i64 5))
%2 = tail call i32 (i8*, ...) bitcast (i32 (...)* @_it to i32 (i8*, ...)*)(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.1, i64 0, i64 0))
%3 = tail call i32 (...) @_begin_assert()
%4 = tail call i32 (i8*, ...) bitcast (i32 (...)* @ft_strdup to i32 (i8*, ...)*)(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
%5 = sext i32 %4 to i64
%6 = inttoptr i64 %5 to i8*
%7 = tail call dereferenceable_or_null(1) i8* @strdup(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
%8 = tail call i32 @strcmp(i8* dereferenceable(1) %6, i8* dereferenceable(1) %7)
%9 = icmp eq i32 %8, 0
br i1 %9, label %20, label %10
10: ; preds = %0
%11 = tail call i32 (...) @_fail_test()
%12 = tail call i32 (i32, ...) bitcast (i32 (...)* @_color to i32 (i32, ...)*)(i32 31)
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @__func__.test_ft_strdup, i64 0, i64 0), i32 67)
%14 = tail call i32 (i32, ...) bitcast (i32 (...)* @_color to i32 (i32, ...)*)(i32 0)
%15 = tail call i32 (i8*, ...) bitcast (i32 (...)* @ft_strdup to i32 (i8*, ...)*)(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
%16 = sext i32 %15 to i64
%17 = inttoptr i64 %16 to i8*
%18 = tail call dereferenceable_or_null(1) i8* @strdup(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i8* %17, i8* %18)
br label %42
20: ; preds = %0
%21 = tail call i32 (...) @_begin_assert()
%22 = tail call i32 (i8*, ...) bitcast (i32 (...)* @ft_strdup to i32 (i8*, ...)*)(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0))
%23 = sext i32 %22 to i64
%24 = inttoptr i64 %23 to i8*
%25 = tail call dereferenceable_or_null(11) i8* @strdup(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0))
%26 = tail call i32 @strcmp(i8* dereferenceable(1) %24, i8* dereferenceable(1) %25)
%27 = icmp eq i32 %26, 0
br i1 %27, label %38, label %28
28: ; preds = %20
%29 = tail call i32 (...) @_fail_test()
%30 = tail call i32 (i32, ...) bitcast (i32 (...)* @_color to i32 (i32, ...)*)(i32 31)
%31 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @__func__.test_ft_strdup, i64 0, i64 0), i32 69)
%32 = tail call i32 (i32, ...) bitcast (i32 (...)* @_color to i32 (i32, ...)*)(i32 0)
%33 = tail call i32 (i8*, ...) bitcast (i32 (...)* @ft_strdup to i32 (i8*, ...)*)(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0))
%34 = sext i32 %33 to i64
%35 = inttoptr i64 %34 to i8*
%36 = tail call dereferenceable_or_null(11) i8* @strdup(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0))
%37 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i8* %35, i8* %36)
br label %42
38: ; preds = %20
%39 = tail call i32 (i8*, ...) bitcast (i32 (...)* @_itx to i32 (i8*, ...)*)(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.6, i64 0, i64 0))
%40 = tail call i32 (...) @_close_pending()
%41 = tail call i32 @putchar(i32 10)
br label %42
42: ; preds = %38, %28, %10
%43 = phi i32 [ 1, %10 ], [ 1, %28 ], [ 0, %38 ]
ret i32 %43
}