#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 */
double RAND_MAX;
double rand();
int /*<<< orphan*/ seed_random();
void populate_graph(void *graph, unsigned long long node_count) {
  unsigned long i;
  void **ptr;
  unsigned long gunk;
  seed_random();
  for (i = 0, ptr = graph; i < node_count; i++, ptr++) {
    gunk = (node_count - 1) * (rand() / (RAND_MAX + 1.0));
    *ptr = (void *)(graph + (gunk * sizeof(void *)));
  }
}


x86 assembly (clang, -O0):
<populate_graph>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1030 <seed_random@plt>
movq   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    1214 <populate_graph+0xf4>
mov    -0x10(%rbp),%rax
add    $0xffffffffffffffff,%rax
movq   %rax,%xmm0
movaps 0xe97(%rip),%xmm1
punpckldq %xmm1,%xmm0
movapd 0xe9b(%rip),%xmm1
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
xor    %eax,%eax
call   1040 <rand@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
mov    0x2e49(%rip),%rax
movsd  (%rax),%xmm2
movsd  0xe75(%rip),%xmm3
addsd  %xmm3,%xmm2
divsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movaps %xmm0,%xmm1
cvttsd2si %xmm1,%rax
mov    %rax,%rdx
sar    $0x3f,%rdx
movsd  0xe5a(%rip),%xmm1
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rcx
and    %rdx,%rcx
or     %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rcx
mov    -0x28(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x20(%rbp)
jmp    1147 <populate_graph+0x27>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<populate_graph>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r14
mov    %rdi,%r12
xor    %eax,%eax
call   1030 <seed_random@plt>
test   %r14,%r14
je     11cd <populate_graph+0xad>
lea    -0x1(%r14),%rax
movq   %rax,%xmm0
punpckldq 0xeae(%rip),%xmm0
subpd  0xeb6(%rip),%xmm0
movapd %xmm0,%xmm1
unpckhpd %xmm0,%xmm1
addsd  %xmm0,%xmm1
movapd %xmm1,(%rsp)
mov    0x2e76(%rip),%r15
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %eax,%eax
call   1040 <rand@plt>
movsd  (%r15),%xmm1
addsd  0xe8c(%rip),%xmm1
divsd  %xmm1,%xmm0
mulsd  (%rsp),%xmm0
cvttsd2si %xmm0,%rax
mov    %rax,%rcx
subsd  0xe7b(%rip),%xmm0
sar    $0x3f,%rcx
cvttsd2si %xmm0,%rdx
and    %rcx,%rdx
or     %rax,%rdx
lea    (%r12,%rdx,8),%rax
mov    %rax,(%r12,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r14
jne    1180 <populate_graph+0x60>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@RAND_MAX = global double 0.000000e+00
define void @populate_graph(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i64
%6 = alloca i8**
%7 = alloca i64
store i8* %0, i8** %3
store i64 %1, i64* %4
%8 = call i32 (...) @seed_random()
store i64 0, i64* %5
%9 = load i8*, i8** %3
%10 = bitcast i8* %9 to i8**
store i8** %10, i8*** %6
br label %11
11: ; preds = %30, %2
%12 = load i64, i64* %5
%13 = load i64, i64* %4
%14 = icmp ult i64 %12, %13
br i1 %14, label %15, label %35
15: ; preds = %11
%16 = load i64, i64* %4
%17 = sub i64 %16, 1
%18 = uitofp i64 %17 to double
%19 = call double (...) @rand()
%20 = load double, double* @RAND_MAX
%21 = fadd double %20, 1.000000e+00
%22 = fdiv double %19, %21
%23 = fmul double %18, %22
%24 = fptoui double %23 to i64
store i64 %24, i64* %7
%25 = load i8*, i8** %3
%26 = load i64, i64* %7
%27 = mul i64 %26, 8
%28 = getelementptr i8, i8* %25, i64 %27
%29 = load i8**, i8*** %6
store i8* %28, i8** %29
br label %30
30: ; preds = %15
%31 = load i64, i64* %5
%32 = add i64 %31, 1
store i64 %32, i64* %5
%33 = load i8**, i8*** %6
%34 = getelementptr inbounds i8*, i8** %33, i32 1
store i8** %34, i8*** %6
br label %11
35: ; preds = %11
ret void
}

LLVM IR (-O2):
@RAND_MAX = global double 0.000000e+00
define void @populate_graph(i8* %0, i64 %1) {
%3 = tail call i32 (...) @seed_random()
%4 = icmp eq i64 %1, 0
br i1 %4, label %23, label %5
5: ; preds = %2
%6 = bitcast i8* %0 to i8**
%7 = add i64 %1, -1
%8 = uitofp i64 %7 to double
br label %9
9: ; preds = %5, %9
%10 = phi i64 [ 0, %5 ], [ %20, %9 ]
%11 = phi i8** [ %6, %5 ], [ %21, %9 ]
%12 = tail call double (...) @rand()
%13 = load double, double* @RAND_MAX
%14 = fadd double %13, 1.000000e+00
%15 = fdiv double %12, %14
%16 = fmul double %15, %8
%17 = fptoui double %16 to i64
%18 = shl i64 %17, 3
%19 = getelementptr i8, i8* %0, i64 %18
store i8* %19, i8** %11
%20 = add nuw i64 %10, 1
%21 = getelementptr inbounds i8*, i8** %11, i64 1
%22 = icmp eq i64 %20, %1
br i1 %22, label %23, label %9
23: ; preds = %9, %2
ret void
}