#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*/ mergeSort(int *, int);
int checkMergeSort(int arr[], int n) {
  int i;
  mergeSort(arr, n);
  for (i = 1; i < n; ++i) {
    if (arr[i - 1] > arr[i]) {
      return 1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<checkMergeSort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1030 <mergeSort@plt>
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    117e <checkMergeSort+0x6e>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%eax
mov    -0x10(%rbp),%rcx
movslq -0x18(%rbp),%rdx
cmp    (%rcx,%rdx,4),%eax
jle    116b <checkMergeSort+0x5b>
movl   $0x1,-0x4(%rbp)
jmp    1185 <checkMergeSort+0x75>
jmp    1170 <checkMergeSort+0x60>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1132 <checkMergeSort+0x22>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checkMergeSort>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
call   1030 <mergeSort@plt>
xor    %eax,%eax
cmp    $0x2,%ebp
jl     1149 <checkMergeSort+0x39>
mov    %ebp,%ecx
mov    (%rbx),%edx
mov    $0x1,%esi
nopl   (%rax)
mov    %edx,%edi
mov    (%rbx,%rsi,4),%edx
cmp    %edx,%edi
jg     1144 <checkMergeSort+0x34>
add    $0x1,%rsi
cmp    %rsi,%rcx
jne    1130 <checkMergeSort+0x20>
jmp    1149 <checkMergeSort+0x39>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @checkMergeSort(i32* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
%7 = load i32*, i32** %4
%8 = load i32, i32* %5
%9 = call i32 @mergeSort(i32* %7, i32 %8)
store i32 1, i32* %6
br label %10
10: ; preds = %29, %2
%11 = load i32, i32* %6
%12 = load i32, i32* %5
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %32
14: ; preds = %10
%15 = load i32*, i32** %4
%16 = load i32, i32* %6
%17 = sub nsw i32 %16, 1
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i32, i32* %15, i64 %18
%20 = load i32, i32* %19
%21 = load i32*, i32** %4
%22 = load i32, i32* %6
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i32, i32* %21, i64 %23
%25 = load i32, i32* %24
%26 = icmp sgt i32 %20, %25
br i1 %26, label %27, label %28
27: ; preds = %14
store i32 1, i32* %3
br label %33
28: ; preds = %14
br label %29
29: ; preds = %28
%30 = load i32, i32* %6
%31 = add nsw i32 %30, 1
store i32 %31, i32* %6
br label %10
32: ; preds = %10
store i32 0, i32* %3
br label %33
33: ; preds = %32, %27
%34 = load i32, i32* %3
ret i32 %34
}

LLVM IR (-O2):
define i32 @checkMergeSort(i32* %0, i32 %1) {
%3 = tail call i32 @mergeSort(i32* %0, i32 %1)
%4 = icmp sgt i32 %1, 1
br i1 %4, label %5, label %17
5: ; preds = %2
%6 = zext i32 %1 to i64
%7 = load i32, i32* %0
br label %10
8: ; preds = %10
%9 = icmp eq i64 %16, %6
br i1 %9, label %17, label %10
10: ; preds = %5, %8
%11 = phi i32 [ %7, %5 ], [ %14, %8 ]
%12 = phi i64 [ 1, %5 ], [ %16, %8 ]
%13 = getelementptr inbounds i32, i32* %0, i64 %12
%14 = load i32, i32* %13
%15 = icmp sgt i32 %11, %14
%16 = add nuw nsw i64 %12, 1
br i1 %15, label %17, label %8
17: ; preds = %10, %8, %2
%18 = phi i32 [ 0, %2 ], [ 0, %8 ], [ 1, %10 ]
ret i32 %18
}