#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_three_elements() {
  int sorted[3];
  int a1[] = {1, 3};
  int a2[] = {2};
  merge(a1, 2, a2, 1, 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);
  return 0;
}


x86 assembly (clang, -O0):
<test_merge_array_with_three_elements>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    0xee1(%rip),%rax
mov    %rax,-0x1c(%rbp)
mov    0xedf(%rip),%eax
mov    %eax,-0x20(%rbp)
lea    -0x1c(%rbp),%rdi
lea    -0x20(%rbp),%rdx
lea    -0x14(%rbp),%r8
mov    $0x2,%esi
mov    $0x1,%ecx
call   1030 <merge@plt>
cmpl   $0x1,-0x14(%rbp)
je     1161 <test_merge_array_with_three_elements+0x51>
lea    0xeb4(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11b6 <test_merge_array_with_three_elements+0xa6>
jmp    1166 <test_merge_array_with_three_elements+0x56>
jmp    116b <test_merge_array_with_three_elements+0x5b>
cmpl   $0x2,-0x10(%rbp)
je     1185 <test_merge_array_with_three_elements+0x75>
lea    0xe9f(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11b6 <test_merge_array_with_three_elements+0xa6>
jmp    118a <test_merge_array_with_three_elements+0x7a>
jmp    118f <test_merge_array_with_three_elements+0x7f>
cmpl   $0x3,-0xc(%rbp)
je     11a9 <test_merge_array_with_three_elements+0x99>
lea    0xe8a(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11b6 <test_merge_array_with_three_elements+0xa6>
jmp    11ae <test_merge_array_with_three_elements+0x9e>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_merge_array_with_three_elements>:
sub    $0x18,%rsp
movabs $0x300000001,%rax
mov    %rax,0x10(%rsp)
movl   $0x2,(%rsp)
lea    0x10(%rsp),%rdi
mov    %rsp,%rdx
lea    0x4(%rsp),%r8
mov    $0x2,%esi
mov    $0x1,%ecx
call   1030 <merge@plt>
cmpl   $0x1,0x4(%rsp)
jne    116b <test_merge_array_with_three_elements+0x5b>
cmpl   $0x2,0x8(%rsp)
jne    1177 <test_merge_array_with_three_elements+0x67>
xor    %eax,%eax
cmpl   $0x3,0xc(%rsp)
lea    0xebc(%rip),%rcx
cmovne %rcx,%rax
add    $0x18,%rsp
ret
lea    0xe8e(%rip),%rax
add    $0x18,%rsp
ret
lea    0xe91(%rip),%rax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@__const.test_merge_array_with_three_elements.a1 = [2 x i32] [i32 1, i32 3]
@__const.test_merge_array_with_three_elements.a2 = [1 x i32] [i32 2]
@.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"
define i8* @test_merge_array_with_three_elements() {
%1 = alloca i8*
%2 = alloca [3 x i32]
%3 = alloca [2 x i32]
%4 = alloca [1 x i32]
%5 = bitcast [2 x i32]* %3 to i8*
%6 = bitcast [1 x i32]* %4 to i8*
%7 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%8 = getelementptr inbounds [1 x i32], [1 x i32]* %4, i64 0, i64 0
%9 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 0
%10 = call i32 @merge(i32* %7, i32 2, i32* %8, i32 1, i32* %9)
br label %11
11: ; preds = %0
%12 = getelementptr inbounds [3 x i32], [3 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 %32
16: ; preds = %11
br label %17
17: ; preds = %16
br label %18
18: ; preds = %17
%19 = getelementptr inbounds [3 x i32], [3 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 %32
23: ; preds = %18
br label %24
24: ; preds = %23
br label %25
25: ; preds = %24
%26 = getelementptr inbounds [3 x i32], [3 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 %32
30: ; preds = %25
br label %31
31: ; preds = %30
store i8* null, i8** %1
br label %32
32: ; preds = %31, %29, %22, %15
%33 = load i8*, i8** %1
ret i8* %33
}

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"
define i8* @test_merge_array_with_three_elements() {
%1 = alloca [3 x i32]
%2 = alloca i64
%3 = alloca [1 x i32]
%4 = bitcast [3 x i32]* %1 to i8*
%5 = bitcast i64* %2 to i8*
store i64 12884901889, i64* %2
%6 = bitcast [1 x i32]* %3 to i8*
%7 = getelementptr inbounds [1 x i32], [1 x i32]* %3, i64 0, i64 0
store i32 2, i32* %7
%8 = bitcast i64* %2 to i32*
%9 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 0
%10 = call i32 @merge(i32* %8, i32 2, i32* %7, i32 1, i32* %9)
%11 = load i32, i32* %9
%12 = icmp eq i32 %11, 1
br i1 %12, label %13, label %22
13: ; preds = %0
%14 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 1
%15 = load i32, i32* %14
%16 = icmp eq i32 %15, 2
br i1 %16, label %17, label %22
17: ; preds = %13
%18 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 2
%19 = load i32, i32* %18
%20 = icmp eq i32 %19, 3
%21 = select i1 %20, i8* null, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0)
br label %22
22: ; preds = %17, %13, %0
%23 = 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 ], [ %21, %17 ]
ret i8* %23
}