#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*/ print(int *, int);
int rand();
int /*<<< orphan*/ range(int *, int, int);
int /*<<< orphan*/ shuffle(int *, int);
int /*<<< orphan*/ sort(int *, int);
void test(int *data, int len) {
  int start = rand() % 5;
  range(data, start, start + len);
  print(data, len);
  shuffle(data, len);
  print(data, len);
  sort(data, len);
  print(data, len);
}


x86 assembly (clang, -O0):
<test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    $0x0,%al
call   1070 <rand@plt>
mov    $0x5,%ecx
cltd
idiv   %ecx
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
mov    -0x10(%rbp),%edx
add    -0xc(%rbp),%edx
call   1060 <range@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1050 <print@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1030 <shuffle@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1050 <print@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1040 <sort@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1050 <print@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test>:
push   %r14
push   %rbx
push   %rax
mov    %esi,%r14d
mov    %rdi,%rbx
xor    %eax,%eax
call   1070 <rand@plt>
movslq %eax,%rsi
imul   $0x66666667,%rsi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x21,%rax
add    %ecx,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%esi
lea    (%rsi,%r14,1),%edx
mov    %rbx,%rdi
call   1060 <range@plt>
mov    %rbx,%rdi
mov    %r14d,%esi
call   1050 <print@plt>
mov    %rbx,%rdi
mov    %r14d,%esi
call   1030 <shuffle@plt>
mov    %rbx,%rdi
mov    %r14d,%esi
call   1050 <print@plt>
mov    %rbx,%rdi
mov    %r14d,%esi
call   1040 <sort@plt>
mov    %rbx,%rdi
mov    %r14d,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1050 <print@plt>

LLVM IR (-O0):
define void @test(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
%6 = call i32 (...) @rand()
%7 = srem i32 %6, 5
store i32 %7, i32* %5
%8 = load i32*, i32** %3
%9 = load i32, i32* %5
%10 = load i32, i32* %5
%11 = load i32, i32* %4
%12 = add nsw i32 %10, %11
%13 = call i32 @range(i32* %8, i32 %9, i32 %12)
%14 = load i32*, i32** %3
%15 = load i32, i32* %4
%16 = call i32 @print(i32* %14, i32 %15)
%17 = load i32*, i32** %3
%18 = load i32, i32* %4
%19 = call i32 @shuffle(i32* %17, i32 %18)
%20 = load i32*, i32** %3
%21 = load i32, i32* %4
%22 = call i32 @print(i32* %20, i32 %21)
%23 = load i32*, i32** %3
%24 = load i32, i32* %4
%25 = call i32 @sort(i32* %23, i32 %24)
%26 = load i32*, i32** %3
%27 = load i32, i32* %4
%28 = call i32 @print(i32* %26, i32 %27)
ret void
}

LLVM IR (-O2):
define void @test(i32* %0, i32 %1) {
%3 = tail call i32 (...) @rand()
%4 = srem i32 %3, 5
%5 = add nsw i32 %4, %1
%6 = tail call i32 @range(i32* %0, i32 %4, i32 %5)
%7 = tail call i32 @print(i32* %0, i32 %1)
%8 = tail call i32 @shuffle(i32* %0, i32 %1)
%9 = tail call i32 @print(i32* %0, i32 %1)
%10 = tail call i32 @sort(i32* %0, i32 %1)
%11 = tail call i32 @print(i32* %0, i32 %1)
ret void
}