#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*/ assert(int);
scalar_t__ checkMergeSort(int *, int);
int testMergeSort() {
  int i, j, arr[100000];
  for (i = 0; i < 100000; ++i) {
    arr[i] = 0;
  }
  assert(checkMergeSort(arr, 100000) == 0);
  for (i = 0; i < 100000; ++i) {
    arr[i] = i;
  }
  assert(checkMergeSort(arr, 100000) == 0);
  j = 100000;
  for (i = 0; i < 100000; ++i) {
    arr[i] = j--;
  }
  assert(checkMergeSort(arr, 100000) == 0);
  return 0;
}


x86 assembly (clang, -O0):
<testMergeSort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x61a90,%rsp
movl   $0x0,-0x4(%rbp)
cmpl   $0x186a0,-0x4(%rbp)
jge    115c <testMergeSort+0x3c>
movslq -0x4(%rbp),%rax
movl   $0x0,-0x61a90(%rbp,%rax,4)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1132 <testMergeSort+0x12>
lea    -0x61a90(%rbp),%rdi
mov    $0x186a0,%esi
call   1040 <checkMergeSort@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
movl   $0x0,-0x4(%rbp)
cmpl   $0x186a0,-0x4(%rbp)
jge    11ae <testMergeSort+0x8e>
mov    -0x4(%rbp),%ecx
movslq -0x4(%rbp),%rax
mov    %ecx,-0x61a90(%rbp,%rax,4)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1185 <testMergeSort+0x65>
lea    -0x61a90(%rbp),%rdi
mov    $0x186a0,%esi
call   1040 <checkMergeSort@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
movl   $0x186a0,-0x8(%rbp)
movl   $0x0,-0x4(%rbp)
cmpl   $0x186a0,-0x4(%rbp)
jge    120f <testMergeSort+0xef>
mov    -0x8(%rbp),%ecx
mov    %ecx,%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
movslq -0x4(%rbp),%rax
mov    %ecx,-0x61a90(%rbp,%rax,4)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    11de <testMergeSort+0xbe>
lea    -0x61a90(%rbp),%rdi
mov    $0x186a0,%esi
call   1040 <checkMergeSort@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
xor    %eax,%eax
add    $0x61a90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testMergeSort>:
push   %rbx
sub    $0x61a80,%rsp
mov    %rsp,%rbx
mov    $0x61a80,%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1030 <memset@plt>
mov    %rbx,%rdi
mov    $0x186a0,%esi
call   1050 <checkMergeSort@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1040 <assert@plt>
movdqa 0xe93(%rip),%xmm0
mov    $0x24,%eax
movdqa 0xe95(%rip),%xmm8
movdqa 0xe9c(%rip),%xmm9
movdqa 0xea3(%rip),%xmm10
movdqa 0xeaa(%rip),%xmm11
movdqa 0xeb1(%rip),%xmm12
movdqa 0xeb9(%rip),%xmm6
movdqa 0xec1(%rip),%xmm7
movdqa 0xec9(%rip),%xmm1
movdqa 0xed1(%rip),%xmm2
movdqa 0xed9(%rip),%xmm3
nopw   0x0(%rax,%rax,1)
movdqa %xmm0,%xmm4
paddd  %xmm8,%xmm4
movdqa %xmm0,-0x90(%rsp,%rax,4)
ff ff
movdqa %xmm4,-0x80(%rsp,%rax,4)
movdqa %xmm0,%xmm4
paddd  %xmm9,%xmm4
movdqa %xmm0,%xmm5
paddd  %xmm10,%xmm5
movdqa %xmm4,-0x70(%rsp,%rax,4)
movdqa %xmm5,-0x60(%rsp,%rax,4)
movdqa %xmm0,%xmm4
paddd  %xmm11,%xmm4
movdqa %xmm0,%xmm5
paddd  %xmm12,%xmm5
movdqa %xmm4,-0x50(%rsp,%rax,4)
movdqa %xmm5,-0x40(%rsp,%rax,4)
movdqa %xmm0,%xmm4
paddd  %xmm6,%xmm4
movdqa %xmm0,%xmm5
paddd  %xmm7,%xmm5
movdqa %xmm4,-0x30(%rsp,%rax,4)
movdqa %xmm5,-0x20(%rsp,%rax,4)
movdqa %xmm0,%xmm4
paddd  %xmm1,%xmm4
movdqa %xmm0,%xmm5
paddd  %xmm2,%xmm5
movdqa %xmm4,-0x10(%rsp,%rax,4)
movdqa %xmm5,(%rsp,%rax,4)
paddd  %xmm3,%xmm0
add    $0x28,%rax
cmp    $0x186c4,%rax
jne    11d0 <testMergeSort+0xa0>
mov    %rsp,%rdi
mov    $0x186a0,%esi
call   1050 <checkMergeSort@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1040 <assert@plt>
movdqa 0xe1e(%rip),%xmm0
mov    $0x24,%eax
movdqa 0xe20(%rip),%xmm8
movdqa 0xe27(%rip),%xmm9
movdqa 0xe2e(%rip),%xmm10
movdqa 0xe35(%rip),%xmm11
movdqa 0xe3c(%rip),%xmm12
movdqa 0xe44(%rip),%xmm6
movdqa 0xe4c(%rip),%xmm7
movdqa 0xe54(%rip),%xmm1
movdqa 0xe5c(%rip),%xmm2
movdqa 0xe64(%rip),%xmm3
nopl   0x0(%rax)
movdqa %xmm0,%xmm4
paddd  %xmm8,%xmm4
movdqa %xmm0,-0x90(%rsp,%rax,4)
movdqa %xmm4,-0x80(%rsp,%rax,4)
movdqa %xmm0,%xmm4
paddd  %xmm9,%xmm4
movdqa %xmm0,%xmm5
paddd  %xmm10,%xmm5
movdqa %xmm4,-0x70(%rsp,%rax,4)
movdqa %xmm5,-0x60(%rsp,%rax,4)
movdqa %xmm0,%xmm4
paddd  %xmm11,%xmm4
movdqa %xmm0,%xmm5
paddd  %xmm12,%xmm5
movdqa %xmm4,-0x50(%rsp,%rax,4)
movdqa %xmm5,-0x40(%rsp,%rax,4)
movdqa %xmm0,%xmm4
paddd  %xmm6,%xmm4
movdqa %xmm0,%xmm5
paddd  %xmm7,%xmm5
movdqa %xmm4,-0x30(%rsp,%rax,4)
movdqa %xmm5,-0x20(%rsp,%rax,4)
movdqa %xmm0,%xmm4
paddd  %xmm1,%xmm4
movdqa %xmm0,%xmm5
paddd  %xmm2,%xmm5
movdqa %xmm4,-0x10(%rsp,%rax,4)
movdqa %xmm5,(%rsp,%rax,4)
paddd  %xmm3,%xmm0
add    $0x28,%rax
cmp    $0x186c4,%rax
jne    12f0 <testMergeSort+0x1c0>
mov    %rsp,%rdi
mov    $0x186a0,%esi
call   1050 <checkMergeSort@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1040 <assert@plt>
xor    %eax,%eax
add    $0x61a80,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32 @testMergeSort() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [100000 x i32]
store i32 0, i32* %1
br label %4
4: ; preds = %11, %0
%5 = load i32, i32* %1
%6 = icmp slt i32 %5, 100000
br i1 %6, label %7, label %14
7: ; preds = %4
%8 = load i32, i32* %1
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds [100000 x i32], [100000 x i32]* %3, i64 0, i64 %9
store i32 0, i32* %10
br label %11
11: ; preds = %7
%12 = load i32, i32* %1
%13 = add nsw i32 %12, 1
store i32 %13, i32* %1
br label %4
14: ; preds = %4
%15 = getelementptr inbounds [100000 x i32], [100000 x i32]* %3, i64 0, i64 0
%16 = call i64 @checkMergeSort(i32* %15, i32 100000)
%17 = icmp eq i64 %16, 0
%18 = zext i1 %17 to i32
%19 = call i32 @assert(i32 %18)
store i32 0, i32* %1
br label %20
20: ; preds = %28, %14
%21 = load i32, i32* %1
%22 = icmp slt i32 %21, 100000
br i1 %22, label %23, label %31
23: ; preds = %20
%24 = load i32, i32* %1
%25 = load i32, i32* %1
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [100000 x i32], [100000 x i32]* %3, i64 0, i64 %26
store i32 %24, i32* %27
br label %28
28: ; preds = %23
%29 = load i32, i32* %1
%30 = add nsw i32 %29, 1
store i32 %30, i32* %1
br label %20
31: ; preds = %20
%32 = getelementptr inbounds [100000 x i32], [100000 x i32]* %3, i64 0, i64 0
%33 = call i64 @checkMergeSort(i32* %32, i32 100000)
%34 = icmp eq i64 %33, 0
%35 = zext i1 %34 to i32
%36 = call i32 @assert(i32 %35)
store i32 100000, i32* %2
store i32 0, i32* %1
br label %37
37: ; preds = %46, %31
%38 = load i32, i32* %1
%39 = icmp slt i32 %38, 100000
br i1 %39, label %40, label %49
40: ; preds = %37
%41 = load i32, i32* %2
%42 = add nsw i32 %41, -1
store i32 %42, i32* %2
%43 = load i32, i32* %1
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [100000 x i32], [100000 x i32]* %3, i64 0, i64 %44
store i32 %41, i32* %45
br label %46
46: ; preds = %40
%47 = load i32, i32* %1
%48 = add nsw i32 %47, 1
store i32 %48, i32* %1
br label %37
49: ; preds = %37
%50 = getelementptr inbounds [100000 x i32], [100000 x i32]* %3, i64 0, i64 0
%51 = call i64 @checkMergeSort(i32* %50, i32 100000)
%52 = icmp eq i64 %51, 0
%53 = zext i1 %52 to i32
%54 = call i32 @assert(i32 %53)
ret i32 0
}

