#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*/ counting_sort(int *, int *, int, int, int);
int /*<<< orphan*/ printf(char *, ...);
void test_counting_sort_sub_routine_with_hundreds() {
  int expected[10] = {215, 329, 355, 422, 436, 457, 657, 720, 839, 901};
  int arr[10] = {901, 215, 720, 422, 329, 436, 839, 355, 457, 657};
  printf("hundreds\n");
  int result[10];
  counting_sort(arr, result, 10, 901, 100);
  for (int i = 0; i < 10; i++) {
    printf("expected: %d actual: %d\n", expected[i], result[i]);
    assert(expected[i] == result[i]);
  }
}


x86 assembly (clang, -O0):
<test_counting_sort_sub_routine_with_hundreds>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
lea    -0x30(%rbp),%rdi
lea    0xeaa(%rip),%rsi
mov    $0x28,%edx
call   1060 <memcpy@plt>
lea    -0x60(%rbp),%rdi
lea    0xec5(%rip),%rsi
mov    $0x28,%edx
call   1060 <memcpy@plt>
lea    0xedc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x60(%rbp),%rdi
lea    -0x90(%rbp),%rsi
mov    $0xa,%edx
mov    $0x385,%ecx
mov    $0x64,%r8d
call   1040 <counting_sort@plt>
movl   $0x0,-0x94(%rbp)
cmpl   $0xa,-0x94(%rbp)
jge    121b <test_counting_sort_sub_routine_with_hundreds+0xdb>
movslq -0x94(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%esi
movslq -0x94(%rbp),%rax
mov    -0x90(%rbp,%rax,4),%edx
lea    0xe88(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movslq -0x94(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%eax
movslq -0x94(%rbp),%rcx
cmp    -0x90(%rbp,%rcx,4),%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x94(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x94(%rbp)
jmp    11ad <test_counting_sort_sub_routine_with_hundreds+0x6d>
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_counting_sort_sub_routine_with_hundreds>:
push   %rbx
sub    $0x60,%rsp
mov    0xed4(%rip),%rax
mov    %rax,0x50(%rsp)
movaps 0xeb8(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xe9c(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
lea    0xed1(%rip),%rdi
call   1030 <puts@plt>
lea    0x30(%rsp),%rdi
mov    %rsp,%rsi
mov    $0xa,%edx
mov    $0x385,%ecx
mov    $0x64,%r8d
call   1050 <counting_sort@plt>
mov    (%rsp),%edx
lea    0xe8c(%rip),%rbx
mov    %rbx,%rdi
mov    $0xd7,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %edi,%edi
cmpl   $0xd7,(%rsp)
sete   %dil
call   1060 <assert@plt>
mov    0x4(%rsp),%edx
mov    %rbx,%rdi
mov    $0x149,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %edi,%edi
cmpl   $0x149,0x4(%rsp)
sete   %dil
call   1060 <assert@plt>
mov    0x8(%rsp),%edx
mov    %rbx,%rdi
mov    $0x163,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %edi,%edi
cmpl   $0x163,0x8(%rsp)
sete   %dil
call   1060 <assert@plt>
mov    0xc(%rsp),%edx
mov    %rbx,%rdi
mov    $0x1a6,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %edi,%edi
cmpl   $0x1a6,0xc(%rsp)
sete   %dil
call   1060 <assert@plt>
mov    0x10(%rsp),%edx
mov    %rbx,%rdi
mov    $0x1b4,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %edi,%edi
cmpl   $0x1b4,0x10(%rsp)
sete   %dil
call   1060 <assert@plt>
mov    0x14(%rsp),%edx
mov    %rbx,%rdi
mov    $0x1c9,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %edi,%edi
cmpl   $0x1c9,0x14(%rsp)
sete   %dil
call   1060 <assert@plt>
mov    0x18(%rsp),%edx
mov    %rbx,%rdi
mov    $0x291,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %edi,%edi
cmpl   $0x291,0x18(%rsp)
sete   %dil
call   1060 <assert@plt>
mov    0x1c(%rsp),%edx
mov    %rbx,%rdi
mov    $0x2d0,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %edi,%edi
cmpl   $0x2d0,0x1c(%rsp)
sete   %dil
call   1060 <assert@plt>
mov    0x20(%rsp),%edx
mov    %rbx,%rdi
mov    $0x347,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %edi,%edi
cmpl   $0x347,0x20(%rsp)
sete   %dil
call   1060 <assert@plt>
mov    0x24(%rsp),%edx
mov    %rbx,%rdi
mov    $0x385,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %edi,%edi
cmpl   $0x385,0x24(%rsp)
sete   %dil
call   1060 <assert@plt>
add    $0x60,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.test_counting_sort_sub_routine_with_hundreds.expected = [10 x i32] [i32 215, i32 329, i32 355, i32 422, i32 436, i32 457, i32 657, i32 720, i32 839, i32 901]
@__const.test_counting_sort_sub_routine_with_hundreds.arr = [10 x i32] [i32 901, i32 215, i32 720, i32 422, i32 329, i32 436, i32 839, i32 355, i32 457, i32 657]
@.str = [10 x i8] c"hundreds\0A\00"
@.str.1 = [25 x i8] c"expected: %d actual: %d\0A\00"
define void @test_counting_sort_sub_routine_with_hundreds() {
%1 = alloca [10 x i32]
%2 = alloca [10 x i32]
%3 = alloca [10 x i32]
%4 = alloca i32
%5 = bitcast [10 x i32]* %1 to i8*
%6 = bitcast [10 x i32]* %2 to i8*
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%8 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
%9 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 0
%10 = call i32 @counting_sort(i32* %8, i32* %9, i32 10, i32 901, i32 100)
store i32 0, i32* %4
br label %11
11: ; preds = %35, %0
%12 = load i32, i32* %4
%13 = icmp slt i32 %12, 10
br i1 %13, label %14, label %38
14: ; preds = %11
%15 = load i32, i32* %4
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 %16
%18 = load i32, i32* %17
%19 = load i32, i32* %4
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 %20
%22 = load i32, i32* %21
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 %18, i32 %22)
%24 = load i32, i32* %4
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 %25
%27 = load i32, i32* %26
%28 = load i32, i32* %4
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 %29
%31 = load i32, i32* %30
%32 = icmp eq i32 %27, %31
%33 = zext i1 %32 to i32
%34 = call i32 @assert(i32 %33)
br label %35
35: ; preds = %14
%36 = load i32, i32* %4
%37 = add nsw i32 %36, 1
store i32 %37, i32* %4
br label %11
38: ; preds = %11
ret void
}

LLVM IR (-O2):
@__const.test_counting_sort_sub_routine_with_hundreds.arr = [10 x i32] [i32 901, i32 215, i32 720, i32 422, i32 329, i32 436, i32 839, i32 355, i32 457, i32 657]
@.str.1 = [25 x i8] c"expected: %d actual: %d\0A\00"
@str = [9 x i8] c"hundreds\00"
define void @test_counting_sort_sub_routine_with_hundreds() {
%1 = alloca [10 x i32]
%2 = alloca [10 x i32]
%3 = bitcast [10 x i32]* %1 to i8*
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str, i64 0, i64 0))
%5 = bitcast [10 x i32]* %2 to i8*
%6 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 0
%7 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
%8 = call i32 @counting_sort(i32* %6, i32* %7, i32 10, i32 901, i32 100)
%9 = load i32, i32* %7
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 215, i32 %9)
%11 = load i32, i32* %7
%12 = icmp eq i32 %11, 215
%13 = zext i1 %12 to i32
%14 = call i32 @assert(i32 %13)
%15 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 1
%16 = load i32, i32* %15
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 329, i32 %16)
%18 = load i32, i32* %15
%19 = icmp eq i32 %18, 329
%20 = zext i1 %19 to i32
%21 = call i32 @assert(i32 %20)
%22 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 2
%23 = load i32, i32* %22
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 355, i32 %23)
%25 = load i32, i32* %22
%26 = icmp eq i32 %25, 355
%27 = zext i1 %26 to i32
%28 = call i32 @assert(i32 %27)
%29 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 3
%30 = load i32, i32* %29
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 422, i32 %30)
%32 = load i32, i32* %29
%33 = icmp eq i32 %32, 422
%34 = zext i1 %33 to i32
%35 = call i32 @assert(i32 %34)
%36 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 4
%37 = load i32, i32* %36
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 436, i32 %37)
%39 = load i32, i32* %36
%40 = icmp eq i32 %39, 436
%41 = zext i1 %40 to i32
%42 = call i32 @assert(i32 %41)
%43 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 5
%44 = load i32, i32* %43
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 457, i32 %44)
%46 = load i32, i32* %43
%47 = icmp eq i32 %46, 457
%48 = zext i1 %47 to i32
%49 = call i32 @assert(i32 %48)
%50 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 6
%51 = load i32, i32* %50
%52 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 657, i32 %51)
%53 = load i32, i32* %50
%54 = icmp eq i32 %53, 657
%55 = zext i1 %54 to i32
%56 = call i32 @assert(i32 %55)
%57 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 7
%58 = load i32, i32* %57
%59 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 720, i32 %58)
%60 = load i32, i32* %57
%61 = icmp eq i32 %60, 720
%62 = zext i1 %61 to i32
%63 = call i32 @assert(i32 %62)
%64 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 8
%65 = load i32, i32* %64
%66 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 839, i32 %65)
%67 = load i32, i32* %64
%68 = icmp eq i32 %67, 839
%69 = zext i1 %68 to i32
%70 = call i32 @assert(i32 %69)
%71 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 9
%72 = load i32, i32* %71
%73 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 901, i32 %72)
%74 = load i32, i32* %71
%75 = icmp eq i32 %74, 901
%76 = zext i1 %75 to i32
%77 = call i32 @assert(i32 %76)
ret void
}