#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*/ printf(char *, int);
int selection_sort(int *, int);
char *test_null() {
  int *array = NULL;
  do {
    if (!(selection_sort(array, 0) == -1)) {
      printf("Line number is: %d\n", 29);
      return "error, sorted NULL array";
    }
  } while (0);
  do {
    if (!(selection_sort(array, 3) == -1)) {
      printf("Line number is: %d\n", 30);
      return "error, sorted NULL array";
    }
  } while (0);
  do {
    if (!(selection_sort(array, -2) == -1)) {
      printf("Line number is: %d\n", 31);
      return "error, sorted NULL array";
    }
  } while (0);
  return 0;
}


x86 assembly (clang, -O0):
<test_null>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movq   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
call   1030 <selection_sort@plt>
cmp    $0xffffffff,%eax
je     1165 <test_null+0x45>
lea    0xeb5(%rip),%rdi
mov    $0x1d,%esi
call   1040 <printf@plt>
lea    0xeb8(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11f6 <test_null+0xd6>
jmp    116a <test_null+0x4a>
jmp    116f <test_null+0x4f>
mov    -0x10(%rbp),%rdi
mov    $0x3,%esi
call   1030 <selection_sort@plt>
cmp    $0xffffffff,%eax
je     11a7 <test_null+0x87>
lea    0xe73(%rip),%rdi
mov    $0x1e,%esi
call   1040 <printf@plt>
lea    0xe76(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11f6 <test_null+0xd6>
jmp    11ac <test_null+0x8c>
jmp    11b1 <test_null+0x91>
mov    -0x10(%rbp),%rdi
mov    $0xfffffffe,%esi
call   1030 <selection_sort@plt>
cmp    $0xffffffff,%eax
je     11e9 <test_null+0xc9>
lea    0xe31(%rip),%rdi
mov    $0x1f,%esi
call   1040 <printf@plt>
lea    0xe34(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11f6 <test_null+0xd6>
jmp    11ee <test_null+0xce>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_null>:
push   %rbx
xor    %edi,%edi
xor    %esi,%esi
call   1030 <selection_sort@plt>
mov    $0x1d,%esi
cmp    $0xffffffff,%eax
jne    1162 <test_null+0x42>
xor    %edi,%edi
mov    $0x3,%esi
call   1030 <selection_sort@plt>
mov    $0x1e,%esi
cmp    $0xffffffff,%eax
jne    1162 <test_null+0x42>
xor    %ebx,%ebx
xor    %edi,%edi
mov    $0xfffffffe,%esi
call   1030 <selection_sort@plt>
mov    $0x1f,%esi
cmp    $0xffffffff,%eax
je     1175 <test_null+0x55>
lea    0xe97(%rip),%rdi
call   1040 <printf@plt>
lea    0xe9f(%rip),%rbx
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [20 x i8] c"Line number is: %d\0A\00"
@.str.1 = [25 x i8] c"error, sorted NULL array\00"
define i8* @test_null() {
%1 = alloca i8*
%2 = alloca i32*
store i32* null, i32** %2
br label %3
3: ; preds = %0
%4 = load i32*, i32** %2
%5 = call i32 @selection_sort(i32* %4, i32 0)
%6 = icmp eq i32 %5, -1
br i1 %6, label %9, label %7
7: ; preds = %3
%8 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 29)
store i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8** %1
br label %27
9: ; preds = %3
br label %10
10: ; preds = %9
br label %11
11: ; preds = %10
%12 = load i32*, i32** %2
%13 = call i32 @selection_sort(i32* %12, i32 3)
%14 = icmp eq i32 %13, -1
br i1 %14, label %17, label %15
15: ; preds = %11
%16 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 30)
store i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8** %1
br label %27
17: ; preds = %11
br label %18
18: ; preds = %17
br label %19
19: ; preds = %18
%20 = load i32*, i32** %2
%21 = call i32 @selection_sort(i32* %20, i32 -2)
%22 = icmp eq i32 %21, -1
br i1 %22, label %25, label %23
23: ; preds = %19
%24 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 31)
store i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8** %1
br label %27
25: ; preds = %19
br label %26
26: ; preds = %25
store i8* null, i8** %1
br label %27
27: ; preds = %26, %23, %15, %7
%28 = load i8*, i8** %1
ret i8* %28
}

LLVM IR (-O2):
@.str = [20 x i8] c"Line number is: %d\0A\00"
@.str.1 = [25 x i8] c"error, sorted NULL array\00"
define i8* @test_null() {
%1 = tail call i32 @selection_sort(i32* null, i32 0)
%2 = icmp eq i32 %1, -1
br i1 %2, label %3, label %9
3: ; preds = %0
%4 = tail call i32 @selection_sort(i32* null, i32 3)
%5 = icmp eq i32 %4, -1
br i1 %5, label %6, label %9
6: ; preds = %3
%7 = tail call i32 @selection_sort(i32* null, i32 -2)
%8 = icmp eq i32 %7, -1
br i1 %8, label %12, label %9
9: ; preds = %6, %3, %0
%10 = phi i32 [ 29, %0 ], [ 30, %3 ], [ 31, %6 ]
%11 = tail call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %10)
br label %12
12: ; preds = %9, %6
%13 = phi i8* [ null, %6 ], [ getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), %9 ]
ret i8* %13
}