#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 */

/* Variables and functions */
int /*<<< orphan*/ assert_log(int, int, char *, int *);
char *join_str(char const **, char *);
int /*<<< orphan*/ strcmp(char *, char *);
int test_join_str(int verbose) {
  int ok = 1;
  const char *tmp[4] = {"en", "to", "tre", NULL};
  char *j = join_str(tmp, "/");
  assert_log(!strcmp("en/to/tre", j), verbose, "join_str != en/to/tre", &ok);
  return ok;
}


x86 assembly (clang, -O0):
<test_join_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
mov    0x2cb7(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0x2cb4(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0x2cb1(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0x2cae(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    -0x30(%rbp),%rdi
lea    0xe8d(%rip),%rsi
call   1050 <join_str@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rsi
lea    0xe87(%rip),%rdi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
mov    -0x4(%rbp),%esi
lea    0xe5f(%rip),%rdx
lea    -0x8(%rbp),%rcx
call   1040 <assert_log@plt>
mov    -0x8(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_join_str>:
push   %rbx
sub    $0x30,%rsp
mov    %edi,%ebx
movl   $0x1,0xc(%rsp)
movaps 0x2cca(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0x2cae(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
lea    0xea8(%rip),%rsi
lea    0x10(%rsp),%rdi
call   1050 <join_str@plt>
lea    0xea5(%rip),%rdi
mov    %rax,%rsi
call   1030 <strcmp@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
lea    0xe82(%rip),%rdx
lea    0xc(%rsp),%rcx
mov    %ebx,%esi
call   1040 <assert_log@plt>
mov    0xc(%rsp),%eax
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"en\00"
@.str.1 = [3 x i8] c"to\00"
@.str.2 = [4 x i8] c"tre\00"
@__const.test_join_str.tmp = [4 x i8*] [i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i32 0, i32 0), i8* null]
@.str.3 = [2 x i8] c"/\00"
@.str.4 = [10 x i8] c"en/to/tre\00"
@.str.5 = [22 x i8] c"join_str != en/to/tre\00"
define i32 @test_join_str(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca [4 x i8*]
%5 = alloca i8*
store i32 %0, i32* %2
store i32 1, i32* %3
%6 = bitcast [4 x i8*]* %4 to i8*
%7 = getelementptr inbounds [4 x i8*], [4 x i8*]* %4, i64 0, i64 0
%8 = call i8* @join_str(i8** %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i8* %8, i8** %5
%9 = load i8*, i8** %5
%10 = call i32 @strcmp(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* %9)
%11 = icmp ne i32 %10, 0
%12 = xor i1 %11, true
%13 = zext i1 %12 to i32
%14 = load i32, i32* %2
%15 = call i32 @assert_log(i32 %13, i32 %14, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i32* %3)
%16 = load i32, i32* %3
ret i32 %16
}

LLVM IR (-O2):
@.str = [3 x i8] c"en\00"
@.str.1 = [3 x i8] c"to\00"
@.str.2 = [4 x i8] c"tre\00"
@__const.test_join_str.tmp = [4 x i8*] [i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i32 0, i32 0), i8* null]
@.str.3 = [2 x i8] c"/\00"
@.str.4 = [10 x i8] c"en/to/tre\00"
@.str.5 = [22 x i8] c"join_str != en/to/tre\00"
define i32 @test_join_str(i32 %0) {
%2 = alloca i32
%3 = alloca [4 x i8*]
%4 = bitcast i32* %2 to i8*
store i32 1, i32* %2
%5 = bitcast [4 x i8*]* %3 to i8*
%6 = getelementptr inbounds [4 x i8*], [4 x i8*]* %3, i64 0, i64 0
%7 = call i8* @join_str(i8** %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%8 = call i32 @strcmp(i8* dereferenceable(10) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* dereferenceable(1) %7)
%9 = icmp eq i32 %8, 0
%10 = zext i1 %9 to i32
%11 = call i32 @assert_log(i32 %10, i32 %0, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i32* %2)
%12 = load i32, i32* %2
ret i32 %12
}