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


x86 assembly (clang, -O0):
<test_merge_array_with_two_elements>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x4,-0x4(%rbp)
movl   $0x2,-0x8(%rbp)
lea    -0x4(%rbp),%rdi
lea    -0x8(%rbp),%rdx
lea    -0x10(%rbp),%r8
mov    $0x1,%ecx
mov    %ecx,%esi
call   1030 <merge@plt>
cmpl   $0x2,-0x10(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%esi
lea    0xe9f(%rip),%rdi
call   1040 <mu_assert@plt>
cmpl   $0x4,-0xc(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%esi
lea    0xe96(%rip),%rdi
call   1040 <mu_assert@plt>
xor    %eax,%eax
add    $0x10,%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    %esi,%esi
cmpl   $0x2,0x10(%rsp)
sete   %sil
lea    0xe9c(%rip),%rdi
call   1040 <mu_assert@plt>
xor    %esi,%esi
cmpl   $0x4,0x14(%rsp)
sete   %sil
lea    0xe94(%rip),%rdi
call   1040 <mu_assert@plt>
xor    %eax,%eax
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 [1 x i32]
%2 = alloca [1 x i32]
%3 = alloca [2 x i32]
%4 = getelementptr inbounds [1 x i32], [1 x i32]* %1, i64 0, i64 0
store i32 4, i32* %4
%5 = getelementptr inbounds [1 x i32], [1 x i32]* %2, i64 0, i64 0
store i32 2, i32* %5
%6 = getelementptr inbounds [1 x i32], [1 x i32]* %1, i64 0, i64 0
%7 = getelementptr inbounds [1 x i32], [1 x i32]* %2, i64 0, i64 0
%8 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%9 = call i32 @merge(i32* %6, i32 1, i32* %7, i32 1, i32* %8)
%10 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%11 = load i32, i32* %10
%12 = icmp eq i32 %11, 2
%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 [2 x i32], [2 x i32]* %3, i64 0, i64 1
%16 = load i32, i32* %15
%17 = icmp eq i32 %16, 4
%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)
ret i8* null
}

LLVM IR (-O2):
@.str = [15 x i8] c"sorted[0] != 2\00"
@.str.1 = [15 x i8] c"sorted[1] != 4\00"
define noalias 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 = 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 [2 x i32], [2 x i32]* %3, i64 0, i64 1
%16 = load i32, i32* %15
%17 = icmp eq i32 %16, 4
%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)
ret i8* null
}