int test_jnxstring() {
  jnx_log(0,
          "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
          "2022-01-22/02-19-57/repos/AlexsJones/jnxlibc/refs/heads/master/test/"
          "unit/test_jnxstring.c",
          __FUNCTION__, 26, "Running test for jnxstring\n");
  ;
  jnx_log(0,
          "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
          "2022-01-22/02-19-57/repos/AlexsJones/jnxlibc/refs/heads/master/test/"
          "unit/test_jnxstring.c",
          __FUNCTION__, 28, "- test_string_join");
  ;
  char *temp = malloc(256);
  strcpy(temp, "foo");
  jnx_string_join(&temp, "bar");
  assert(strcmp(temp, "foobar") == 0);
  jnx_log(0,
          "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
          "2022-01-22/02-19-57/repos/AlexsJones/jnxlibc/refs/heads/master/test/"
          "unit/test_jnxstring.c",
          __FUNCTION__, 33, "OK");
  ;
  int a = 15;
  char *expected_output = "15";
  char *actual_output = jnx_string_itos(a);
  assert(strcmp(expected_output, actual_output) == 0);
  jnx_log(0,
          "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
          "2022-01-22/02-19-57/repos/AlexsJones/jnxlibc/refs/heads/master/test/"
          "unit/test_jnxstring.c",
          __FUNCTION__, 39, "String tests completed\n");
  ;
  return 0;
}


