long lran2(long seed) {
  static int first = 1;
  static long x, y, v[97];
  int j;
  if (seed || first) {
    first = 0;
    x = (150889l - seed) % 714025l;
    if (x < 0)
      x = -x;
    for (j = 0; j < 97; j++) {
      x = (1366l * x + 150889l) % 714025l;
      v[j] = x;
    }
    x = (1366l * x + 150889l) % 714025l;
    y = x;
  }
  j = y % 97;
  y = v[j];
  x = (1366l * x + 150889l) % 714025l;
  v[j] = x;
  return y;
}


x86 assembly (clang, -O0):
<lran2>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    1120 <lran2+0x20>
cmpl   $0x0,0x2f06(%rip)
je     11e9 <lran2+0xe9>
movl   $0x0,0x2ef6(%rip)
mov    $0x24d69,%eax
sub    -0x8(%rbp),%rax
mov    $0xae529,%ecx
cqto
idiv   %rcx
mov    %rdx,0x2efc(%rip)
cmpq   $0x0,0x2ef4(%rip)
jge    1162 <lran2+0x62>
xor    %eax,%eax
sub    0x2ee5(%rip),%rax
mov    %rax,0x2ede(%rip)
movl   $0x0,-0xc(%rbp)
cmpl   $0x61,-0xc(%rbp)
jge    11b9 <lran2+0xb9>
imul   $0x556,0x2ec2(%rip),%rax
add    $0x24d69,%rax
mov    $0xae529,%ecx
cqto
idiv   %rcx
mov    %rdx,0x2eab(%rip)
mov    0x2ea4(%rip),%rdx
movslq -0xc(%rbp),%rcx
lea    0x2ea9(%rip),%rax
mov    %rdx,(%rax,%rcx,8)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1169 <lran2+0x69>
imul   $0x556,0x2e7c(%rip),%rax
add    $0x24d69,%rax
mov    $0xae529,%ecx
cqto
idiv   %rcx
mov    %rdx,0x2e65(%rip)
mov    0x2e5e(%rip),%rax
mov    %rax,0x2e5f(%rip)
mov    0x2e58(%rip),%rax
mov    $0x61,%ecx
cqto
idiv   %rcx
mov    %edx,%eax
mov    %eax,-0xc(%rbp)
movslq -0xc(%rbp),%rcx
lea    0x2e46(%rip),%rax
mov    (%rax,%rcx,8),%rax
mov    %rax,0x2e33(%rip)
imul   $0x556,0x2e20(%rip),%rax
add    $0x24d69,%rax
mov    $0xae529,%ecx
cqto
idiv   %rcx
mov    %rdx,0x2e09(%rip)
mov    0x2e02(%rip),%rdx
movslq -0xc(%rbp),%rcx
lea    0x2e07(%rip),%rax
mov    %rdx,(%rax,%rcx,8)
mov    0x2df4(%rip),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<lran2>:
movabs $0x5dfc995681872319,%r9
99 fc 5d
test   %rdi,%rdi
jne    112b <lran2+0x2b>
testb  $0x1,0x2f1a(%rip)
je     112b <lran2+0x2b>
mov    0x2f21(%rip),%rcx
mov    0x2f12(%rip),%rsi
jmp    120c <lran2+0x10c>
movb   $0x1,0x2efe(%rip)
mov    $0x24d69,%r8d
sub    %rdi,%r8
mov    %r8,%rax
imul   %r9
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x12,%rdx
add    %rax,%rdx
imul   $0xae529,%rdx,%rax
sub    %rax,%r8
mov    %r8,%rcx
neg    %rcx
cmovs  %r8,%rcx
mov    $0x1,%edi
lea    0x2ee1(%rip),%rsi
nop
imul   $0x556,%rcx,%rcx
add    $0x24d69,%rcx
mov    %rcx,%rax
imul   %r9
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x12,%rdx
add    %rax,%rdx
imul   $0xae529,%rdx,%rax
sub    %rax,%rcx
mov    %rcx,-0x8(%rsi,%rdi,8)
cmp    $0x61,%rdi
je     11dd <lran2+0xdd>
imul   $0x556,%rcx,%rcx
add    $0x24d69,%rcx
mov    %rcx,%rax
imul   %r9
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x12,%rdx
add    %rax,%rdx
imul   $0xae529,%rdx,%rax
sub    %rax,%rcx
mov    %rcx,(%rsi,%rdi,8)
add    $0x2,%rdi
jmp    1170 <lran2+0x70>
imul   $0x556,%ecx,%eax
add    $0x24d69,%eax
cltq
imul   $0x5dfc9957,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x32,%rcx
add    %edx,%ecx
imul   $0xae529,%ecx,%ecx
sub    %ecx,%eax
movslq %eax,%rsi
mov    %rsi,%rcx
movabs $0xa8e83f5717c0a8e9,%rdx
3f e8 a8
mov    %rcx,%rax
imul   %rdx
add    %rcx,%rdx
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x6,%rdx
add    %rax,%rdx
imul   $0x61,%rdx,%rax
sub    %rax,%rcx
lea    0x2e15(%rip),%r10
mov    (%r10,%rcx,8),%r8
imul   $0x556,%rsi,%rdi
add    $0x24d69,%rdi
mov    %rdi,%rax
imul   %r9
mov    %r8,0x2de6(%rip)
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x12,%rdx
add    %rax,%rdx
imul   $0xae529,%rdx,%rax
sub    %rax,%rdi
mov    %rdi,0x2dbf(%rip)
mov    %rdi,(%r10,%rcx,8)
mov    %r8,%rax
ret

