#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 *sortArrayByParity(int *, int, int *);
int main(int argc, char **argv) {
  int A[] = {3, 1, 2, 4};
  int ASize = 4;
  int returnSize = 0;
  int *retval = sortArrayByParity(A, ASize, &returnSize);
  assert(returnSize == ASize);
  assert(retval[0] == 2);
  assert(retval[1] == 4);
  assert(retval[2] == 3);
  assert(retval[3] == 1);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xec3(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xec0(%rip),%rax
mov    %rax,-0x18(%rbp)
movl   $0x4,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
lea    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%esi
lea    -0x28(%rbp),%rdx
call   1030 <sortArrayByParity@plt>
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x30(%rbp),%rax
cmpl   $0x2,(%rax)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x30(%rbp),%rax
cmpl   $0x4,0x4(%rax)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x30(%rbp),%rax
cmpl   $0x3,0x8(%rax)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x30(%rbp),%rax
cmpl   $0x1,0xc(%rax)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
movaps 0xed4(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movl   $0x0,0xc(%rsp)
lea    0x10(%rsp),%rdi
lea    0xc(%rsp),%rdx
mov    $0x4,%esi
call   1030 <sortArrayByParity@plt>
mov    %rax,%rbx
xor    %edi,%edi
cmpl   $0x4,0xc(%rsp)
sete   %dil
call   1040 <assert@plt>
xor    %edi,%edi
cmpl   $0x2,(%rbx)
sete   %dil
call   1040 <assert@plt>
xor    %edi,%edi
cmpl   $0x4,0x4(%rbx)
sete   %dil
call   1040 <assert@plt>
xor    %edi,%edi
cmpl   $0x3,0x8(%rbx)
sete   %dil
call   1040 <assert@plt>
xor    %edi,%edi
cmpl   $0x1,0xc(%rbx)
sete   %dil
call   1040 <assert@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.A = [4 x i32] [i32 3, i32 1, i32 2, i32 4]
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [4 x i32]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = bitcast [4 x i32]* %6 to i8*
store i32 4, i32* %7
store i32 0, i32* %8
%11 = getelementptr inbounds [4 x i32], [4 x i32]* %6, i64 0, i64 0
%12 = load i32, i32* %7
%13 = call i32* @sortArrayByParity(i32* %11, i32 %12, i32* %8)
store i32* %13, i32** %9
%14 = load i32, i32* %8
%15 = load i32, i32* %7
%16 = icmp eq i32 %14, %15
%17 = zext i1 %16 to i32
%18 = call i32 @assert(i32 %17)
%19 = load i32*, i32** %9
%20 = getelementptr inbounds i32, i32* %19, i64 0
%21 = load i32, i32* %20
%22 = icmp eq i32 %21, 2
%23 = zext i1 %22 to i32
%24 = call i32 @assert(i32 %23)
%25 = load i32*, i32** %9
%26 = getelementptr inbounds i32, i32* %25, i64 1
%27 = load i32, i32* %26
%28 = icmp eq i32 %27, 4
%29 = zext i1 %28 to i32
%30 = call i32 @assert(i32 %29)
%31 = load i32*, i32** %9
%32 = getelementptr inbounds i32, i32* %31, i64 2
%33 = load i32, i32* %32
%34 = icmp eq i32 %33, 3
%35 = zext i1 %34 to i32
%36 = call i32 @assert(i32 %35)
%37 = load i32*, i32** %9
%38 = getelementptr inbounds i32, i32* %37, i64 3
%39 = load i32, i32* %38
%40 = icmp eq i32 %39, 1
%41 = zext i1 %40 to i32
%42 = call i32 @assert(i32 %41)
ret i32 0
}

LLVM IR (-O2):
@__const.main.A = [4 x i32] [i32 3, i32 1, i32 2, i32 4]
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [4 x i32]
%4 = alloca i32
%5 = bitcast [4 x i32]* %3 to i8*
%6 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%7 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 0
%8 = call i32* @sortArrayByParity(i32* %7, i32 4, i32* %4)
%9 = load i32, i32* %4
%10 = icmp eq i32 %9, 4
%11 = zext i1 %10 to i32
%12 = call i32 @assert(i32 %11)
%13 = load i32, i32* %8
%14 = icmp eq i32 %13, 2
%15 = zext i1 %14 to i32
%16 = call i32 @assert(i32 %15)
%17 = getelementptr inbounds i32, i32* %8, i64 1
%18 = load i32, i32* %17
%19 = icmp eq i32 %18, 4
%20 = zext i1 %19 to i32
%21 = call i32 @assert(i32 %20)
%22 = getelementptr inbounds i32, i32* %8, i64 2
%23 = load i32, i32* %22
%24 = icmp eq i32 %23, 3
%25 = zext i1 %24 to i32
%26 = call i32 @assert(i32 %25)
%27 = getelementptr inbounds i32, i32* %8, i64 3
%28 = load i32, i32* %27
%29 = icmp eq i32 %28, 1
%30 = zext i1 %29 to i32
%31 = call i32 @assert(i32 %30)
ret i32 0
}