#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 /*<<< orphan*/ randlc(double *, double *);
double find_my_seed(int kn, int np, long nn, double s, double a) {
  double t1, t2;
  long mq, nq, kk, ik;
  if (kn == 0)
    return s;
  mq = (nn / 4 + np - 1) / np;
  nq = mq * 4 * kn;
  t1 = s;
  t2 = a;
  kk = nq;
  while (kk > 1) {
    ik = kk / 2;
    if (2 * ik == kk) {
      (void)randlc(&t2, &t2);
      kk = ik;
    } else {
      (void)randlc(&t1, &t2);
      kk = kk - 1;
    }
  }
  (void)randlc(&t1, &t2);
  return (t1);
}


x86 assembly (clang, -O0):
<find_my_seed>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0xc(%rbp)
mov    %esi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movsd  %xmm0,-0x20(%rbp)
movsd  %xmm1,-0x28(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    1145 <find_my_seed+0x35>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1218 <find_my_seed+0x108>
mov    -0x18(%rbp),%rax
mov    $0x4,%ecx
cqto
idiv   %rcx
movslq -0x10(%rbp),%rcx
add    %rcx,%rax
sub    $0x1,%rax
movslq -0x10(%rbp),%rcx
cqto
idiv   %rcx
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
shl    $0x2,%rax
movslq -0xc(%rbp),%rcx
imul   %rcx,%rax
mov    %rax,-0x48(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x48(%rbp),%rax
mov    %rax,-0x50(%rbp)
cmpq   $0x1,-0x50(%rbp)
jle    1201 <find_my_seed+0xf1>
mov    -0x50(%rbp),%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
mov    %rax,-0x58(%rbp)
mov    -0x58(%rbp),%rax
shl    $0x1,%rax
cmp    -0x50(%rbp),%rax
jne    11e3 <find_my_seed+0xd3>
lea    -0x38(%rbp),%rsi
mov    %rsi,%rdi
call   1030 <randlc@plt>
mov    -0x58(%rbp),%rax
mov    %rax,-0x50(%rbp)
jmp    11fc <find_my_seed+0xec>
lea    -0x30(%rbp),%rdi
lea    -0x38(%rbp),%rsi
call   1030 <randlc@plt>
mov    -0x50(%rbp),%rax
sub    $0x1,%rax
mov    %rax,-0x50(%rbp)
jmp    119b <find_my_seed+0x8b>
lea    -0x30(%rbp),%rdi
lea    -0x38(%rbp),%rsi
call   1030 <randlc@plt>
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_my_seed>:
test   %edi,%edi
je     11c9 <find_my_seed+0xb9>
lea    0x3(%rdx),%rax
test   %rdx,%rdx
cmovns %rdx,%rax
sar    $0x2,%rax
movslq %esi,%rcx
add    %rcx,%rax
add    $0xffffffffffffffff,%rax
mov    %rax,%rdx
or     %rcx,%rdx
shr    $0x20,%rdx
je     1144 <find_my_seed+0x34>
cqto
idiv   %rcx
jmp    1148 <find_my_seed+0x38>
xor    %edx,%edx
div    %esi
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
movslq %edi,%rbx
imul   %rax,%rbx
shl    $0x2,%rbx
movsd  %xmm0,(%rsp)
movsd  %xmm1,0x8(%rsp)
cmp    $0x2,%rbx
jl     11ae <find_my_seed+0x9e>
lea    0x8(%rsp),%r15
mov    %rsp,%r14
jmp    1195 <find_my_seed+0x85>
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r15,%rsi
call   1030 <randlc@plt>
add    $0xffffffffffffffff,%rbx
cmp    $0x1,%rbx
jle    11ae <find_my_seed+0x9e>
test   $0x1,%bl
jne    1180 <find_my_seed+0x70>
shr    %rbx
mov    %r15,%rdi
mov    %r15,%rsi
call   1030 <randlc@plt>
cmp    $0x1,%rbx
jg     1195 <find_my_seed+0x85>
mov    %rsp,%rdi
lea    0x8(%rsp),%rsi
call   1030 <randlc@plt>
movsd  (%rsp),%xmm0
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

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