#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 */
scalar_t__ malloc(int);
int random();
int /*<<< orphan*/ srandomdev();
int *getMyArray(int count, int unique) {
  int *myArray;
  int halfCount, i;
  myArray = (int *)malloc(sizeof(int) * count);
  halfCount = count / 2;
  srandomdev();
  for (i = 0; i < halfCount; i++) {
    myArray[i] = random();
    myArray[count - i - 1] = myArray[i];
  }
  myArray[i] = unique;
  return myArray;
}


x86 assembly (clang, -O0):
<getMyArray>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movslq -0x4(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
mov    $0x0,%al
call   1050 <srandomdev@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11b9 <getMyArray+0x89>
mov    $0x0,%al
call   1030 <random@plt>
mov    %eax,%edx
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x10(%rbp),%rax
mov    -0x4(%rbp),%ecx
sub    -0x18(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    116d <getMyArray+0x3d>
mov    -0x8(%rbp),%edx
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getMyArray>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %esi,%r14d
mov    %edi,%ebp
lea    0x0(,%rbp,4),%edi
call   1040 <malloc@plt>
mov    %rax,%r12
xor    %r15d,%r15d
xor    %eax,%eax
call   1050 <srandomdev@plt>
cmp    $0x2,%ebp
jl     118e <getMyArray+0x5e>
mov    %ebp,%eax
shr    $0x1f,%eax
add    %ebp,%eax
sar    %eax
mov    %eax,%r15d
add    $0xffffffff,%ebp
xor    %ebx,%ebx
nopl   0x0(%rax)
xor    %eax,%eax
call   1030 <random@plt>
mov    %eax,(%r12,%rbx,4)
movslq %ebp,%rbp
mov    %eax,(%r12,%rbp,4)
add    $0x1,%rbx
add    $0xffffffff,%ebp
cmp    %rbx,%r15
jne    1170 <getMyArray+0x40>
mov    %r14d,(%r12,%r15,4)
mov    %r12,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32* @getMyArray(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%8 = load i32, i32* %3
%9 = sext i32 %8 to i64
%10 = mul i64 4, %9
%11 = trunc i64 %10 to i32
%12 = call i64 @malloc(i32 %11)
%13 = inttoptr i64 %12 to i32*
store i32* %13, i32** %5
%14 = load i32, i32* %3
%15 = sdiv i32 %14, 2
store i32 %15, i32* %6
%16 = call i32 (...) @srandomdev()
store i32 0, i32* %7
br label %17
17: ; preds = %39, %2
%18 = load i32, i32* %7
%19 = load i32, i32* %6
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %42
21: ; preds = %17
%22 = call i32 (...) @random()
%23 = load i32*, i32** %5
%24 = load i32, i32* %7
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i32, i32* %23, i64 %25
store i32 %22, i32* %26
%27 = load i32*, i32** %5
%28 = load i32, i32* %7
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i32, i32* %27, i64 %29
%31 = load i32, i32* %30
%32 = load i32*, i32** %5
%33 = load i32, i32* %3
%34 = load i32, i32* %7
%35 = sub nsw i32 %33, %34
%36 = sub nsw i32 %35, 1
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i32, i32* %32, i64 %37
store i32 %31, i32* %38
br label %39
39: ; preds = %21
%40 = load i32, i32* %7
%41 = add nsw i32 %40, 1
store i32 %41, i32* %7
br label %17
42: ; preds = %17
%43 = load i32, i32* %4
%44 = load i32*, i32** %5
%45 = load i32, i32* %7
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i32, i32* %44, i64 %46
store i32 %43, i32* %47
%48 = load i32*, i32** %5
ret i32* %48
}

LLVM IR (-O2):
define i32* @getMyArray(i32 %0, i32 %1) {
%3 = shl i32 %0, 2
%4 = tail call i64 @malloc(i32 %3)
%5 = inttoptr i64 %4 to i32*
%6 = sdiv i32 %0, 2
%7 = tail call i32 (...) @srandomdev()
%8 = icmp sgt i32 %0, 1
br i1 %8, label %9, label %24
9: ; preds = %2
%10 = zext i32 %6 to i64
br label %11
11: ; preds = %9, %11
%12 = phi i64 [ 0, %9 ], [ %20, %11 ]
%13 = tail call i32 (...) @random()
%14 = getelementptr inbounds i32, i32* %5, i64 %12
store i32 %13, i32* %14
%15 = trunc i64 %12 to i32
%16 = xor i32 %15, -1
%17 = add i32 %16, %0
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i32, i32* %5, i64 %18
store i32 %13, i32* %19
%20 = add nuw nsw i64 %12, 1
%21 = icmp eq i64 %20, %10
br i1 %21, label %22, label %11
22: ; preds = %11
%23 = zext i32 %6 to i64
br label %24
24: ; preds = %2, %22
%25 = phi i64 [ %23, %22 ], [ 0, %2 ]
%26 = getelementptr inbounds i32, i32* %5, i64 %25
store i32 %1, i32* %26
ret i32* %5
}