#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*/ merge_sort(int *, int /*<<< orphan*/, int);
void test_reversed_list() {
  int array[] = {3, 2, 1};
  merge_sort(array, 0, 2);
  assert(array[0] == 1);
  assert(array[1] == 2);
  assert(array[2] == 3);
}


x86 assembly (clang, -O0):
<test_reversed_list>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0xed1(%rip),%rax
mov    %rax,-0xc(%rbp)
mov    0xecf(%rip),%eax
mov    %eax,-0x4(%rbp)
lea    -0xc(%rbp),%rdi
xor    %esi,%esi
mov    $0x2,%edx
call   1040 <merge_sort@plt>
cmpl   $0x1,-0xc(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpl   $0x2,-0x8(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpl   $0x3,-0x4(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_reversed_list>:
sub    $0x18,%rsp
mov    0xede(%rip),%eax
mov    %eax,0x10(%rsp)
mov    0xecb(%rip),%rax
mov    %rax,0x8(%rsp)
lea    0x8(%rsp),%rdi
xor    %esi,%esi
mov    $0x2,%edx
call   1040 <merge_sort@plt>
xor    %edi,%edi
cmpl   $0x1,0x8(%rsp)
sete   %dil
call   1030 <assert@plt>
xor    %edi,%edi
cmpl   $0x2,0xc(%rsp)
sete   %dil
call   1030 <assert@plt>
xor    %edi,%edi
cmpl   $0x3,0x10(%rsp)
sete   %dil
call   1030 <assert@plt>
add    $0x18,%rsp
ret

LLVM IR (-O0):
@__const.test_reversed_list.array = [3 x i32] [i32 3, i32 2, i32 1]
define void @test_reversed_list() {
%1 = alloca [3 x i32]
%2 = bitcast [3 x i32]* %1 to i8*
%3 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 0
%4 = call i32 @merge_sort(i32* %3, i32 0, i32 2)
%5 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 0
%6 = load i32, i32* %5
%7 = icmp eq i32 %6, 1
%8 = zext i1 %7 to i32
%9 = call i32 @assert(i32 %8)
%10 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 1
%11 = load i32, i32* %10
%12 = icmp eq i32 %11, 2
%13 = zext i1 %12 to i32
%14 = call i32 @assert(i32 %13)
%15 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 2
%16 = load i32, i32* %15
%17 = icmp eq i32 %16, 3
%18 = zext i1 %17 to i32
%19 = call i32 @assert(i32 %18)
ret void
}

LLVM IR (-O2):
@__const.test_reversed_list.array = [3 x i32] [i32 3, i32 2, i32 1]
define void @test_reversed_list() {
%1 = alloca [3 x i32]
%2 = bitcast [3 x i32]* %1 to i8*
%3 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 0
%4 = call i32 @merge_sort(i32* %3, i32 0, i32 2)
%5 = load i32, i32* %3
%6 = icmp eq i32 %5, 1
%7 = zext i1 %6 to i32
%8 = call i32 @assert(i32 %7)
%9 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 1
%10 = load i32, i32* %9
%11 = icmp eq i32 %10, 2
%12 = zext i1 %11 to i32
%13 = call i32 @assert(i32 %12)
%14 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 2
%15 = load i32, i32* %14
%16 = icmp eq i32 %15, 3
%17 = zext i1 %16 to i32
%18 = call i32 @assert(i32 %17)
ret void
}