#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 pow(int, double);
double solve(const double y) {
  double left = 0.0, right = 20.0, mid, val;
  while (right - left > 1e-4) {
    mid = (left + right) / 2;
    val = mid * pow(2, mid);
    if (val == y) {
      return mid;
    } else if (val > y) {
      right = mid;
    } else {
      left = mid;
    }
  }
  return mid;
}


x86 assembly (clang, -O0):
<solve>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xed3(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  0xec4(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11eb <solve+0xdb>
movsd  -0x18(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  0xeb0(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x28(%rbp),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
ucomisd -0x10(%rbp),%xmm0
jne    11b8 <solve+0xa8>
jp     11b8 <solve+0xa8>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11f5 <solve+0xe5>
movsd  -0x30(%rbp),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    11d7 <solve+0xc7>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    11e1 <solve+0xd1>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    11e6 <solve+0xd6>
jmp    1132 <solve+0x22>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<solve>:
sub    $0x38,%rsp
movapd %xmm0,%xmm3
xorpd  %xmm4,%xmm4
movsd  0xedc(%rip),%xmm1
movsd  %xmm0,(%rsp)
jmp    1157 <solve+0x47>
nopl   0x0(%rax,%rax,1)
movapd %xmm3,%xmm2
cmpltsd %xmm0,%xmm2
andpd  %xmm2,%xmm4
andnpd %xmm5,%xmm2
orpd   %xmm2,%xmm4
movapd %xmm1,%xmm0
subsd  %xmm4,%xmm0
ucomisd 0xebb(%rip),%xmm0
jbe    11b5 <solve+0xa5>
movsd  %xmm1,0x8(%rsp)
movapd %xmm4,0x20(%rsp)
movapd %xmm4,%xmm0
addsd  %xmm1,%xmm0
mulsd  0xe95(%rip),%xmm0
movapd %xmm0,0x10(%rsp)
mov    $0x2,%edi
call   1030 <pow@plt>
movsd  0x8(%rsp),%xmm2
movapd 0x10(%rsp),%xmm5
movapd 0x20(%rsp),%xmm4
movsd  (%rsp),%xmm3
mulsd  %xmm5,%xmm0
ucomisd %xmm3,%xmm0
jne    11a6 <solve+0x96>
jnp    11b5 <solve+0xa5>
movapd %xmm5,%xmm1
ja     1130 <solve+0x20>
movapd %xmm2,%xmm1
jmp    1130 <solve+0x20>
movapd %xmm5,%xmm0
add    $0x38,%rsp
ret

LLVM IR (-O0):
define double @solve(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
store double %0, double* %3
store double 0.000000e+00, double* %4
store double 2.000000e+01, double* %5
br label %8
8: ; preds = %36, %1
%9 = load double, double* %5
%10 = load double, double* %4
%11 = fsub double %9, %10
%12 = fcmp ogt double %11, 1.000000e-04
br i1 %12, label %13, label %37
13: ; preds = %8
%14 = load double, double* %4
%15 = load double, double* %5
%16 = fadd double %14, %15
%17 = fdiv double %16, 2.000000e+00
store double %17, double* %6
%18 = load double, double* %6
%19 = load double, double* %6
%20 = call double @pow(i32 2, double %19)
%21 = fmul double %18, %20
store double %21, double* %7
%22 = load double, double* %7
%23 = load double, double* %3
%24 = fcmp oeq double %22, %23
br i1 %24, label %25, label %27
25: ; preds = %13
%26 = load double, double* %6
store double %26, double* %2
br label %39
27: ; preds = %13
%28 = load double, double* %7
%29 = load double, double* %3
%30 = fcmp ogt double %28, %29
br i1 %30, label %31, label %33
31: ; preds = %27
%32 = load double, double* %6
store double %32, double* %5
br label %35
33: ; preds = %27
%34 = load double, double* %6
store double %34, double* %4
br label %35
35: ; preds = %33, %31
br label %36
36: ; preds = %35
br label %8
37: ; preds = %8
%38 = load double, double* %6
store double %38, double* %2
br label %39
39: ; preds = %37, %25
%40 = load double, double* %2
ret double %40
}

LLVM IR (-O2):
define double @solve(double %0) {
br label %2
2: ; preds = %1, %10
%3 = phi double [ 2.000000e+01, %1 ], [ %13, %10 ]
%4 = phi double [ 0.000000e+00, %1 ], [ %12, %10 ]
%5 = fadd double %4, %3
%6 = fmul double %5, 5.000000e-01
%7 = tail call double @pow(i32 2, double %6)
%8 = fmul double %6, %7
%9 = fcmp oeq double %8, %0
br i1 %9, label %16, label %10
10: ; preds = %2
%11 = fcmp ogt double %8, %0
%12 = select i1 %11, double %4, double %6
%13 = select i1 %11, double %6, double %3
%14 = fsub double %13, %12
%15 = fcmp ogt double %14, 1.000000e-04
br i1 %15, label %2, label %16
16: ; preds = %10, %2
ret double %6
}