#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*/ merge(int *, int, int *, int, int *);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  int a[3] = {1, 4, 6}, b[4] = {2, 3, 5, 7}, c[7], i;
  merge(a, 3, b, 4, c);
  for (i = 0; i < 7; i++)
    printf("%d ", c[i]);
  printf("\nMerge complete.\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeca(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0xec8(%rip),%eax
mov    %eax,-0x8(%rbp)
mov    0xec6(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xec3(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rdx
lea    -0x40(%rbp),%r8
mov    $0x3,%esi
mov    $0x4,%ecx
call   1040 <merge@plt>
movl   $0x0,-0x44(%rbp)
cmpl   $0x7,-0x44(%rbp)
jge    11a9 <main+0x89>
movslq -0x44(%rbp),%rax
mov    -0x40(%rbp,%rax,4),%esi
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    117b <main+0x5b>
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x40,%rsp
mov    0xecd(%rip),%eax
mov    %eax,0x28(%rsp)
mov    0xeba(%rip),%rax
mov    %rax,0x20(%rsp)
movaps 0xebe(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
lea    0x20(%rsp),%rdi
lea    0x30(%rsp),%rdx
mov    %rsp,%r8
mov    $0x3,%esi
mov    $0x4,%ecx
call   1050 <merge@plt>
mov    (%rsp),%esi
lea    0xea3(%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>
lea    0xe42(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
@__const.main.a = [3 x i32] [i32 1, i32 4, i32 6]
@__const.main.b = [4 x i32] [i32 2, i32 3, i32 5, i32 7]
@.str = [4 x i8] c"%d \00"
@str = [17 x i8] c"\0AMerge complete.\00"
define i32 @main() {
%1 = alloca [3 x i32]
%2 = alloca [4 x i32]
%3 = alloca [7 x i32]
%4 = bitcast [3 x i32]* %1 to i8*
%5 = bitcast [4 x i32]* %2 to i8*
%6 = bitcast [7 x i32]* %3 to i8*
%7 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 0
%8 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 0
%9 = getelementptr inbounds [7 x i32], [7 x i32]* %3, i64 0, i64 0
%10 = call i32 @merge(i32* %7, i32 3, i32* %8, i32 4, i32* %9)
%11 = load i32, i32* %9
%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 [7 x i32], [7 x i32]* %3, 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 [7 x i32], [7 x i32]* %3, 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 [7 x i32], [7 x i32]* %3, 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 [7 x i32], [7 x i32]* %3, 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 [7 x i32], [7 x i32]* %3, 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 [7 x i32], [7 x i32]* %3, 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 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
ret i32 0
}