#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 */
typedef int /*<<< orphan*/ strings;
typedef int /*<<< orphan*/ mydest;

/* Variables and functions */
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, char *);
char *strbld(char *, char const *);
char *strbld_array(char *, char const **);
char *strcat(char *, char *);
char *strnbld(char *, char *, int);
int main(int argc, char *argv[]) {
  int i;
  char mydest[20];
  char *ret;
  char *strings[] = {"Say", " ", "hello", " ", "world", NULL};
  int numstrings = (sizeof(strings) / sizeof(strings[0])) - 1;
  memset(mydest, 0, sizeof(mydest));
  for (i = 0; i < numstrings; i++) {
    if (i == 0) {
      ret = strbld(mydest, strings[i]);
    } else {
      ret = strbld(ret, strings[i]);
    }
  }
  printf("test_strbld - using strbld: Final string = [%s]\n", mydest);
  memset(mydest, 0, sizeof(mydest));
  for (i = numstrings - 1; i >= 0; i--) {
    if (i == numstrings - 1) {
      ret = strbld(mydest, strings[i]);
    } else {
      ret = strbld(ret, strings[i]);
    }
  }
  printf("test_strbld - using strbld: Final string = [%s]\n", mydest);
  memset(mydest, 0, sizeof(mydest));
  for (i = 0; i < numstrings; i++) {
    if (i == 0) {
      ret = strcat(mydest, strings[i]);
    } else {
      ret = strcat(mydest, strings[i]);
    }
  }
  printf("test_strbld - using strcat for comparison: Final string = [%s]\n",
         mydest);
  memset(mydest, 0, sizeof(mydest));
  for (i = numstrings - 1; i >= 0; i--) {
    if (i == numstrings - 1) {
      ret = strcat(mydest, strings[i]);
    } else {
      ret = strcat(mydest, strings[i]);
    }
  }
  printf("test_strbld - using strcat for comparison: Final string = [%s]\n",
         mydest);
  memset(mydest, 0, sizeof(mydest));
  ret = strbld_array(mydest, (const char **)strings);
  printf("test_strbld - using strbld_array: Final string = [%s]\n", mydest);
  char *the_end = NULL;
  const char *the_arr[] = {"World", "!", NULL};
  char the_beginning[] = "012345678901234";
  printf("test_strbld - using strbld, strnbld, and strbld_array: Orig. string "
         "= [%s]\n",
         the_beginning);
  the_end = strbld(the_beginning, "Hello");
  printf("test_strbld - using strbld, strnbld, and strbld_array: Curr. string "
         "= [%s]\n",
         the_beginning);
  the_end = strnbld(the_end, " ", 1);
  printf("test_strbld - using strbld, strnbld, and strbld_array: Curr. string "
         "= [%s]\n",
         the_beginning);
  the_end = strbld_array(the_end, the_arr);
  printf("test_strbld - using strbld, strnbld, and strbld_array: Curr. string "
         "= [%s]\n",
         the_beginning);
  the_end = strbld(the_end, the_arr[1]);
  printf("test_strbld - using strbld, strnbld, and strbld_array: Final string "
         "= [%s]\n",
         the_beginning);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x70(%rbp),%rdi
xor    %esi,%esi
mov    $0x30,%edx
call   1040 <memset@plt>
lea    0xe70(%rip),%rax
mov    %rax,-0x70(%rbp)
lea    0xe69(%rip),%rax
mov    %rax,-0x68(%rbp)
lea    0xe60(%rip),%rax
mov    %rax,-0x60(%rbp)
lea    0xe53(%rip),%rax
mov    %rax,-0x58(%rbp)
lea    0xe50(%rip),%rax
mov    %rax,-0x50(%rbp)
movl   $0x5,-0x74(%rbp)
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x14,%edx
call   1040 <memset@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x74(%rbp),%eax
jge    1238 <main+0xd8>
cmpl   $0x0,-0x14(%rbp)
jne    120f <main+0xaf>
lea    -0x30(%rbp),%rdi
movslq -0x14(%rbp),%rax
mov    -0x70(%rbp,%rax,8),%rsi
call   1060 <strbld@plt>
mov    %rax,-0x38(%rbp)
jmp    1225 <main+0xc5>
mov    -0x38(%rbp),%rdi
movslq -0x14(%rbp),%rax
mov    -0x70(%rbp,%rax,8),%rsi
call   1060 <strbld@plt>
mov    %rax,-0x38(%rbp)
jmp    122a <main+0xca>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11de <main+0x7e>
lea    -0x30(%rbp),%rsi
lea    0xdcf(%rip),%rdi
call   1030 <printf@plt>
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x14,%edx
call   1040 <memset@plt>
mov    -0x74(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jl     12c0 <main+0x160>
mov    -0x14(%rbp),%eax
mov    -0x74(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    1297 <main+0x137>
lea    -0x30(%rbp),%rdi
movslq -0x14(%rbp),%rax
mov    -0x70(%rbp,%rax,8),%rsi
call   1060 <strbld@plt>
mov    %rax,-0x38(%rbp)
jmp    12ad <main+0x14d>
mov    -0x38(%rbp),%rdi
movslq -0x14(%rbp),%rax
mov    -0x70(%rbp,%rax,8),%rsi
call   1060 <strbld@plt>
mov    %rax,-0x38(%rbp)
jmp    12b2 <main+0x152>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    1261 <main+0x101>
lea    -0x30(%rbp),%rsi
lea    0xd47(%rip),%rdi
call   1030 <printf@plt>
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x14,%edx
call   1040 <memset@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x74(%rbp),%eax
jge    1341 <main+0x1e1>
cmpl   $0x0,-0x14(%rbp)
jne    1318 <main+0x1b8>
lea    -0x30(%rbp),%rdi
movslq -0x14(%rbp),%rax
mov    -0x70(%rbp,%rax,8),%rsi
call   1070 <strcat@plt>
mov    %rax,-0x38(%rbp)
jmp    132e <main+0x1ce>
lea    -0x30(%rbp),%rdi
movslq -0x14(%rbp),%rax
mov    -0x70(%rbp,%rax,8),%rsi
call   1070 <strcat@plt>
mov    %rax,-0x38(%rbp)
jmp    1333 <main+0x1d3>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    12e7 <main+0x187>
lea    -0x30(%rbp),%rsi
lea    0xcf7(%rip),%rdi
call   1030 <printf@plt>
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x14,%edx
call   1040 <memset@plt>
mov    -0x74(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jl     13c9 <main+0x269>
mov    -0x14(%rbp),%eax
mov    -0x74(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    13a0 <main+0x240>
lea    -0x30(%rbp),%rdi
movslq -0x14(%rbp),%rax
mov    -0x70(%rbp,%rax,8),%rsi
call   1070 <strcat@plt>
mov    %rax,-0x38(%rbp)
jmp    13b6 <main+0x256>
lea    -0x30(%rbp),%rdi
movslq -0x14(%rbp),%rax
mov    -0x70(%rbp,%rax,8),%rsi
call   1070 <strcat@plt>
mov    %rax,-0x38(%rbp)
jmp    13bb <main+0x25b>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    136a <main+0x20a>
lea    -0x30(%rbp),%rsi
lea    0xc6f(%rip),%rdi
call   1030 <printf@plt>
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x14,%edx
call   1040 <memset@plt>
lea    -0x30(%rbp),%rdi
lea    -0x70(%rbp),%rsi
call   1050 <strbld_array@plt>
mov    %rax,-0x38(%rbp)
lea    -0x30(%rbp),%rsi
lea    0xc7e(%rip),%rdi
call   1030 <printf@plt>
movq   $0x0,-0x80(%rbp)
mov    0x29e7(%rip),%rax
mov    %rax,-0xa0(%rbp)
mov    0x29e1(%rip),%rax
mov    %rax,-0x98(%rbp)
mov    0x29db(%rip),%rax
mov    %rax,-0x90(%rbp)
mov    0xd6d(%rip),%rax
mov    %rax,-0xb0(%rbp)
mov    0xd67(%rip),%rax
mov    %rax,-0xa8(%rbp)
lea    -0xb0(%rbp),%rsi
lea    0xc5c(%rip),%rdi
call   1030 <printf@plt>
lea    -0xb0(%rbp),%rdi
lea    0xc95(%rip),%rsi
call   1060 <strbld@plt>
mov    %rax,-0x80(%rbp)
lea    -0xb0(%rbp),%rsi
lea    0xc84(%rip),%rdi
call   1030 <printf@plt>
mov    -0x80(%rbp),%rdi
lea    0xb64(%rip),%rsi
mov    $0x1,%edx
call   1080 <strnbld@plt>
mov    %rax,-0x80(%rbp)
lea    -0xb0(%rbp),%rsi
lea    0xc58(%rip),%rdi
call   1030 <printf@plt>
mov    -0x80(%rbp),%rdi
lea    -0xa0(%rbp),%rsi
call   1050 <strbld_array@plt>
mov    %rax,-0x80(%rbp)
lea    -0xb0(%rbp),%rsi
lea    0xc31(%rip),%rdi
call   1030 <printf@plt>
mov    -0x80(%rbp),%rdi
mov    -0x98(%rbp),%rsi
call   1060 <strbld@plt>
mov    %rax,-0x80(%rbp)
lea    -0xb0(%rbp),%rsi
lea    0xc56(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x60(%rsp)
lea    0xe80(%rip),%r15
mov    %r15,0x40(%rsp)
lea    0xe78(%rip),%r14
mov    %r14,0x48(%rsp)
lea    0xe6e(%rip),%r12
mov    %r12,0x50(%rsp)
mov    %r14,0x58(%rsp)
lea    0xe63(%rip),%r13
mov    %r13,0x60(%rsp)
mov    %rsp,%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x14,%edx
call   1050 <memset@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1070 <strbld@plt>
mov    %rax,%rdi
mov    %r14,%rsi
call   1070 <strbld@plt>
mov    %rax,%rdi
mov    %r12,%rsi
call   1070 <strbld@plt>
mov    %rax,%rdi
mov    %r14,%rsi
call   1070 <strbld@plt>
mov    %rax,%rdi
mov    %r13,%rsi
call   1070 <strbld@plt>
lea    0xe14(%rip),%rbp
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x14,%edx
call   1050 <memset@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1070 <strbld@plt>
mov    %rax,%rdi
mov    %r14,%rsi
call   1070 <strbld@plt>
mov    %rax,%rdi
mov    %r12,%rsi
call   1070 <strbld@plt>
mov    %rax,%rdi
mov    %r14,%rsi
call   1070 <strbld@plt>
mov    %rax,%rdi
mov    %r15,%rsi
call   1070 <strbld@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x14,%edx
call   1050 <memset@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
movl   $0x796153,(%rsp,%rax,1)
mov    %rbx,%rdi
call   1030 <strlen@plt>
movw   $0x20,(%rsp,%rax,1)
mov    %rbx,%rdi
call   1030 <strlen@plt>
movl   $0x6c6c6568,(%rsp,%rax,1)
movw   $0x6f,0x4(%rsp,%rax,1)
mov    %rbx,%rdi
call   1030 <strlen@plt>
movw   $0x20,(%rsp,%rax,1)
mov    %rbx,%rdi
call   1030 <strlen@plt>
movl   $0x6c726f77,(%rsp,%rax,1)
movw   $0x64,0x4(%rsp,%rax,1)
lea    0xd7c(%rip),%r15
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x14,%edx
call   1050 <memset@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
movl   $0x6c726f77,(%rsp,%rax,1)
movw   $0x64,0x4(%rsp,%rax,1)
mov    %rbx,%rdi
call   1030 <strlen@plt>
movw   $0x20,(%rsp,%rax,1)
mov    %rbx,%rdi
call   1030 <strlen@plt>
movl   $0x6c6c6568,(%rsp,%rax,1)
movw   $0x6f,0x4(%rsp,%rax,1)
mov    %rbx,%rdi
call   1030 <strlen@plt>
movw   $0x20,(%rsp,%rax,1)
mov    %rbx,%rdi
call   1030 <strlen@plt>
movl   $0x796153,(%rsp,%rax,1)
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x14,%edx
call   1050 <memset@plt>
lea    0x40(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <strbld_array@plt>
lea    0xd1d(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    0x2a9b(%rip),%rax
mov    %rax,0x30(%rsp)
movaps 0x2a7f(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xe23(%rip),%xmm0
movaps %xmm0,0x70(%rsp)
lea    0xd29(%rip),%rdi
lea    0x70(%rsp),%rbx
mov    %rbx,%rsi
call   1040 <printf@plt>
lea    0xd61(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strbld@plt>
mov    %rax,%rbp
lea    0xd55(%rip),%r15
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    %rbp,%rdi
mov    %r14,%rsi
mov    $0x1,%edx
call   1080 <strnbld@plt>
mov    %rax,%rbp
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
lea    0x20(%rsp),%rsi
mov    %rbp,%rdi
call   1060 <strbld_array@plt>
mov    %rax,%rbp
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    0x28(%rsp),%rsi
mov    %rbp,%rdi
call   1070 <strbld@plt>
lea    0xd49(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"Say\00"
@.str.1 = [2 x i8] c" \00"
@.str.2 = [6 x i8] c"hello\00"
@.str.3 = [6 x i8] c"world\00"
@.str.4 = [49 x i8] c"test_strbld - using strbld: Final string = [%s]\0A\00"
@.str.5 = [64 x i8] c"test_strbld - using strcat for comparison: Final string = [%s]\0A\00"
@.str.6 = [55 x i8] c"test_strbld - using strbld_array: Final string = [%s]\0A\00"
@.str.7 = [6 x i8] c"World\00"
@.str.8 = [2 x i8] c"!\00"
@__const.main.the_arr = [3 x i8*] [i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i32 0, i32 0), i8* null]
@__const.main.the_beginning = [16 x i8] c"012345678901234\00"
@.str.9 = [76 x i8] c"test_strbld - using strbld, strnbld, and strbld_array: Orig. string = [%s]\0A\00"
@.str.10 = [6 x i8] c"Hello\00"
@.str.11 = [76 x i8] c"test_strbld - using strbld, strnbld, and strbld_array: Curr. string = [%s]\0A\00"
@.str.12 = [76 x i8] c"test_strbld - using strbld, strnbld, and strbld_array: Final string = [%s]\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [20 x i8]
%8 = alloca i8*
%9 = alloca [6 x i8*]
%10 = alloca i32
%11 = alloca i8*
%12 = alloca [3 x i8*]
%13 = alloca [16 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = bitcast [6 x i8*]* %9 to i8*
%15 = bitcast i8* %14 to [6 x i8*]*
%16 = getelementptr inbounds [6 x i8*], [6 x i8*]* %15, i32 0, i32 0
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i8** %16
%17 = getelementptr inbounds [6 x i8*], [6 x i8*]* %15, i32 0, i32 1
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i32 0, i32 0), i8** %17
%18 = getelementptr inbounds [6 x i8*], [6 x i8*]* %15, i32 0, i32 2
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i32 0, i32 0), i8** %18
%19 = getelementptr inbounds [6 x i8*], [6 x i8*]* %15, i32 0, i32 3
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i32 0, i32 0), i8** %19
%20 = getelementptr inbounds [6 x i8*], [6 x i8*]* %15, i32 0, i32 4
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i32 0, i32 0), i8** %20
store i32 5, i32* %10
%21 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 0
%22 = call i32 @memset(i8* %21, i32 0, i32 20)
store i32 0, i32* %6
br label %23
23: ; preds = %45, %2
%24 = load i32, i32* %6
%25 = load i32, i32* %10
%26 = icmp slt i32 %24, %25
br i1 %26, label %27, label %48
27: ; preds = %23
%28 = load i32, i32* %6
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %37
30: ; preds = %27
%31 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 0
%32 = load i32, i32* %6
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [6 x i8*], [6 x i8*]* %9, i64 0, i64 %33
%35 = load i8*, i8** %34
%36 = call i8* @strbld(i8* %31, i8* %35)
store i8* %36, i8** %8
br label %44
37: ; preds = %27
%38 = load i8*, i8** %8
%39 = load i32, i32* %6
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [6 x i8*], [6 x i8*]* %9, i64 0, i64 %40
%42 = load i8*, i8** %41
%43 = call i8* @strbld(i8* %38, i8* %42)
store i8* %43, i8** %8
br label %44
44: ; preds = %37, %30
br label %45
45: ; preds = %44
%46 = load i32, i32* %6
%47 = add nsw i32 %46, 1
store i32 %47, i32* %6
br label %23
48: ; preds = %23
%49 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 0
%50 = call i32 @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.4, i64 0, i64 0), i8* %49)
%51 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 0
%52 = call i32 @memset(i8* %51, i32 0, i32 20)
%53 = load i32, i32* %10
%54 = sub nsw i32 %53, 1
store i32 %54, i32* %6
br label %55
55: ; preds = %78, %48
%56 = load i32, i32* %6
%57 = icmp sge i32 %56, 0
br i1 %57, label %58, label %81
58: ; preds = %55
%59 = load i32, i32* %6
%60 = load i32, i32* %10
%61 = sub nsw i32 %60, 1
%62 = icmp eq i32 %59, %61
br i1 %62, label %63, label %70
63: ; preds = %58
%64 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 0
%65 = load i32, i32* %6
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds [6 x i8*], [6 x i8*]* %9, i64 0, i64 %66
%68 = load i8*, i8** %67
%69 = call i8* @strbld(i8* %64, i8* %68)
store i8* %69, i8** %8
br label %77
70: ; preds = %58
%71 = load i8*, i8** %8
%72 = load i32, i32* %6
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds [6 x i8*], [6 x i8*]* %9, i64 0, i64 %73
%75 = load i8*, i8** %74
%76 = call i8* @strbld(i8* %71, i8* %75)
store i8* %76, i8** %8
br label %77
77: ; preds = %70, %63
br label %78
78: ; preds = %77
%79 = load i32, i32* %6
%80 = add nsw i32 %79, -1
store i32 %80, i32* %6
br label %55
81: ; preds = %55
%82 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 0
%83 = call i32 @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.4, i64 0, i64 0), i8* %82)
%84 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 0
%85 = call i32 @memset(i8* %84, i32 0, i32 20)
store i32 0, i32* %6
br label %86
86: ; preds = %108, %81
%87 = load i32, i32* %6
%88 = load i32, i32* %10
%89 = icmp slt i32 %87, %88
br i1 %89, label %90, label %111
90: ; preds = %86
%91 = load i32, i32* %6
%92 = icmp eq i32 %91, 0
br i1 %92, label %93, label %100
93: ; preds = %90
%94 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 0
%95 = load i32, i32* %6
%96 = sext i32 %95 to i64
%97 = getelementptr inbounds [6 x i8*], [6 x i8*]* %9, i64 0, i64 %96
%98 = load i8*, i8** %97
%99 = call i8* @strcat(i8* %94, i8* %98)
store i8* %99, i8** %8
br label %107
100: ; preds = %90
%101 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 0
%102 = load i32, i32* %6
%103 = sext i32 %102 to i64
%104 = getelementptr inbounds [6 x i8*], [6 x i8*]* %9, i64 0, i64 %103
%105 = load i8*, i8** %104
%106 = call i8* @strcat(i8* %101, i8* %105)
store i8* %106, i8** %8
br label %107
107: ; preds = %100, %93
br label %108
108: ; preds = %107
%109 = load i32, i32* %6
%110 = add nsw i32 %109, 1
store i32 %110, i32* %6
br label %86
111: ; preds = %86
%112 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 0
%113 = call i32 @printf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.5, i64 0, i64 0), i8* %112)
%114 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 0
%115 = call i32 @memset(i8* %114, i32 0, i32 20)
%116 = load i32, i32* %10
%117 = sub nsw i32 %116, 1
store i32 %117, i32* %6
br label %118
118: ; preds = %141, %111
%119 = load i32, i32* %6
%120 = icmp sge i32 %119, 0
br i1 %120, label %121, label %144
121: ; preds = %118
%122 = load i32, i32* %6
%123 = load i32, i32* %10
%124 = sub nsw i32 %123, 1
%125 = icmp eq i32 %122, %124
br i1 %125, label %126, label %133
126: ; preds = %121
%127 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 0
%128 = load i32, i32* %6
%129 = sext i32 %128 to i64
%130 = getelementptr inbounds [6 x i8*], [6 x i8*]* %9, i64 0, i64 %129
%131 = load i8*, i8** %130
%132 = call i8* @strcat(i8* %127, i8* %131)
store i8* %132, i8** %8
br label %140
133: ; preds = %121
%134 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 0
%135 = load i32, i32* %6
%136 = sext i32 %135 to i64
%137 = getelementptr inbounds [6 x i8*], [6 x i8*]* %9, i64 0, i64 %136
%138 = load i8*, i8** %137
%139 = call i8* @strcat(i8* %134, i8* %138)
store i8* %139, i8** %8
br label %140
140: ; preds = %133, %126
br label %141
141: ; preds = %140
%142 = load i32, i32* %6
%143 = add nsw i32 %142, -1
store i32 %143, i32* %6
br label %118
144: ; preds = %118
%145 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 0
%146 = call i32 @printf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.5, i64 0, i64 0), i8* %145)
%147 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 0
%148 = call i32 @memset(i8* %147, i32 0, i32 20)
%149 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 0
%150 = getelementptr inbounds [6 x i8*], [6 x i8*]* %9, i64 0, i64 0
%151 = call i8* @strbld_array(i8* %149, i8** %150)
store i8* %151, i8** %8
%152 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 0
%153 = call i32 @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.6, i64 0, i64 0), i8* %152)
store i8* null, i8** %11
%154 = bitcast [3 x i8*]* %12 to i8*
%155 = bitcast [16 x i8]* %13 to i8*
%156 = getelementptr inbounds [16 x i8], [16 x i8]* %13, i64 0, i64 0
%157 = call i32 @printf(i8* getelementptr inbounds ([76 x i8], [76 x i8]* @.str.9, i64 0, i64 0), i8* %156)
%158 = getelementptr inbounds [16 x i8], [16 x i8]* %13, i64 0, i64 0
%159 = call i8* @strbld(i8* %158, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0))
store i8* %159, i8** %11
%160 = getelementptr inbounds [16 x i8], [16 x i8]* %13, i64 0, i64 0
%161 = call i32 @printf(i8* getelementptr inbounds ([76 x i8], [76 x i8]* @.str.11, i64 0, i64 0), i8* %160)
%162 = load i8*, i8** %11
%163 = call i8* @strnbld(i8* %162, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
store i8* %163, i8** %11
%164 = getelementptr inbounds [16 x i8], [16 x i8]* %13, i64 0, i64 0
%165 = call i32 @printf(i8* getelementptr inbounds ([76 x i8], [76 x i8]* @.str.11, i64 0, i64 0), i8* %164)
%166 = load i8*, i8** %11
%167 = getelementptr inbounds [3 x i8*], [3 x i8*]* %12, i64 0, i64 0
%168 = call i8* @strbld_array(i8* %166, i8** %167)
store i8* %168, i8** %11
%169 = getelementptr inbounds [16 x i8], [16 x i8]* %13, i64 0, i64 0
%170 = call i32 @printf(i8* getelementptr inbounds ([76 x i8], [76 x i8]* @.str.11, i64 0, i64 0), i8* %169)
%171 = load i8*, i8** %11
%172 = getelementptr inbounds [3 x i8*], [3 x i8*]* %12, i64 0, i64 1
%173 = load i8*, i8** %172
%174 = call i8* @strbld(i8* %171, i8* %173)
store i8* %174, i8** %11
%175 = getelementptr inbounds [16 x i8], [16 x i8]* %13, i64 0, i64 0
%176 = call i32 @printf(i8* getelementptr inbounds ([76 x i8], [76 x i8]* @.str.12, i64 0, i64 0), i8* %175)
%177 = load i32, i32* %3
ret i32 %177
}

