#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 *nconcat_strings(char *, char *, int);
int /*<<< orphan*/ printf(char *, char *);
int main(void) {
  char s1[98] = "Hello ";
  char s2[] = "World!\n";
  char *p;
  printf("%s\n", s1);
  printf("%s", s2);
  p = nconcat_strings(s1, s2, 1);
  printf("%s\n", s1);
  printf("%s", s2);
  printf("%s\n", p);
  p = nconcat_strings(s1, s2, 1024);
  printf("%s", s1);
  printf("%s", s2);
  printf("%s", p);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x70(%rbp),%rdi
xor    %esi,%esi
mov    $0x62,%edx
call   1040 <memset@plt>
movb   $0x48,-0x70(%rbp)
movb   $0x65,-0x6f(%rbp)
movb   $0x6c,-0x6e(%rbp)
movb   $0x6c,-0x6d(%rbp)
movb   $0x6f,-0x6c(%rbp)
movb   $0x20,-0x6b(%rbp)
mov    0xe8f(%rip),%rax
mov    %rax,-0x78(%rbp)
lea    -0x70(%rbp),%rsi
lea    0xe88(%rip),%rdi
call   1030 <printf@plt>
lea    -0x78(%rbp),%rsi
lea    0xe7c(%rip),%rdi
call   1030 <printf@plt>
lea    -0x70(%rbp),%rdi
lea    -0x78(%rbp),%rsi
mov    $0x1,%edx
call   1050 <nconcat_strings@plt>
mov    %rax,-0x80(%rbp)
lea    -0x70(%rbp),%rsi
lea    0xe52(%rip),%rdi
call   1030 <printf@plt>
lea    -0x78(%rbp),%rsi
lea    0xe46(%rip),%rdi
call   1030 <printf@plt>
mov    -0x80(%rbp),%rsi
lea    0xe32(%rip),%rdi
call   1030 <printf@plt>
lea    -0x70(%rbp),%rdi
lea    -0x78(%rbp),%rsi
mov    $0x400,%edx
call   1050 <nconcat_strings@plt>
mov    %rax,-0x80(%rbp)
lea    -0x70(%rbp),%rsi
lea    0xe10(%rip),%rdi
call   1030 <printf@plt>
lea    -0x78(%rbp),%rsi
lea    0xe00(%rip),%rdi
call   1030 <printf@plt>
mov    -0x80(%rbp),%rsi
lea    0xdf0(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x80,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x10(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movw   $0x0,0x70(%rsp)
movl   $0x6c6c6548,0x10(%rsp)
6c
movw   $0x206f,0x14(%rsp)
movabs $0xa21646c726f57,%rax
mov    %rax,0x8(%rsp)
lea    0xe83(%rip),%r12
lea    0x10(%rsp),%r15
mov    %r12,%rdi
mov    %r15,%rsi
call   1030 <printf@plt>
lea    0xe70(%rip),%r14
lea    0x8(%rsp),%r13
mov    %r14,%rdi
mov    %r13,%rsi
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %r13,%rsi
mov    $0x1,%edx
call   1040 <nconcat_strings@plt>
mov    %rax,%rbx
mov    %r12,%rdi
mov    %r15,%rsi
call   1030 <printf@plt>
mov    %r14,%rdi
mov    %r13,%rsi
call   1030 <printf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %r13,%rsi
mov    $0x400,%edx
call   1040 <nconcat_strings@plt>
mov    %rax,%rbx
mov    %r14,%rdi
mov    %r15,%rsi
call   1030 <printf@plt>
mov    %r14,%rdi
mov    %r13,%rsi
call   1030 <printf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.s2 = [8 x i8] c"World!\0A\00"
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [98 x i8]
%3 = alloca [8 x i8]
%4 = alloca i8*
store i32 0, i32* %1
%5 = bitcast [98 x i8]* %2 to i8*
%6 = bitcast i8* %5 to [98 x i8]*
%7 = getelementptr inbounds [98 x i8], [98 x i8]* %6, i32 0, i32 0
store i8 72, i8* %7
%8 = getelementptr inbounds [98 x i8], [98 x i8]* %6, i32 0, i32 1
store i8 101, i8* %8
%9 = getelementptr inbounds [98 x i8], [98 x i8]* %6, i32 0, i32 2
store i8 108, i8* %9
%10 = getelementptr inbounds [98 x i8], [98 x i8]* %6, i32 0, i32 3
store i8 108, i8* %10
%11 = getelementptr inbounds [98 x i8], [98 x i8]* %6, i32 0, i32 4
store i8 111, i8* %11
%12 = getelementptr inbounds [98 x i8], [98 x i8]* %6, i32 0, i32 5
store i8 32, i8* %12
%13 = bitcast [8 x i8]* %3 to i8*
%14 = getelementptr inbounds [98 x i8], [98 x i8]* %2, i64 0, i64 0
%15 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %14)
%16 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 0
%17 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %16)
%18 = getelementptr inbounds [98 x i8], [98 x i8]* %2, i64 0, i64 0
%19 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 0
%20 = call i8* @nconcat_strings(i8* %18, i8* %19, i32 1)
store i8* %20, i8** %4
%21 = getelementptr inbounds [98 x i8], [98 x i8]* %2, i64 0, i64 0
%22 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %21)
%23 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 0
%24 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %23)
%25 = load i8*, i8** %4
%26 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %25)
%27 = getelementptr inbounds [98 x i8], [98 x i8]* %2, i64 0, i64 0
%28 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 0
%29 = call i8* @nconcat_strings(i8* %27, i8* %28, i32 1024)
store i8* %29, i8** %4
%30 = getelementptr inbounds [98 x i8], [98 x i8]* %2, i64 0, i64 0
%31 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %30)
%32 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 0
%33 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %32)
%34 = load i8*, i8** %4
%35 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %34)
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca [98 x i8]
%2 = alloca i64
%3 = getelementptr inbounds [98 x i8], [98 x i8]* %1, i64 0, i64 0
store i8 72, i8* %3
%4 = getelementptr inbounds [98 x i8], [98 x i8]* %1, i64 0, i64 1
store i8 101, i8* %4
%5 = getelementptr inbounds [98 x i8], [98 x i8]* %1, i64 0, i64 2
store i8 108, i8* %5
%6 = getelementptr inbounds [98 x i8], [98 x i8]* %1, i64 0, i64 3
store i8 108, i8* %6
%7 = getelementptr inbounds [98 x i8], [98 x i8]* %1, i64 0, i64 4
store i8 111, i8* %7
%8 = getelementptr inbounds [98 x i8], [98 x i8]* %1, i64 0, i64 5
store i8 32, i8* %8
%9 = bitcast i64* %2 to i8*
store i64 2851464966991703, i64* %2
%10 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %3)
%11 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%12 = call i8* @nconcat_strings(i8* %3, i8* %9, i32 1)
%13 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %3)
%14 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%15 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %12)
%16 = call i8* @nconcat_strings(i8* %3, i8* %9, i32 1024)
%17 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%18 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%19 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %16)
ret i32 0
}