#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(int);
char *concatStrs(char *, char *, int);
int /*<<< orphan*/ printf(char *);
void concatStrsTestB() {
  char *result = concatStrs("", "test string", 5);
  assert(result && result[0] == 't' && result[1] == 'e' && result[2] == 's' &&
         result[3] == 't' && result[4] == ' ' && result[5] == '\0');
  printf("Test successful.");
}


x86 assembly (clang, -O0):
<concatStrsTestB>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xedd(%rip),%rdi
lea    0xeba(%rip),%rsi
mov    $0x5,%edx
call   1050 <concatStrs@plt>
mov    %rax,-0x8(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x8(%rbp)
mov    %al,-0x9(%rbp)
je     11e2 <concatStrsTestB+0xb2>
mov    -0x8(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x74,%ecx
mov    %al,-0x9(%rbp)
jne    11e2 <concatStrsTestB+0xb2>
mov    -0x8(%rbp),%rax
movsbl 0x1(%rax),%ecx
xor    %eax,%eax
cmp    $0x65,%ecx
mov    %al,-0x9(%rbp)
jne    11e2 <concatStrsTestB+0xb2>
mov    -0x8(%rbp),%rax
movsbl 0x2(%rax),%ecx
xor    %eax,%eax
cmp    $0x73,%ecx
mov    %al,-0x9(%rbp)
jne    11e2 <concatStrsTestB+0xb2>
mov    -0x8(%rbp),%rax
movsbl 0x3(%rax),%ecx
xor    %eax,%eax
cmp    $0x74,%ecx
mov    %al,-0x9(%rbp)
jne    11e2 <concatStrsTestB+0xb2>
mov    -0x8(%rbp),%rax
movsbl 0x4(%rax),%ecx
xor    %eax,%eax
cmp    $0x20,%ecx
mov    %al,-0x9(%rbp)
jne    11e2 <concatStrsTestB+0xb2>
mov    -0x8(%rbp),%rax
movsbl 0x5(%rax),%eax
cmp    $0x0,%eax
sete   %al
mov    %al,-0x9(%rbp)
mov    -0x9(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
lea    0xe16(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<concatStrsTestB>:
push   %rax
lea    0xee4(%rip),%rdi
lea    0xec1(%rip),%rsi
mov    $0x5,%edx
call   1050 <concatStrs@plt>
xor    %edi,%edi
test   %rax,%rax
je     1177 <concatStrsTestB+0x47>
cmpb   $0x74,(%rax)
jne    1177 <concatStrsTestB+0x47>
cmpb   $0x65,0x1(%rax)
jne    1177 <concatStrsTestB+0x47>
cmpb   $0x73,0x2(%rax)
jne    1177 <concatStrsTestB+0x47>
cmpb   $0x74,0x3(%rax)
jne    1177 <concatStrsTestB+0x47>
cmpb   $0x20,0x4(%rax)
jne    1177 <concatStrsTestB+0x47>
xor    %edi,%edi
cmpb   $0x0,0x5(%rax)
sete   %dil
call   1040 <assert@plt>
lea    0xe89(%rip),%rdi
pop    %rax
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
@.str.1 = [12 x i8] c"test string\00"
@.str.2 = [17 x i8] c"Test successful.\00"
define void @concatStrsTestB() {
%1 = alloca i8*
%2 = call i8* @concatStrs(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 5)
store i8* %2, i8** %1
%3 = load i8*, i8** %1
%4 = icmp ne i8* %3, null
br i1 %4, label %5, label %41
5: ; preds = %0
%6 = load i8*, i8** %1
%7 = getelementptr inbounds i8, i8* %6, i64 0
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
%10 = icmp eq i32 %9, 116
br i1 %10, label %11, label %41
11: ; preds = %5
%12 = load i8*, i8** %1
%13 = getelementptr inbounds i8, i8* %12, i64 1
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 101
br i1 %16, label %17, label %41
17: ; preds = %11
%18 = load i8*, i8** %1
%19 = getelementptr inbounds i8, i8* %18, i64 2
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %21, 115
br i1 %22, label %23, label %41
23: ; preds = %17
%24 = load i8*, i8** %1
%25 = getelementptr inbounds i8, i8* %24, i64 3
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 116
br i1 %28, label %29, label %41
29: ; preds = %23
%30 = load i8*, i8** %1
%31 = getelementptr inbounds i8, i8* %30, i64 4
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp eq i32 %33, 32
br i1 %34, label %35, label %41
35: ; preds = %29
%36 = load i8*, i8** %1
%37 = getelementptr inbounds i8, i8* %36, i64 5
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = icmp eq i32 %39, 0
br label %41
41: ; preds = %35, %29, %23, %17, %11, %5, %0
%42 = phi i1 [ false, %29 ], [ false, %23 ], [ false, %17 ], [ false, %11 ], [ false, %5 ], [ false, %0 ], [ %40, %35 ]
%43 = zext i1 %42 to i32
%44 = call i32 @assert(i32 %43)
%45 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
@.str.1 = [12 x i8] c"test string\00"
@.str.2 = [17 x i8] c"Test successful.\00"
define void @concatStrsTestB() {
%1 = tail call i8* @concatStrs(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 5)
%2 = icmp eq i8* %1, null
br i1 %2, label %27, label %3
3: ; preds = %0
%4 = load i8, i8* %1
%5 = icmp eq i8 %4, 116
br i1 %5, label %6, label %27
6: ; preds = %3
%7 = getelementptr inbounds i8, i8* %1, i64 1
%8 = load i8, i8* %7
%9 = icmp eq i8 %8, 101
br i1 %9, label %10, label %27
10: ; preds = %6
%11 = getelementptr inbounds i8, i8* %1, i64 2
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 115
br i1 %13, label %14, label %27
14: ; preds = %10
%15 = getelementptr inbounds i8, i8* %1, i64 3
%16 = load i8, i8* %15
%17 = icmp eq i8 %16, 116
br i1 %17, label %18, label %27
18: ; preds = %14
%19 = getelementptr inbounds i8, i8* %1, i64 4
%20 = load i8, i8* %19
%21 = icmp eq i8 %20, 32
br i1 %21, label %22, label %27
22: ; preds = %18
%23 = getelementptr inbounds i8, i8* %1, i64 5
%24 = load i8, i8* %23
%25 = icmp eq i8 %24, 0
%26 = zext i1 %25 to i32
br label %27
27: ; preds = %22, %18, %14, %10, %6, %3, %0
%28 = phi i32 [ 0, %18 ], [ 0, %14 ], [ 0, %10 ], [ 0, %6 ], [ 0, %3 ], [ 0, %0 ], [ %26, %22 ]
%29 = tail call i32 @assert(i32 %28)
%30 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
ret void
}