LLVM IR (-O2):
@.str = [4 x i8] c"Say\00"
@.str.1 = [2 x i8] c" \00"
@.str.2 = [6 x i8] c"hello\00"
@.str.3 = [6 x i8] c"world\00"
@.str.4 = [49 x i8] c"test_strbld - using strbld: Final string = [%s]\0A\00"
@.str.5 = [64 x i8] c"test_strbld - using strcat for comparison: Final string = [%s]\0A\00"
@.str.6 = [55 x i8] c"test_strbld - using strbld_array: Final string = [%s]\0A\00"
@.str.7 = [6 x i8] c"World\00"
@.str.8 = [2 x i8] c"!\00"
@__const.main.the_arr = [3 x i8*] [i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i32 0, i32 0), i8* null]
@__const.main.the_beginning = [16 x i8] c"012345678901234\00"
@.str.9 = [76 x i8] c"test_strbld - using strbld, strnbld, and strbld_array: Orig. string = [%s]\0A\00"
@.str.10 = [6 x i8] c"Hello\00"
@.str.11 = [76 x i8] c"test_strbld - using strbld, strnbld, and strbld_array: Curr. string = [%s]\0A\00"
@.str.12 = [76 x i8] c"test_strbld - using strbld, strnbld, and strbld_array: Final string = [%s]\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [20 x i8]
%4 = alloca [6 x i8*]
%5 = alloca [3 x i8*]
%6 = alloca [16 x i8]
%7 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%8 = bitcast [6 x i8*]* %4 to i8*
%9 = getelementptr inbounds [6 x i8*], [6 x i8*]* %4, i64 0, i64 4
%10 = bitcast i8** %9 to i8*
%11 = getelementptr inbounds [6 x i8*], [6 x i8*]* %4, i64 0, i64 0
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8** %11
%12 = getelementptr inbounds [6 x i8*], [6 x i8*]* %4, i64 0, i64 1
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8** %12
%13 = getelementptr inbounds [6 x i8*], [6 x i8*]* %4, i64 0, i64 2
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8** %13
%14 = getelementptr inbounds [6 x i8*], [6 x i8*]* %4, i64 0, i64 3
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8** %14
%15 = getelementptr inbounds [6 x i8*], [6 x i8*]* %4, i64 0, i64 4
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8** %15
%16 = call i32 @memset(i8* %7, i32 0, i32 20)
%17 = call i8* @strbld(i8* %7, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%18 = call i8* @strbld(i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%19 = call i8* @strbld(i8* %18, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%20 = call i8* @strbld(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%21 = call i8* @strbld(i8* %20, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%22 = call i32 @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.4, i64 0, i64 0), i8* %7)
%23 = call i32 @memset(i8* %7, i32 0, i32 20)
%24 = call i8* @strbld(i8* %7, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%25 = call i8* @strbld(i8* %24, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%26 = call i8* @strbld(i8* %25, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%27 = call i8* @strbld(i8* %26, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%28 = call i8* @strbld(i8* %27, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%29 = call i32 @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.4, i64 0, i64 0), i8* %7)
%30 = call i32 @memset(i8* %7, i32 0, i32 20)
%31 = call i64 @strlen(i8* %7)
%32 = getelementptr [20 x i8], [20 x i8]* %3, i64 0, i64 %31
%33 = bitcast i8* %32 to i32*
store i32 7954771, i32* %33
%34 = call i64 @strlen(i8* %7)
%35 = getelementptr [20 x i8], [20 x i8]* %3, i64 0, i64 %34
%36 = bitcast i8* %35 to i16*
store i16 32, i16* %36
%37 = call i64 @strlen(i8* %7)
%38 = getelementptr [20 x i8], [20 x i8]* %3, i64 0, i64 %37
%39 = call i64 @strlen(i8* %7)
%40 = getelementptr [20 x i8], [20 x i8]* %3, i64 0, i64 %39
%41 = bitcast i8* %40 to i16*
store i16 32, i16* %41
%42 = call i64 @strlen(i8* %7)
%43 = getelementptr [20 x i8], [20 x i8]* %3, i64 0, i64 %42
%44 = call i32 @printf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.5, i64 0, i64 0), i8* %7)
%45 = call i32 @memset(i8* %7, i32 0, i32 20)
%46 = call i64 @strlen(i8* %7)
%47 = getelementptr [20 x i8], [20 x i8]* %3, i64 0, i64 %46
%48 = call i64 @strlen(i8* %7)
%49 = getelementptr [20 x i8], [20 x i8]* %3, i64 0, i64 %48
%50 = bitcast i8* %49 to i16*
store i16 32, i16* %50
%51 = call i64 @strlen(i8* %7)
%52 = getelementptr [20 x i8], [20 x i8]* %3, i64 0, i64 %51
%53 = call i64 @strlen(i8* %7)
%54 = getelementptr [20 x i8], [20 x i8]* %3, i64 0, i64 %53
%55 = bitcast i8* %54 to i16*
store i16 32, i16* %55
%56 = call i64 @strlen(i8* %7)
%57 = getelementptr [20 x i8], [20 x i8]* %3, i64 0, i64 %56
%58 = bitcast i8* %57 to i32*
store i32 7954771, i32* %58
%59 = call i32 @printf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.5, i64 0, i64 0), i8* %7)
%60 = call i32 @memset(i8* %7, i32 0, i32 20)
%61 = call i8* @strbld_array(i8* %7, i8** %11)
%62 = call i32 @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.6, i64 0, i64 0), i8* %7)
%63 = bitcast [3 x i8*]* %5 to i8*
%64 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 0
%65 = call i32 @printf(i8* getelementptr inbounds ([76 x i8], [76 x i8]* @.str.9, i64 0, i64 0), i8* %64)
%66 = call i8* @strbld(i8* %64, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0))
%67 = call i32 @printf(i8* getelementptr inbounds ([76 x i8], [76 x i8]* @.str.11, i64 0, i64 0), i8* %64)
%68 = call i8* @strnbld(i8* %66, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
%69 = call i32 @printf(i8* getelementptr inbounds ([76 x i8], [76 x i8]* @.str.11, i64 0, i64 0), i8* %64)
%70 = getelementptr inbounds [3 x i8*], [3 x i8*]* %5, i64 0, i64 0
%71 = call i8* @strbld_array(i8* %68, i8** %70)
%72 = call i32 @printf(i8* getelementptr inbounds ([76 x i8], [76 x i8]* @.str.11, i64 0, i64 0), i8* %64)
%73 = getelementptr inbounds [3 x i8*], [3 x i8*]* %5, i64 0, i64 1
%74 = load i8*, i8** %73
%75 = call i8* @strbld(i8* %71, i8* %74)
%76 = call i32 @printf(i8* getelementptr inbounds ([76 x i8], [76 x i8]* @.str.12, i64 0, i64 0), i8* %64)
ret i32 0
}