#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*/ radix_sort(int *, int);
int rand();
int main() {
  int a[50];
  int n = rand() % 50;
  int i;
  for (i = 0; i < n; ++i)
    a[i] = rand() % 50;
  radix_sort(a, 50);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <rand@plt>
mov    $0x32,%ecx
cltd
idiv   %ecx
mov    %edx,-0xd4(%rbp)
movl   $0x0,-0xd8(%rbp)
mov    -0xd8(%rbp),%eax
cmp    -0xd4(%rbp),%eax
jge    1194 <main+0x74>
mov    $0x0,%al
call   1040 <rand@plt>
mov    $0x32,%ecx
cltd
idiv   %ecx
movslq -0xd8(%rbp),%rax
mov    %edx,-0xd0(%rbp,%rax,4)
mov    -0xd8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xd8(%rbp)
jmp    1151 <main+0x31>
lea    -0xd0(%rbp),%rdi
mov    $0x32,%esi
call   1030 <radix_sort@plt>
xor    %eax,%eax
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0xc8,%rsp
xor    %eax,%eax
call   1040 <rand@plt>
cltq
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x24,%rcx
add    %edx,%ecx
imul   $0x32,%ecx,%ecx
sub    %ecx,%eax
test   %eax,%eax
jle    118e <main+0x6e>
mov    %eax,%r14d
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
xor    %eax,%eax
call   1040 <rand@plt>
cltq
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x24,%rcx
add    %edx,%ecx
imul   $0x32,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,(%rsp,%rbx,4)
add    $0x1,%rbx
cmp    %rbx,%r14
jne    1160 <main+0x40>
mov    %rsp,%rdi
mov    $0x32,%esi
call   1030 <radix_sort@plt>
xor    %eax,%eax
add    $0xc8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca [50 x i32]
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 (...) @rand()
%6 = srem i32 %5, 50
store i32 %6, i32* %3
store i32 0, i32* %4
br label %7
7: ; preds = %17, %0
%8 = load i32, i32* %4
%9 = load i32, i32* %3
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %20
11: ; preds = %7
%12 = call i32 (...) @rand()
%13 = srem i32 %12, 50
%14 = load i32, i32* %4
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 %15
store i32 %13, i32* %16
br label %17
17: ; preds = %11
%18 = load i32, i32* %4
%19 = add nsw i32 %18, 1
store i32 %19, i32* %4
br label %7
20: ; preds = %7
%21 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 0
%22 = call i32 @radix_sort(i32* %21, i32 50)
ret i32 0
}

LLVM IR (-O2):
define i32 @main() {
%1 = alloca [50 x i32]
%2 = bitcast [50 x i32]* %1 to i8*
%3 = tail call i32 (...) @rand()
%4 = srem i32 %3, 50
%5 = icmp sgt i32 %4, 0
br i1 %5, label %6, label %15
6: ; preds = %0
%7 = zext i32 %4 to i64
br label %8
8: ; preds = %6, %8
%9 = phi i64 [ 0, %6 ], [ %13, %8 ]
%10 = tail call i32 (...) @rand()
%11 = srem i32 %10, 50
%12 = getelementptr inbounds [50 x i32], [50 x i32]* %1, i64 0, i64 %9
store i32 %11, i32* %12
%13 = add nuw nsw i64 %9, 1
%14 = icmp eq i64 %13, %7
br i1 %14, label %15, label %8
15: ; preds = %8, %0
%16 = getelementptr inbounds [50 x i32], [50 x i32]* %1, i64 0, i64 0
%17 = call i32 @radix_sort(i32* %16, i32 50)
ret i32 0
}