#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*/ free(int /*<<< orphan*/);
int /*<<< orphan*/ merge(int *, int, int *, int);
int /*<<< orphan*/ print_array(int /*<<< orphan*/, int);
int test_merge(int argc, char *argv[]) {
  int alen = 5;
  int tlen = alen + alen;
  int arr[5] = {1, 2, 3, 1000, 30000};
  int arr2[5] = {10, 11, 30, 1000, 1001};
  free(print_array(merge(arr, alen, arr2, alen), tlen));
}


x86 assembly (clang, -O0):
<test_merge>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x5,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    0xeaa(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xea7(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xea5(%rip),%eax
mov    %eax,-0x20(%rbp)
mov    0xeab(%rip),%rax
mov    %rax,-0x50(%rbp)
mov    0xea8(%rip),%rax
mov    %rax,-0x48(%rbp)
mov    0xea6(%rip),%eax
mov    %eax,-0x40(%rbp)
lea    -0x30(%rbp),%rdi
mov    -0x14(%rbp),%esi
lea    -0x50(%rbp),%rdx
mov    -0x14(%rbp),%ecx
call   1050 <merge@plt>
mov    %eax,%edi
mov    -0x18(%rbp),%esi
call   1040 <print_array@plt>
mov    %eax,%edi
call   1030 <free@plt>
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_merge>:
sub    $0x38,%rsp
mov    0xed6(%rip),%eax
mov    %eax,0x30(%rsp)
movaps 0xebb(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
mov    0xee0(%rip),%eax
mov    %eax,0x10(%rsp)
movaps 0xec5(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0x20(%rsp),%rdi
mov    %rsp,%rdx
mov    $0x5,%esi
mov    $0x5,%ecx
call   1050 <merge@plt>
mov    %eax,%edi
mov    $0xa,%esi
call   1040 <print_array@plt>
mov    %eax,%edi
call   1030 <free@plt>
add    $0x38,%rsp
ret

LLVM IR (-O0):
@__const.test_merge.arr = [5 x i32] [i32 1, i32 2, i32 3, i32 1000, i32 30000]
@__const.test_merge.arr2 = [5 x i32] [i32 10, i32 11, i32 30, i32 1000, i32 1001]
define i32 @test_merge(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca [5 x i32]
%9 = alloca [5 x i32]
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 5, i32* %6
%10 = load i32, i32* %6
%11 = load i32, i32* %6
%12 = add nsw i32 %10, %11
store i32 %12, i32* %7
%13 = bitcast [5 x i32]* %8 to i8*
%14 = bitcast [5 x i32]* %9 to i8*
%15 = getelementptr inbounds [5 x i32], [5 x i32]* %8, i64 0, i64 0
%16 = load i32, i32* %6
%17 = getelementptr inbounds [5 x i32], [5 x i32]* %9, i64 0, i64 0
%18 = load i32, i32* %6
%19 = call i32 @merge(i32* %15, i32 %16, i32* %17, i32 %18)
%20 = load i32, i32* %7
%21 = call i32 @print_array(i32 %19, i32 %20)
%22 = call i32 @free(i32 %21)
%23 = load i32, i32* %3
ret i32 %23
}

LLVM IR (-O2):
@__const.test_merge.arr = [5 x i32] [i32 1, i32 2, i32 3, i32 1000, i32 30000]
@__const.test_merge.arr2 = [5 x i32] [i32 10, i32 11, i32 30, i32 1000, i32 1001]
define i32 @test_merge(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 = getelementptr inbounds [5 x i32], [5 x i32]* %4, i64 0, i64 0
%9 = call i32 @merge(i32* %7, i32 5, i32* %8, i32 5)
%10 = call i32 @print_array(i32 %9, i32 10)
%11 = call i32 @free(i32 %10)
ret i32 undef
}