#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);
int /*<<< orphan*/ free(int *);
int *malloc(int);
int /*<<< orphan*/ top_down_merge_sorti(int *, int, int *);
int simple_top_down_merge_sorti(int arr[], int n) {
  int *temp;
  assert(arr != NULL && n > 0);
  temp = malloc(n * sizeof(int));
  if (temp == NULL)
    return 1;
  top_down_merge_sorti(arr, n, temp);
  free(temp);
  return 0;
}


x86 assembly (clang, -O0):
<simple_top_down_merge_sorti>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x10(%rbp)
mov    %al,-0x21(%rbp)
je     1169 <simple_top_down_merge_sorti+0x29>
cmpl   $0x0,-0x14(%rbp)
setg   %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11a0 <simple_top_down_merge_sorti+0x60>
movl   $0x1,-0x4(%rbp)
jmp    11c0 <simple_top_down_merge_sorti+0x80>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rdx
call   1040 <top_down_merge_sorti@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<simple_top_down_merge_sorti>:
push   %r15
push   %r14
push   %rbx
mov    %esi,%r15d
mov    %rdi,%r14
test   %rdi,%rdi
setne  %al
test   %esi,%esi
setg   %cl
and    %al,%cl
movzbl %cl,%edi
call   1050 <assert@plt>
lea    0x0(,%r15,4),%edi
call   1060 <malloc@plt>
test   %rax,%rax
je     118f <simple_top_down_merge_sorti+0x4f>
mov    %rax,%rbx
mov    %r14,%rdi
mov    %r15d,%esi
mov    %rax,%rdx
call   1040 <top_down_merge_sorti@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
jmp    1194 <simple_top_down_merge_sorti+0x54>
mov    $0x1,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @simple_top_down_merge_sorti(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 = icmp ne i32* %7, null
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = load i32, i32* %5
%11 = icmp sgt i32 %10, 0
br label %12
12: ; preds = %9, %2
%13 = phi i1 [ false, %2 ], [ %11, %9 ]
%14 = zext i1 %13 to i32
%15 = call i32 @assert(i32 %14)
%16 = load i32, i32* %5
%17 = sext i32 %16 to i64
%18 = mul i64 %17, 4
%19 = trunc i64 %18 to i32
%20 = call i32* @malloc(i32 %19)
store i32* %20, i32** %6
%21 = load i32*, i32** %6
%22 = icmp eq i32* %21, null
br i1 %22, label %23, label %24
23: ; preds = %12
store i32 1, i32* %3
br label %31
24: ; preds = %12
%25 = load i32*, i32** %4
%26 = load i32, i32* %5
%27 = load i32*, i32** %6
%28 = call i32 @top_down_merge_sorti(i32* %25, i32 %26, i32* %27)
%29 = load i32*, i32** %6
%30 = call i32 @free(i32* %29)
store i32 0, i32* %3
br label %31
31: ; preds = %24, %23
%32 = load i32, i32* %3
ret i32 %32
}

LLVM IR (-O2):
define i32 @simple_top_down_merge_sorti(i32* %0, i32 %1) {
%3 = icmp ne i32* %0, null
%4 = icmp sgt i32 %1, 0
%5 = and i1 %3, %4
%6 = zext i1 %5 to i32
%7 = tail call i32 @assert(i32 %6)
%8 = shl i32 %1, 2
%9 = tail call i32* @malloc(i32 %8)
%10 = icmp eq i32* %9, null
br i1 %10, label %14, label %11
11: ; preds = %2
%12 = tail call i32 @top_down_merge_sorti(i32* %0, i32 %1, i32* %9)
%13 = tail call i32 @free(i32* %9)
br label %14
14: ; preds = %2, %11
%15 = phi i32 [ 0, %11 ], [ 1, %2 ]
ret i32 %15
}