LLVM IR (-O0):
@lran2.first = internal global i32 1
@lran2.x = internal global i64 0
@lran2.y = internal global i64 0
@lran2.v = internal global [97 x i64] zeroinitializer
define i64 @lran2(i64 %0) {
%2 = alloca i64
%3 = alloca i32
store i64 %0, i64* %2
%4 = load i64, i64* %2
%5 = icmp ne i64 %4, 0
br i1 %5, label %9, label %6
6: ; preds = %1
%7 = load i32, i32* @lran2.first
%8 = icmp ne i32 %7, 0
br i1 %8, label %9, label %40
9: ; preds = %6, %1
store i32 0, i32* @lran2.first
%10 = load i64, i64* %2
%11 = sub nsw i64 150889, %10
%12 = srem i64 %11, 714025
store i64 %12, i64* @lran2.x
%13 = load i64, i64* @lran2.x
%14 = icmp slt i64 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %9
%16 = load i64, i64* @lran2.x
%17 = sub nsw i64 0, %16
store i64 %17, i64* @lran2.x
br label %18
18: ; preds = %15, %9
store i32 0, i32* %3
br label %19
19: ; preds = %31, %18
%20 = load i32, i32* %3
%21 = icmp slt i32 %20, 97
br i1 %21, label %22, label %34
22: ; preds = %19
%23 = load i64, i64* @lran2.x
%24 = mul nsw i64 1366, %23
%25 = add nsw i64 %24, 150889
%26 = srem i64 %25, 714025
store i64 %26, i64* @lran2.x
%27 = load i64, i64* @lran2.x
%28 = load i32, i32* %3
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [97 x i64], [97 x i64]* @lran2.v, i64 0, i64 %29
store i64 %27, i64* %30
br label %31
31: ; preds = %22
%32 = load i32, i32* %3
%33 = add nsw i32 %32, 1
store i32 %33, i32* %3
br label %19
34: ; preds = %19
%35 = load i64, i64* @lran2.x
%36 = mul nsw i64 1366, %35
%37 = add nsw i64 %36, 150889
%38 = srem i64 %37, 714025
store i64 %38, i64* @lran2.x
%39 = load i64, i64* @lran2.x
store i64 %39, i64* @lran2.y
br label %40
40: ; preds = %34, %6
%41 = load i64, i64* @lran2.y
%42 = srem i64 %41, 97
%43 = trunc i64 %42 to i32
store i32 %43, i32* %3
%44 = load i32, i32* %3
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [97 x i64], [97 x i64]* @lran2.v, i64 0, i64 %45
%47 = load i64, i64* %46
store i64 %47, i64* @lran2.y
%48 = load i64, i64* @lran2.x
%49 = mul nsw i64 1366, %48
%50 = add nsw i64 %49, 150889
%51 = srem i64 %50, 714025
store i64 %51, i64* @lran2.x
%52 = load i64, i64* @lran2.x
%53 = load i32, i32* %3
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds [97 x i64], [97 x i64]* @lran2.v, i64 0, i64 %54
store i64 %52, i64* %55
%56 = load i64, i64* @lran2.y
ret i64 %56
}

LLVM IR (-O2):
@lran2.first = internal unnamed_addr global i1 false
@lran2.x = internal unnamed_addr global i64 0
@lran2.y = internal unnamed_addr global i64 0
@lran2.v = internal unnamed_addr global [97 x i64] zeroinitializer
define i64 @lran2(i64 %0) {
%2 = icmp ne i64 %0, 0
%3 = load i1, i1* @lran2.first
%4 = xor i1 %3, true
%5 = select i1 %2, i1 true, i1 %4
br i1 %5, label %9, label %6
6: ; preds = %1
%7 = load i64, i64* @lran2.y
%8 = load i64, i64* @lran2.x
br label %34
9: ; preds = %1
store i1 true, i1* @lran2.first
%10 = sub nsw i64 150889, %0
%11 = srem i64 %10, 714025
%12 = tail call i64 @llvm.abs.i64(i64 %11, i1 true)
br label %13
13: ; preds = %22, %9
%14 = phi i64 [ 0, %9 ], [ %27, %22 ]
%15 = phi i64 [ %12, %9 ], [ %25, %22 ]
%16 = mul nsw i64 %15, 1366
%17 = add nsw i64 %16, 150889
%18 = srem i64 %17, 714025
%19 = getelementptr inbounds [97 x i64], [97 x i64]* @lran2.v, i64 0, i64 %14
store i64 %18, i64* %19
%20 = or i64 %14, 1
%21 = icmp eq i64 %20, 97
br i1 %21, label %28, label %22
22: ; preds = %13
%23 = mul nsw i64 %18, 1366
%24 = add nsw i64 %23, 150889
%25 = srem i64 %24, 714025
%26 = getelementptr inbounds [97 x i64], [97 x i64]* @lran2.v, i64 0, i64 %20
store i64 %25, i64* %26
%27 = add nuw nsw i64 %14, 2
br label %13
28: ; preds = %13
%29 = trunc i64 %18 to i32
%30 = mul i32 %29, 1366
%31 = add i32 %30, 150889
%32 = srem i32 %31, 714025
%33 = sext i32 %32 to i64
br label %34
34: ; preds = %6, %28
%35 = phi i64 [ %8, %6 ], [ %33, %28 ]
%36 = phi i64 [ %7, %6 ], [ %33, %28 ]
%37 = srem i64 %36, 97
%38 = getelementptr inbounds [97 x i64], [97 x i64]* @lran2.v, i64 0, i64 %37
%39 = load i64, i64* %38
store i64 %39, i64* @lran2.y
%40 = mul nsw i64 %35, 1366
%41 = add nsw i64 %40, 150889
%42 = srem i64 %41, 714025
store i64 %42, i64* @lran2.x
store i64 %42, i64* %38
ret i64 %39
}