void test_str_prepend() {
  char *buffer;
  buffer = malloc(sizeof(buffer) * 200);
  str_prepend(buffer, "");
  {
    if (strcmp(buffer, "") == 0) {
      if (0 == 1)
        printf((0 == 1) ? "\033[1;37;42mOK\033[00m: %s (%s, %d)\n"
                        : "OK: %s (%s, %d)\n",
               __func__,
               "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
               "outputs/2022-01-22/02-19-57/repos/setivolkylany/c-utils/refs/"
               "heads/master/utils/str.h",
               1186);
    } else
      printf("%s (%s %d): \"%s\" != \"%s\"\n", __func__,
             "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/setivolkylany/c-utils/refs/heads/"
             "master/utils/str.h",
             1186, buffer, "");
  };
  str_prepend(buffer, "1");
  {
    if (strcmp(buffer, "1") == 0) {
      if (0 == 1)
        printf((0 == 1) ? "\033[1;37;42mOK\033[00m: %s (%s, %d)\n"
                        : "OK: %s (%s, %d)\n",
               __func__,
               "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
               "outputs/2022-01-22/02-19-57/repos/setivolkylany/c-utils/refs/"
               "heads/master/utils/str.h",
               1188);
    } else
      printf("%s (%s %d): \"%s\" != \"%s\"\n", __func__,
             "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/setivolkylany/c-utils/refs/heads/"
             "master/utils/str.h",
             1188, buffer, "1");
  };
  str_prepend(buffer, "text ");
  {
    if (strcmp(buffer, "text 1") == 0) {
      if (0 == 1)
        printf((0 == 1) ? "\033[1;37;42mOK\033[00m: %s (%s, %d)\n"
                        : "OK: %s (%s, %d)\n",
               __func__,
               "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
               "outputs/2022-01-22/02-19-57/repos/setivolkylany/c-utils/refs/"
               "heads/master/utils/str.h",
               1190);
    } else
      printf("%s (%s %d): \"%s\" != \"%s\"\n", __func__,
             "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/setivolkylany/c-utils/refs/heads/"
             "master/utils/str.h",
             1190, buffer, "text 1");
  };
  str_prepend(buffer, "\tI prepended some text before\n");
  {
    if (strcmp(buffer, "\tI prepended some text before\ntext 1") == 0) {
      if (0 == 1)
        printf((0 == 1) ? "\033[1;37;42mOK\033[00m: %s (%s, %d)\n"
                        : "OK: %s (%s, %d)\n",
               __func__,
               "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
               "outputs/2022-01-22/02-19-57/repos/setivolkylany/c-utils/refs/"
               "heads/master/utils/str.h",
               1192);
    } else
      printf("%s (%s %d): \"%s\" != \"%s\"\n", __func__,
             "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/setivolkylany/c-utils/refs/heads/"
             "master/utils/str.h",
             1192, buffer, "\tI prepended some text before\ntext 1");
  };
}


