#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 */
scalar_t__ malloc(int);
int random();
int /*<<< orphan*/ srandom(int);
int *select_random_points(int Nv) {
  int i, j;
  int *rverts;
  rverts = (int *)malloc(5 * sizeof(int));
  srandom(Nv);
  for (i = 0; i < 5; i++) {
    j = random() % Nv;
    rverts[i] = j;
  }
  return rverts;
}


x86 assembly (clang, -O0):
<select_random_points>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    $0x14,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x4(%rbp),%edi
call   1030 <srandom@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x5,-0x8(%rbp)
jge    118c <select_random_points+0x5c>
mov    $0x0,%al
call   1040 <random@plt>
cltd
idivl  -0x4(%rbp)
mov    %edx,-0xc(%rbp)
mov    -0xc(%rbp),%edx
mov    -0x18(%rbp),%rax
movslq -0x8(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1158 <select_random_points+0x28>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<select_random_points>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebp
mov    $0x14,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
mov    %ebp,%edi
call   1030 <srandom@plt>
xor    %eax,%eax
call   1040 <random@plt>
cltd
idiv   %ebp
mov    %edx,(%rbx)
xor    %eax,%eax
call   1040 <random@plt>
cltd
idiv   %ebp
mov    %edx,0x4(%rbx)
xor    %eax,%eax
call   1040 <random@plt>
cltd
idiv   %ebp
mov    %edx,0x8(%rbx)
xor    %eax,%eax
call   1040 <random@plt>
cltd
idiv   %ebp
mov    %edx,0xc(%rbx)
xor    %eax,%eax
call   1040 <random@plt>
cltd
idiv   %ebp
mov    %edx,0x10(%rbx)
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32* @select_random_points(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32*
store i32 %0, i32* %2
%6 = call i64 @malloc(i32 20)
%7 = inttoptr i64 %6 to i32*
store i32* %7, i32** %5
%8 = load i32, i32* %2
%9 = call i32 @srandom(i32 %8)
store i32 0, i32* %3
br label %10
10: ; preds = %22, %1
%11 = load i32, i32* %3
%12 = icmp slt i32 %11, 5
br i1 %12, label %13, label %25
13: ; preds = %10
%14 = call i32 (...) @random()
%15 = load i32, i32* %2
%16 = srem i32 %14, %15
store i32 %16, i32* %4
%17 = load i32, i32* %4
%18 = load i32*, i32** %5
%19 = load i32, i32* %3
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i32, i32* %18, i64 %20
store i32 %17, i32* %21
br label %22
22: ; preds = %13
%23 = load i32, i32* %3
%24 = add nsw i32 %23, 1
store i32 %24, i32* %3
br label %10
25: ; preds = %10
%26 = load i32*, i32** %5
ret i32* %26
}

LLVM IR (-O2):
define i32* @select_random_points(i32 %0) {
%2 = tail call i64 @malloc(i32 20)
%3 = inttoptr i64 %2 to i32*
%4 = tail call i32 @srandom(i32 %0)
%5 = tail call i32 (...) @random()
%6 = srem i32 %5, %0
store i32 %6, i32* %3
%7 = tail call i32 (...) @random()
%8 = srem i32 %7, %0
%9 = getelementptr inbounds i32, i32* %3, i64 1
store i32 %8, i32* %9
%10 = tail call i32 (...) @random()
%11 = srem i32 %10, %0
%12 = getelementptr inbounds i32, i32* %3, i64 2
store i32 %11, i32* %12
%13 = tail call i32 (...) @random()
%14 = srem i32 %13, %0
%15 = getelementptr inbounds i32, i32* %3, i64 3
store i32 %14, i32* %15
%16 = tail call i32 (...) @random()
%17 = srem i32 %16, %0
%18 = getelementptr inbounds i32, i32* %3, i64 4
store i32 %17, i32* %18
ret i32* %3
}