#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 merge(int **, int, int, int, int, int, int);
int /*<<< orphan*/ printf(char *, int, int);
int mergesort_rec(int A[(2)][(25)], int h, int low, int high) {
  int div;
  int lh, rh;
  if (low > high) {
    printf("FATAL: low: %d, high: %d\n", low, high);
    return h;
  }
  if (low == high) {
    return h;
  }
  div = (low + high) / 2;
  lh = mergesort_rec(A, h, low, div);
  rh = mergesort_rec(A, h, div + 1, high);
  return merge(A, lh, rh, low, div, div + 1, high);
}


x86 assembly (clang, -O0):
<mergesort_rec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jle    116e <mergesort_rec+0x3e>
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
lea    0xea2(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11ea <mergesort_rec+0xba>
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jne    1185 <mergesort_rec+0x55>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11ea <mergesort_rec+0xba>
mov    -0x18(%rbp),%eax
add    -0x1c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x20(%rbp),%ecx
call   1050 <mergesort_rec@plt>
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%edx
add    $0x1,%edx
mov    -0x1c(%rbp),%ecx
call   1050 <mergesort_rec@plt>
mov    %eax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    -0x28(%rbp),%edx
mov    -0x18(%rbp),%ecx
mov    -0x20(%rbp),%r8d
mov    -0x20(%rbp),%r9d
add    $0x1,%r9d
mov    -0x1c(%rbp),%eax
mov    %eax,(%rsp)
call   1040 <merge@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mergesort_rec>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %ecx,%ebx
mov    %edx,%r14d
mov    %esi,%r12d
cmp    %ecx,%edx
jle    115d <mergesort_rec+0x2d>
lea    0xeaf(%rip),%rdi
mov    %r14d,%esi
mov    %ebx,%edx
call   1030 <printf@plt>
jmp    115f <mergesort_rec+0x2f>
jne    1164 <mergesort_rec+0x34>
mov    %r12d,%eax
jmp    11b3 <mergesort_rec+0x83>
mov    %rdi,%r15
lea    (%rbx,%r14,1),%eax
mov    %eax,%ebp
shr    $0x1f,%ebp
add    %eax,%ebp
sar    %ebp
mov    %r12d,%esi
mov    %r14d,%edx
mov    %ebp,%ecx
call   1050 <mergesort_rec@plt>
mov    %eax,0x14(%rsp)
lea    0x1(%rbp),%r13d
mov    %r15,%rdi
mov    %r12d,%esi
mov    %r13d,%edx
mov    %ebx,%ecx
call   1050 <mergesort_rec@plt>
mov    %ebx,(%rsp)
mov    %r15,%rdi
mov    0x14(%rsp),%esi
mov    %eax,%edx
mov    %r14d,%ecx
mov    %ebp,%r8d
mov    %r13d,%r9d
call   1040 <merge@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [26 x i8] c"FATAL: low: %d, high: %d\0A\00"
define i32 @mergesort_rec([25 x i32]* %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca [25 x i32]*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store [25 x i32]* %0, [25 x i32]** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
%13 = load i32, i32* %8
%14 = load i32, i32* %9
%15 = icmp sgt i32 %13, %14
br i1 %15, label %16, label %21
16: ; preds = %4
%17 = load i32, i32* %8
%18 = load i32, i32* %9
%19 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %17, i32 %18)
%20 = load i32, i32* %7
store i32 %20, i32* %5
br label %53
21: ; preds = %4
%22 = load i32, i32* %8
%23 = load i32, i32* %9
%24 = icmp eq i32 %22, %23
br i1 %24, label %25, label %27
25: ; preds = %21
%26 = load i32, i32* %7
store i32 %26, i32* %5
br label %53
27: ; preds = %21
%28 = load i32, i32* %8
%29 = load i32, i32* %9
%30 = add nsw i32 %28, %29
%31 = sdiv i32 %30, 2
store i32 %31, i32* %10
%32 = load [25 x i32]*, [25 x i32]** %6
%33 = load i32, i32* %7
%34 = load i32, i32* %8
%35 = load i32, i32* %10
%36 = call i32 @mergesort_rec([25 x i32]* %32, i32 %33, i32 %34, i32 %35)
store i32 %36, i32* %11
%37 = load [25 x i32]*, [25 x i32]** %6
%38 = load i32, i32* %7
%39 = load i32, i32* %10
%40 = add nsw i32 %39, 1
%41 = load i32, i32* %9
%42 = call i32 @mergesort_rec([25 x i32]* %37, i32 %38, i32 %40, i32 %41)
store i32 %42, i32* %12
%43 = load [25 x i32]*, [25 x i32]** %6
%44 = bitcast [25 x i32]* %43 to i32**
%45 = load i32, i32* %11
%46 = load i32, i32* %12
%47 = load i32, i32* %8
%48 = load i32, i32* %10
%49 = load i32, i32* %10
%50 = add nsw i32 %49, 1
%51 = load i32, i32* %9
%52 = call i32 @merge(i32** %44, i32 %45, i32 %46, i32 %47, i32 %48, i32 %50, i32 %51)
store i32 %52, i32* %5
br label %53
53: ; preds = %27, %25, %16
%54 = load i32, i32* %5
ret i32 %54
}

LLVM IR (-O2):
@.str = [26 x i8] c"FATAL: low: %d, high: %d\0A\00"
define i32 @mergesort_rec([25 x i32]* %0, i32 %1, i32 %2, i32 %3) {
%5 = icmp sgt i32 %2, %3
br i1 %5, label %6, label %8
6: ; preds = %4
%7 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %2, i32 %3)
br label %10
8: ; preds = %4
%9 = icmp eq i32 %2, %3
br i1 %9, label %10, label %12
10: ; preds = %6, %8, %12
%11 = phi i32 [ %19, %12 ], [ %1, %8 ], [ %1, %6 ]
ret i32 %11
12: ; preds = %8
%13 = add nsw i32 %3, %2
%14 = sdiv i32 %13, 2
%15 = tail call i32 @mergesort_rec([25 x i32]* %0, i32 %1, i32 %2, i32 %14)
%16 = add nsw i32 %14, 1
%17 = tail call i32 @mergesort_rec([25 x i32]* %0, i32 %1, i32 %16, i32 %3)
%18 = bitcast [25 x i32]* %0 to i32**
%19 = tail call i32 @merge(i32** %18, i32 %15, i32 %17, i32 %2, i32 %14, i32 %16, i32 %3)
br label %10
}