#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 */
typedef int /*<<< orphan*/ arr;

/* Variables and functions */
int /*<<< orphan*/ arrayPrint(int *, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sortPeaksValleys(int *, int);
int main(int argc, const char *argv[]) {
  int arr[] = {1, 4, 2, 0, 5, 5, 2, 7, 8, 9, 65, 44, 1};
  int arraySize = sizeof(arr) / sizeof(int);
  printf("Original: ");
  arrayPrint(arr, arraySize);
  printf("Sorted: ");
  sortPeaksValleys(arr, arraySize);
  arrayPrint(arr, arraySize);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x50(%rbp),%rdi
lea    0xe9f(%rip),%rsi
mov    $0x34,%edx
call   1060 <memcpy@plt>
movl   $0xd,-0x54(%rbp)
lea    0xebb(%rip),%rdi
call   1040 <printf@plt>
lea    -0x50(%rbp),%rdi
mov    -0x54(%rbp),%esi
call   1030 <arrayPrint@plt>
lea    0xeae(%rip),%rdi
call   1040 <printf@plt>
lea    -0x50(%rbp),%rdi
mov    -0x54(%rbp),%esi
call   1050 <sortPeaksValleys@plt>
lea    -0x50(%rbp),%rdi
mov    -0x54(%rbp),%esi
call   1030 <arrayPrint@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x40,%rsp
mov    0xef5(%rip),%eax
mov    %eax,0x30(%rsp)
movaps 0xeda(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xebe(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xea2(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0xecb(%rip),%rdi
call   1040 <printf@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0xd,%esi
call   1030 <arrayPrint@plt>
lea    0xeba(%rip),%rdi
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0xd,%esi
call   1050 <sortPeaksValleys@plt>
mov    %rbx,%rdi
mov    $0xd,%esi
call   1030 <arrayPrint@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.arr = [13 x i32] [i32 1, i32 4, i32 2, i32 0, i32 5, i32 5, i32 2, i32 7, i32 8, i32 9, i32 65, i32 44, i32 1]
@.str = [11 x i8] c"Original: \00"
@.str.1 = [9 x i8] c"Sorted: \00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [13 x i32]
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = bitcast [13 x i32]* %6 to i8*
store i32 13, i32* %7
%9 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%10 = getelementptr inbounds [13 x i32], [13 x i32]* %6, i64 0, i64 0
%11 = load i32, i32* %7
%12 = call i32 @arrayPrint(i32* %10, i32 %11)
%13 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%14 = getelementptr inbounds [13 x i32], [13 x i32]* %6, i64 0, i64 0
%15 = load i32, i32* %7
%16 = call i32 @sortPeaksValleys(i32* %14, i32 %15)
%17 = getelementptr inbounds [13 x i32], [13 x i32]* %6, i64 0, i64 0
%18 = load i32, i32* %7
%19 = call i32 @arrayPrint(i32* %17, i32 %18)
ret i32 0
}

LLVM IR (-O2):
@__const.main.arr = [13 x i32] [i32 1, i32 4, i32 2, i32 0, i32 5, i32 5, i32 2, i32 7, i32 8, i32 9, i32 65, i32 44, i32 1]
@.str = [11 x i8] c"Original: \00"
@.str.1 = [9 x i8] c"Sorted: \00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [13 x i32]
%4 = bitcast [13 x i32]* %3 to i8*
%5 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%6 = getelementptr inbounds [13 x i32], [13 x i32]* %3, i64 0, i64 0
%7 = call i32 @arrayPrint(i32* %6, i32 13)
%8 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 @sortPeaksValleys(i32* %6, i32 13)
%10 = call i32 @arrayPrint(i32* %6, i32 13)
ret i32 0
}