#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 /*<<< orphan*/ countingSort(int *, int, int);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char **argv) {
  int i;
  int ar[7] = {3, 0, 2, 0, 0, 2, 2};
  countingSort(ar, 7, 4);
  for (i = 0; i < 7 - 1; i++) {
    printf("%d ", ar[i]);
  }
  printf("\n");
  for (i = 0; i < 7 - 1; i++) {
    assert(ar[i] <= ar[i + 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    0xeb3(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xeb0(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xead(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xeab(%rip),%eax
mov    %eax,-0x18(%rbp)
lea    -0x30(%rbp),%rdi
mov    $0x7,%esi
mov    $0x4,%edx
call   1050 <countingSort@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x6,-0x14(%rbp)
jge    11b8 <main+0x88>
movslq -0x14(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%esi
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    118a <main+0x5a>
lea    0xe61(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x6,-0x14(%rbp)
jge    1207 <main+0xd7>
movslq -0x14(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%eax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
cmp    -0x30(%rbp,%rcx,4),%eax
setle  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11cd <main+0x9d>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
movups 0xec0(%rip),%xmm0
movups %xmm0,0xc(%rsp)
movaps 0xea8(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rdi
mov    $0x7,%esi
mov    $0x4,%edx
call   1060 <countingSort@plt>
mov    (%rsp),%esi
lea    0xea4(%rip),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x10(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x14(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    (%rsp),%eax
xor    %edi,%edi
cmp    0x4(%rsp),%eax
setle  %dil
call   1050 <assert@plt>
mov    0x4(%rsp),%eax
xor    %edi,%edi
cmp    0x8(%rsp),%eax
setle  %dil
call   1050 <assert@plt>
mov    0x8(%rsp),%eax
xor    %edi,%edi
cmp    0xc(%rsp),%eax
setle  %dil
call   1050 <assert@plt>
mov    0xc(%rsp),%eax
xor    %edi,%edi
cmp    0x10(%rsp),%eax
setle  %dil
call   1050 <assert@plt>
mov    0x10(%rsp),%eax
xor    %edi,%edi
cmp    0x14(%rsp),%eax
setle  %dil
call   1050 <assert@plt>
mov    0x14(%rsp),%eax
xor    %edi,%edi
cmp    0x18(%rsp),%eax
setle  %dil
call   1050 <assert@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

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

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