#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();
void fill_rand(int tid, int a[]) {
  int i;
  for (i = tid * 100000 / 8; i < (tid + 1) * 100000 / 8; i++)
    a[i] = random();
}


x86 assembly (clang, -O0):
<fill_rand>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
imul   $0x186a0,-0x4(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
imul   $0x186a0,%eax,%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
cmp    %ecx,%eax
jge    117a <fill_rand+0x6a>
mov    $0x0,%al
call   1030 <random@plt>
mov    %eax,%edx
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1131 <fill_rand+0x21>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fill_rand>:
push   %r15
push   %r14
push   %rbx
imul   $0x30d4,%edi,%eax
imul   $0x186a0,%edi,%r15d
lea    0x186a0(%r15),%ecx
add    $0x186a7,%r15d
test   %ecx,%ecx
cmovns %ecx,%r15d
sar    $0x3,%r15d
cmp    %r15d,%eax
jge    1164 <fill_rand+0x54>
movslq %eax,%rcx
lea    (%rsi,%rcx,4),%r14
sub    %eax,%r15d
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1030 <random@plt>
mov    %eax,(%r14,%rbx,4)
add    $0x1,%rbx
cmp    %ebx,%r15d
jne    1150 <fill_rand+0x40>
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define void @fill_rand(i32 %0, i32* nocapture writeonly %1) {
%3 = mul i32 %0, 12500
%4 = mul i32 %0, 100000
%5 = add i32 %4, 100000
%6 = sdiv i32 %5, 8
%7 = icmp slt i32 %3, %6
br i1 %7, label %8, label %17
8: ; preds = %2
%9 = sext i32 %3 to i64
br label %10
10: ; preds = %8, %10
%11 = phi i64 [ %9, %8 ], [ %14, %10 ]
%12 = tail call i32 (...) @random()
%13 = getelementptr inbounds i32, i32* %1, i64 %11
store i32 %12, i32* %13
%14 = add nsw i64 %11, 1
%15 = trunc i64 %14 to i32
%16 = icmp eq i32 %6, %15
br i1 %16, label %17, label %10
17: ; preds = %10, %2
ret void
}