#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 < 40; i++)
    randindices[i] = -1;
  srandom(time(NULL));
  i = 0;
  while (i != 40) {
    int rand_index = random() % 40;
    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   $0x28,-0xc(%rbp)
jge    1171 <generate_randindices+0x41>
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   $0x28,-0xc(%rbp)
je     11d2 <generate_randindices+0xa2>
mov    $0x0,%al
call   1050 <random@plt>
mov    $0x28,%ecx
cltd
idiv   %ecx
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
cmpl   $0xffffffff,(%rax,%rcx,4)
jne    11cd <generate_randindices+0x9d>
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    1188 <generate_randindices+0x58>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<generate_randindices>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
pcmpeqd %xmm0,%xmm0
movdqu %xmm0,0x90(%rdi)
movdqu %xmm0,0x80(%rdi)
movdqu %xmm0,0x70(%rdi)
movdqu %xmm0,0x60(%rdi)
movdqu %xmm0,0x50(%rdi)
movdqu %xmm0,0x40(%rdi)
movdqu %xmm0,0x30(%rdi)
movdqu %xmm0,0x20(%rdi)
movdqu %xmm0,0x10(%rdi)
movdqu %xmm0,(%rdi)
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srandom@plt>
xor    %ebp,%ebp
jmp    1195 <generate_randindices+0x65>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
cmp    $0x28,%ebp
je     11ca <generate_randindices+0x9a>
xor    %eax,%eax
call   1050 <random@plt>
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x24,%rcx
add    %edx,%ecx
shl    $0x3,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
cltq
cmpl   $0xffffffff,(%rbx,%rax,4)
jne    1190 <generate_randindices+0x60>
mov    %ebp,(%rbx,%rax,4)
add    $0x1,%ebp
jmp    1190 <generate_randindices+0x60>
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, 40
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, 40
br i1 %21, label %22, label %40
22: ; preds = %19
%23 = call i32 (...) @random()
%24 = srem i32 %23, 40
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, 40
%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, 40
br i1 %17, label %18, label %5
18: ; preds = %15
ret void
}