#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*/ equal(double, double);
double floor(int /*<<< orphan*/);
int /*<<< orphan*/ pow(double, double);
int /*<<< orphan*/ printf(char *, double);
int /*<<< orphan*/ scanf(char *, double *, double *);
int main() {
  double u0, b;
  scanf("%lf %lf", &u0, &b);
  double u[3];
  u[0] = u0;
  u[1] = -1;
  u[2] = -1;
  int index = 0;
  while (!equal(u[index], u[(index + 1) % 3])) {
    double u_new = floor(pow((double)2.0, b - u[index] * u[index]));
    u_new /= (double)1000000000;
    index = (index + 1) % 3;
    u[index] = u_new;
  }
  printf("%.9lf\n", u[index] + u[(index - 1 + 3) % 3]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeb2(%rip),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x18(%rbp),%rdx
call   1040 <scanf@plt>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xe7b(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xe6e(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x0,-0x34(%rbp)
movslq -0x34(%rbp),%rax
movsd  -0x30(%rbp,%rax,8),%xmm0
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
movslq %edx,%rax
movsd  -0x30(%rbp,%rax,8),%xmm1
call   1060 <equal@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11d9 <main+0x89>
jmp    1265 <main+0x115>
movsd  -0x18(%rbp),%xmm0
movslq -0x34(%rbp),%rax
movsd  -0x30(%rbp,%rax,8),%xmm1
movslq -0x34(%rbp),%rax
movsd  -0x30(%rbp,%rax,8),%xmm2
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  0xdf7(%rip),%xmm0
call   1050 <pow@plt>
mov    %eax,%edi
call   1070 <floor@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  0xdd1(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    %edx,-0x34(%rbp)
movsd  -0x40(%rbp),%xmm0
movslq -0x34(%rbp),%rax
movsd  %xmm0,-0x30(%rbp,%rax,8)
jmp    119e <main+0x4e>
movslq -0x34(%rbp),%rax
movsd  -0x30(%rbp,%rax,8),%xmm0
mov    -0x34(%rbp),%eax
sub    $0x1,%eax
add    $0x3,%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
movslq %edx,%rax
addsd  -0x30(%rbp,%rax,8),%xmm0
lea    0xd90(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x40,%rsp
lea    0xec8(%rip),%rdi
lea    0x38(%rsp),%rsi
lea    0x30(%rsp),%rdx
call   1040 <scanf@plt>
movsd  0x38(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
movaps 0xe7e(%rip),%xmm1
movups %xmm1,0x18(%rsp)
movsd  0xe81(%rip),%xmm1
movsd  %xmm0,0x8(%rsp)
call   1060 <equal@plt>
xor    %r15d,%r15d
test   %eax,%eax
je     11ac <main+0x5c>
movsd  0x8(%rsp),%xmm0
jmp    1247 <main+0xf7>
lea    0x18(%rsp),%r14
mov    $0x1,%ebx
movsd  0x8(%rsp),%xmm0
nopl   0x0(%rax)
mov    %ebx,%r15d
movsd  0x30(%rsp),%xmm1
mulsd  %xmm0,%xmm0
subsd  %xmm0,%xmm1
movsd  0xe3f(%rip),%xmm0
call   1050 <pow@plt>
mov    %eax,%edi
call   1070 <floor@plt>
divsd  0xe33(%rip),%xmm0
movsd  %xmm0,(%r14)
mov    %ebx,%eax
movsd  0x10(%rsp,%rax,8),%xmm0
movsd  %xmm0,0x8(%rsp)
lea    0x1(%r15),%eax
cltq
imul   $0x55555556,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rax
add    %ecx,%eax
lea    (%rax,%rax,2),%eax
neg    %eax
lea    (%r15,%rax,1),%ebx
add    $0x1,%ebx
lea    (%rsp,%rbx,8),%r14
add    $0x10,%r14
movsd  0x10(%rsp,%rbx,8),%xmm1
call   1060 <equal@plt>
movsd  0x8(%rsp),%xmm0
test   %eax,%eax
je     11c0 <main+0x70>
add    $0x2,%r15d
movslq %r15d,%rax
imul   $0x55555556,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,2),%ecx
sub    %ecx,%eax
addsd  0x10(%rsp,%rax,8),%xmm0
lea    0xdbc(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [8 x i8] c"%lf %lf\00"
@.str.1 = [7 x i8] c"%.9lf\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca [3 x double]
%5 = alloca i32
%6 = alloca double
store i32 0, i32* %1
%7 = call i32 @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), double* %2, double* %3)
%8 = load double, double* %2
%9 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 0
store double %8, double* %9
%10 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 1
store double -1.000000e+00, double* %10
%11 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 2
store double -1.000000e+00, double* %11
store i32 0, i32* %5
br label %12
12: ; preds = %26, %0
%13 = load i32, i32* %5
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 %14
%16 = load double, double* %15
%17 = load i32, i32* %5
%18 = add nsw i32 %17, 1
%19 = srem i32 %18, 3
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 %20
%22 = load double, double* %21
%23 = call i32 @equal(double %16, double %22)
%24 = icmp ne i32 %23, 0
%25 = xor i1 %24, true
br i1 %25, label %26, label %49
26: ; preds = %12
%27 = load double, double* %3
%28 = load i32, i32* %5
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 %29
%31 = load double, double* %30
%32 = load i32, i32* %5
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 %33
%35 = load double, double* %34
%36 = fneg double %31
%37 = call double @llvm.fmuladd.f64(double %36, double %35, double %27)
%38 = call i32 @pow(double 2.000000e+00, double %37)
%39 = call double @floor(i32 %38)
store double %39, double* %6
%40 = load double, double* %6
%41 = fdiv double %40, 1.000000e+09
store double %41, double* %6
%42 = load i32, i32* %5
%43 = add nsw i32 %42, 1
%44 = srem i32 %43, 3
store i32 %44, i32* %5
%45 = load double, double* %6
%46 = load i32, i32* %5
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 %47
store double %45, double* %48
br label %12
49: ; preds = %12
%50 = load i32, i32* %5
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 %51
%53 = load double, double* %52
%54 = load i32, i32* %5
%55 = sub nsw i32 %54, 1
%56 = add nsw i32 %55, 3
%57 = srem i32 %56, 3
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 %58
%60 = load double, double* %59
%61 = fadd double %53, %60
%62 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), double %61)
ret i32 0
}

LLVM IR (-O2):
@.str = [8 x i8] c"%lf %lf\00"
@.str.1 = [7 x i8] c"%.9lf\0A\00"
define i32 @main() {
%1 = alloca double
%2 = alloca double
%3 = alloca [3 x double]
%4 = bitcast double* %1 to i8*
%5 = bitcast double* %2 to i8*
%6 = call i32 @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), double* %1, double* %2)
%7 = bitcast [3 x double]* %3 to i8*
%8 = load double, double* %1
%9 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 0
store double %8, double* %9
%10 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 1
%11 = bitcast double* %10 to <2 x double>*
store <2 x double> <double -1.000000e+00, double -1.000000e+00>, <2 x double>* %11
%12 = call i32 @equal(double %8, double -1.000000e+00)
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %34
14: ; preds = %0, %14
%15 = phi double* [ %30, %14 ], [ %10, %0 ]
%16 = phi i32 [ %28, %14 ], [ 1, %0 ]
%17 = phi double [ %26, %14 ], [ %8, %0 ]
%18 = load double, double* %2
%19 = fneg double %17
%20 = call double @llvm.fmuladd.f64(double %19, double %17, double %18)
%21 = call i32 @pow(double 2.000000e+00, double %20)
%22 = call double @floor(i32 %21)
%23 = fdiv double %22, 1.000000e+09
store double %23, double* %15
%24 = zext i32 %16 to i64
%25 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 %24
%26 = load double, double* %25
%27 = add nsw i32 %16, 1
%28 = srem i32 %27, 3
%29 = zext i32 %28 to i64
%30 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 %29
%31 = load double, double* %30
%32 = call i32 @equal(double %26, double %31)
%33 = icmp eq i32 %32, 0
br i1 %33, label %14, label %34
34: ; preds = %14, %0
%35 = phi i32 [ 0, %0 ], [ %16, %14 ]
%36 = phi double [ %8, %0 ], [ %26, %14 ]
%37 = add nsw i32 %35, 2
%38 = srem i32 %37, 3
%39 = zext i32 %38 to i64
%40 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 %39
%41 = load double, double* %40
%42 = fadd double %36, %41
%43 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), double %42)
ret i32 0
}