#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 atoi(char *);
int /*<<< orphan*/ check_is_inc_arr(int *, int);
int /*<<< orphan*/ counting_sort(int *, int *, int, int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ initArr(int *, int, int, int);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ srand(int);
scalar_t__ time(int /*<<< orphan*/ *);
int main(int argc, char **argv) {
  if (argc != 4) {
    printf("input array length and the random value range.\n");
    exit(0);
  }
  srand((int)time(NULL));
  int length = atoi(argv[1]);
  int lowV = atoi(argv[2]);
  int upV = atoi(argv[3]);
  int *arr = (int *)malloc(sizeof(int) * (length));
  int *new_arr = (int *)malloc(sizeof(int) * length);
  int i = 1000;
  for (; i > 0; i--) {
    initArr(arr, lowV, upV, length);
    counting_sort(arr, new_arr, length, upV);
    check_is_inc_arr(new_arr, length);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x4,-0x8(%rbp)
je     11c3 <main+0x33>
lea    0xe49(%rip),%rdi
call   1030 <printf@plt>
xor    %edi,%edi
call   10a0 <exit@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x1c(%rbp)
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x28(%rbp)
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x30(%rbp)
movl   $0x3e8,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
jle    1279 <main+0xe9>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x14(%rbp),%ecx
call   1080 <initArr@plt>
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x1c(%rbp),%ecx
call   1040 <counting_sort@plt>
mov    -0x30(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   10b0 <check_is_inc_arr@plt>
mov    -0x34(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x34(%rbp)
jmp    1230 <main+0xa0>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x4,%edi
jne    1243 <main+0xb3>
mov    %rsi,%rbp
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
mov    0x8(%rbp),%rdi
call   1090 <atoi@plt>
mov    %eax,%ebx
mov    0x10(%rbp),%rdi
call   1090 <atoi@plt>
mov    %eax,%r14d
mov    0x18(%rbp),%rdi
call   1090 <atoi@plt>
mov    %eax,%r15d
mov    %ebx,%ebp
shl    $0x2,%ebp
mov    %ebp,%edi
call   1070 <malloc@plt>
mov    %rax,%r12
mov    %ebp,%edi
call   1070 <malloc@plt>
mov    %rax,%r13
mov    $0x3e9,%ebp
cs nopw 0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    %r14d,%esi
mov    %r15d,%edx
mov    %ebx,%ecx
call   1080 <initArr@plt>
mov    %r12,%rdi
mov    %r13,%rsi
mov    %ebx,%edx
mov    %r15d,%ecx
call   1040 <counting_sort@plt>
mov    %r13,%rdi
mov    %ebx,%esi
call   10b0 <check_is_inc_arr@plt>
add    $0xffffffff,%ebp
cmp    $0x1,%ebp
ja     1200 <main+0x70>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xdb6(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [48 x i8] c"input array length and the random value range.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i32, i32* %4
%13 = icmp ne i32 %12, 4
br i1 %13, label %14, label %17
14: ; preds = %2
%15 = call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0))
%16 = call i32 @exit(i32 0)
unreachable
17: ; preds = %2
%18 = call i64 @time(i32* null)
%19 = trunc i64 %18 to i32
%20 = call i32 @srand(i32 %19)
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = call i32 @atoi(i8* %23)
store i32 %24, i32* %6
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 2
%27 = load i8*, i8** %26
%28 = call i32 @atoi(i8* %27)
store i32 %28, i32* %7
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 3
%31 = load i8*, i8** %30
%32 = call i32 @atoi(i8* %31)
store i32 %32, i32* %8
%33 = load i32, i32* %6
%34 = sext i32 %33 to i64
%35 = mul i64 4, %34
%36 = trunc i64 %35 to i32
%37 = call i64 @malloc(i32 %36)
%38 = inttoptr i64 %37 to i32*
store i32* %38, i32** %9
%39 = load i32, i32* %6
%40 = sext i32 %39 to i64
%41 = mul i64 4, %40
%42 = trunc i64 %41 to i32
%43 = call i64 @malloc(i32 %42)
%44 = inttoptr i64 %43 to i32*
store i32* %44, i32** %10
store i32 1000, i32* %11
br label %45
45: ; preds = %62, %17
%46 = load i32, i32* %11
%47 = icmp sgt i32 %46, 0
br i1 %47, label %48, label %65
48: ; preds = %45
%49 = load i32*, i32** %9
%50 = load i32, i32* %7
%51 = load i32, i32* %8
%52 = load i32, i32* %6
%53 = call i32 @initArr(i32* %49, i32 %50, i32 %51, i32 %52)
%54 = load i32*, i32** %9
%55 = load i32*, i32** %10
%56 = load i32, i32* %6
%57 = load i32, i32* %8
%58 = call i32 @counting_sort(i32* %54, i32* %55, i32 %56, i32 %57)
%59 = load i32*, i32** %10
%60 = load i32, i32* %6
%61 = call i32 @check_is_inc_arr(i32* %59, i32 %60)
br label %62
62: ; preds = %48
%63 = load i32, i32* %11
%64 = add nsw i32 %63, -1
store i32 %64, i32* %11
br label %45
65: ; preds = %45
ret i32 0
}

LLVM IR (-O2):
@str = [47 x i8] c"input array length and the random value range.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 4
br i1 %3, label %7, label %4
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @str, i64 0, i64 0))
%6 = tail call i32 @exit(i32 0)
unreachable
7: ; preds = %2
%8 = tail call i64 @time(i32* null)
%9 = trunc i64 %8 to i32
%10 = tail call i32 @srand(i32 %9)
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = tail call i32 @atoi(i8* %12)
%14 = getelementptr inbounds i8*, i8** %1, i64 2
%15 = load i8*, i8** %14
%16 = tail call i32 @atoi(i8* %15)
%17 = getelementptr inbounds i8*, i8** %1, i64 3
%18 = load i8*, i8** %17
%19 = tail call i32 @atoi(i8* %18)
%20 = shl i32 %13, 2
%21 = tail call i64 @malloc(i32 %20)
%22 = inttoptr i64 %21 to i32*
%23 = tail call i64 @malloc(i32 %20)
%24 = inttoptr i64 %23 to i32*
br label %25
25: ; preds = %7, %25
%26 = phi i32 [ 1000, %7 ], [ %30, %25 ]
%27 = tail call i32 @initArr(i32* %22, i32 %16, i32 %19, i32 %13)
%28 = tail call i32 @counting_sort(i32* %22, i32* %24, i32 %13, i32 %19)
%29 = tail call i32 @check_is_inc_arr(i32* %24, i32 %13)
%30 = add nsw i32 %26, -1
%31 = icmp ugt i32 %26, 1
br i1 %31, label %25, label %32
32: ; preds = %25
ret i32 0
}