#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*/ mergearrays(int *, int, int *, int, int *);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  int A[] = {5, 10, 15, 16, 19};
  int na = 5;
  int B[] = {1, 2, 7, 17, 20, 21, 500};
  int nb = 7;
  int C[na + nb];
  mergearrays(A, na, B, nb, C);
  int i;
  for (i = 0; i < na + nb; i++) {
    printf("%d ", C[i]);
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xedb(%rip),%eax
mov    %eax,-0x10(%rbp)
movaps 0xec1(%rip),%xmm0
movaps %xmm0,-0x20(%rbp)
movl   $0x5,-0x24(%rbp)
movups 0xedb(%rip),%xmm0
movups %xmm0,-0x34(%rbp)
movaps 0xec4(%rip),%xmm0
movaps %xmm0,-0x40(%rbp)
movl   $0x7,-0x44(%rbp)
mov    -0x24(%rbp),%eax
mov    -0x44(%rbp),%ecx
add    %ecx,%eax
mov    %rsp,%rcx
mov    %rcx,-0x50(%rbp)
lea    0xf(,%rax,4),%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%r8
sub    %rcx,%r8
mov    %r8,-0x68(%rbp)
mov    %r8,%rsp
mov    %rax,-0x58(%rbp)
lea    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%esi
lea    -0x40(%rbp),%rdx
mov    -0x44(%rbp),%ecx
call   1040 <mergearrays@plt>
movl   $0x0,-0x5c(%rbp)
mov    -0x5c(%rbp),%eax
mov    -0x24(%rbp),%ecx
add    -0x44(%rbp),%ecx
cmp    %ecx,%eax
jge    11e5 <main+0xc5>
mov    -0x68(%rbp),%rax
movslq -0x5c(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe6c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    11ad <main+0x8d>
lea    0xe54(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x50(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x78,%rsp
mov    %rsp,%r14
mov    0xed0(%rip),%eax
mov    %eax,0x40(%rsp)
movaps 0xeb5(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movups 0xed5(%rip),%xmm0
movups %xmm0,0x5c(%rsp)
movaps 0xebd(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
lea    0x30(%rsp),%rdi
lea    0x50(%rsp),%rdx
mov    %rsp,%r8
mov    $0x5,%esi
mov    $0x7,%ecx
call   1050 <mergearrays@plt>
mov    (%rsp),%esi
lea    0xeae(%rip),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x10(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x14(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x18(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x1c(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x20(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x24(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x28(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2c(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r14,%rsp
xor    %eax,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.A = [5 x i32] [i32 5, i32 10, i32 15, i32 16, i32 19]
@__const.main.B = [7 x i32] [i32 1, i32 2, i32 7, i32 17, i32 20, i32 21, i32 500]
@.str = [4 x i8] c"%d \00"
@.str.1 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [5 x i32]
%3 = alloca i32
%4 = alloca [7 x i32]
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i32
store i32 0, i32* %1
%9 = bitcast [5 x i32]* %2 to i8*
store i32 5, i32* %3
%10 = bitcast [7 x i32]* %4 to i8*
store i32 7, i32* %5
%11 = load i32, i32* %3
%12 = load i32, i32* %5
%13 = add nsw i32 %11, %12
%14 = zext i32 %13 to i64
%15 = call i8* @llvm.stacksave()
store i8* %15, i8** %6
%16 = alloca i32, i64 %14
store i64 %14, i64* %7
%17 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 0
%18 = load i32, i32* %3
%19 = getelementptr inbounds [7 x i32], [7 x i32]* %4, i64 0, i64 0
%20 = load i32, i32* %5
%21 = call i32 @mergearrays(i32* %17, i32 %18, i32* %19, i32 %20, i32* %16)
store i32 0, i32* %8
br label %22
22: ; preds = %34, %0
%23 = load i32, i32* %8
%24 = load i32, i32* %3
%25 = load i32, i32* %5
%26 = add nsw i32 %24, %25
%27 = icmp slt i32 %23, %26
br i1 %27, label %28, label %37
28: ; preds = %22
%29 = load i32, i32* %8
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i32, i32* %16, i64 %30
%32 = load i32, i32* %31
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %32)
br label %34
34: ; preds = %28
%35 = load i32, i32* %8
%36 = add nsw i32 %35, 1
store i32 %36, i32* %8
br label %22
37: ; preds = %22
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%39 = load i8*, i8** %6
%40 = load i32, i32* %1
ret i32 %40
}

LLVM IR (-O2):
@__const.main.A = [5 x i32] [i32 5, i32 10, i32 15, i32 16, i32 19]
@__const.main.B = [7 x i32] [i32 1, i32 2, i32 7, i32 17, i32 20, i32 21, i32 500]
@.str = [4 x i8] c"%d \00"
define i32 @main() {
%1 = alloca [5 x i32]
%2 = alloca [7 x i32]
%3 = bitcast [5 x i32]* %1 to i8*
%4 = bitcast [7 x i32]* %2 to i8*
%5 = tail call i8* @llvm.stacksave()
%6 = alloca [12 x i32]
%7 = getelementptr inbounds [12 x i32], [12 x i32]* %6, i64 0, i64 0
%8 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 0
%9 = getelementptr inbounds [7 x i32], [7 x i32]* %2, i64 0, i64 0
%10 = call i32 @mergearrays(i32* %8, i32 5, i32* %9, i32 7, i32* %7)
%11 = load i32, i32* %7
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = getelementptr inbounds [12 x i32], [12 x i32]* %6, i64 0, i64 1
%14 = load i32, i32* %13
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %14)
%16 = getelementptr inbounds [12 x i32], [12 x i32]* %6, i64 0, i64 2
%17 = load i32, i32* %16
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %17)
%19 = getelementptr inbounds [12 x i32], [12 x i32]* %6, i64 0, i64 3
%20 = load i32, i32* %19
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %20)
%22 = getelementptr inbounds [12 x i32], [12 x i32]* %6, i64 0, i64 4
%23 = load i32, i32* %22
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %23)
%25 = getelementptr inbounds [12 x i32], [12 x i32]* %6, i64 0, i64 5
%26 = load i32, i32* %25
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %26)
%28 = getelementptr inbounds [12 x i32], [12 x i32]* %6, i64 0, i64 6
%29 = load i32, i32* %28
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %29)
%31 = getelementptr inbounds [12 x i32], [12 x i32]* %6, i64 0, i64 7
%32 = load i32, i32* %31
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %32)
%34 = getelementptr inbounds [12 x i32], [12 x i32]* %6, i64 0, i64 8
%35 = load i32, i32* %34
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %35)
%37 = getelementptr inbounds [12 x i32], [12 x i32]* %6, i64 0, i64 9
%38 = load i32, i32* %37
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %38)
%40 = getelementptr inbounds [12 x i32], [12 x i32]* %6, i64 0, i64 10
%41 = load i32, i32* %40
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %41)
%43 = getelementptr inbounds [12 x i32], [12 x i32]* %6, i64 0, i64 11
%44 = load i32, i32* %43
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %44)
%46 = call i32 @putchar(i32 10)
ret i32 0
}