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


x86 assembly (clang, -O0):
<test_split_n_sort_four_elements>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    0xee1(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xede(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    -0x20(%rbp),%rdi
mov    $0x4,%esi
call   1030 <split_n_sort@plt>
cmpl   $0x1,-0x20(%rbp)
je     1156 <test_split_n_sort_four_elements+0x46>
lea    0xec3(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11cf <test_split_n_sort_four_elements+0xbf>
jmp    115b <test_split_n_sort_four_elements+0x4b>
jmp    1160 <test_split_n_sort_four_elements+0x50>
cmpl   $0x2,-0x1c(%rbp)
je     117a <test_split_n_sort_four_elements+0x6a>
lea    0xeae(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11cf <test_split_n_sort_four_elements+0xbf>
jmp    117f <test_split_n_sort_four_elements+0x6f>
jmp    1184 <test_split_n_sort_four_elements+0x74>
cmpl   $0x3,-0x18(%rbp)
je     119e <test_split_n_sort_four_elements+0x8e>
lea    0xe99(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11cf <test_split_n_sort_four_elements+0xbf>
jmp    11a3 <test_split_n_sort_four_elements+0x93>
jmp    11a8 <test_split_n_sort_four_elements+0x98>
cmpl   $0x4,-0x14(%rbp)
je     11c2 <test_split_n_sort_four_elements+0xb2>
lea    0xe84(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11cf <test_split_n_sort_four_elements+0xbf>
jmp    11c7 <test_split_n_sort_four_elements+0xb7>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_split_n_sort_four_elements>:
sub    $0x18,%rsp
movaps 0xee5(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rdi
mov    $0x4,%esi
call   1030 <split_n_sort@plt>
cmpl   $0x1,(%rsp)
jne    1157 <test_split_n_sort_four_elements+0x47>
cmpl   $0x2,0x4(%rsp)
jne    1163 <test_split_n_sort_four_elements+0x53>
cmpl   $0x3,0x8(%rsp)
jne    116f <test_split_n_sort_four_elements+0x5f>
xor    %eax,%eax
cmpl   $0x4,0xc(%rsp)
lea    0xeef(%rip),%rcx
cmovne %rcx,%rax
add    $0x18,%rsp
ret
lea    0xeb2(%rip),%rax
add    $0x18,%rsp
ret
lea    0xeb5(%rip),%rax
add    $0x18,%rsp
ret
lea    0xeb8(%rip),%rax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@__const.test_split_n_sort_four_elements.a = [4 x i32] [i32 4, i32 3, i32 2, i32 1]
@.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_split_n_sort_four_elements() {
%1 = alloca i8*
%2 = alloca [4 x i32]
%3 = bitcast [4 x i32]* %2 to i8*
%4 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 0
%5 = call i32 @split_n_sort(i32* %4, i32 4)
br label %6
6: ; preds = %0
%7 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 0
%8 = load i32, i32* %7
%9 = icmp eq i32 %8, 1
br i1 %9, label %11, label %10
10: ; preds = %6
store i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8** %1
br label %34
11: ; preds = %6
br label %12
12: ; preds = %11
br label %13
13: ; preds = %12
%14 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 1
%15 = load i32, i32* %14
%16 = icmp eq i32 %15, 2
br i1 %16, label %18, label %17
17: ; preds = %13
store i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8** %1
br label %34
18: ; preds = %13
br label %19
19: ; preds = %18
br label %20
20: ; preds = %19
%21 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 2
%22 = load i32, i32* %21
%23 = icmp eq i32 %22, 3
br i1 %23, label %25, label %24
24: ; preds = %20
store i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8** %1
br label %34
25: ; preds = %20
br label %26
26: ; preds = %25
br label %27
27: ; preds = %26
%28 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 3
%29 = load i32, i32* %28
%30 = icmp eq i32 %29, 4
br i1 %30, label %32, label %31
31: ; preds = %27
store i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i8** %1
br label %34
32: ; preds = %27
br label %33
33: ; preds = %32
store i8* null, i8** %1
br label %34
34: ; preds = %33, %31, %24, %17, %10
%35 = load i8*, i8** %1
ret i8* %35
}

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