#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 product_mod_46(double, double);
double ran_num_init(unsigned long k, double b, double t) {
  unsigned long j;
  while (k != 0) {
    j = k >> 1;
    if ((j << 1) != k) {
      b = product_mod_46(b, t);
    }
    t = product_mod_46(t, t);
    k = j;
  }
  return b;
}


x86 assembly (clang, -O0):
<ran_num_init>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1184 <ran_num_init+0x74>
mov    -0x8(%rbp),%rax
shr    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
shl    $0x1,%rax
cmp    -0x8(%rbp),%rax
je     1163 <ran_num_init+0x53>
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
call   1030 <product_mod_46@plt>
movsd  %xmm0,-0x10(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
call   1030 <product_mod_46@plt>
movsd  %xmm0,-0x18(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1126 <ran_num_init+0x16>
movsd  -0x10(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ran_num_init>:
push   %r14
push   %rbx
sub    $0x18,%rsp
movsd  %xmm0,0x8(%rsp)
test   %rdi,%rdi
je     1175 <ran_num_init+0x65>
mov    %rdi,%r14
jmp    114a <ran_num_init+0x3a>
nopw   0x0(%rax,%rax,1)
mov    %r14,%rbx
shr    %rbx
movaps %xmm1,%xmm0
call   1030 <product_mod_46@plt>
movaps %xmm0,%xmm1
cmp    $0x1,%r14
mov    %rbx,%r14
jbe    1175 <ran_num_init+0x65>
test   $0x1,%r14b
je     1130 <ran_num_init+0x20>
movsd  0x8(%rsp),%xmm0
movsd  %xmm1,0x10(%rsp)
movsd  0x10(%rsp),%xmm1
call   1030 <product_mod_46@plt>
movsd  0x10(%rsp),%xmm1
movsd  %xmm0,0x8(%rsp)
jmp    1130 <ran_num_init+0x20>
movsd  0x8(%rsp),%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define double @ran_num_init(i64 %0, double %1, double %2) {
%4 = alloca i64
%5 = alloca double
%6 = alloca double
%7 = alloca i64
store i64 %0, i64* %4
store double %1, double* %5
store double %2, double* %6
br label %8
8: ; preds = %22, %3
%9 = load i64, i64* %4
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %27
11: ; preds = %8
%12 = load i64, i64* %4
%13 = lshr i64 %12, 1
store i64 %13, i64* %7
%14 = load i64, i64* %7
%15 = shl i64 %14, 1
%16 = load i64, i64* %4
%17 = icmp ne i64 %15, %16
br i1 %17, label %18, label %22
18: ; preds = %11
%19 = load double, double* %5
%20 = load double, double* %6
%21 = call double @product_mod_46(double %19, double %20)
store double %21, double* %5
br label %22
22: ; preds = %18, %11
%23 = load double, double* %6
%24 = load double, double* %6
%25 = call double @product_mod_46(double %23, double %24)
store double %25, double* %6
%26 = load i64, i64* %7
store i64 %26, i64* %4
br label %8
27: ; preds = %8
%28 = load double, double* %5
ret double %28
}

LLVM IR (-O2):
define double @ran_num_init(i64 %0, double %1, double %2) {
%4 = icmp eq i64 %0, 0
br i1 %4, label %18, label %5
5: ; preds = %3, %14
%6 = phi i64 [ %9, %14 ], [ %0, %3 ]
%7 = phi double [ %16, %14 ], [ %2, %3 ]
%8 = phi double [ %15, %14 ], [ %1, %3 ]
%9 = lshr i64 %6, 1
%10 = and i64 %6, -2
%11 = icmp eq i64 %10, %6
br i1 %11, label %14, label %12
12: ; preds = %5
%13 = tail call double @product_mod_46(double %8, double %7)
br label %14
14: ; preds = %12, %5
%15 = phi double [ %13, %12 ], [ %8, %5 ]
%16 = tail call double @product_mod_46(double %7, double %7)
%17 = icmp ult i64 %6, 2
br i1 %17, label %18, label %5
18: ; preds = %14, %3
%19 = phi double [ %1, %3 ], [ %15, %14 ]
ret double %19
}