#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 random();
int /*<<< orphan*/ srandom(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
void generate_randindices(int *randindices) {
  int i = 0;
  for (i = 0; i < 128; i++)
    randindices[i] = -1;
  srandom(time(NULL));
  i = 0;
  while (i != 128) {
    int rand_index = random() % 128;
    if (randindices[rand_index] == -1) {
      randindices[rand_index] = i;
      i++;
    }
  }
  return;
}


x86 assembly (clang, -O0):
<generate_randindices>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x80,-0xc(%rbp)
jge    1174 <generate_randindices+0x44>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movl   $0xffffffff,(%rax,%rcx,4)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    114a <generate_randindices+0x1a>
xor    %eax,%eax
mov    %eax,%edi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srandom@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0x80,-0xc(%rbp)
je     11d8 <generate_randindices+0xa8>
mov    $0x0,%al
call   1050 <random@plt>
mov    $0x80,%ecx
cltd
idiv   %ecx
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
cmpl   $0xffffffff,(%rax,%rcx,4)
jne    11d3 <generate_randindices+0xa3>
mov    -0xc(%rbp),%edx
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    118b <generate_randindices+0x5b>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<generate_randindices>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    $0x200,%edx
mov    $0xff,%esi
call   1040 <memset@plt>
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1030 <srandom@plt>
xor    %ebp,%ebp
jmp    1178 <generate_randindices+0x38>
nopw   0x0(%rax,%rax,1)
cmp    $0x80,%ebp
je     119c <generate_randindices+0x5c>
xor    %eax,%eax
call   1060 <random@plt>
lea    0x7f(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xffffff80,%ecx
sub    %ecx,%eax
cltq
cmpl   $0xffffffff,(%rbx,%rax,4)
jne    1170 <generate_randindices+0x30>
mov    %ebp,(%rbx,%rax,4)
add    $0x1,%ebp
jmp    1170 <generate_randindices+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define void @generate_randindices(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
store i32* %0, i32** %2
store i32 0, i32* %3
store i32 0, i32* %3
br label %5
5: ; preds = %13, %1
%6 = load i32, i32* %3
%7 = icmp slt i32 %6, 128
br i1 %7, label %8, label %16
8: ; preds = %5
%9 = load i32*, i32** %2
%10 = load i32, i32* %3
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i32, i32* %9, i64 %11
store i32 -1, i32* %12
br label %13
13: ; preds = %8
%14 = load i32, i32* %3
%15 = add nsw i32 %14, 1
store i32 %15, i32* %3
br label %5
16: ; preds = %5
%17 = call i32 @time(i32* null)
%18 = call i32 @srandom(i32 %17)
store i32 0, i32* %3
br label %19
19: ; preds = %39, %16
%20 = load i32, i32* %3
%21 = icmp ne i32 %20, 128
br i1 %21, label %22, label %40
22: ; preds = %19
%23 = call i32 (...) @random()
%24 = srem i32 %23, 128
store i32 %24, i32* %4
%25 = load i32*, i32** %2
%26 = load i32, i32* %4
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i32, i32* %25, i64 %27
%29 = load i32, i32* %28
%30 = icmp eq i32 %29, -1
br i1 %30, label %31, label %39
31: ; preds = %22
%32 = load i32, i32* %3
%33 = load i32*, i32** %2
%34 = load i32, i32* %4
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i32, i32* %33, i64 %35
store i32 %32, i32* %36
%37 = load i32, i32* %3
%38 = add nsw i32 %37, 1
store i32 %38, i32* %3
br label %39
39: ; preds = %31, %22
br label %19
40: ; preds = %19
ret void
}

LLVM IR (-O2):
define void @generate_randindices(i32* nocapture %0) {
%2 = bitcast i32* %0 to i8*
%3 = tail call i32 @time(i32* null)
%4 = tail call i32 @srandom(i32 %3)
br label %5
5: ; preds = %1, %15
%6 = phi i32 [ 0, %1 ], [ %16, %15 ]
%7 = tail call i32 (...) @random()
%8 = srem i32 %7, 128
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds i32, i32* %0, i64 %9
%11 = load i32, i32* %10
%12 = icmp eq i32 %11, -1
br i1 %12, label %13, label %15
13: ; preds = %5
store i32 %6, i32* %10
%14 = add nsw i32 %6, 1
br label %15
15: ; preds = %13, %5
%16 = phi i32 [ %14, %13 ], [ %6, %5 ]
%17 = icmp eq i32 %16, 128
br i1 %17, label %18, label %5
18: ; preds = %15
ret void
}