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


x86 assembly (clang, -O0):
<test_merge_array_with_four_elements>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0xee1(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xede(%rip),%rax
mov    %rax,-0x30(%rbp)
lea    -0x28(%rbp),%rdi
lea    -0x30(%rbp),%rdx
lea    -0x20(%rbp),%r8
mov    $0x2,%ecx
mov    %ecx,%esi
call   1030 <merge@plt>
cmpl   $0x1,-0x20(%rbp)
je     1160 <test_merge_array_with_four_elements+0x50>
lea    0xeb9(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11d9 <test_merge_array_with_four_elements+0xc9>
jmp    1165 <test_merge_array_with_four_elements+0x55>
jmp    116a <test_merge_array_with_four_elements+0x5a>
cmpl   $0x2,-0x1c(%rbp)
je     1184 <test_merge_array_with_four_elements+0x74>
lea    0xea4(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11d9 <test_merge_array_with_four_elements+0xc9>
jmp    1189 <test_merge_array_with_four_elements+0x79>
jmp    118e <test_merge_array_with_four_elements+0x7e>
cmpl   $0x3,-0x18(%rbp)
je     11a8 <test_merge_array_with_four_elements+0x98>
lea    0xe8f(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11d9 <test_merge_array_with_four_elements+0xc9>
jmp    11ad <test_merge_array_with_four_elements+0x9d>
jmp    11b2 <test_merge_array_with_four_elements+0xa2>
cmpl   $0x4,-0x14(%rbp)
je     11cc <test_merge_array_with_four_elements+0xbc>
lea    0xe7a(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11d9 <test_merge_array_with_four_elements+0xc9>
jmp    11d1 <test_merge_array_with_four_elements+0xc1>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%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>
cmpl   $0x1,(%rsp)
jne    1179 <test_merge_array_with_four_elements+0x69>
cmpl   $0x2,0x4(%rsp)
jne    1185 <test_merge_array_with_four_elements+0x75>
cmpl   $0x3,0x8(%rsp)
jne    1191 <test_merge_array_with_four_elements+0x81>
xor    %eax,%eax
cmpl   $0x4,0xc(%rsp)
lea    0xebd(%rip),%rcx
cmovne %rcx,%rax
add    $0x28,%rsp
ret
lea    0xe80(%rip),%rax
add    $0x28,%rsp
ret
lea    0xe83(%rip),%rax
add    $0x28,%rsp
ret
lea    0xe86(%rip),%rax
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 i8*
%2 = alloca [4 x i32]
%3 = alloca [2 x i32]
%4 = alloca [2 x i32]
%5 = bitcast [2 x i32]* %3 to i8*
%6 = bitcast [2 x i32]* %4 to i8*
%7 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%8 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 0
%9 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 0
%10 = call i32 @merge(i32* %7, i32 2, i32* %8, i32 2, i32* %9)
br label %11
11: ; preds = %0
%12 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 0
%13 = load i32, i32* %12
%14 = icmp eq i32 %13, 1
br i1 %14, label %16, label %15
15: ; preds = %11
store i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8** %1
br label %39
16: ; preds = %11
br label %17
17: ; preds = %16
br label %18
18: ; preds = %17
%19 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 1
%20 = load i32, i32* %19
%21 = icmp eq i32 %20, 2
br i1 %21, label %23, label %22
22: ; preds = %18
store i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8** %1
br label %39
23: ; preds = %18
br label %24
24: ; preds = %23
br label %25
25: ; preds = %24
%26 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 2
%27 = load i32, i32* %26
%28 = icmp eq i32 %27, 3
br i1 %28, label %30, label %29
29: ; preds = %25
store i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8** %1
br label %39
30: ; preds = %25
br label %31
31: ; preds = %30
br label %32
32: ; preds = %31
%33 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 3
%34 = load i32, i32* %33
%35 = icmp eq i32 %34, 4
br i1 %35, label %37, label %36
36: ; preds = %32
store i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i8** %1
br label %39
37: ; preds = %32
br label %38
38: ; preds = %37
store i8* null, i8** %1
br label %39
39: ; preds = %38, %36, %29, %22, %15
%40 = load i8*, i8** %1
ret i8* %40
}

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 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
br i1 %12, label %13, label %26
13: ; preds = %0
%14 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 1
%15 = load i32, i32* %14
%16 = icmp eq i32 %15, 2
br i1 %16, label %17, label %26
17: ; preds = %13
%18 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 2
%19 = load i32, i32* %18
%20 = icmp eq i32 %19, 3
br i1 %20, label %21, label %26
21: ; preds = %17
%22 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 3
%23 = load i32, i32* %22
%24 = icmp eq i32 %23, 4
%25 = select i1 %24, i8* null, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0)
br label %26
26: ; preds = %21, %17, %13, %0
%27 = phi i8* [ getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), %0 ], [ getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), %13 ], [ getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), %17 ], [ %25, %21 ]
ret i8* %27
}