x86 assembly (clang, -O0):
<test_str_prepend>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x640,%edi
call   1060 <malloc@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xeb8(%rip),%rsi
mov    $0x0,%al
call   1030 <str_prepend@plt>
mov    -0x8(%rbp),%rdi
lea    0xea6(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    1186 <test_str_prepend+0x46>
jmp    11b2 <test_str_prepend+0x72>
mov    -0x8(%rbp),%r8
lea    0xe6f(%rip),%rdi
lea    0xe82(%rip),%rsi
lea    0xe8c(%rip),%rdx
mov    $0x4a2,%ecx
lea    0xe6e(%rip),%r9
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
lea    0xf44(%rip),%rsi
mov    $0x0,%al
call   1030 <str_prepend@plt>
mov    -0x8(%rbp),%rdi
lea    0xf32(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    11e2 <test_str_prepend+0xa2>
jmp    120e <test_str_prepend+0xce>
mov    -0x8(%rbp),%r8
lea    0xe13(%rip),%rdi
lea    0xe26(%rip),%rsi
lea    0xe30(%rip),%rdx
mov    $0x4a4,%ecx
lea    0xefa(%rip),%r9
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
lea    0xea0(%rip),%rsi
mov    $0x0,%al
call   1030 <str_prepend@plt>
mov    -0x8(%rbp),%rdi
lea    0xed1(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    123e <test_str_prepend+0xfe>
jmp    126a <test_str_prepend+0x12a>
mov    -0x8(%rbp),%r8
lea    0xdb7(%rip),%rdi
lea    0xdca(%rip),%rsi
lea    0xdd4(%rip),%rdx
mov    $0x4a6,%ecx
lea    0xe99(%rip),%r9
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
lea    0xe4a(%rip),%rsi
mov    $0x0,%al
call   1030 <str_prepend@plt>
mov    -0x8(%rbp),%rdi
lea    0xe57(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    129a <test_str_prepend+0x15a>
jmp    12c6 <test_str_prepend+0x186>
mov    -0x8(%rbp),%r8
lea    0xd5b(%rip),%rdi
lea    0xd6e(%rip),%rsi
lea    0xd78(%rip),%rdx
mov    $0x4a8,%ecx
lea    0xe1f(%rip),%r9
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_str_prepend>:
push   %r14
push   %rbx
push   %rax
mov    $0x640,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
lea    0xec1(%rip),%rsi
mov    %rax,%rdi
xor    %eax,%eax
call   1030 <str_prepend@plt>
cmpb   $0x0,(%rbx)
je     1192 <test_str_prepend+0x52>
lea    0xe92(%rip),%rdi
lea    0xea5(%rip),%rsi
lea    0xeaf(%rip),%rdx
lea    0xe96(%rip),%r9
mov    $0x4a2,%ecx
mov    %rbx,%r8
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf68(%rip),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1030 <str_prepend@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <strcmp@plt>
test   %eax,%eax
je     11e0 <test_str_prepend+0xa0>
lea    0xe44(%rip),%rdi
lea    0xe57(%rip),%rsi
lea    0xe61(%rip),%rdx
lea    0xf30(%rip),%r9
mov    $0x4a4,%ecx
mov    %rbx,%r8
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xed2(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <str_prepend@plt>
lea    0xf04(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
je     122f <test_str_prepend+0xef>
lea    0xdf5(%rip),%rdi
lea    0xe08(%rip),%rsi
lea    0xe12(%rip),%rdx
lea    0xedc(%rip),%r9
mov    $0x4a6,%ecx
mov    %rbx,%r8
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe89(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <str_prepend@plt>
lea    0xe97(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
je     1285 <test_str_prepend+0x145>
lea    0xda6(%rip),%rdi
lea    0xdb9(%rip),%rsi
lea    0xdc3(%rip),%rdx
lea    0xe6f(%rip),%r9
mov    $0x4a8,%ecx
mov    %rbx,%r8
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <printf@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
@.str.1 = [26 x i8] c"%s (%s %d): \22%s\22 != \22%s\22\0A\00"
@__func__.test_str_prepend = [17 x i8] c"test_str_prepend\00"
@.str.2 = [142 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/setivolkylany/c-utils/refs/heads/master/utils/str.h\00"
@.str.3 = [2 x i8] c"1\00"
@.str.4 = [6 x i8] c"text \00"
@.str.5 = [7 x i8] c"text 1\00"
@.str.6 = [31 x i8] c"\09I prepended some text before\0A\00"
@.str.7 = [37 x i8] c"\09I prepended some text before\0Atext 1\00"
define void @test_str_prepend() {
%1 = alloca i8*
%2 = call i8* @malloc(i64 1600)
store i8* %2, i8** %1
%3 = load i8*, i8** %1
%4 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @str_prepend to i32 (i8*, i8*, ...)*)(i8* %3, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%5 = load i8*, i8** %1
%6 = call i32 @strcmp(i8* %5, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %9
8: ; preds = %0
br label %12
9: ; preds = %0
%10 = load i8*, i8** %1
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @__func__.test_str_prepend, i64 0, i64 0), i8* getelementptr inbounds ([142 x i8], [142 x i8]* @.str.2, i64 0, i64 0), i32 1186, i8* %10, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
br label %12
12: ; preds = %9, %8
%13 = load i8*, i8** %1
%14 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @str_prepend to i32 (i8*, i8*, ...)*)(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%15 = load i8*, i8** %1
%16 = call i32 @strcmp(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %12
br label %22
19: ; preds = %12
%20 = load i8*, i8** %1
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @__func__.test_str_prepend, i64 0, i64 0), i8* getelementptr inbounds ([142 x i8], [142 x i8]* @.str.2, i64 0, i64 0), i32 1188, i8* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %22
22: ; preds = %19, %18
%23 = load i8*, i8** %1
%24 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @str_prepend to i32 (i8*, i8*, ...)*)(i8* %23, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%25 = load i8*, i8** %1
%26 = call i32 @strcmp(i8* %25, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %29
28: ; preds = %22
br label %32
29: ; preds = %22
%30 = load i8*, i8** %1
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @__func__.test_str_prepend, i64 0, i64 0), i8* getelementptr inbounds ([142 x i8], [142 x i8]* @.str.2, i64 0, i64 0), i32 1190, i8* %30, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
br label %32
32: ; preds = %29, %28
%33 = load i8*, i8** %1
%34 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @str_prepend to i32 (i8*, i8*, ...)*)(i8* %33, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0))
%35 = load i8*, i8** %1
%36 = call i32 @strcmp(i8* %35, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.7, i64 0, i64 0))
%37 = icmp eq i32 %36, 0
br i1 %37, label %38, label %39
38: ; preds = %32
br label %42
39: ; preds = %32
%40 = load i8*, i8** %1
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @__func__.test_str_prepend, i64 0, i64 0), i8* getelementptr inbounds ([142 x i8], [142 x i8]* @.str.2, i64 0, i64 0), i32 1192, i8* %40, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.7, i64 0, i64 0))
br label %42
42: ; preds = %39, %38
ret void
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
@.str.1 = [26 x i8] c"%s (%s %d): \22%s\22 != \22%s\22\0A\00"
@__func__.test_str_prepend = [17 x i8] c"test_str_prepend\00"
@.str.2 = [142 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/setivolkylany/c-utils/refs/heads/master/utils/str.h\00"
@.str.3 = [2 x i8] c"1\00"
@.str.4 = [6 x i8] c"text \00"
@.str.5 = [7 x i8] c"text 1\00"
@.str.6 = [31 x i8] c"\09I prepended some text before\0A\00"
@.str.7 = [37 x i8] c"\09I prepended some text before\0Atext 1\00"
define void @test_str_prepend() {
%1 = tail call dereferenceable_or_null(1600) i8* @malloc(i64 1600)
%2 = tail call i32 (i8*, i8*, ...) bitcast (i32 (...)* @str_prepend to i32 (i8*, i8*, ...)*)(i8* %1, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%3 = load i8, i8* %1
%4 = icmp eq i8 %3, 0
br i1 %4, label %7, label %5
5: ; preds = %0
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @__func__.test_str_prepend, i64 0, i64 0), i8* getelementptr inbounds ([142 x i8], [142 x i8]* @.str.2, i64 0, i64 0), i32 1186, i8* %1, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
br label %7
7: ; preds = %0, %5
%8 = tail call i32 (i8*, i8*, ...) bitcast (i32 (...)* @str_prepend to i32 (i8*, i8*, ...)*)(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%9 = tail call i32 @strcmp(i8* %1, i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%10 = icmp eq i32 %9, 0
br i1 %10, label %13, label %11
11: ; preds = %7
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @__func__.test_str_prepend, i64 0, i64 0), i8* getelementptr inbounds ([142 x i8], [142 x i8]* @.str.2, i64 0, i64 0), i32 1188, i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %13
13: ; preds = %7, %11
%14 = tail call i32 (i8*, i8*, ...) bitcast (i32 (...)* @str_prepend to i32 (i8*, i8*, ...)*)(i8* %1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%15 = tail call i32 @strcmp(i8* %1, i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
%16 = icmp eq i32 %15, 0
br i1 %16, label %19, label %17
17: ; preds = %13
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @__func__.test_str_prepend, i64 0, i64 0), i8* getelementptr inbounds ([142 x i8], [142 x i8]* @.str.2, i64 0, i64 0), i32 1190, i8* %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
br label %19
19: ; preds = %13, %17
%20 = tail call i32 (i8*, i8*, ...) bitcast (i32 (...)* @str_prepend to i32 (i8*, i8*, ...)*)(i8* %1, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0))
%21 = tail call i32 @strcmp(i8* %1, i8* dereferenceable(37) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.7, i64 0, i64 0))
%22 = icmp eq i32 %21, 0
br i1 %22, label %25, label %23
23: ; preds = %19
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @__func__.test_str_prepend, i64 0, i64 0), i8* getelementptr inbounds ([142 x i8], [142 x i8]* @.str.2, i64 0, i64 0), i32 1192, i8* %1, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.7, i64 0, i64 0))
br label %25
25: ; preds = %19, %23
ret void
}