#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*/ count_sort(int, int *, int, int);
int /*<<< orphan*/ print_list(int *, int);
int /*<<< orphan*/ printf(char *);
int rand();
int main() {
  int size = 25;
  int l[25];
  int c;
  for (c = 0; c < size; c++) {
    l[c] = (rand() % 25) + 25;
  }
  printf("out of order: \n");
  print_list(l, size);
  printf("in order: \n");
  count_sort(size, l, 25, 50);
  print_list(l, size);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x19,-0x8(%rbp)
movl   $0x0,-0x74(%rbp)
mov    -0x74(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1194 <main+0x54>
mov    $0x0,%al
call   1060 <rand@plt>
mov    $0x19,%ecx
cltd
idiv   %ecx
add    $0x19,%edx
movslq -0x74(%rbp),%rax
mov    %edx,-0x70(%rbp,%rax,4)
mov    -0x74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x74(%rbp)
jmp    1160 <main+0x20>
lea    0xe65(%rip),%rdi
call   1040 <printf@plt>
lea    -0x70(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1030 <print_list@plt>
lea    0xe5d(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%edi
lea    -0x70(%rbp),%rsi
mov    $0x19,%edx
mov    $0x32,%ecx
call   1050 <count_sort@plt>
lea    -0x70(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1030 <print_list@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x70,%rsp
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1060 <rand@plt>
cltq
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x23,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,4),%ecx
lea    (%rcx,%rcx,4),%ecx
neg    %ecx
add    %ecx,%eax
add    $0x19,%eax
mov    %eax,(%rsp,%rbx,4)
add    $0x1,%rbx
cmp    $0x19,%rbx
jne    1150 <main+0x10>
lea    0xe72(%rip),%rdi
call   1030 <puts@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x19,%esi
call   1040 <print_list@plt>
lea    0xe65(%rip),%rdi
call   1030 <puts@plt>
mov    $0x19,%edi
mov    %rbx,%rsi
mov    $0x19,%edx
mov    $0x32,%ecx
call   1050 <count_sort@plt>
mov    %rbx,%rdi
mov    $0x19,%esi
call   1040 <print_list@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [16 x i8] c"out of order: \0A\00"
@.str.1 = [12 x i8] c"in order: \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [25 x i32]
%4 = alloca i32
store i32 0, i32* %1
store i32 25, i32* %2
store i32 0, i32* %4
br label %5
5: ; preds = %16, %0
%6 = load i32, i32* %4
%7 = load i32, i32* %2
%8 = icmp slt i32 %6, %7
br i1 %8, label %9, label %19
9: ; preds = %5
%10 = call i32 (...) @rand()
%11 = srem i32 %10, 25
%12 = add nsw i32 %11, 25
%13 = load i32, i32* %4
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [25 x i32], [25 x i32]* %3, i64 0, i64 %14
store i32 %12, i32* %15
br label %16
16: ; preds = %9
%17 = load i32, i32* %4
%18 = add nsw i32 %17, 1
store i32 %18, i32* %4
br label %5
19: ; preds = %5
%20 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%21 = getelementptr inbounds [25 x i32], [25 x i32]* %3, i64 0, i64 0
%22 = load i32, i32* %2
%23 = call i32 @print_list(i32* %21, i32 %22)
%24 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%25 = load i32, i32* %2
%26 = getelementptr inbounds [25 x i32], [25 x i32]* %3, i64 0, i64 0
%27 = call i32 @count_sort(i32 %25, i32* %26, i32 25, i32 50)
%28 = getelementptr inbounds [25 x i32], [25 x i32]* %3, i64 0, i64 0
%29 = load i32, i32* %2
%30 = call i32 @print_list(i32* %28, i32 %29)
ret i32 0
}

LLVM IR (-O2):
@str = [15 x i8] c"out of order: \00"
@str.2 = [11 x i8] c"in order: \00"
define i32 @main() {
%1 = alloca [25 x i32]
%2 = bitcast [25 x i32]* %1 to i8*
br label %3
3: ; preds = %0, %3
%4 = phi i64 [ 0, %0 ], [ %9, %3 ]
%5 = tail call i32 (...) @rand()
%6 = srem i32 %5, 25
%7 = add nsw i32 %6, 25
%8 = getelementptr inbounds [25 x i32], [25 x i32]* %1, i64 0, i64 %4
store i32 %7, i32* %8
%9 = add nuw nsw i64 %4, 1
%10 = icmp eq i64 %9, 25
br i1 %10, label %11, label %3
11: ; preds = %3
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
%13 = getelementptr inbounds [25 x i32], [25 x i32]* %1, i64 0, i64 0
%14 = call i32 @print_list(i32* %13, i32 25)
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.2, i64 0, i64 0))
%16 = call i32 @count_sort(i32 25, i32* %13, i32 25, i32 50)
%17 = call i32 @print_list(i32* %13, i32 25)
ret i32 0
}