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


x86 assembly (clang, -O0):
<test_merge_array_with_two_elements>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x4,-0xc(%rbp)
movl   $0x2,-0x10(%rbp)
lea    -0xc(%rbp),%rdi
lea    -0x10(%rbp),%rdx
lea    -0x18(%rbp),%r8
mov    $0x1,%ecx
mov    %ecx,%esi
call   1030 <merge@plt>
cmpl   $0x2,-0x18(%rbp)
je     1158 <test_merge_array_with_two_elements+0x48>
lea    0xeb1(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1189 <test_merge_array_with_two_elements+0x79>
jmp    115d <test_merge_array_with_two_elements+0x4d>
jmp    1162 <test_merge_array_with_two_elements+0x52>
cmpl   $0x4,-0x14(%rbp)
je     117c <test_merge_array_with_two_elements+0x6c>
lea    0xe9c(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1189 <test_merge_array_with_two_elements+0x79>
jmp    1181 <test_merge_array_with_two_elements+0x71>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_merge_array_with_two_elements>:
sub    $0x18,%rsp
movl   $0x4,0xc(%rsp)
movl   $0x2,0x8(%rsp)
lea    0xc(%rsp),%rdi
lea    0x8(%rsp),%rdx
lea    0x10(%rsp),%r8
mov    $0x1,%esi
mov    $0x1,%ecx
call   1030 <merge@plt>
xor    %ecx,%ecx
cmpl   $0x4,0x14(%rsp)
lea    0xebf(%rip),%rax
cmovne %rax,%rcx
cmpl   $0x2,0x10(%rsp)
lea    0xea0(%rip),%rax
cmove  %rcx,%rax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [15 x i8] c"sorted[0] != 2\00"
@.str.1 = [15 x i8] c"sorted[1] != 4\00"
define i8* @test_merge_array_with_two_elements() {
%1 = alloca i8*
%2 = alloca [1 x i32]
%3 = alloca [1 x i32]
%4 = alloca [2 x i32]
%5 = getelementptr inbounds [1 x i32], [1 x i32]* %2, i64 0, i64 0
store i32 4, i32* %5
%6 = getelementptr inbounds [1 x i32], [1 x i32]* %3, i64 0, i64 0
store i32 2, i32* %6
%7 = getelementptr inbounds [1 x i32], [1 x i32]* %2, i64 0, i64 0
%8 = getelementptr inbounds [1 x i32], [1 x i32]* %3, i64 0, i64 0
%9 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 0
%10 = call i32 @merge(i32* %7, i32 1, i32* %8, i32 1, i32* %9)
br label %11
11: ; preds = %0
%12 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 0
%13 = load i32, i32* %12
%14 = icmp eq i32 %13, 2
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 %25
16: ; preds = %11
br label %17
17: ; preds = %16
br label %18
18: ; preds = %17
%19 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 1
%20 = load i32, i32* %19
%21 = icmp eq i32 %20, 4
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 %25
23: ; preds = %18
br label %24
24: ; preds = %23
store i8* null, i8** %1
br label %25
25: ; preds = %24, %22, %15
%26 = load i8*, i8** %1
ret i8* %26
}

LLVM IR (-O2):
@.str = [15 x i8] c"sorted[0] != 2\00"
@.str.1 = [15 x i8] c"sorted[1] != 4\00"
define i8* @test_merge_array_with_two_elements() {
%1 = alloca [1 x i32]
%2 = alloca [1 x i32]
%3 = alloca [2 x i32]
%4 = bitcast [1 x i32]* %1 to i8*
%5 = bitcast [1 x i32]* %2 to i8*
%6 = bitcast [2 x i32]* %3 to i8*
%7 = getelementptr inbounds [1 x i32], [1 x i32]* %1, i64 0, i64 0
store i32 4, i32* %7
%8 = getelementptr inbounds [1 x i32], [1 x i32]* %2, i64 0, i64 0
store i32 2, i32* %8
%9 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%10 = call i32 @merge(i32* %7, i32 1, i32* %8, i32 1, i32* %9)
%11 = load i32, i32* %9
%12 = icmp eq i32 %11, 2
%13 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%14 = load i32, i32* %13
%15 = icmp eq i32 %14, 4
%16 = select i1 %15, i8* null, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0)
%17 = select i1 %12, i8* %16, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0)
ret i8* %17
}