#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(int kn, int np, long nn, double s, double a) {
  long i;
  double t1, t2, t3, 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)
      t3 = randlc(&t1, &t2);
    if (ik == 0)
      break;
    t3 = randlc(&t2, &t2);
    kk = ik;
  }
  return (t1);
}


x86 assembly (clang, -O0):
<find_my_seed>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
movsd  %xmm1,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x8(%rbp),%rcx
cqto
idiv   %rcx
mov    %rax,-0x58(%rbp)
movq   $0x0,-0x50(%rbp)
cmpq   $0x1,-0x58(%rbp)
jle    1178 <find_my_seed+0x68>
jmp    1155 <find_my_seed+0x45>
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    1145 <find_my_seed+0x35>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movq   $0x1,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x50(%rbp),%rax
jg     11ba <find_my_seed+0xaa>
lea    -0x30(%rbp),%rsi
mov    %rsi,%rdi
call   1030 <randlc@plt>
movsd  %xmm0,-0x38(%rbp)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    118a <find_my_seed+0x7a>
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movslq -0x4(%rbp),%rax
mov    %rax,-0x60(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movq   $0x1,-0x28(%rbp)
cmpq   $0x64,-0x28(%rbp)
jg     1263 <find_my_seed+0x153>
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     1229 <find_my_seed+0x119>
lea    -0x30(%rbp),%rdi
lea    -0x38(%rbp),%rsi
call   1030 <randlc@plt>
movsd  %xmm0,-0x40(%rbp)
cmpq   $0x0,-0x68(%rbp)
jne    1239 <find_my_seed+0x129>
jmp    1263 <find_my_seed+0x153>
lea    -0x38(%rbp),%rsi
mov    %rsi,%rdi
call   1030 <randlc@plt>
movsd  %xmm0,-0x40(%rbp)
mov    -0x68(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    11e8 <find_my_seed+0xd8>
movsd  -0x30(%rbp),%xmm0
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_my_seed>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x20,%rsp
mov    %rdx,%rax
mov    %edi,%r14d
movslq %esi,%rcx
or     %rcx,%rdx
shr    $0x20,%rdx
je     113b <find_my_seed+0x2b>
cqto
idiv   %rcx
cmp    $0x2,%rax
jge    1145 <find_my_seed+0x35>
jmp    118d <find_my_seed+0x7d>
xor    %edx,%edx
div    %esi
cmp    $0x2,%rax
jl     118d <find_my_seed+0x7d>
movsd  %xmm0,0x10(%rsp)
xor    %ebp,%ebp
mov    %rax,%rcx
add    $0x1,%rbp
shr    %rcx
cmp    $0x3,%rax
mov    %rcx,%rax
ja     1150 <find_my_seed+0x40>
movsd  %xmm1,0x8(%rsp)
lea    0x8(%rsp),%rbx
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %rbx,%rsi
call   1030 <randlc@plt>
add    $0xffffffffffffffff,%rbp
jne    1170 <find_my_seed+0x60>
movsd  0x8(%rsp),%xmm1
movsd  0x10(%rsp),%xmm0
movslq %r14d,%rbp
movsd  %xmm0,0x8(%rsp)
movsd  %xmm1,0x18(%rsp)
mov    $0x64,%r12d
lea    0x18(%rsp),%r15
lea    0x8(%rsp),%r14
mov    %rbp,%rbx
nop
shr    $0x3f,%rbx
add    %rbp,%rbx
mov    %rbx,%rax
and    $0xfffffffffffffffe,%rax
cmp    %rbp,%rax
je     11ce <find_my_seed+0xbe>
mov    %r14,%rdi
mov    %r15,%rsi
call   1030 <randlc@plt>
add    $0x1,%rbp
cmp    $0x3,%rbp
jb     11ef <find_my_seed+0xdf>
sar    %rbx
mov    %r15,%rdi
mov    %r15,%rsi
call   1030 <randlc@plt>
mov    %rbx,%rbp
add    $0xffffffffffffffff,%r12
jne    11b0 <find_my_seed+0xa0>
movsd  0x8(%rsp),%xmm0
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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