#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*/ is_sorted(int *, int);
int /*<<< orphan*/ merge_sort(int *, int);
int /*<<< orphan*/ printf(char *);
int main() {
  int input[] = {0, -1, -2, -1, 10, 3, 8};
  merge_sort(input, 7);
  if (!is_sorted(input, 7)) {
    printf("Input array has not been sorted!\n");
  } else {
    printf("Input array is sorted.\n");
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeba(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xeb7(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xeb4(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0xeb2(%rip),%eax
mov    %eax,-0x8(%rbp)
lea    -0x20(%rbp),%rdi
mov    $0x7,%esi
call   1050 <merge_sort@plt>
lea    -0x20(%rbp),%rdi
mov    $0x7,%esi
call   1030 <is_sorted@plt>
cmp    $0x0,%eax
jne    119f <main+0x6f>
lea    0xe87(%rip),%rdi
call   1040 <printf@plt>
jmp    11ab <main+0x7b>
lea    0xe98(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
movups 0xed0(%rip),%xmm0
movups %xmm0,0xc(%rsp)
movaps 0xeb8(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x7,%esi
call   1050 <merge_sort@plt>
mov    %rbx,%rdi
mov    $0x7,%esi
call   1040 <is_sorted@plt>
test   %eax,%eax
lea    0xeaa(%rip),%rax
lea    0xec4(%rip),%rdi
cmove  %rax,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.input = [7 x i32] [i32 0, i32 -1, i32 -2, i32 -1, i32 10, i32 3, i32 8]
@.str = [34 x i8] c"Input array has not been sorted!\0A\00"
@.str.1 = [24 x i8] c"Input array is sorted.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [7 x i32]
store i32 0, i32* %1
%3 = bitcast [7 x i32]* %2 to i8*
%4 = getelementptr inbounds [7 x i32], [7 x i32]* %2, i64 0, i64 0
%5 = call i32 @merge_sort(i32* %4, i32 7)
%6 = getelementptr inbounds [7 x i32], [7 x i32]* %2, i64 0, i64 0
%7 = call i32 @is_sorted(i32* %6, i32 7)
%8 = icmp ne i32 %7, 0
br i1 %8, label %11, label %9
9: ; preds = %0
%10 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
br label %13
11: ; preds = %0
%12 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
br label %13
13: ; preds = %11, %9
%14 = load i32, i32* %1
ret i32 %14
}

LLVM IR (-O2):
@__const.main.input = [7 x i32] [i32 0, i32 -1, i32 -2, i32 -1, i32 10, i32 3, i32 8]
@str = [33 x i8] c"Input array has not been sorted!\00"
@str.2 = [23 x i8] c"Input array is sorted.\00"
define i32 @main() {
%1 = alloca [7 x i32]
%2 = bitcast [7 x i32]* %1 to i8*
%3 = getelementptr inbounds [7 x i32], [7 x i32]* %1, i64 0, i64 0
%4 = call i32 @merge_sort(i32* %3, i32 7)
%5 = call i32 @is_sorted(i32* %3, i32 7)
%6 = icmp eq i32 %5, 0
%7 = select i1 %6, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @str, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @str.2, i64 0, i64 0)
%8 = call i32 @puts(i8* dereferenceable(1) %7)
ret i32 0
}