#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*/ printf(char *);
int /*<<< orphan*/ sort(int *, int);
int main() {
  int ages[] = {12, 34, 65, 4, 78, 9, 43, 98, 51, 12};
  sort(ages, 10);
  if (!is_sorted(ages, 10)) {
    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    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x30(%rbp),%rdi
lea    0xea6(%rip),%rsi
mov    $0x28,%edx
call   1060 <memcpy@plt>
lea    -0x30(%rbp),%rdi
mov    $0xa,%esi
call   1050 <sort@plt>
lea    -0x30(%rbp),%rdi
mov    $0xa,%esi
call   1030 <is_sorted@plt>
cmp    $0x0,%eax
jne    119a <main+0x5a>
lea    0xe98(%rip),%rdi
call   1040 <printf@plt>
jmp    11a6 <main+0x66>
lea    0xea9(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x30,%rsp
mov    0xee4(%rip),%rax
mov    %rax,0x20(%rsp)
movaps 0xec8(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xeac(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0xa,%esi
call   1050 <sort@plt>
mov    %rbx,%rdi
mov    $0xa,%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    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.ages = [10 x i32] [i32 12, i32 34, i32 65, i32 4, i32 78, i32 9, i32 43, i32 98, i32 51, i32 12]
@.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 [10 x i32]
store i32 0, i32* %1
%3 = bitcast [10 x i32]* %2 to i8*
%4 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
%5 = call i32 @sort(i32* %4, i32 10)
%6 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
%7 = call i32 @is_sorted(i32* %6, i32 10)
%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.ages = [10 x i32] [i32 12, i32 34, i32 65, i32 4, i32 78, i32 9, i32 43, i32 98, i32 51, i32 12]
@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 [10 x i32]
%2 = bitcast [10 x i32]* %1 to i8*
%3 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 0
%4 = call i32 @sort(i32* %3, i32 10)
%5 = call i32 @is_sorted(i32* %3, i32 10)
%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
}