int main(int argc, char **argv) {
  int first_array[5] = {1, 2, 3, 4, 5};
  int second_array[5] = {6, 7, 8, 9, 10};
  int *ultimate_array;
  char *buffer1, *buffer2, *buffer3;
  buffer1 = arrayDisplay(first_array, 5);
  buffer2 = arrayDisplay(second_array, 5);
  ultimate_array = arrayMerge(first_array, 5, second_array, 5);
  buffer3 = arrayDisplay(ultimate_array, 10);
  printf("So, we have two arrays.\n\nThe first one is %s.\nThe second one is "
         "%s.\n\nIf we merge both we get:\n%s\n",
         buffer1, buffer2, buffer3);
  free(buffer1);
  free(buffer2);
  free(buffer3);
  free(ultimate_array);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xea3(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xea0(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xe9e(%rip),%eax
mov    %eax,-0x20(%rbp)
mov    0xea4(%rip),%rax
mov    %rax,-0x50(%rbp)
mov    0xea1(%rip),%rax
mov    %rax,-0x48(%rbp)
mov    0xe9f(%rip),%eax
mov    %eax,-0x40(%rbp)
lea    -0x30(%rbp),%rdi
mov    $0x5,%esi
mov    $0x0,%al
call   1060 <arrayDisplay@plt>
cltq
mov    %rax,-0x60(%rbp)
lea    -0x50(%rbp),%rdi
mov    $0x5,%esi
mov    $0x0,%al
call   1060 <arrayDisplay@plt>
cltq
mov    %rax,-0x68(%rbp)
lea    -0x30(%rbp),%rdi
lea    -0x50(%rbp),%rdx
mov    $0x5,%ecx
mov    %ecx,%esi
mov    $0x0,%al
call   1050 <arrayMerge@plt>
cltq
mov    %rax,-0x58(%rbp)
mov    -0x58(%rbp),%rdi
mov    $0xa,%esi
mov    $0x0,%al
call   1060 <arrayDisplay@plt>
cltq
mov    %rax,-0x70(%rbp)
mov    -0x60(%rbp),%rsi
mov    -0x68(%rbp),%rdx
mov    -0x70(%rbp),%rcx
lea    0xe2f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x60(%rbp),%rdi
call   1030 <free@plt>
mov    -0x68(%rbp),%rdi
call   1030 <free@plt>
mov    -0x70(%rbp),%rdi
call   1030 <free@plt>
mov    -0x58(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    0xebf(%rip),%eax
mov    %eax,0x30(%rsp)
movaps 0xea4(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
mov    0xec9(%rip),%eax
mov    %eax,0x10(%rsp)
movaps 0xeae(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0x20(%rsp),%r12
mov    %r12,%rdi
mov    $0x5,%esi
xor    %eax,%eax
call   1060 <arrayDisplay@plt>
movslq %eax,%r14
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x5,%esi
xor    %eax,%eax
call   1060 <arrayDisplay@plt>
movslq %eax,%r15
mov    %r12,%rdi
mov    $0x5,%esi
mov    %rbx,%rdx
mov    $0x5,%ecx
xor    %eax,%eax
call   1050 <arrayMerge@plt>
movslq %eax,%r12
mov    %r12,%rdi
mov    $0xa,%esi
xor    %eax,%eax
call   1060 <arrayDisplay@plt>
movslq %eax,%rbx
lea    0xe5f(%rip),%rdi
mov    %r14,%rsi
mov    %r15,%rdx
mov    %rbx,%rcx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r12,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.first_array = [5 x i32] [i32 1, i32 2, i32 3, i32 4, i32 5]
@__const.main.second_array = [5 x i32] [i32 6, i32 7, i32 8, i32 9, i32 10]
@.str = [98 x i8] c"So, we have two arrays.\0A\0AThe first one is %s.\0AThe second one is %s.\0A\0AIf we merge both we get:\0A%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [5 x i32]
%7 = alloca [5 x i32]
%8 = alloca i32*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = bitcast [5 x i32]* %6 to i8*
%13 = bitcast [5 x i32]* %7 to i8*
%14 = getelementptr inbounds [5 x i32], [5 x i32]* %6, i64 0, i64 0
%15 = call i32 (i32*, i32, ...) bitcast (i32 (...)* @arrayDisplay to i32 (i32*, i32, ...)*)(i32* %14, i32 5)
%16 = sext i32 %15 to i64
%17 = inttoptr i64 %16 to i8*
store i8* %17, i8** %9
%18 = getelementptr inbounds [5 x i32], [5 x i32]* %7, i64 0, i64 0
%19 = call i32 (i32*, i32, ...) bitcast (i32 (...)* @arrayDisplay to i32 (i32*, i32, ...)*)(i32* %18, i32 5)
%20 = sext i32 %19 to i64
%21 = inttoptr i64 %20 to i8*
store i8* %21, i8** %10
%22 = getelementptr inbounds [5 x i32], [5 x i32]* %6, i64 0, i64 0
%23 = getelementptr inbounds [5 x i32], [5 x i32]* %7, i64 0, i64 0
%24 = call i32 (i32*, i32, i32*, i32, ...) bitcast (i32 (...)* @arrayMerge to i32 (i32*, i32, i32*, i32, ...)*)(i32* %22, i32 5, i32* %23, i32 5)
%25 = sext i32 %24 to i64
%26 = inttoptr i64 %25 to i32*
store i32* %26, i32** %8
%27 = load i32*, i32** %8
%28 = call i32 (i32*, i32, ...) bitcast (i32 (...)* @arrayDisplay to i32 (i32*, i32, ...)*)(i32* %27, i32 10)
%29 = sext i32 %28 to i64
%30 = inttoptr i64 %29 to i8*
store i8* %30, i8** %11
%31 = load i8*, i8** %9
%32 = load i8*, i8** %10
%33 = load i8*, i8** %11
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([98 x i8], [98 x i8]* @.str, i64 0, i64 0), i8* %31, i8* %32, i8* %33)
%35 = load i8*, i8** %9
%36 = load i8*, i8** %10
%37 = load i8*, i8** %11
%38 = load i32*, i32** %8
%39 = bitcast i32* %38 to i8*
ret i32 0
}

LLVM IR (-O2):
@__const.main.first_array = [5 x i32] [i32 1, i32 2, i32 3, i32 4, i32 5]
@__const.main.second_array = [5 x i32] [i32 6, i32 7, i32 8, i32 9, i32 10]
@.str = [98 x i8] c"So, we have two arrays.\0A\0AThe first one is %s.\0AThe second one is %s.\0A\0AIf we merge both we get:\0A%s\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [5 x i32]
%4 = alloca [5 x i32]
%5 = bitcast [5 x i32]* %3 to i8*
%6 = bitcast [5 x i32]* %4 to i8*
%7 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 0
%8 = call i32 (i32*, i32, ...) bitcast (i32 (...)* @arrayDisplay to i32 (i32*, i32, ...)*)(i32* %7, i32 5)
%9 = sext i32 %8 to i64
%10 = inttoptr i64 %9 to i8*
%11 = getelementptr inbounds [5 x i32], [5 x i32]* %4, i64 0, i64 0
%12 = call i32 (i32*, i32, ...) bitcast (i32 (...)* @arrayDisplay to i32 (i32*, i32, ...)*)(i32* %11, i32 5)
%13 = sext i32 %12 to i64
%14 = inttoptr i64 %13 to i8*
%15 = call i32 (i32*, i32, i32*, i32, ...) bitcast (i32 (...)* @arrayMerge to i32 (i32*, i32, i32*, i32, ...)*)(i32* %7, i32 5, i32* %11, i32 5)
%16 = sext i32 %15 to i64
%17 = inttoptr i64 %16 to i32*
%18 = call i32 (i32*, i32, ...) bitcast (i32 (...)* @arrayDisplay to i32 (i32*, i32, ...)*)(i32* %17, i32 10)
%19 = sext i32 %18 to i64
%20 = inttoptr i64 %19 to i8*
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([98 x i8], [98 x i8]* @.str, i64 0, i64 0), i8* %10, i8* %14, i8* %20)
%22 = inttoptr i64 %16 to i8*
ret i32 0
}