LLVM IR (-O2):
define i32 @testMergeSort() {
%1 = alloca [100000 x i32]
%2 = bitcast [100000 x i32]* %1 to i8*
%3 = getelementptr inbounds [100000 x i32], [100000 x i32]* %1, i64 0, i64 0
%4 = call i64 @checkMergeSort(i32* %3, i32 100000)
%5 = icmp eq i64 %4, 0
%6 = zext i1 %5 to i32
%7 = call i32 @assert(i32 %6)
br label %8
8: ; preds = %8, %0
%9 = phi i64 [ 0, %0 ], [ %44, %8 ]
%10 = phi <4 x i32> [ <i32 0, i32 1, i32 2, i32 3>, %0 ], [ %45, %8 ]
%11 = add <4 x i32> %10, <i32 4, i32 4, i32 4, i32 4>
%12 = getelementptr inbounds [100000 x i32], [100000 x i32]* %1, i64 0, i64 %9
%13 = bitcast i32* %12 to <4 x i32>*
store <4 x i32> %10, <4 x i32>* %13
%14 = getelementptr inbounds i32, i32* %12, i64 4
%15 = bitcast i32* %14 to <4 x i32>*
store <4 x i32> %11, <4 x i32>* %15
%16 = add nuw nsw i64 %9, 8
%17 = add <4 x i32> %10, <i32 8, i32 8, i32 8, i32 8>
%18 = add <4 x i32> %10, <i32 12, i32 12, i32 12, i32 12>
%19 = getelementptr inbounds [100000 x i32], [100000 x i32]* %1, i64 0, i64 %16
%20 = bitcast i32* %19 to <4 x i32>*
store <4 x i32> %17, <4 x i32>* %20
%21 = getelementptr inbounds i32, i32* %19, i64 4
%22 = bitcast i32* %21 to <4 x i32>*
store <4 x i32> %18, <4 x i32>* %22
%23 = add nuw nsw i64 %9, 16
%24 = add <4 x i32> %10, <i32 16, i32 16, i32 16, i32 16>
%25 = add <4 x i32> %10, <i32 20, i32 20, i32 20, i32 20>
%26 = getelementptr inbounds [100000 x i32], [100000 x i32]* %1, i64 0, i64 %23
%27 = bitcast i32* %26 to <4 x i32>*
store <4 x i32> %24, <4 x i32>* %27
%28 = getelementptr inbounds i32, i32* %26, i64 4
%29 = bitcast i32* %28 to <4 x i32>*
store <4 x i32> %25, <4 x i32>* %29
%30 = add nuw nsw i64 %9, 24
%31 = add <4 x i32> %10, <i32 24, i32 24, i32 24, i32 24>
%32 = add <4 x i32> %10, <i32 28, i32 28, i32 28, i32 28>
%33 = getelementptr inbounds [100000 x i32], [100000 x i32]* %1, i64 0, i64 %30
%34 = bitcast i32* %33 to <4 x i32>*
store <4 x i32> %31, <4 x i32>* %34
%35 = getelementptr inbounds i32, i32* %33, i64 4
%36 = bitcast i32* %35 to <4 x i32>*
store <4 x i32> %32, <4 x i32>* %36
%37 = add nuw nsw i64 %9, 32
%38 = add <4 x i32> %10, <i32 32, i32 32, i32 32, i32 32>
%39 = add <4 x i32> %10, <i32 36, i32 36, i32 36, i32 36>
%40 = getelementptr inbounds [100000 x i32], [100000 x i32]* %1, i64 0, i64 %37
%41 = bitcast i32* %40 to <4 x i32>*
store <4 x i32> %38, <4 x i32>* %41
%42 = getelementptr inbounds i32, i32* %40, i64 4
%43 = bitcast i32* %42 to <4 x i32>*
store <4 x i32> %39, <4 x i32>* %43
%44 = add nuw nsw i64 %9, 40
%45 = add <4 x i32> %10, <i32 40, i32 40, i32 40, i32 40>
%46 = icmp eq i64 %44, 100000
br i1 %46, label %47, label %8
47: ; preds = %8
%48 = call i64 @checkMergeSort(i32* %3, i32 100000)
%49 = icmp eq i64 %48, 0
%50 = zext i1 %49 to i32
%51 = call i32 @assert(i32 %50)
br label %52
52: ; preds = %52, %47
%53 = phi i64 [ 0, %47 ], [ %88, %52 ]
%54 = phi <4 x i32> [ <i32 100000, i32 99999, i32 99998, i32 99997>, %47 ], [ %89, %52 ]
%55 = add <4 x i32> %54, <i32 -4, i32 -4, i32 -4, i32 -4>
%56 = getelementptr inbounds [100000 x i32], [100000 x i32]* %1, i64 0, i64 %53
%57 = bitcast i32* %56 to <4 x i32>*
store <4 x i32> %54, <4 x i32>* %57
%58 = getelementptr inbounds i32, i32* %56, i64 4
%59 = bitcast i32* %58 to <4 x i32>*
store <4 x i32> %55, <4 x i32>* %59
%60 = add nuw nsw i64 %53, 8
%61 = add <4 x i32> %54, <i32 -8, i32 -8, i32 -8, i32 -8>
%62 = add <4 x i32> %54, <i32 -12, i32 -12, i32 -12, i32 -12>
%63 = getelementptr inbounds [100000 x i32], [100000 x i32]* %1, i64 0, i64 %60
%64 = bitcast i32* %63 to <4 x i32>*
store <4 x i32> %61, <4 x i32>* %64
%65 = getelementptr inbounds i32, i32* %63, i64 4
%66 = bitcast i32* %65 to <4 x i32>*
store <4 x i32> %62, <4 x i32>* %66
%67 = add nuw nsw i64 %53, 16
%68 = add <4 x i32> %54, <i32 -16, i32 -16, i32 -16, i32 -16>
%69 = add <4 x i32> %54, <i32 -20, i32 -20, i32 -20, i32 -20>
%70 = getelementptr inbounds [100000 x i32], [100000 x i32]* %1, i64 0, i64 %67
%71 = bitcast i32* %70 to <4 x i32>*
store <4 x i32> %68, <4 x i32>* %71
%72 = getelementptr inbounds i32, i32* %70, i64 4
%73 = bitcast i32* %72 to <4 x i32>*
store <4 x i32> %69, <4 x i32>* %73
%74 = add nuw nsw i64 %53, 24
%75 = add <4 x i32> %54, <i32 -24, i32 -24, i32 -24, i32 -24>
%76 = add <4 x i32> %54, <i32 -28, i32 -28, i32 -28, i32 -28>
%77 = getelementptr inbounds [100000 x i32], [100000 x i32]* %1, i64 0, i64 %74
%78 = bitcast i32* %77 to <4 x i32>*
store <4 x i32> %75, <4 x i32>* %78
%79 = getelementptr inbounds i32, i32* %77, i64 4
%80 = bitcast i32* %79 to <4 x i32>*
store <4 x i32> %76, <4 x i32>* %80
%81 = add nuw nsw i64 %53, 32
%82 = add <4 x i32> %54, <i32 -32, i32 -32, i32 -32, i32 -32>
%83 = add <4 x i32> %54, <i32 -36, i32 -36, i32 -36, i32 -36>
%84 = getelementptr inbounds [100000 x i32], [100000 x i32]* %1, i64 0, i64 %81
%85 = bitcast i32* %84 to <4 x i32>*
store <4 x i32> %82, <4 x i32>* %85
%86 = getelementptr inbounds i32, i32* %84, i64 4
%87 = bitcast i32* %86 to <4 x i32>*
store <4 x i32> %83, <4 x i32>* %87
%88 = add nuw nsw i64 %53, 40
%89 = add <4 x i32> %54, <i32 -40, i32 -40, i32 -40, i32 -40>
%90 = icmp eq i64 %88, 100000
br i1 %90, label %91, label %52
91: ; preds = %52
%92 = call i64 @checkMergeSort(i32* %3, i32 100000)
%93 = icmp eq i64 %92, 0
%94 = zext i1 %93 to i32
%95 = call i32 @assert(i32 %94)
ret i32 0
}