#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 */
typedef size_t uint64_t;

/* Variables and functions */
int nextrand(size_t *);
int /*<<< orphan*/ printf(char *, size_t);
int /*<<< orphan*/ test_lookup(int, size_t);
void *read_table(void *val) {
  size_t id = (size_t)val;
  printf("Running with %ld\n", id);
  uint64_t rng = id ^ (id * 100) ^ ((id + 2) * 43234455);
  for (size_t i = 0; i < (100 * 100 * 100 * 100); i++) {
    test_lookup(nextrand(&rng) % (3000 * 2), id);
  }
  return 0;
}


x86 assembly (clang, -O0):
<read_table>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xeb1(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
imul   $0x64,-0x10(%rbp),%rcx
xor    %rcx,%rax
mov    -0x10(%rbp),%rcx
add    $0x2,%rcx
imul   $0x293b497,%rcx,%rcx
xor    %rcx,%rax
mov    %rax,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
cmpq   $0x5f5e100,-0x20(%rbp)
05
jae    11b9 <read_table+0x89>
lea    -0x18(%rbp),%rdi
call   1040 <nextrand@plt>
mov    $0x1770,%ecx
cltd
idiv   %ecx
mov    %edx,%edi
mov    -0x10(%rbp),%rsi
call   1050 <test_lookup@plt>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    117e <read_table+0x4e>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_table>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%r15
lea    0xebd(%rip),%rdi
mov    %r15,%rsi
call   1030 <printf@plt>
imul   $0x64,%r15,%rax
xor    %r15,%rax
imul   $0x293b497,%r15,%rcx
add    $0x527692e,%rcx
xor    %rax,%rcx
mov    %rcx,0x8(%rsp)
mov    $0x5f5e100,%ebx
lea    0x8(%rsp),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
call   1040 <nextrand@plt>
movslq %eax,%rdi
imul   $0x57619f1,%rdi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x27,%rax
add    %ecx,%eax
imul   $0x1770,%eax,%eax
sub    %eax,%edi
mov    %r15,%rsi
call   1050 <test_lookup@plt>
add    $0xffffffffffffffff,%rbx
jne    1180 <read_table+0x50>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [18 x i8] c"Running with %ld\0A\00"
define i8* @read_table(i8* %0) {
%2 = alloca i8*
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = ptrtoint i8* %6 to i64
store i64 %7, i64* %3
%8 = load i64, i64* %3
%9 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i64 %8)
%10 = load i64, i64* %3
%11 = load i64, i64* %3
%12 = mul i64 %11, 100
%13 = xor i64 %10, %12
%14 = load i64, i64* %3
%15 = add i64 %14, 2
%16 = mul i64 %15, 43234455
%17 = xor i64 %13, %16
store i64 %17, i64* %4
store i64 0, i64* %5
br label %18
18: ; preds = %26, %1
%19 = load i64, i64* %5
%20 = icmp ult i64 %19, 100000000
br i1 %20, label %21, label %29
21: ; preds = %18
%22 = call i32 @nextrand(i64* %4)
%23 = srem i32 %22, 6000
%24 = load i64, i64* %3
%25 = call i32 @test_lookup(i32 %23, i64 %24)
br label %26
26: ; preds = %21
%27 = load i64, i64* %5
%28 = add i64 %27, 1
store i64 %28, i64* %5
br label %18
29: ; preds = %18
ret i8* null
}

LLVM IR (-O2):
@.str = [18 x i8] c"Running with %ld\0A\00"
define noalias i8* @read_table(i8* %0) {
%2 = alloca i64
%3 = ptrtoint i8* %0 to i64
%4 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i64 %3)
%5 = bitcast i64* %2 to i8*
%6 = mul i64 %3, 100
%7 = xor i64 %6, %3
%8 = mul i64 %3, 43234455
%9 = add i64 %8, 86468910
%10 = xor i64 %7, %9
store i64 %10, i64* %2
br label %12
11: ; preds = %12
ret i8* null
12: ; preds = %1, %12
%13 = phi i64 [ 0, %1 ], [ %17, %12 ]
%14 = call i32 @nextrand(i64* %2)
%15 = srem i32 %14, 6000
%16 = call i32 @test_lookup(i32 %15, i64 %3)
%17 = add nuw nsw i64 %13, 1
%18 = icmp eq i64 %17, 100000000
br i1 %18, label %11, label %12
}