#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*/ printf(char *, ...);
int main(void) {
  printf("\ncombinechararrays started\n\n");
  void concat(char result[], const char str1[], int n1, const char str2[],
              int n2);
  const char s1[5] = {'T', 'e', 's', 't', ' '};
  const char s2[6] = {'w', 'o', 'r', 'k', 's', '.'};
  char s3[11];
  int i;
  concat(s3, s1, 5, s2, 6);
  for (i = 0; i < 11; ++i)
    printf("%c", s3[i]);
  printf("\n\n");
  printf("combinechararrays ended\n\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0xef7(%rip),%eax
mov    %eax,-0x9(%rbp)
mov    0xef2(%rip),%al
mov    %al,-0x5(%rbp)
mov    0xeea(%rip),%eax
mov    %eax,-0xf(%rbp)
mov    0xee4(%rip),%ax
mov    %ax,-0xb(%rbp)
lea    -0x1a(%rbp),%rdi
lea    -0x9(%rbp),%rsi
lea    -0xf(%rbp),%rcx
mov    $0x5,%edx
mov    $0x6,%r8d
call   1040 <concat@plt>
movl   $0x0,-0x20(%rbp)
cmpl   $0xb,-0x20(%rbp)
jge    11b5 <main+0x95>
movslq -0x20(%rbp),%rax
movsbl -0x1a(%rbp,%rax,1),%esi
lea    0xe7d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1186 <main+0x66>
lea    0xe7b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe56(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x28,%rsp
lea    0xed0(%rip),%rdi
call   1040 <puts@plt>
movb   $0x20,0x1c(%rsp)
movl   $0x74736554,0x18(%rsp)
74
movw   $0x2e73,0x24(%rsp)
movl   $0x6b726f77,0x20(%rsp)
6b
lea    0xd(%rsp),%rdi
lea    0x18(%rsp),%rsi
lea    0x20(%rsp),%rcx
mov    $0x5,%edx
mov    $0x6,%r8d
call   1050 <concat@plt>
movsbl 0xd(%rsp),%edi
call   1030 <putchar@plt>
movsbl 0xe(%rsp),%edi
call   1030 <putchar@plt>
movsbl 0xf(%rsp),%edi
call   1030 <putchar@plt>
movsbl 0x10(%rsp),%edi
call   1030 <putchar@plt>
movsbl 0x11(%rsp),%edi
call   1030 <putchar@plt>
movsbl 0x12(%rsp),%edi
call   1030 <putchar@plt>
movsbl 0x13(%rsp),%edi
call   1030 <putchar@plt>
movsbl 0x14(%rsp),%edi
call   1030 <putchar@plt>
movsbl 0x15(%rsp),%edi
call   1030 <putchar@plt>
movsbl 0x16(%rsp),%edi
call   1030 <putchar@plt>
movsbl 0x17(%rsp),%edi
call   1030 <putchar@plt>
lea    0xe4e(%rip),%rdi
call   1040 <puts@plt>
lea    0xe2b(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x28,%rsp
ret

LLVM IR (-O0):
@.str = [29 x i8] c"\0Acombinechararrays started\0A\0A\00"
@__const.main.s1 = [5 x i8] c"Test "
@__const.main.s2 = [6 x i8] c"works."
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [3 x i8] c"\0A\0A\00"
@.str.3 = [26 x i8] c"combinechararrays ended\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [5 x i8]
%3 = alloca [6 x i8]
%4 = alloca [11 x i8]
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%7 = bitcast [5 x i8]* %2 to i8*
%8 = bitcast [6 x i8]* %3 to i8*
%9 = getelementptr inbounds [11 x i8], [11 x i8]* %4, i64 0, i64 0
%10 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%11 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 0
store i32 0, i32* %5
br label %12
12: ; preds = %22, %0
%13 = load i32, i32* %5
%14 = icmp slt i32 %13, 11
br i1 %14, label %15, label %25
15: ; preds = %12
%16 = load i32, i32* %5
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [11 x i8], [11 x i8]* %4, i64 0, i64 %17
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %20)
br label %22
22: ; preds = %15
%23 = load i32, i32* %5
%24 = add nsw i32 %23, 1
store i32 %24, i32* %5
br label %12
25: ; preds = %12
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@__const.main.s1 = [5 x i8] c"Test "
@__const.main.s2 = [6 x i8] c"works."
@str = [28 x i8] c"\0Acombinechararrays started\0A\00"
@str.4 = [2 x i8] c"\0A\00"
@str.5 = [25 x i8] c"combinechararrays ended\0A\00"
define i32 @main() {
%1 = alloca [5 x i8]
%2 = alloca [6 x i8]
%3 = alloca [11 x i8]
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0))
%5 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
%6 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%7 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 0
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
%10 = call i32 @putchar(i32 %9)
%11 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 1
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = call i32 @putchar(i32 %13)
%15 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 2
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = call i32 @putchar(i32 %17)
%19 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 3
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = call i32 @putchar(i32 %21)
%23 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 4
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = call i32 @putchar(i32 %25)
%27 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 5
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = call i32 @putchar(i32 %29)
%31 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 6
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = call i32 @putchar(i32 %33)
%35 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 7
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = call i32 @putchar(i32 %37)
%39 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 8
%40 = load i8, i8* %39
%41 = sext i8 %40 to i32
%42 = call i32 @putchar(i32 %41)
%43 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 9
%44 = load i8, i8* %43
%45 = sext i8 %44 to i32
%46 = call i32 @putchar(i32 %45)
%47 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 10
%48 = load i8, i8* %47
%49 = sext i8 %48 to i32
%50 = call i32 @putchar(i32 %49)
%51 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.4, i64 0, i64 0))
%52 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.5, i64 0, i64 0))
ret i32 0
}