#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*/ mu_assert(char *, int);
char *test_merge_array_with_four_elements() {
  int sorted[4];
  int a1[] = {1, 3};
  int a2[] = {2, 4};
  merge(a1, 2, a2, 2, sorted);
  mu_assert("sorted[0] != 1", sorted[0] == 1);
  mu_assert("sorted[1] != 2", sorted[1] == 2);
  mu_assert("sorted[2] != 3", sorted[2] == 3);
  mu_assert("sorted[3] != 4", sorted[3] == 4);
  return 0;
}


x86 assembly (clang, -O0):
<test_merge_array_with_four_elements>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    0xed1(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xece(%rip),%rax
mov    %rax,-0x20(%rbp)
lea    -0x18(%rbp),%rdi
lea    -0x20(%rbp),%rdx
lea    -0x10(%rbp),%r8
mov    $0x2,%ecx
mov    %ecx,%esi
call   1030 <merge@plt>
cmpl   $0x1,-0x10(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%esi
lea    0xea7(%rip),%rdi
call   1040 <mu_assert@plt>
cmpl   $0x2,-0xc(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%esi
lea    0xe9e(%rip),%rdi
call   1040 <mu_assert@plt>
cmpl   $0x3,-0x8(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%esi
lea    0xe95(%rip),%rdi
call   1040 <mu_assert@plt>
cmpl   $0x4,-0x4(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%esi
lea    0xe8c(%rip),%rdi
call   1040 <mu_assert@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_merge_array_with_four_elements>:
sub    $0x28,%rsp
movabs $0x300000001,%rax
mov    %rax,0x20(%rsp)
movabs $0x400000002,%rax
mov    %rax,0x18(%rsp)
lea    0x20(%rsp),%rdi
lea    0x18(%rsp),%rdx
mov    %rsp,%r8
mov    $0x2,%esi
mov    $0x2,%ecx
call   1030 <merge@plt>
xor    %esi,%esi
cmpl   $0x1,(%rsp)
sete   %sil
lea    0xe91(%rip),%rdi
call   1040 <mu_assert@plt>
xor    %esi,%esi
cmpl   $0x2,0x4(%rsp)
sete   %sil
lea    0xe89(%rip),%rdi
call   1040 <mu_assert@plt>
xor    %esi,%esi
cmpl   $0x3,0x8(%rsp)
sete   %sil
lea    0xe81(%rip),%rdi
call   1040 <mu_assert@plt>
xor    %esi,%esi
cmpl   $0x4,0xc(%rsp)
sete   %sil
lea    0xe79(%rip),%rdi
call   1040 <mu_assert@plt>
xor    %eax,%eax
add    $0x28,%rsp
ret

LLVM IR (-O0):
@__const.test_merge_array_with_four_elements.a1 = [2 x i32] [i32 1, i32 3]
@__const.test_merge_array_with_four_elements.a2 = [2 x i32] [i32 2, i32 4]
@.str = [15 x i8] c"sorted[0] != 1\00"
@.str.1 = [15 x i8] c"sorted[1] != 2\00"
@.str.2 = [15 x i8] c"sorted[2] != 3\00"
@.str.3 = [15 x i8] c"sorted[3] != 4\00"
define i8* @test_merge_array_with_four_elements() {
%1 = alloca [4 x i32]
%2 = alloca [2 x i32]
%3 = alloca [2 x i32]
%4 = bitcast [2 x i32]* %2 to i8*
%5 = bitcast [2 x i32]* %3 to i8*
%6 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0
%7 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%8 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 0
%9 = call i32 @merge(i32* %6, i32 2, i32* %7, i32 2, i32* %8)
%10 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 0
%11 = load i32, i32* %10
%12 = icmp eq i32 %11, 1
%13 = zext i1 %12 to i32
%14 = call i32 @mu_assert(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %13)
%15 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 1
%16 = load i32, i32* %15
%17 = icmp eq i32 %16, 2
%18 = zext i1 %17 to i32
%19 = call i32 @mu_assert(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %18)
%20 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 2
%21 = load i32, i32* %20
%22 = icmp eq i32 %21, 3
%23 = zext i1 %22 to i32
%24 = call i32 @mu_assert(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i32 %23)
%25 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 3
%26 = load i32, i32* %25
%27 = icmp eq i32 %26, 4
%28 = zext i1 %27 to i32
%29 = call i32 @mu_assert(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 %28)
ret i8* null
}

LLVM IR (-O2):
@.str = [15 x i8] c"sorted[0] != 1\00"
@.str.1 = [15 x i8] c"sorted[1] != 2\00"
@.str.2 = [15 x i8] c"sorted[2] != 3\00"
@.str.3 = [15 x i8] c"sorted[3] != 4\00"
define noalias i8* @test_merge_array_with_four_elements() {
%1 = alloca [4 x i32]
%2 = alloca i64
%3 = alloca i64
%4 = bitcast [4 x i32]* %1 to i8*
%5 = bitcast i64* %2 to i8*
store i64 12884901889, i64* %2
%6 = bitcast i64* %3 to i8*
store i64 17179869186, i64* %3
%7 = bitcast i64* %2 to i32*
%8 = bitcast i64* %3 to i32*
%9 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 0
%10 = call i32 @merge(i32* %7, i32 2, i32* %8, i32 2, i32* %9)
%11 = load i32, i32* %9
%12 = icmp eq i32 %11, 1
%13 = zext i1 %12 to i32
%14 = call i32 @mu_assert(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %13)
%15 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 1
%16 = load i32, i32* %15
%17 = icmp eq i32 %16, 2
%18 = zext i1 %17 to i32
%19 = call i32 @mu_assert(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %18)
%20 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 2
%21 = load i32, i32* %20
%22 = icmp eq i32 %21, 3
%23 = zext i1 %22 to i32
%24 = call i32 @mu_assert(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i32 %23)
%25 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 3
%26 = load i32, i32* %25
%27 = icmp eq i32 %26, 4
%28 = zext i1 %27 to i32
%29 = call i32 @mu_assert(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 %28)
ret i8* null
}