#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) {
  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");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xecb(%rip),%eax
mov    %eax,-0x9(%rbp)
mov    0xec6(%rip),%al
mov    %al,-0x5(%rbp)
mov    0xebe(%rip),%eax
mov    %eax,-0xf(%rbp)
mov    0xeb8(%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    11a7 <main+0x87>
movslq -0x20(%rbp),%rax
movsbl -0x1a(%rbp,%rax,1),%esi
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1178 <main+0x58>
lea    0xe60(%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
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   1040 <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>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x28,%rsp
ret

LLVM IR (-O0):
@__const.main.s1 = [5 x i8] c"Test "
@__const.main.s2 = [6 x i8] c"works."
@.str = [3 x i8] c"%c\00"
@.str.1 = [2 x i8] c"\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 = bitcast [5 x i8]* %2 to i8*
%7 = bitcast [6 x i8]* %3 to i8*
%8 = getelementptr inbounds [11 x i8], [11 x i8]* %4, i64 0, i64 0
%9 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%10 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 0
store i32 0, i32* %5
br label %11
11: ; preds = %21, %0
%12 = load i32, i32* %5
%13 = icmp slt i32 %12, 11
br i1 %13, label %14, label %24
14: ; preds = %11
%15 = load i32, i32* %5
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [11 x i8], [11 x i8]* %4, i64 0, i64 %16
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %19)
br label %21
21: ; preds = %14
%22 = load i32, i32* %5
%23 = add nsw i32 %22, 1
store i32 %23, i32* %5
br label %11
24: ; preds = %11
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, 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."
define i32 @main() {
%1 = alloca [5 x i8]
%2 = alloca [6 x i8]
%3 = alloca [11 x i8]
%4 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 0
%7 = load i8, i8* %6
%8 = sext i8 %7 to i32
%9 = call i32 @putchar(i32 %8)
%10 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 1
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = call i32 @putchar(i32 %12)
%14 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 2
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = call i32 @putchar(i32 %16)
%18 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 3
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = call i32 @putchar(i32 %20)
%22 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 4
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = call i32 @putchar(i32 %24)
%26 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 5
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = call i32 @putchar(i32 %28)
%30 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 6
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = call i32 @putchar(i32 %32)
%34 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 7
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = call i32 @putchar(i32 %36)
%38 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 8
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = call i32 @putchar(i32 %40)
%42 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 9
%43 = load i8, i8* %42
%44 = sext i8 %43 to i32
%45 = call i32 @putchar(i32 %44)
%46 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 10
%47 = load i8, i8* %46
%48 = sext i8 %47 to i32
%49 = call i32 @putchar(i32 %48)
%50 = call i32 @putchar(i32 10)
ret i32 0
}