#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*/ array_equal(double *, double *, int);
int /*<<< orphan*/ assert(int /*<<< orphan*/);
int /*<<< orphan*/ merge(double *, double *, double *, int, int);
void test2(void) {
  double a[] = {8.0};
  double b[] = {4.0, 15.0, 16.0, 23.0, 42.0};
  double out[6];
  double expected[6] = {4, 8, 15, 16, 23, 42};
  merge(a, b, out, 1, 5);
  assert(array_equal(out, expected, 6));
  merge(b, a, out, 5, 1);
  assert(array_equal(out, expected, 6));
}


x86 assembly (clang, -O0):
<test2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    0xece(%rip),%rax
mov    %rax,-0x8(%rbp)
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1030 <memset@plt>
movsd  0xeba(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xe9d(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xe88(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe73(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xe5e(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
lea    -0x90(%rbp),%rdi
xor    %esi,%esi
mov    $0x30,%edx
call   1030 <memset@plt>
movsd  0xe66(%rip),%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
movsd  0xe4e(%rip),%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  0xe36(%rip),%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  0xe21(%rip),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  0xe0c(%rip),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  0xdf7(%rip),%xmm0
movsd  %xmm0,-0x68(%rbp)
lea    -0x8(%rbp),%rdi
lea    -0x30(%rbp),%rsi
lea    -0x60(%rbp),%rdx
mov    $0x1,%ecx
mov    $0x5,%r8d
call   1060 <merge@plt>
lea    -0x60(%rbp),%rdi
lea    -0x90(%rbp),%rsi
mov    $0x6,%edx
call   1050 <array_equal@plt>
mov    %eax,%edi
call   1040 <assert@plt>
lea    -0x30(%rbp),%rdi
lea    -0x8(%rbp),%rsi
lea    -0x60(%rbp),%rdx
mov    $0x5,%ecx
mov    $0x1,%r8d
call   1060 <merge@plt>
lea    -0x60(%rbp),%rdi
lea    -0x90(%rbp),%rsi
mov    $0x6,%edx
call   1050 <array_equal@plt>
mov    %eax,%edi
call   1040 <assert@plt>
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test2>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0xa8,%rsp
movabs $0x4020000000000000,%rax
mov    %rax,0x8(%rsp)
movaps 0xeac(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xeb0(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movabs $0x4045000000000000,%rax
mov    %rax,0x30(%rsp)
movaps 0xea5(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xea9(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0xead(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
lea    0x8(%rsp),%r14
lea    0x10(%rsp),%r15
lea    0x70(%rsp),%rbx
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
mov    $0x1,%ecx
mov    $0x5,%r8d
call   1050 <merge@plt>
lea    0x40(%rsp),%r12
mov    %rbx,%rdi
mov    %r12,%rsi
mov    $0x6,%edx
call   1040 <array_equal@plt>
mov    %eax,%edi
call   1030 <assert@plt>
mov    %r15,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
mov    $0x5,%ecx
mov    $0x1,%r8d
call   1050 <merge@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    $0x6,%edx
call   1040 <array_equal@plt>
mov    %eax,%edi
call   1030 <assert@plt>
add    $0xa8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.test2.a = [1 x double] [double 8.000000e+00]
define void @test2() {
%1 = alloca [1 x double]
%2 = alloca [5 x double]
%3 = alloca [6 x double]
%4 = alloca [6 x double]
%5 = bitcast [1 x double]* %1 to i8*
%6 = bitcast [5 x double]* %2 to i8*
%7 = bitcast i8* %6 to [5 x double]*
%8 = getelementptr inbounds [5 x double], [5 x double]* %7, i32 0, i32 0
store double 4.000000e+00, double* %8
%9 = getelementptr inbounds [5 x double], [5 x double]* %7, i32 0, i32 1
store double 1.500000e+01, double* %9
%10 = getelementptr inbounds [5 x double], [5 x double]* %7, i32 0, i32 2
store double 1.600000e+01, double* %10
%11 = getelementptr inbounds [5 x double], [5 x double]* %7, i32 0, i32 3
store double 2.300000e+01, double* %11
%12 = getelementptr inbounds [5 x double], [5 x double]* %7, i32 0, i32 4
store double 4.200000e+01, double* %12
%13 = bitcast [6 x double]* %4 to i8*
%14 = bitcast i8* %13 to [6 x double]*
%15 = getelementptr inbounds [6 x double], [6 x double]* %14, i32 0, i32 0
store double 4.000000e+00, double* %15
%16 = getelementptr inbounds [6 x double], [6 x double]* %14, i32 0, i32 1
store double 8.000000e+00, double* %16
%17 = getelementptr inbounds [6 x double], [6 x double]* %14, i32 0, i32 2
store double 1.500000e+01, double* %17
%18 = getelementptr inbounds [6 x double], [6 x double]* %14, i32 0, i32 3
store double 1.600000e+01, double* %18
%19 = getelementptr inbounds [6 x double], [6 x double]* %14, i32 0, i32 4
store double 2.300000e+01, double* %19
%20 = getelementptr inbounds [6 x double], [6 x double]* %14, i32 0, i32 5
store double 4.200000e+01, double* %20
%21 = getelementptr inbounds [1 x double], [1 x double]* %1, i64 0, i64 0
%22 = getelementptr inbounds [5 x double], [5 x double]* %2, i64 0, i64 0
%23 = getelementptr inbounds [6 x double], [6 x double]* %3, i64 0, i64 0
%24 = call i32 @merge(double* %21, double* %22, double* %23, i32 1, i32 5)
%25 = getelementptr inbounds [6 x double], [6 x double]* %3, i64 0, i64 0
%26 = getelementptr inbounds [6 x double], [6 x double]* %4, i64 0, i64 0
%27 = call i32 @array_equal(double* %25, double* %26, i32 6)
%28 = call i32 @assert(i32 %27)
%29 = getelementptr inbounds [5 x double], [5 x double]* %2, i64 0, i64 0
%30 = getelementptr inbounds [1 x double], [1 x double]* %1, i64 0, i64 0
%31 = getelementptr inbounds [6 x double], [6 x double]* %3, i64 0, i64 0
%32 = call i32 @merge(double* %29, double* %30, double* %31, i32 5, i32 1)
%33 = getelementptr inbounds [6 x double], [6 x double]* %3, i64 0, i64 0
%34 = getelementptr inbounds [6 x double], [6 x double]* %4, i64 0, i64 0
%35 = call i32 @array_equal(double* %33, double* %34, i32 6)
%36 = call i32 @assert(i32 %35)
ret void
}

LLVM IR (-O2):
define void @test2() {
%1 = alloca [1 x double]
%2 = alloca [5 x double]
%3 = alloca [6 x double]
%4 = alloca [6 x double]
%5 = bitcast [1 x double]* %1 to i8*
%6 = bitcast [1 x double]* %1 to i64*
store i64 4620693217682128896, i64* %6
%7 = bitcast [5 x double]* %2 to i8*
%8 = getelementptr inbounds [5 x double], [5 x double]* %2, i64 0, i64 0
%9 = bitcast [5 x double]* %2 to <2 x double>*
store <2 x double> <double 4.000000e+00, double 1.500000e+01>, <2 x double>* %9
%10 = getelementptr inbounds [5 x double], [5 x double]* %2, i64 0, i64 2
%11 = bitcast double* %10 to <2 x double>*
store <2 x double> <double 1.600000e+01, double 2.300000e+01>, <2 x double>* %11
%12 = getelementptr inbounds [5 x double], [5 x double]* %2, i64 0, i64 4
store double 4.200000e+01, double* %12
%13 = bitcast [6 x double]* %3 to i8*
%14 = bitcast [6 x double]* %4 to i8*
%15 = getelementptr inbounds [6 x double], [6 x double]* %4, i64 0, i64 0
%16 = bitcast [6 x double]* %4 to <2 x double>*
store <2 x double> <double 4.000000e+00, double 8.000000e+00>, <2 x double>* %16
%17 = getelementptr inbounds [6 x double], [6 x double]* %4, i64 0, i64 2
%18 = bitcast double* %17 to <2 x double>*
store <2 x double> <double 1.500000e+01, double 1.600000e+01>, <2 x double>* %18
%19 = getelementptr inbounds [6 x double], [6 x double]* %4, i64 0, i64 4
%20 = bitcast double* %19 to <2 x double>*
store <2 x double> <double 2.300000e+01, double 4.200000e+01>, <2 x double>* %20
%21 = getelementptr inbounds [1 x double], [1 x double]* %1, i64 0, i64 0
%22 = getelementptr inbounds [6 x double], [6 x double]* %3, i64 0, i64 0
%23 = call i32 @merge(double* %21, double* %8, double* %22, i32 1, i32 5)
%24 = call i32 @array_equal(double* %22, double* %15, i32 6)
%25 = call i32 @assert(i32 %24)
%26 = call i32 @merge(double* %8, double* %21, double* %22, i32 5, i32 1)
%27 = call i32 @array_equal(double* %22, double* %15, i32 6)
%28 = call i32 @assert(i32 %27)
ret void
}