#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 *, ...);
void print_counting_sort(int n, int hcs[n]) {
  int i, j, ai, f = 1;
  for (i = 0; i < n; i++) {
    ai = i + 20;
    for (j = 0; j < hcs[i]; j++) {
      if (!f)
        printf(" ");
      printf("%d", ai);
      f = 0;
    }
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<print_counting_sort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x20(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11ae <print_counting_sort+0x9e>
mov    -0x14(%rbp),%eax
add    $0x14,%eax
mov    %eax,-0x1c(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x10(%rbp),%rcx
movslq -0x14(%rbp),%rdx
cmp    (%rcx,%rdx,4),%eax
jge    119b <print_counting_sort+0x8b>
cmpl   $0x0,-0x20(%rbp)
jne    1175 <print_counting_sort+0x65>
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%esi
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1149 <print_counting_sort+0x39>
jmp    11a0 <print_counting_sort+0x90>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    112d <print_counting_sort+0x1d>
lea    0xe50(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_counting_sort>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %edi,%edi
jle    11b5 <print_counting_sort+0x95>
mov    %rsi,%r12
mov    %edi,%eax
mov    %rax,(%rsp)
mov    $0x1,%ebp
xor    %ebx,%ebx
lea    0xeb6(%rip),%r14
jmp    115a <print_counting_sort+0x3a>
nopl   0x0(%rax)
add    $0x1,%rbx
cmp    (%rsp),%rbx
je     11b5 <print_counting_sort+0x95>
cmpl   $0x0,(%r12,%rbx,4)
jle    1150 <print_counting_sort+0x30>
test   %ebp,%ebp
jne    116f <print_counting_sort+0x4f>
mov    $0x20,%edi
call   1030 <putchar@plt>
lea    0x14(%rbx),%r13d
xor    %ebp,%ebp
mov    %r14,%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
cmpl   $0x2,(%r12,%rbx,4)
jl     1150 <print_counting_sort+0x30>
mov    $0x1,%r15d
nop
mov    $0x20,%edi
call   1030 <putchar@plt>
xor    %ebp,%ebp
mov    %r14,%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%r15d
cmp    (%r12,%rbx,4),%r15d
jl     1190 <print_counting_sort+0x70>
jmp    1150 <print_counting_sort+0x30>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

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

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
define void @print_counting_sort(i32 %0, i32* nocapture %1) {
%3 = icmp sgt i32 %0, 0
br i1 %3, label %4, label %33
4: ; preds = %2
%5 = zext i32 %0 to i64
br label %6
6: ; preds = %4, %29
%7 = phi i64 [ 0, %4 ], [ %31, %29 ]
%8 = phi i32 [ 1, %4 ], [ %30, %29 ]
%9 = getelementptr inbounds i32, i32* %1, i64 %7
%10 = load i32, i32* %9
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %29
12: ; preds = %6
%13 = icmp eq i32 %8, 0
br i1 %13, label %14, label %16
14: ; preds = %12
%15 = tail call i32 @putchar(i32 32)
br label %16
16: ; preds = %14, %12
%17 = trunc i64 %7 to i32
%18 = add i32 %17, 20
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %18)
%20 = load i32, i32* %9
%21 = icmp sgt i32 %20, 1
br i1 %21, label %22, label %29
22: ; preds = %16, %22
%23 = phi i32 [ %26, %22 ], [ 1, %16 ]
%24 = tail call i32 @putchar(i32 32)
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %18)
%26 = add nuw nsw i32 %23, 1
%27 = load i32, i32* %9
%28 = icmp slt i32 %26, %27
br i1 %28, label %22, label %29
29: ; preds = %22, %16, %6
%30 = phi i32 [ %8, %6 ], [ 0, %16 ], [ 0, %22 ]
%31 = add nuw nsw i64 %7, 1
%32 = icmp eq i64 %31, %5
br i1 %32, label %33, label %6
33: ; preds = %29, %2
%34 = tail call i32 @putchar(i32 10)
ret void
}