x86 assembly (clang, -O0):
<test_jnxstring>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
xor    %edi,%edi
lea    0xe7f(%rip),%rsi
lea    0xf12(%rip),%rdx
mov    $0x1a,%ecx
lea    0xf15(%rip),%r8
mov    $0x0,%al
call   1050 <jnx_log@plt>
xor    %edi,%edi
lea    0xe5c(%rip),%rsi
lea    0xeef(%rip),%rdx
mov    $0x1c,%ecx
lea    0xf0e(%rip),%r8
mov    $0x0,%al
call   1050 <jnx_log@plt>
mov    $0x100,%edi
call   1080 <malloc@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xf01(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x8(%rbp),%rdi
lea    0xef8(%rip),%rsi
mov    $0x0,%al
call   1040 <jnx_string_join@plt>
mov    -0x8(%rbp),%rdi
lea    0xee3(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   1070 <assert@plt>
xor    %edi,%edi
lea    0xde7(%rip),%rsi
lea    0xe7a(%rip),%rdx
mov    $0x21,%ecx
lea    0xeb7(%rip),%r8
mov    $0x0,%al
call   1050 <jnx_log@plt>
movl   $0xf,-0xc(%rbp)
lea    0xea5(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0xc(%rbp),%edi
mov    $0x0,%al
call   1090 <jnx_string_itos@plt>
cltq
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   1070 <assert@plt>
xor    %edi,%edi
lea    0xd83(%rip),%rsi
lea    0xe16(%rip),%rdx
mov    $0x27,%ecx
lea    0xe59(%rip),%r8
mov    $0x0,%al
call   1050 <jnx_log@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_jnxstring>:
push   %r14
push   %rbx
push   %rax
lea    0xe95(%rip),%rbx
lea    0xf28(%rip),%r14
lea    0xf30(%rip),%r8
xor    %edi,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
mov    $0x1a,%ecx
xor    %eax,%eax
call   1040 <jnx_log@plt>
lea    0xf31(%rip),%r8
xor    %edi,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
mov    $0x1c,%ecx
xor    %eax,%eax
call   1040 <jnx_log@plt>
mov    $0x100,%edi
call   1070 <malloc@plt>
mov    %rax,(%rsp)
movl   $0x6f6f66,(%rax)
lea    0xf18(%rip),%rsi
mov    %rsp,%rdi
xor    %eax,%eax
call   1030 <jnx_string_join@plt>
mov    (%rsp),%rdi
lea    0xf00(%rip),%rsi
call   1050 <strcmp@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
xor    %eax,%eax
call   1060 <assert@plt>
lea    0xeec(%rip),%r8
xor    %edi,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
mov    $0x21,%ecx
xor    %eax,%eax
call   1040 <jnx_log@plt>
mov    $0xf,%edi
xor    %eax,%eax
call   1080 <jnx_string_itos@plt>
movslq %eax,%rsi
lea    0xec5(%rip),%rdi
call   1050 <strcmp@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
xor    %eax,%eax
call   1060 <assert@plt>
lea    0xead(%rip),%r8
xor    %edi,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
mov    $0x27,%ecx
xor    %eax,%eax
call   1040 <jnx_log@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [154 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/AlexsJones/jnxlibc/refs/heads/master/test/unit/test_jnxstring.c\00"
@__FUNCTION__.test_jnxstring = [15 x i8] c"test_jnxstring\00"
@.str.1 = [28 x i8] c"Running test for jnxstring\0A\00"
@.str.2 = [19 x i8] c"- test_string_join\00"
@.str.3 = [4 x i8] c"foo\00"
@.str.4 = [4 x i8] c"bar\00"
@.str.5 = [7 x i8] c"foobar\00"
@.str.6 = [3 x i8] c"OK\00"
@.str.7 = [3 x i8] c"15\00"
@.str.8 = [24 x i8] c"String tests completed\0A\00"
define i32 @test_jnxstring() {
%1 = alloca i8*
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
%5 = call i32 (i32, i8*, i8*, i32, i8*, ...) bitcast (i32 (...)* @jnx_log to i32 (i32, i8*, i8*, i32, i8*, ...)*)(i32 0, i8* getelementptr inbounds ([154 x i8], [154 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @__FUNCTION__.test_jnxstring, i64 0, i64 0), i32 26, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 (i32, i8*, i8*, i32, i8*, ...) bitcast (i32 (...)* @jnx_log to i32 (i32, i8*, i8*, i32, i8*, ...)*)(i32 0, i8* getelementptr inbounds ([154 x i8], [154 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @__FUNCTION__.test_jnxstring, i64 0, i64 0), i32 28, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%7 = call i8* @malloc(i64 256)
store i8* %7, i8** %1
%8 = load i8*, i8** %1
%9 = call i8* @strcpy(i8* %8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%10 = call i32 (i8**, i8*, ...) bitcast (i32 (...)* @jnx_string_join to i32 (i8**, i8*, ...)*)(i8** %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%11 = load i8*, i8** %1
%12 = call i32 @strcmp(i8* %11, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
%13 = icmp eq i32 %12, 0
%14 = zext i1 %13 to i32
%15 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %14)
%16 = call i32 (i32, i8*, i8*, i32, i8*, ...) bitcast (i32 (...)* @jnx_log to i32 (i32, i8*, i8*, i32, i8*, ...)*)(i32 0, i8* getelementptr inbounds ([154 x i8], [154 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @__FUNCTION__.test_jnxstring, i64 0, i64 0), i32 33, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
store i32 15, i32* %2
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8** %3
%17 = load i32, i32* %2
%18 = call i32 (i32, ...) bitcast (i32 (...)* @jnx_string_itos to i32 (i32, ...)*)(i32 %17)
%19 = sext i32 %18 to i64
%20 = inttoptr i64 %19 to i8*
store i8* %20, i8** %4
%21 = load i8*, i8** %3
%22 = load i8*, i8** %4
%23 = call i32 @strcmp(i8* %21, i8* %22)
%24 = icmp eq i32 %23, 0
%25 = zext i1 %24 to i32
%26 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %25)
%27 = call i32 (i32, i8*, i8*, i32, i8*, ...) bitcast (i32 (...)* @jnx_log to i32 (i32, i8*, i8*, i32, i8*, ...)*)(i32 0, i8* getelementptr inbounds ([154 x i8], [154 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @__FUNCTION__.test_jnxstring, i64 0, i64 0), i32 39, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.8, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [154 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/AlexsJones/jnxlibc/refs/heads/master/test/unit/test_jnxstring.c\00"
@__FUNCTION__.test_jnxstring = [15 x i8] c"test_jnxstring\00"
@.str.1 = [28 x i8] c"Running test for jnxstring\0A\00"
@.str.2 = [19 x i8] c"- test_string_join\00"
@.str.4 = [4 x i8] c"bar\00"
@.str.5 = [7 x i8] c"foobar\00"
@.str.6 = [3 x i8] c"OK\00"
@.str.7 = [3 x i8] c"15\00"
@.str.8 = [24 x i8] c"String tests completed\0A\00"
define i32 @test_jnxstring() {
%1 = alloca i8*
%2 = tail call i32 (i32, i8*, i8*, i32, i8*, ...) bitcast (i32 (...)* @jnx_log to i32 (i32, i8*, i8*, i32, i8*, ...)*)(i32 0, i8* getelementptr inbounds ([154 x i8], [154 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @__FUNCTION__.test_jnxstring, i64 0, i64 0), i32 26, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
%3 = tail call i32 (i32, i8*, i8*, i32, i8*, ...) bitcast (i32 (...)* @jnx_log to i32 (i32, i8*, i8*, i32, i8*, ...)*)(i32 0, i8* getelementptr inbounds ([154 x i8], [154 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @__FUNCTION__.test_jnxstring, i64 0, i64 0), i32 28, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%4 = bitcast i8** %1 to i8*
%5 = tail call dereferenceable_or_null(256) i8* @malloc(i64 256)
store i8* %5, i8** %1
%6 = bitcast i8* %5 to i32*
store i32 7303014, i32* %6
%7 = call i32 (i8**, i8*, ...) bitcast (i32 (...)* @jnx_string_join to i32 (i8**, i8*, ...)*)(i8** %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%8 = load i8*, i8** %1
%9 = call i32 @strcmp(i8* dereferenceable(1) %8, i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
%10 = icmp eq i32 %9, 0
%11 = zext i1 %10 to i32
%12 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %11)
%13 = call i32 (i32, i8*, i8*, i32, i8*, ...) bitcast (i32 (...)* @jnx_log to i32 (i32, i8*, i8*, i32, i8*, ...)*)(i32 0, i8* getelementptr inbounds ([154 x i8], [154 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @__FUNCTION__.test_jnxstring, i64 0, i64 0), i32 33, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%14 = call i32 (i32, ...) bitcast (i32 (...)* @jnx_string_itos to i32 (i32, ...)*)(i32 15)
%15 = sext i32 %14 to i64
%16 = inttoptr i64 %15 to i8*
%17 = call i32 @strcmp(i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8* dereferenceable(1) %16)
%18 = icmp eq i32 %17, 0
%19 = zext i1 %18 to i32
%20 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %19)
%21 = call i32 (i32, i8*, i8*, i32, i8*, ...) bitcast (i32 (...)* @jnx_log to i32 (i32, i8*, i8*, i32, i8*, ...)*)(i32 0, i8* getelementptr inbounds ([154 x i8], [154 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @__FUNCTION__.test_jnxstring, i64 0, i64 0), i32 39, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.8, i64 0, i64 0))
ret i32 0
}