#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 */
char *StrConcat(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
char *strcat(char *, char *);
scalar_t__ strcmp(char *, char *);
void TestStrConcat() {
  char str1[] = "test StrConcat";
  char str2[] = "test StrConcat with Null\0 Following character "
                "should not be added";
  char str_empty[] = "";
  char dest1[100] = "Previous dest: ";
  char dest2[100] = "Previous dest: ";
  char dest3[100] = "Previous dest: ";
  char dest4[100] = "";
  char answer1[100] = "Previous dest: ";
  char answer2[100] = "Previous dest: ";
  char answer3[100] = "Previous dest: ";
  char answer4[100] = "";
  char *res1, *res2;
  printf("===========================\n"
         "Test StrConcat\n"
         "===========================\n");
  printf("Test1:\n");
  res1 = StrConcat(dest1, str1);
  res2 = strcat(answer1, str1);
  ((strcmp(res1, res2) == 0)) ? printf("Correct!\n") : printf("Wrong!\n");
  printf("Your     Answer: [%s]\n", res1);
  printf("String.h Answer: [%s]\n", res2);
  printf("\nTest2:\n");
  res1 = StrConcat(dest2, str2);
  res2 = strcat(answer2, str2);
  ((strcmp(res1, res2) == 0)) ? printf("Correct!\n") : printf("Wrong!\n");
  printf("Your     Answer: [%s]\n", res1);
  printf("String.h Answer: [%s]\n", res2);
  printf("\nTest3:\n");
  res1 = StrConcat(dest3, str_empty);
  res2 = strcat(answer3, str_empty);
  ((strcmp(res1, res2) == 0)) ? printf("Correct!\n") : printf("Wrong!\n");
  printf("Your     Answer: [%s]\n", res1);
  printf("String.h Answer: [%s]\n", res2);
  printf("\nTest4:\n");
  res1 = StrConcat(dest4, str1);
  res2 = strcat(answer4, str1);
  ((strcmp(res1, res2) == 0)) ? printf("Correct!\n") : printf("Wrong!\n");
  printf("Your     Answer: [%s]\n", res1);
  printf("String.h Answer: [%s]\n", res2);
  return;
}


x86 assembly (clang, -O0):
<TestStrConcat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x3f0,%rsp
mov    0xe8e(%rip),%rax
mov    %rax,-0xf(%rbp)
mov    0xe8c(%rip),%eax
mov    %eax,-0x7(%rbp)
mov    0xe86(%rip),%ax
mov    %ax,-0x3(%rbp)
mov    0xe7e(%rip),%al
mov    %al,-0x1(%rbp)
lea    -0x60(%rbp),%rdi
lea    0xf22(%rip),%rsi
mov    $0x42,%edx
call   1060 <memcpy@plt>
lea    -0x61(%rbp),%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1040 <memset@plt>
lea    -0xd0(%rbp),%rdi
lea    0xf4a(%rip),%rsi
mov    $0x64,%edx
call   1060 <memcpy@plt>
lea    -0x140(%rbp),%rdi
lea    0xfa2(%rip),%rsi
mov    $0x64,%edx
call   1060 <memcpy@plt>
lea    -0x1b0(%rbp),%rdi
lea    0xffa(%rip),%rsi
mov    $0x64,%edx
call   1060 <memcpy@plt>
lea    -0x220(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1040 <memset@plt>
lea    -0x290(%rbp),%rdi
lea    0x103f(%rip),%rsi
mov    $0x64,%edx
call   1060 <memcpy@plt>
lea    -0x300(%rbp),%rdi
lea    0x1097(%rip),%rsi
mov    $0x64,%edx
call   1060 <memcpy@plt>
lea    -0x370(%rbp),%rdi
lea    0x10ef(%rip),%rsi
mov    $0x64,%edx
call   1060 <memcpy@plt>
lea    -0x3e0(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1040 <memset@plt>
lea    0xd9a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xdd4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0xd0(%rbp),%rdi
lea    -0xf(%rbp),%rsi
call   1070 <StrConcat@plt>
mov    %rax,-0x3e8(%rbp)
lea    -0x290(%rbp),%rdi
lea    -0xf(%rbp),%rsi
call   1080 <strcat@plt>
mov    %rax,-0x3f0(%rbp)
mov    -0x3e8(%rbp),%rdi
mov    -0x3f0(%rbp),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    12e8 <TestStrConcat+0x188>
lea    0xd83(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12f6 <TestStrConcat+0x196>
lea    0xd7a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x3e8(%rbp),%rsi
lea    0xd6d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x3f0(%rbp),%rsi
lea    0xd6f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xd78(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x140(%rbp),%rdi
lea    -0x60(%rbp),%rsi
call   1070 <StrConcat@plt>
mov    %rax,-0x3e8(%rbp)
lea    -0x300(%rbp),%rdi
lea    -0x60(%rbp),%rsi
call   1080 <strcat@plt>
mov    %rax,-0x3f0(%rbp)
mov    -0x3e8(%rbp),%rdi
mov    -0x3f0(%rbp),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    138c <TestStrConcat+0x22c>
lea    0xcdf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    139a <TestStrConcat+0x23a>
lea    0xcd6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x3e8(%rbp),%rsi
lea    0xcc9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x3f0(%rbp),%rsi
lea    0xccb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xcdd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x1b0(%rbp),%rdi
lea    -0x61(%rbp),%rsi
call   1070 <StrConcat@plt>
mov    %rax,-0x3e8(%rbp)
lea    -0x370(%rbp),%rdi
lea    -0x61(%rbp),%rsi
call   1080 <strcat@plt>
mov    %rax,-0x3f0(%rbp)
mov    -0x3e8(%rbp),%rdi
mov    -0x3f0(%rbp),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1430 <TestStrConcat+0x2d0>
lea    0xc3b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    143e <TestStrConcat+0x2de>
lea    0xc32(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x3e8(%rbp),%rsi
lea    0xc25(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x3f0(%rbp),%rsi
lea    0xc27(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xc42(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x220(%rbp),%rdi
lea    -0xf(%rbp),%rsi
call   1070 <StrConcat@plt>
mov    %rax,-0x3e8(%rbp)
lea    -0x3e0(%rbp),%rdi
lea    -0xf(%rbp),%rsi
call   1080 <strcat@plt>
mov    %rax,-0x3f0(%rbp)
mov    -0x3e8(%rbp),%rdi
mov    -0x3f0(%rbp),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    14d4 <TestStrConcat+0x374>
lea    0xb97(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    14e2 <TestStrConcat+0x382>
lea    0xb8e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x3e8(%rbp),%rsi
lea    0xb81(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x3f0(%rbp),%rsi
lea    0xb83(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x3f0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<TestStrConcat>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x3e8,%rsp
movabs $0x7461636e6f4372,%rax
mov    %rax,0x17(%rsp)
movabs $0x7274532074736574,%rax
53 74 72
mov    %rax,0x10(%rsp)
movaps 0xf6a(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0xf4e(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xf32(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xf16(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movw   $0x64,0x60(%rsp)
movb   $0x0,0xf(%rsp)
movaps 0xf9e(%rip),%xmm0
movaps %xmm0,0x3d0(%rsp)
movaps 0xf7f(%rip),%xmm1
movaps %xmm1,0x3c0(%rsp)
movaps 0xf60(%rip),%xmm2
movaps %xmm2,0x3b0(%rsp)
movaps 0xf41(%rip),%xmm3
movaps %xmm3,0x3a0(%rsp)
movaps 0xf22(%rip),%xmm4
movaps %xmm4,0x390(%rsp)
movaps 0xf03(%rip),%xmm5
movaps %xmm5,0x380(%rsp)
movl   $0x0,0x3e0(%rsp)
movaps %xmm0,0x360(%rsp)
movaps %xmm1,0x350(%rsp)
movaps %xmm2,0x340(%rsp)
movaps %xmm3,0x330(%rsp)
movaps %xmm4,0x320(%rsp)
movaps %xmm5,0x310(%rsp)
movl   $0x0,0x370(%rsp)
movaps %xmm0,0x2f0(%rsp)
movaps %xmm1,0x2e0(%rsp)
movaps %xmm2,0x2d0(%rsp)
movaps %xmm3,0x2c0(%rsp)
movaps %xmm4,0x2b0(%rsp)
movaps %xmm5,0x2a0(%rsp)
movl   $0x0,0x300(%rsp)
xorps  %xmm6,%xmm6
movaps %xmm6,0x280(%rsp)
movaps %xmm6,0x270(%rsp)
movaps %xmm6,0x260(%rsp)
movaps %xmm6,0x250(%rsp)
movaps %xmm6,0x240(%rsp)
movaps %xmm6,0x230(%rsp)
movl   $0x0,0x290(%rsp)
movaps %xmm0,0x210(%rsp)
movaps %xmm1,0x200(%rsp)
movaps %xmm2,0x1f0(%rsp)
movaps %xmm3,0x1e0(%rsp)
movaps %xmm4,0x1d0(%rsp)
movaps %xmm5,0x1c0(%rsp)
movl   $0x0,0x220(%rsp)
movaps %xmm0,0x1a0(%rsp)
movaps %xmm1,0x190(%rsp)
movaps %xmm2,0x180(%rsp)
movaps %xmm3,0x170(%rsp)
movaps %xmm4,0x160(%rsp)
movaps %xmm5,0x150(%rsp)
movl   $0x0,0x1b0(%rsp)
movaps %xmm0,0x130(%rsp)
movaps %xmm1,0x120(%rsp)
movaps %xmm2,0x110(%rsp)
movaps %xmm3,0x100(%rsp)
movaps %xmm4,0xf0(%rsp)
movaps %xmm5,0xe0(%rsp)
movl   $0x0,0x140(%rsp)
movaps %xmm6,0xc0(%rsp)
movaps %xmm6,0xb0(%rsp)
movaps %xmm6,0xa0(%rsp)
movaps %xmm6,0x90(%rsp)
movaps %xmm6,0x80(%rsp)
movaps %xmm6,0x70(%rsp)
movl   $0x0,0xd0(%rsp)
lea    0xc79(%rip),%rdi
call   1030 <puts@plt>
lea    0xcb4(%rip),%rdi
call   1030 <puts@plt>
lea    0x380(%rsp),%rdi
lea    0x10(%rsp),%rbp
mov    %rbp,%rsi
call   1060 <StrConcat@plt>
mov    %rax,%rbx
lea    0x1c0(%rsp),%r13
mov    %r13,%rdi
mov    %rbp,%rsi
call   1070 <strcat@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
lea    0xc95(%rip),%r15
lea    0xc87(%rip),%r14
mov    %r14,%rdi
cmove  %r15,%rdi
call   1030 <puts@plt>
lea    0xbe0(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xbe6(%rip),%r12
mov    %r12,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xc37(%rip),%rdi
call   1030 <puts@plt>
lea    0x310(%rsp),%rdi
lea    0x20(%rsp),%rbx
mov    %rbx,%rsi
call   1060 <StrConcat@plt>
mov    %rax,%rbp
lea    0x150(%rsp),%r13
mov    %r13,%rdi
mov    %rbx,%rsi
call   1070 <strcat@plt>
mov    %rbp,%rdi
mov    %r13,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
mov    %r14,%rdi
cmove  %r15,%rdi
call   1030 <puts@plt>
lea    0xb6a(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xbd0(%rip),%rdi
call   1030 <puts@plt>
lea    0x2a0(%rsp),%rdi
lea    0xf(%rsp),%rbx
mov    %rbx,%rsi
call   1060 <StrConcat@plt>
mov    %rax,%rbp
lea    0xe0(%rsp),%r13
mov    %r13,%rdi
mov    %rbx,%rsi
call   1070 <strcat@plt>
mov    %rbp,%rdi
mov    %r13,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
mov    %r14,%rdi
cmove  %r15,%rdi
call   1030 <puts@plt>
lea    0xafb(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xb69(%rip),%rdi
call   1030 <puts@plt>
lea    0x230(%rsp),%rdi
lea    0x10(%rsp),%rbp
mov    %rbp,%rsi
call   1060 <StrConcat@plt>
mov    %rax,%rbx
lea    0x70(%rsp),%r13
mov    %r13,%rdi
mov    %rbp,%rsi
call   1070 <strcat@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
cmove  %r15,%r14
mov    %r14,%rdi
call   1030 <puts@plt>
lea    0xa8f(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x3e8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.TestStrConcat.str1 = [15 x i8] c"test StrConcat\00"
@__const.TestStrConcat.str2 = [66 x i8] c"test StrConcat with Null\00 Following character should not be added\00"
@__const.TestStrConcat.dest1 = [100 x i8] c"Previous dest: \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@__const.TestStrConcat.dest2 = [100 x i8] c"Previous dest: \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@__const.TestStrConcat.dest3 = [100 x i8] c"Previous dest: \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@__const.TestStrConcat.answer1 = [100 x i8] c"Previous dest: \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@__const.TestStrConcat.answer2 = [100 x i8] c"Previous dest: \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@__const.TestStrConcat.answer3 = [100 x i8] c"Previous dest: \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str = [72 x i8] c"===========================\0ATest StrConcat\0A===========================\0A\00"
@.str.1 = [8 x i8] c"Test1:\0A\00"
@.str.2 = [10 x i8] c"Correct!\0A\00"
@.str.3 = [8 x i8] c"Wrong!\0A\00"
@.str.4 = [23 x i8] c"Your Answer: [%s]\0A\00"
@.str.5 = [23 x i8] c"String.h Answer: [%s]\0A\00"
@.str.6 = [9 x i8] c"\0ATest2:\0A\00"
@.str.7 = [9 x i8] c"\0ATest3:\0A\00"
@.str.8 = [9 x i8] c"\0ATest4:\0A\00"
define void @TestStrConcat() {
%1 = alloca [15 x i8]
%2 = alloca [66 x i8]
%3 = alloca [1 x i8]
%4 = alloca [100 x i8]
%5 = alloca [100 x i8]
%6 = alloca [100 x i8]
%7 = alloca [100 x i8]
%8 = alloca [100 x i8]
%9 = alloca [100 x i8]
%10 = alloca [100 x i8]
%11 = alloca [100 x i8]
%12 = alloca i8*
%13 = alloca i8*
%14 = bitcast [15 x i8]* %1 to i8*
%15 = bitcast [66 x i8]* %2 to i8*
%16 = bitcast [1 x i8]* %3 to i8*
%17 = bitcast [100 x i8]* %4 to i8*
%18 = bitcast [100 x i8]* %5 to i8*
%19 = bitcast [100 x i8]* %6 to i8*
%20 = bitcast [100 x i8]* %7 to i8*
%21 = bitcast [100 x i8]* %8 to i8*
%22 = bitcast [100 x i8]* %9 to i8*
%23 = bitcast [100 x i8]* %10 to i8*
%24 = bitcast [100 x i8]* %11 to i8*
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str, i64 0, i64 0))
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%27 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%28 = getelementptr inbounds [15 x i8], [15 x i8]* %1, i64 0, i64 0
%29 = call i8* @StrConcat(i8* %27, i8* %28)
store i8* %29, i8** %12
%30 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%31 = getelementptr inbounds [15 x i8], [15 x i8]* %1, i64 0, i64 0
%32 = call i8* @strcat(i8* %30, i8* %31)
store i8* %32, i8** %13
%33 = load i8*, i8** %12
%34 = load i8*, i8** %13
%35 = call i64 @strcmp(i8* %33, i8* %34)
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %39
37: ; preds = %0
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
br label %41
39: ; preds = %0
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
br label %41
41: ; preds = %39, %37
%42 = phi i32 [ %38, %37 ], [ %40, %39 ]
%43 = load i8*, i8** %12
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i8* %43)
%45 = load i8*, i8** %13
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i8* %45)
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
%48 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%49 = getelementptr inbounds [66 x i8], [66 x i8]* %2, i64 0, i64 0
%50 = call i8* @StrConcat(i8* %48, i8* %49)
store i8* %50, i8** %12
%51 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%52 = getelementptr inbounds [66 x i8], [66 x i8]* %2, i64 0, i64 0
%53 = call i8* @strcat(i8* %51, i8* %52)
store i8* %53, i8** %13
%54 = load i8*, i8** %12
%55 = load i8*, i8** %13
%56 = call i64 @strcmp(i8* %54, i8* %55)
%57 = icmp eq i64 %56, 0
br i1 %57, label %58, label %60
58: ; preds = %41
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
br label %62
60: ; preds = %41
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
br label %62
62: ; preds = %60, %58
%63 = phi i32 [ %59, %58 ], [ %61, %60 ]
%64 = load i8*, i8** %12
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i8* %64)
%66 = load i8*, i8** %13
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i8* %66)
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
%69 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%70 = getelementptr inbounds [1 x i8], [1 x i8]* %3, i64 0, i64 0
%71 = call i8* @StrConcat(i8* %69, i8* %70)
store i8* %71, i8** %12
%72 = getelementptr inbounds [100 x i8], [100 x i8]* %10, i64 0, i64 0
%73 = getelementptr inbounds [1 x i8], [1 x i8]* %3, i64 0, i64 0
%74 = call i8* @strcat(i8* %72, i8* %73)
store i8* %74, i8** %13
%75 = load i8*, i8** %12
%76 = load i8*, i8** %13
%77 = call i64 @strcmp(i8* %75, i8* %76)
%78 = icmp eq i64 %77, 0
br i1 %78, label %79, label %81
79: ; preds = %62
%80 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
br label %83
81: ; preds = %62
%82 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
br label %83
83: ; preds = %81, %79
%84 = phi i32 [ %80, %79 ], [ %82, %81 ]
%85 = load i8*, i8** %12
%86 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i8* %85)
%87 = load i8*, i8** %13
%88 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i8* %87)
%89 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0))
%90 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%91 = getelementptr inbounds [15 x i8], [15 x i8]* %1, i64 0, i64 0
%92 = call i8* @StrConcat(i8* %90, i8* %91)
store i8* %92, i8** %12
%93 = getelementptr inbounds [100 x i8], [100 x i8]* %11, i64 0, i64 0
%94 = getelementptr inbounds [15 x i8], [15 x i8]* %1, i64 0, i64 0
%95 = call i8* @strcat(i8* %93, i8* %94)
store i8* %95, i8** %13
%96 = load i8*, i8** %12
%97 = load i8*, i8** %13
%98 = call i64 @strcmp(i8* %96, i8* %97)
%99 = icmp eq i64 %98, 0
br i1 %99, label %100, label %102
100: ; preds = %83
%101 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
br label %104
102: ; preds = %83
%103 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
br label %104
104: ; preds = %102, %100
%105 = phi i32 [ %101, %100 ], [ %103, %102 ]
%106 = load i8*, i8** %12
%107 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i8* %106)
%108 = load i8*, i8** %13
%109 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i8* %108)
ret void
}

LLVM IR (-O2):
@__const.TestStrConcat.str1 = [15 x i8] c"test StrConcat\00"
@__const.TestStrConcat.str2 = [66 x i8] c"test StrConcat with Null\00 Following character should not be added\00"
@__const.TestStrConcat.answer3 = [100 x i8] c"Previous dest: \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str.4 = [23 x i8] c"Your Answer: [%s]\0A\00"
@.str.5 = [23 x i8] c"String.h Answer: [%s]\0A\00"
@str = [71 x i8] c"===========================\0ATest StrConcat\0A===========================\00"
@str.9 = [7 x i8] c"Test1:\00"
@str.11 = [8 x i8] c"\0ATest2:\00"
@str.13 = [8 x i8] c"\0ATest3:\00"
@str.15 = [8 x i8] c"\0ATest4:\00"
@str.16 = [7 x i8] c"Wrong!\00"
@str.20 = [9 x i8] c"Correct!\00"
define void @TestStrConcat() {
%1 = alloca [15 x i8]
%2 = alloca [66 x i8]
%3 = alloca [1 x i8]
%4 = alloca [100 x i8]
%5 = alloca [100 x i8]
%6 = alloca [100 x i8]
%7 = alloca [100 x i8]
%8 = alloca [100 x i8]
%9 = alloca [100 x i8]
%10 = alloca [100 x i8]
%11 = alloca [100 x i8]
%12 = getelementptr inbounds [15 x i8], [15 x i8]* %1, i64 0, i64 0
%13 = getelementptr inbounds [66 x i8], [66 x i8]* %2, i64 0, i64 0
%14 = getelementptr inbounds [1 x i8], [1 x i8]* %3, i64 0, i64 0
store i8 0, i8* %14
%15 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%16 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%17 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%18 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%19 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%20 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%21 = getelementptr inbounds [100 x i8], [100 x i8]* %10, i64 0, i64 0
%22 = getelementptr inbounds [100 x i8], [100 x i8]* %11, i64 0, i64 0
%23 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([71 x i8], [71 x i8]* @str, i64 0, i64 0))
%24 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str.9, i64 0, i64 0))
%25 = call i8* @StrConcat(i8* %15, i8* %12)
%26 = call i8* @strcat(i8* %19, i8* %12)
%27 = call i64 @strcmp(i8* %25, i8* %19)
%28 = icmp eq i64 %27, 0
%29 = select i1 %28, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @str.20, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @str.16, i64 0, i64 0)
%30 = call i32 @puts(i8* dereferenceable(1) %29)
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i8* %25)
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i8* %19)
%33 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.11, i64 0, i64 0))
%34 = call i8* @StrConcat(i8* %16, i8* %13)
%35 = call i8* @strcat(i8* %20, i8* %13)
%36 = call i64 @strcmp(i8* %34, i8* %20)
%37 = icmp eq i64 %36, 0
%38 = select i1 %37, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @str.20, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @str.16, i64 0, i64 0)
%39 = call i32 @puts(i8* dereferenceable(1) %38)
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i8* %34)
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i8* %20)
%42 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.13, i64 0, i64 0))
%43 = call i8* @StrConcat(i8* %17, i8* %14)
%44 = call i8* @strcat(i8* %21, i8* %14)
%45 = call i64 @strcmp(i8* %43, i8* %21)
%46 = icmp eq i64 %45, 0
%47 = select i1 %46, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @str.20, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @str.16, i64 0, i64 0)
%48 = call i32 @puts(i8* dereferenceable(1) %47)
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i8* %43)
%50 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i8* %21)
%51 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.15, i64 0, i64 0))
%52 = call i8* @StrConcat(i8* %18, i8* %12)
%53 = call i8* @strcat(i8* %22, i8* %12)
%54 = call i64 @strcmp(i8* %52, i8* %22)
%55 = icmp eq i64 %54, 0
%56 = select i1 %55, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @str.20, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @str.16, i64 0, i64 0)
%57 = call i32 @puts(i8* dereferenceable(1) %56)
%58 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i8* %52)
%59 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i8* %22)
ret void
}