#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*/ printf(char *, ...);
int /*<<< orphan*/ sortColors(int *, int);
int main() {
  int n[] = {0, 2, 1, 0, 2, 0, 2, 0, 2, 1, 1, 2, 0, 2, 1, 2};
  sortColors(n, 16);
  for (int i = 0; i < 16; i++)
    printf("%d ", n[i]);
  printf("\n");
  int m[] = {2, 0, 0};
  sortColors(m, 3);
  for (int i = 0; i < 3; i++)
    printf("%d ", m[i]);
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x50(%rbp),%rdi
lea    0xeb6(%rip),%rsi
mov    $0x40,%edx
call   1050 <memcpy@plt>
lea    -0x50(%rbp),%rdi
mov    $0x10,%esi
call   1030 <sortColors@plt>
movl   $0x0,-0x54(%rbp)
cmpl   $0x10,-0x54(%rbp)
jge    1197 <main+0x67>
movslq -0x54(%rbp),%rax
mov    -0x50(%rbp,%rax,4),%esi
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    1169 <main+0x39>
lea    0xeb2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0xe94(%rip),%rax
mov    %rax,-0x60(%rbp)
mov    0xe92(%rip),%eax
mov    %eax,-0x58(%rbp)
lea    -0x60(%rbp),%rdi
mov    $0x3,%esi
call   1030 <sortColors@plt>
movl   $0x0,-0x64(%rbp)
cmpl   $0x3,-0x64(%rbp)
jge    11fc <main+0xcc>
movslq -0x64(%rbp),%rax
mov    -0x60(%rbp,%rax,4),%esi
lea    0xe65(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    11ce <main+0x9e>
lea    0xe4d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x50,%rsp
movaps 0xef4(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xed8(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xebc(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xea0(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
lea    0x10(%rsp),%rdi
mov    $0x10,%esi
call   1030 <sortColors@plt>
mov    0x10(%rsp),%esi
lea    0xecd(%rip),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x14(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x18(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x1c(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x20(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x24(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x28(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2c(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x30(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x34(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x38(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x3c(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x40(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x44(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x48(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x4c(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    0xddd(%rip),%eax
mov    %eax,0x8(%rsp)
mov    0xdca(%rip),%rax
mov    %rax,(%rsp)
mov    %rsp,%rdi
mov    $0x3,%esi
call   1030 <sortColors@plt>
mov    (%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x4(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.n = [16 x i32] [i32 0, i32 2, i32 1, i32 0, i32 2, i32 0, i32 2, i32 0, i32 2, i32 1, i32 1, i32 2, i32 0, i32 2, i32 1, i32 2]
@.str = [4 x i8] c"%d \00"
@.str.1 = [2 x i8] c"\0A\00"
@__const.main.m = [3 x i32] [i32 2, i32 0, i32 0]
define i32 @main() {
%1 = alloca i32
%2 = alloca [16 x i32]
%3 = alloca i32
%4 = alloca [3 x i32]
%5 = alloca i32
store i32 0, i32* %1
%6 = bitcast [16 x i32]* %2 to i8*
%7 = getelementptr inbounds [16 x i32], [16 x i32]* %2, i64 0, i64 0
%8 = call i32 @sortColors(i32* %7, i32 16)
store i32 0, i32* %3
br label %9
9: ; preds = %18, %0
%10 = load i32, i32* %3
%11 = icmp slt i32 %10, 16
br i1 %11, label %12, label %21
12: ; preds = %9
%13 = load i32, i32* %3
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [16 x i32], [16 x i32]* %2, i64 0, i64 %14
%16 = load i32, i32* %15
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %16)
br label %18
18: ; preds = %12
%19 = load i32, i32* %3
%20 = add nsw i32 %19, 1
store i32 %20, i32* %3
br label %9
21: ; preds = %9
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%23 = bitcast [3 x i32]* %4 to i8*
%24 = getelementptr inbounds [3 x i32], [3 x i32]* %4, i64 0, i64 0
%25 = call i32 @sortColors(i32* %24, i32 3)
store i32 0, i32* %5
br label %26
26: ; preds = %35, %21
%27 = load i32, i32* %5
%28 = icmp slt i32 %27, 3
br i1 %28, label %29, label %38
29: ; preds = %26
%30 = load i32, i32* %5
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [3 x i32], [3 x i32]* %4, i64 0, i64 %31
%33 = load i32, i32* %32
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %33)
br label %35
35: ; preds = %29
%36 = load i32, i32* %5
%37 = add nsw i32 %36, 1
store i32 %37, i32* %5
br label %26
38: ; preds = %26
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@__const.main.n = [16 x i32] [i32 0, i32 2, i32 1, i32 0, i32 2, i32 0, i32 2, i32 0, i32 2, i32 1, i32 1, i32 2, i32 0, i32 2, i32 1, i32 2]
@.str = [4 x i8] c"%d \00"
@__const.main.m = [3 x i32] [i32 2, i32 0, i32 0]
define i32 @main() {
%1 = alloca [16 x i32]
%2 = alloca [3 x i32]
%3 = bitcast [16 x i32]* %1 to i8*
%4 = getelementptr inbounds [16 x i32], [16 x i32]* %1, i64 0, i64 0
%5 = call i32 @sortColors(i32* %4, i32 16)
%6 = load i32, i32* %4
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = getelementptr inbounds [16 x i32], [16 x i32]* %1, i64 0, i64 1
%9 = load i32, i32* %8
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = getelementptr inbounds [16 x i32], [16 x i32]* %1, i64 0, i64 2
%12 = load i32, i32* %11
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %12)
%14 = getelementptr inbounds [16 x i32], [16 x i32]* %1, i64 0, i64 3
%15 = load i32, i32* %14
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %15)
%17 = getelementptr inbounds [16 x i32], [16 x i32]* %1, i64 0, i64 4
%18 = load i32, i32* %17
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %18)
%20 = getelementptr inbounds [16 x i32], [16 x i32]* %1, i64 0, i64 5
%21 = load i32, i32* %20
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %21)
%23 = getelementptr inbounds [16 x i32], [16 x i32]* %1, i64 0, i64 6
%24 = load i32, i32* %23
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %24)
%26 = getelementptr inbounds [16 x i32], [16 x i32]* %1, i64 0, i64 7
%27 = load i32, i32* %26
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %27)
%29 = getelementptr inbounds [16 x i32], [16 x i32]* %1, i64 0, i64 8
%30 = load i32, i32* %29
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %30)
%32 = getelementptr inbounds [16 x i32], [16 x i32]* %1, i64 0, i64 9
%33 = load i32, i32* %32
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %33)
%35 = getelementptr inbounds [16 x i32], [16 x i32]* %1, i64 0, i64 10
%36 = load i32, i32* %35
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %36)
%38 = getelementptr inbounds [16 x i32], [16 x i32]* %1, i64 0, i64 11
%39 = load i32, i32* %38
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %39)
%41 = getelementptr inbounds [16 x i32], [16 x i32]* %1, i64 0, i64 12
%42 = load i32, i32* %41
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %42)
%44 = getelementptr inbounds [16 x i32], [16 x i32]* %1, i64 0, i64 13
%45 = load i32, i32* %44
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %45)
%47 = getelementptr inbounds [16 x i32], [16 x i32]* %1, i64 0, i64 14
%48 = load i32, i32* %47
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %48)
%50 = getelementptr inbounds [16 x i32], [16 x i32]* %1, i64 0, i64 15
%51 = load i32, i32* %50
%52 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %51)
%53 = call i32 @putchar(i32 10)
%54 = bitcast [3 x i32]* %2 to i8*
%55 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 0
%56 = call i32 @sortColors(i32* %55, i32 3)
%57 = load i32, i32* %55
%58 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %57)
%59 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 1
%60 = load i32, i32* %59
%61 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %60)
%62 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 2
%63 = load i32, i32* %62
%64 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %63)
%65 = call i32 @putchar(i32 10)
ret i32 0
}