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

/* Variables and functions */
int /*<<< orphan*/ assert(int);
scalar_t__ memcmp(int *, int *, int);
int /*<<< orphan*/ sort_array_of_zeros_ones_and_twos_ver1(int *, int);
int /*<<< orphan*/ sort_array_of_zeros_ones_and_twos_ver2(int *, int);
int main() {
  int array_test_ver1_1[] = {2, 2, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0};
  int array_expect_ver1_1[] = {0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2};
  sort_array_of_zeros_ones_and_twos_ver1(
      array_test_ver1_1, sizeof(array_test_ver1_1) / sizeof(int));
  assert(memcmp(array_test_ver1_1, array_expect_ver1_1,
                sizeof(array_test_ver1_1)) == 0);
  int array_test_ver2_1[] = {2, 2, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0};
  int array_expect_ver2_1[] = {0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2};
  sort_array_of_zeros_ones_and_twos_ver2(
      array_test_ver2_1, sizeof(array_test_ver2_1) / sizeof(int));
  assert(memcmp(array_test_ver2_1, array_expect_ver2_1,
                sizeof(array_test_ver2_1)) == 0);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x40(%rbp),%rdi
lea    0xe93(%rip),%rsi
mov    $0x38,%edx
call   1060 <memcpy@plt>
lea    -0x80(%rbp),%rdi
lea    0xebe(%rip),%rsi
mov    $0x38,%edx
call   1060 <memcpy@plt>
lea    -0x40(%rbp),%rdi
mov    $0xe,%esi
call   1040 <sort_array_of_zeros_ones_and_twos_ver1@plt>
lea    -0x40(%rbp),%rdi
lea    -0x80(%rbp),%rsi
mov    $0x38,%edx
call   1030 <memcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
lea    -0xc0(%rbp),%rdi
lea    0xeb5(%rip),%rsi
mov    $0x38,%edx
call   1060 <memcpy@plt>
lea    -0x100(%rbp),%rdi
lea    0xedd(%rip),%rsi
mov    $0x38,%edx
call   1060 <memcpy@plt>
lea    -0xc0(%rbp),%rdi
mov    $0xe,%esi
call   1070 <sort_array_of_zeros_ones_and_twos_ver2@plt>
lea    -0xc0(%rbp),%rdi
lea    -0x100(%rbp),%rsi
mov    $0x38,%edx
call   1030 <memcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
xor    %eax,%eax
add    $0x100,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x100,%rsp
mov    0xedd(%rip),%r14
mov    %r14,0xf0(%rsp)
movaps 0xebe(%rip),%xmm0
movaps %xmm0,0xe0(%rsp)
movaps 0xe9f(%rip),%xmm0
movaps %xmm0,0xd0(%rsp)
movaps 0xe80(%rip),%xmm0
movaps %xmm0,0xc0(%rsp)
mov    0xee1(%rip),%r15
mov    %r15,0xb0(%rsp)
movaps 0xec2(%rip),%xmm0
movaps %xmm0,0xa0(%rsp)
movaps 0xea3(%rip),%xmm0
movaps %xmm0,0x90(%rsp)
movaps 0xe84(%rip),%xmm0
movaps %xmm0,0x80(%rsp)
lea    0xc0(%rsp),%rbx
mov    %rbx,%rdi
mov    $0xe,%esi
call   1040 <sort_array_of_zeros_ones_and_twos_ver1@plt>
lea    0x80(%rsp),%rsi
mov    %rbx,%rdi
mov    $0x38,%edx
call   1030 <memcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1050 <assert@plt>
mov    %r14,0x70(%rsp)
movaps 0xe18(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
movaps 0xdfc(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0xde0(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
mov    %r15,0x30(%rsp)
movaps 0xe2f(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xe13(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xdf7(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0x40(%rsp),%rbx
mov    %rbx,%rdi
mov    $0xe,%esi
call   1060 <sort_array_of_zeros_ones_and_twos_ver2@plt>
mov    %rsp,%rsi
mov    %rbx,%rdi
mov    $0x38,%edx
call   1030 <memcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1050 <assert@plt>
xor    %eax,%eax
add    $0x100,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.array_test_ver1_1 = [14 x i32] [i32 2, i32 2, i32 2, i32 2, i32 1, i32 1, i32 1, i32 1, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0]
@__const.main.array_expect_ver1_1 = [14 x i32] [i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 1, i32 1, i32 1, i32 1, i32 2, i32 2, i32 2, i32 2]
@__const.main.array_test_ver2_1 = [14 x i32] [i32 2, i32 2, i32 2, i32 2, i32 1, i32 1, i32 1, i32 1, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0]
@__const.main.array_expect_ver2_1 = [14 x i32] [i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 1, i32 1, i32 1, i32 1, i32 2, i32 2, i32 2, i32 2]
define i32 @main() {
%1 = alloca i32
%2 = alloca [14 x i32]
%3 = alloca [14 x i32]
%4 = alloca [14 x i32]
%5 = alloca [14 x i32]
store i32 0, i32* %1
%6 = bitcast [14 x i32]* %2 to i8*
%7 = bitcast [14 x i32]* %3 to i8*
%8 = getelementptr inbounds [14 x i32], [14 x i32]* %2, i64 0, i64 0
%9 = call i32 @sort_array_of_zeros_ones_and_twos_ver1(i32* %8, i32 14)
%10 = getelementptr inbounds [14 x i32], [14 x i32]* %2, i64 0, i64 0
%11 = getelementptr inbounds [14 x i32], [14 x i32]* %3, i64 0, i64 0
%12 = call i64 @memcmp(i32* %10, i32* %11, i32 56)
%13 = icmp eq i64 %12, 0
%14 = zext i1 %13 to i32
%15 = call i32 @assert(i32 %14)
%16 = bitcast [14 x i32]* %4 to i8*
%17 = bitcast [14 x i32]* %5 to i8*
%18 = getelementptr inbounds [14 x i32], [14 x i32]* %4, i64 0, i64 0
%19 = call i32 @sort_array_of_zeros_ones_and_twos_ver2(i32* %18, i32 14)
%20 = getelementptr inbounds [14 x i32], [14 x i32]* %4, i64 0, i64 0
%21 = getelementptr inbounds [14 x i32], [14 x i32]* %5, i64 0, i64 0
%22 = call i64 @memcmp(i32* %20, i32* %21, i32 56)
%23 = icmp eq i64 %22, 0
%24 = zext i1 %23 to i32
%25 = call i32 @assert(i32 %24)
ret i32 0
}

LLVM IR (-O2):
@__const.main.array_test_ver2_1 = [14 x i32] [i32 2, i32 2, i32 2, i32 2, i32 1, i32 1, i32 1, i32 1, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0]
@__const.main.array_expect_ver2_1 = [14 x i32] [i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 1, i32 1, i32 1, i32 1, i32 2, i32 2, i32 2, i32 2]
define i32 @main() {
%1 = alloca [14 x i32]
%2 = alloca [14 x i32]
%3 = alloca [14 x i32]
%4 = alloca [14 x i32]
%5 = bitcast [14 x i32]* %1 to i8*
%6 = bitcast [14 x i32]* %2 to i8*
%7 = getelementptr inbounds [14 x i32], [14 x i32]* %1, i64 0, i64 0
%8 = call i32 @sort_array_of_zeros_ones_and_twos_ver1(i32* %7, i32 14)
%9 = getelementptr inbounds [14 x i32], [14 x i32]* %2, i64 0, i64 0
%10 = call i64 @memcmp(i32* %7, i32* %9, i32 56)
%11 = icmp eq i64 %10, 0
%12 = zext i1 %11 to i32
%13 = call i32 @assert(i32 %12)
%14 = bitcast [14 x i32]* %3 to i8*
%15 = bitcast [14 x i32]* %4 to i8*
%16 = getelementptr inbounds [14 x i32], [14 x i32]* %3, i64 0, i64 0
%17 = call i32 @sort_array_of_zeros_ones_and_twos_ver2(i32* %16, i32 14)
%18 = getelementptr inbounds [14 x i32], [14 x i32]* %4, i64 0, i64 0
%19 = call i64 @memcmp(i32* %16, i32* %18, i32 56)
%20 = icmp eq i64 %19, 0
%21 = zext i1 %20 to i32
%22 = call i32 @assert(i32 %21)
ret i32 0
}