#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 randlc(double *, double *);
double find_my_seed(long kn, long np, long nn, double s, double a) {
  long i;
  double t1, t2, an;
  long mq, nq, kk, ik;
  nq = nn / np;
  for (mq = 0; nq > 1; mq++, nq /= 2)
    ;
  t1 = a;
  for (i = 1; i <= mq; i++)
    t2 = randlc(&t1, &t1);
  an = t1;
  kk = kn;
  t1 = s;
  t2 = an;
  for (i = 1; i <= 100; i++) {
    ik = kk / 2;
    if (2 * ik != kk)
      randlc(&t1, &t2);
    if (ik == 0)
      break;
    randlc(&t2, &t2);
    kk = ik;
  }
  return (t1);
}


x86 assembly (clang, -O0):
<find_my_seed>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movsd  %xmm0,-0x20(%rbp)
movsd  %xmm1,-0x28(%rbp)
mov    -0x18(%rbp),%rax
cqto
idivq  -0x10(%rbp)
mov    %rax,-0x58(%rbp)
movq   $0x0,-0x50(%rbp)
cmpq   $0x1,-0x58(%rbp)
jle    1177 <find_my_seed+0x67>
jmp    1154 <find_my_seed+0x44>
mov    -0x50(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x50(%rbp)
mov    -0x58(%rbp),%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
mov    %rax,-0x58(%rbp)
jmp    1144 <find_my_seed+0x34>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movq   $0x1,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x50(%rbp),%rax
jg     11b9 <find_my_seed+0xa9>
lea    -0x38(%rbp),%rsi
mov    %rsi,%rdi
call   1030 <randlc@plt>
movsd  %xmm0,-0x40(%rbp)
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    1189 <find_my_seed+0x79>
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x60(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movq   $0x1,-0x30(%rbp)
cmpq   $0x64,-0x30(%rbp)
jg     1258 <find_my_seed+0x148>
mov    -0x60(%rbp),%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
mov    %rax,-0x68(%rbp)
mov    -0x68(%rbp),%rax
shl    $0x1,%rax
cmp    -0x60(%rbp),%rax
je     1223 <find_my_seed+0x113>
lea    -0x38(%rbp),%rdi
lea    -0x40(%rbp),%rsi
call   1030 <randlc@plt>
cmpq   $0x0,-0x68(%rbp)
jne    1233 <find_my_seed+0x123>
jmp    1258 <find_my_seed+0x148>
lea    -0x40(%rbp),%rsi
mov    %rsi,%rdi
call   1030 <randlc@plt>
mov    -0x68(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    11e7 <find_my_seed+0xd7>
movsd  -0x38(%rbp),%xmm0
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_my_seed>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x20,%rsp
mov    %rdx,%rax
mov    %rdi,%r12
mov    %rdx,%rcx
or     %rsi,%rcx
shr    $0x20,%rcx
je     113c <find_my_seed+0x2c>
cqto
idiv   %rsi
cmp    $0x2,%rax
jge    1146 <find_my_seed+0x36>
jmp    119d <find_my_seed+0x8d>
xor    %edx,%edx
div    %esi
cmp    $0x2,%rax
jl     119d <find_my_seed+0x8d>
movsd  %xmm0,0x10(%rsp)
xor    %ebx,%ebx
mov    %rax,%rcx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbx
shr    %rcx
cmp    $0x3,%rax
mov    %rcx,%rax
ja     1160 <find_my_seed+0x50>
movsd  %xmm1,0x8(%rsp)
lea    0x8(%rsp),%r14
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r14,%rsi
call   1030 <randlc@plt>
add    $0xffffffffffffffff,%rbx
jne    1180 <find_my_seed+0x70>
movsd  0x8(%rsp),%xmm1
movsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  %xmm1,0x18(%rsp)
mov    $0x64,%r13d
lea    0x18(%rsp),%r14
lea    0x8(%rsp),%r15
mov    %r12,%rbx
nopl   0x0(%rax)
shr    $0x3f,%rbx
add    %r12,%rbx
mov    %rbx,%rax
and    $0xfffffffffffffffe,%rax
cmp    %r12,%rax
je     11de <find_my_seed+0xce>
mov    %r15,%rdi
mov    %r14,%rsi
call   1030 <randlc@plt>
add    $0x1,%r12
cmp    $0x3,%r12
jb     11ff <find_my_seed+0xef>
sar    %rbx
mov    %r14,%rdi
mov    %r14,%rsi
call   1030 <randlc@plt>
mov    %rbx,%r12
add    $0xffffffffffffffff,%r13
jne    11c0 <find_my_seed+0xb0>
movsd  0x8(%rsp),%xmm0
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define double @find_my_seed(i64 %0, i64 %1, i64 %2, double %3, double %4) {
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
%9 = alloca double
%10 = alloca double
%11 = alloca i64
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca i64
%16 = alloca i64
%17 = alloca i64
%18 = alloca i64
store i64 %0, i64* %6
store i64 %1, i64* %7
store i64 %2, i64* %8
store double %3, double* %9
store double %4, double* %10
%19 = load i64, i64* %8
%20 = load i64, i64* %7
%21 = sdiv i64 %19, %20
store i64 %21, i64* %16
store i64 0, i64* %15
br label %22
22: ; preds = %26, %5
%23 = load i64, i64* %16
%24 = icmp sgt i64 %23, 1
br i1 %24, label %25, label %31
25: ; preds = %22
br label %26
26: ; preds = %25
%27 = load i64, i64* %15
%28 = add nsw i64 %27, 1
store i64 %28, i64* %15
%29 = load i64, i64* %16
%30 = sdiv i64 %29, 2
store i64 %30, i64* %16
br label %22
31: ; preds = %22
%32 = load double, double* %10
store double %32, double* %12
store i64 1, i64* %11
br label %33
33: ; preds = %39, %31
%34 = load i64, i64* %11
%35 = load i64, i64* %15
%36 = icmp sle i64 %34, %35
br i1 %36, label %37, label %42
37: ; preds = %33
%38 = call double @randlc(double* %12, double* %12)
store double %38, double* %13
br label %39
39: ; preds = %37
%40 = load i64, i64* %11
%41 = add nsw i64 %40, 1
store i64 %41, i64* %11
br label %33
42: ; preds = %33
%43 = load double, double* %12
store double %43, double* %14
%44 = load i64, i64* %6
store i64 %44, i64* %17
%45 = load double, double* %9
store double %45, double* %12
%46 = load double, double* %14
store double %46, double* %13
store i64 1, i64* %11
br label %47
47: ; preds = %66, %42
%48 = load i64, i64* %11
%49 = icmp sle i64 %48, 100
br i1 %49, label %50, label %69
50: ; preds = %47
%51 = load i64, i64* %17
%52 = sdiv i64 %51, 2
store i64 %52, i64* %18
%53 = load i64, i64* %18
%54 = mul nsw i64 2, %53
%55 = load i64, i64* %17
%56 = icmp ne i64 %54, %55
br i1 %56, label %57, label %59
57: ; preds = %50
%58 = call double @randlc(double* %12, double* %13)
br label %59
59: ; preds = %57, %50
%60 = load i64, i64* %18
%61 = icmp eq i64 %60, 0
br i1 %61, label %62, label %63
62: ; preds = %59
br label %69
63: ; preds = %59
%64 = call double @randlc(double* %13, double* %13)
%65 = load i64, i64* %18
store i64 %65, i64* %17
br label %66
66: ; preds = %63
%67 = load i64, i64* %11
%68 = add nsw i64 %67, 1
store i64 %68, i64* %11
br label %47
69: ; preds = %62, %47
%70 = load double, double* %12
ret double %70
}

LLVM IR (-O2):
define double @find_my_seed(i64 %0, i64 %1, i64 %2, double %3, double %4) {
%6 = alloca double
%7 = alloca double
%8 = bitcast double* %6 to i8*
%9 = bitcast double* %7 to i8*
%10 = sdiv i64 %2, %1
%11 = icmp sgt i64 %10, 1
br i1 %11, label %12, label %26
12: ; preds = %5, %12
%13 = phi i64 [ %16, %12 ], [ %10, %5 ]
%14 = phi i64 [ %15, %12 ], [ 0, %5 ]
%15 = add nuw nsw i64 %14, 1
%16 = lshr i64 %13, 1
%17 = icmp ugt i64 %13, 3
br i1 %17, label %12, label %18
18: ; preds = %12
store double %4, double* %6
br label %19
19: ; preds = %18, %19
%20 = phi i64 [ %22, %19 ], [ 1, %18 ]
%21 = call double @randlc(double* %6, double* %6)
%22 = add nuw nsw i64 %20, 1
%23 = icmp eq i64 %20, %15
br i1 %23, label %24, label %19
24: ; preds = %19
%25 = load double, double* %6
br label %26
26: ; preds = %5, %24
%27 = phi double [ %25, %24 ], [ %4, %5 ]
store double %3, double* %6
store double %27, double* %7
br label %28
28: ; preds = %26, %39
%29 = phi i64 [ 1, %26 ], [ %41, %39 ]
%30 = phi i64 [ %0, %26 ], [ %31, %39 ]
%31 = sdiv i64 %30, 2
%32 = shl nsw i64 %31, 1
%33 = icmp eq i64 %32, %30
br i1 %33, label %36, label %34
34: ; preds = %28
%35 = call double @randlc(double* %6, double* %7)
br label %36
36: ; preds = %34, %28
%37 = add i64 %30, 1
%38 = icmp ult i64 %37, 3
br i1 %38, label %43, label %39
39: ; preds = %36
%40 = call double @randlc(double* %7, double* %7)
%41 = add nuw nsw i64 %29, 1
%42 = icmp eq i64 %41, 101
br i1 %42, label %43, label %28
43: ; preds = %36, %39
%44 = load double, double* %6
ret double %44
}