#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 ran3(long *);
void initialize_hot(int height[]) {
  int ix;
  long int idum;
  int zero_one, plus_minus;
  height[0] = 0;
  for (ix = 1; ix < 100; ix++) {
    zero_one = 2 * ran3(&idum);
    plus_minus = 2 * zero_one - 1;
    height[ix] = height[ix - 1] + plus_minus;
  }
}


x86 assembly (clang, -O0):
<initialize_hot>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movl   $0x0,(%rax)
movl   $0x1,-0xc(%rbp)
cmpl   $0x64,-0xc(%rbp)
jge    117e <initialize_hot+0x6e>
lea    -0x18(%rbp),%rdi
call   1030 <ran3@plt>
shl    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
shl    $0x1,%eax
sub    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%edx
add    -0x20(%rbp),%edx
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    112d <initialize_hot+0x1d>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<initialize_hot>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%r15
movl   $0x0,(%rdi)
mov    $0x1,%ebx
lea    0x8(%rsp),%r14
nopl   0x0(%rax)
mov    %r14,%rdi
call   1030 <ran3@plt>
mov    -0x4(%r15,%rbx,4),%ecx
lea    (%rcx,%rax,4),%eax
add    $0xffffffff,%eax
mov    %eax,(%r15,%rbx,4)
add    $0x1,%rbx
cmp    $0x64,%rbx
jne    1130 <initialize_hot+0x20>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @initialize_hot(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i64
%5 = alloca i32
%6 = alloca i32
store i32* %0, i32** %2
%7 = load i32*, i32** %2
%8 = getelementptr inbounds i32, i32* %7, i64 0
store i32 0, i32* %8
store i32 1, i32* %3
br label %9
9: ; preds = %30, %1
%10 = load i32, i32* %3
%11 = icmp slt i32 %10, 100
br i1 %11, label %12, label %33
12: ; preds = %9
%13 = call i32 @ran3(i64* %4)
%14 = mul nsw i32 2, %13
store i32 %14, i32* %5
%15 = load i32, i32* %5
%16 = mul nsw i32 2, %15
%17 = sub nsw i32 %16, 1
store i32 %17, i32* %6
%18 = load i32*, i32** %2
%19 = load i32, i32* %3
%20 = sub nsw i32 %19, 1
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i32, i32* %18, i64 %21
%23 = load i32, i32* %22
%24 = load i32, i32* %6
%25 = add nsw i32 %23, %24
%26 = load i32*, i32** %2
%27 = load i32, i32* %3
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i32, i32* %26, i64 %28
store i32 %25, i32* %29
br label %30
30: ; preds = %12
%31 = load i32, i32* %3
%32 = add nsw i32 %31, 1
store i32 %32, i32* %3
br label %9
33: ; preds = %9
ret void
}

LLVM IR (-O2):
define void @initialize_hot(i32* nocapture %0) {
%2 = alloca i64
%3 = bitcast i64* %2 to i8*
store i32 0, i32* %0
br label %4
4: ; preds = %1, %4
%5 = phi i64 [ 1, %1 ], [ %14, %4 ]
%6 = call i32 @ran3(i64* %2)
%7 = shl nsw i32 %6, 2
%8 = add nsw i32 %7, -1
%9 = add nsw i64 %5, -1
%10 = getelementptr inbounds i32, i32* %0, i64 %9
%11 = load i32, i32* %10
%12 = add nsw i32 %8, %11
%13 = getelementptr inbounds i32, i32* %0, i64 %5
store i32 %12, i32* %13
%14 = add nuw nsw i64 %5, 1
%15 = icmp eq i64 %14, 100
br i1 %15, label %16, label %4
16: ; preds = %4
ret void
}