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


x86 assembly (clang, -O0):
<test_split_n_sort_three_elements>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    0xee1(%rip),%rax
mov    %rax,-0x14(%rbp)
mov    0xedf(%rip),%eax
mov    %eax,-0xc(%rbp)
lea    -0x14(%rbp),%rdi
mov    $0x3,%esi
call   1030 <split_n_sort@plt>
cmpl   $0x1,-0x14(%rbp)
je     1154 <test_split_n_sort_three_elements+0x44>
lea    0xec1(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11a9 <test_split_n_sort_three_elements+0x99>
jmp    1159 <test_split_n_sort_three_elements+0x49>
jmp    115e <test_split_n_sort_three_elements+0x4e>
cmpl   $0x2,-0x10(%rbp)
je     1178 <test_split_n_sort_three_elements+0x68>
lea    0xeac(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11a9 <test_split_n_sort_three_elements+0x99>
jmp    117d <test_split_n_sort_three_elements+0x6d>
jmp    1182 <test_split_n_sort_three_elements+0x72>
cmpl   $0x3,-0xc(%rbp)
je     119c <test_split_n_sort_three_elements+0x8c>
lea    0xe97(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11a9 <test_split_n_sort_three_elements+0x99>
jmp    11a1 <test_split_n_sort_three_elements+0x91>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_split_n_sort_three_elements>:
sub    $0x18,%rsp
mov    0xeee(%rip),%eax
mov    %eax,0x10(%rsp)
mov    0xedb(%rip),%rax
mov    %rax,0x8(%rsp)
lea    0x8(%rsp),%rdi
mov    $0x3,%esi
call   1030 <split_n_sort@plt>
cmpl   $0x1,0x8(%rsp)
jne    115e <test_split_n_sort_three_elements+0x4e>
cmpl   $0x2,0xc(%rsp)
jne    116a <test_split_n_sort_three_elements+0x5a>
xor    %eax,%eax
cmpl   $0x3,0x10(%rsp)
lea    0xed5(%rip),%rcx
cmovne %rcx,%rax
add    $0x18,%rsp
ret
lea    0xea7(%rip),%rax
add    $0x18,%rsp
ret
lea    0xeaa(%rip),%rax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@__const.test_split_n_sort_three_elements.a = [3 x i32] [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"
define i8* @test_split_n_sort_three_elements() {
%1 = alloca i8*
%2 = alloca [3 x i32]
%3 = bitcast [3 x i32]* %2 to i8*
%4 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 0
%5 = call i32 @split_n_sort(i32* %4, i32 3)
br label %6
6: ; preds = %0
%7 = getelementptr inbounds [3 x i32], [3 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 %27
11: ; preds = %6
br label %12
12: ; preds = %11
br label %13
13: ; preds = %12
%14 = getelementptr inbounds [3 x i32], [3 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 %27
18: ; preds = %13
br label %19
19: ; preds = %18
br label %20
20: ; preds = %19
%21 = getelementptr inbounds [3 x i32], [3 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 %27
25: ; preds = %20
br label %26
26: ; preds = %25
store i8* null, i8** %1
br label %27
27: ; preds = %26, %24, %17, %10
%28 = load i8*, i8** %1
ret i8* %28
}

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