#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 truncation(double, double);
void findu(double *utx, double accx) {
  double u, ut;
  int i;
  static double divis[] = {2.0, 1.4, 1.2, 1.1};
  ut = *utx;
  u = ut / 4.0;
  if (truncation(u, 0.0) > accx) {
    for (u = ut; truncation(u, 0.0) > accx; u = ut)
      ut = ut * 4.0;
  } else {
    ut = u;
    for (u = u / 4.0; truncation(u, 0.0) <= accx; u = u / 4.0)
      ut = u;
  }
  for (i = 0; i < 4; i++) {
    u = ut / divis[i];
    if (truncation(u, 0.0) <= accx)
      ut = u;
  }
  *utx = ut;
}


x86 assembly (clang, -O0):
<findu>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  0xec5(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
xorps  %xmm1,%xmm1
call   1030 <truncation@plt>
ucomisd -0x10(%rbp),%xmm0
jbe    11a4 <findu+0x94>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
xorps  %xmm1,%xmm1
call   1030 <truncation@plt>
ucomisd -0x10(%rbp),%xmm0
jbe    119f <findu+0x8f>
movsd  0xe7a(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    1166 <findu+0x56>
jmp    120d <findu+0xfd>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xe45(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
xorps  %xmm1,%xmm1
call   1030 <truncation@plt>
movaps %xmm0,%xmm1
movsd  -0x10(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     1208 <findu+0xf8>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xe06(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    11c4 <findu+0xb4>
jmp    120d <findu+0xfd>
movl   $0x0,-0x24(%rbp)
cmpl   $0x4,-0x24(%rbp)
jge    1274 <findu+0x164>
movsd  -0x20(%rbp),%xmm0
movslq -0x24(%rbp),%rcx
lea    0x2e02(%rip),%rax
divsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
xorps  %xmm1,%xmm1
call   1030 <truncation@plt>
movaps %xmm0,%xmm1
movsd  -0x10(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     1261 <findu+0x151>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    1266 <findu+0x156>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1214 <findu+0x104>
movsd  -0x20(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<findu>:
push   %rbx
sub    $0x30,%rsp
movsd  %xmm0,0x8(%rsp)
mov    %rdi,%rbx
movsd  (%rdi),%xmm1
movsd  0xed6(%rip),%xmm0
movapd %xmm1,0x10(%rsp)
mulsd  %xmm1,%xmm0
xorpd  %xmm1,%xmm1
movsd  %xmm0,0x20(%rsp)
call   1030 <truncation@plt>
movsd  0x8(%rsp),%xmm1
ucomisd %xmm1,%xmm0
jbe    1190 <findu+0x80>
xorpd  %xmm1,%xmm1
movapd 0x10(%rsp),%xmm0
nopl   0x0(%rax)
call   1030 <truncation@plt>
ucomisd 0x8(%rsp),%xmm0
jbe    11c3 <findu+0xb3>
movapd 0x10(%rsp),%xmm0
mulsd  0xe8d(%rip),%xmm0
xorpd  %xmm1,%xmm1
movapd %xmm0,0x10(%rsp)
jmp    1160 <findu+0x50>
nopw   0x0(%rax,%rax,1)
movsd  0x20(%rsp),%xmm2
movapd %xmm2,0x10(%rsp)
mulsd  0xe5c(%rip),%xmm2
xorpd  %xmm1,%xmm1
movsd  %xmm2,0x20(%rsp)
movapd %xmm2,%xmm0
call   1030 <truncation@plt>
movsd  0x8(%rsp),%xmm1
ucomisd %xmm0,%xmm1
jae    1190 <findu+0x80>
movsd  0xe45(%rip),%xmm0
mulsd  0x10(%rsp),%xmm0
movapd %xmm0,0x20(%rsp)
xorpd  %xmm1,%xmm1
call   1030 <truncation@plt>
cmpnlesd 0x8(%rsp),%xmm0
movapd 0x10(%rsp),%xmm1
andpd  %xmm0,%xmm1
andnpd 0x20(%rsp),%xmm0
orpd   %xmm1,%xmm0
movapd %xmm0,0x10(%rsp)
divsd  0xe0f(%rip),%xmm0
movapd %xmm0,0x20(%rsp)
xorpd  %xmm1,%xmm1
call   1030 <truncation@plt>
cmpnlesd 0x8(%rsp),%xmm0
movapd %xmm0,%xmm1
andpd  0x10(%rsp),%xmm1
andnpd 0x20(%rsp),%xmm0
orpd   %xmm1,%xmm0
movapd %xmm0,0x10(%rsp)
divsd  0xddf(%rip),%xmm0
movapd %xmm0,0x20(%rsp)
xorpd  %xmm1,%xmm1
call   1030 <truncation@plt>
cmpnlesd 0x8(%rsp),%xmm0
movapd %xmm0,%xmm1
andpd  0x10(%rsp),%xmm1
andnpd 0x20(%rsp),%xmm0
orpd   %xmm1,%xmm0
movapd %xmm0,0x10(%rsp)
divsd  0xdaf(%rip),%xmm0
movapd %xmm0,0x20(%rsp)
xorpd  %xmm1,%xmm1
call   1030 <truncation@plt>
cmpnlesd 0x8(%rsp),%xmm0
movapd %xmm0,%xmm1
andpd  0x10(%rsp),%xmm1
andnpd 0x20(%rsp),%xmm0
orpd   %xmm1,%xmm0
movlpd %xmm0,(%rbx)
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@findu.divis = internal global [4 x double] [double 2.000000e+00, double 1.400000e+00, double 1.200000e+00, double 1.100000e+00]
define void @findu(double* %0, double %1) {
%3 = alloca double*
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca i32
store double* %0, double** %3
store double %1, double* %4
%8 = load double*, double** %3
%9 = load double, double* %8
store double %9, double* %6
%10 = load double, double* %6
%11 = fdiv double %10, 4.000000e+00
store double %11, double* %5
%12 = load double, double* %5
%13 = call double @truncation(double %12, double 0.000000e+00)
%14 = load double, double* %4
%15 = fcmp ogt double %13, %14
br i1 %15, label %16, label %29
16: ; preds = %2
%17 = load double, double* %6
store double %17, double* %5
br label %18
18: ; preds = %26, %16
%19 = load double, double* %5
%20 = call double @truncation(double %19, double 0.000000e+00)
%21 = load double, double* %4
%22 = fcmp ogt double %20, %21
br i1 %22, label %23, label %28
23: ; preds = %18
%24 = load double, double* %6
%25 = fmul double %24, 4.000000e+00
store double %25, double* %6
br label %26
26: ; preds = %23
%27 = load double, double* %6
store double %27, double* %5
br label %18
28: ; preds = %18
br label %44
29: ; preds = %2
%30 = load double, double* %5
store double %30, double* %6
%31 = load double, double* %5
%32 = fdiv double %31, 4.000000e+00
store double %32, double* %5
br label %33
33: ; preds = %40, %29
%34 = load double, double* %5
%35 = call double @truncation(double %34, double 0.000000e+00)
%36 = load double, double* %4
%37 = fcmp ole double %35, %36
br i1 %37, label %38, label %43
38: ; preds = %33
%39 = load double, double* %5
store double %39, double* %6
br label %40
40: ; preds = %38
%41 = load double, double* %5
%42 = fdiv double %41, 4.000000e+00
store double %42, double* %5
br label %33
43: ; preds = %33
br label %44
44: ; preds = %43, %28
store i32 0, i32* %7
br label %45
45: ; preds = %62, %44
%46 = load i32, i32* %7
%47 = icmp slt i32 %46, 4
br i1 %47, label %48, label %65
48: ; preds = %45
%49 = load double, double* %6
%50 = load i32, i32* %7
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds [4 x double], [4 x double]* @findu.divis, i64 0, i64 %51
%53 = load double, double* %52
%54 = fdiv double %49, %53
store double %54, double* %5
%55 = load double, double* %5
%56 = call double @truncation(double %55, double 0.000000e+00)
%57 = load double, double* %4
%58 = fcmp ole double %56, %57
br i1 %58, label %59, label %61
59: ; preds = %48
%60 = load double, double* %5
store double %60, double* %6
br label %61
61: ; preds = %59, %48
br label %62
62: ; preds = %61
%63 = load i32, i32* %7
%64 = add nsw i32 %63, 1
store i32 %64, i32* %7
br label %45
65: ; preds = %45
%66 = load double, double* %6
%67 = load double*, double** %3
store double %66, double* %67
ret void
}

LLVM IR (-O2):
define void @findu(double* nocapture %0, double %1) {
%3 = load double, double* %0
%4 = fmul double %3, 2.500000e-01
%5 = tail call double @truncation(double %4, double 0.000000e+00)
%6 = fcmp ogt double %5, %1
br i1 %6, label %7, label %15
7: ; preds = %2
%8 = tail call double @truncation(double %3, double 0.000000e+00)
%9 = fcmp ogt double %8, %1
br i1 %9, label %10, label %20
10: ; preds = %7, %10
%11 = phi double [ %12, %10 ], [ %3, %7 ]
%12 = fmul double %11, 4.000000e+00
%13 = tail call double @truncation(double %12, double 0.000000e+00)
%14 = fcmp ogt double %13, %1
br i1 %14, label %10, label %20
15: ; preds = %2, %15
%16 = phi double [ %17, %15 ], [ %4, %2 ]
%17 = fmul double %16, 2.500000e-01
%18 = tail call double @truncation(double %17, double 0.000000e+00)
%19 = fcmp ugt double %18, %1
br i1 %19, label %20, label %15
20: ; preds = %15, %10, %7
%21 = phi double [ %3, %7 ], [ %12, %10 ], [ %16, %15 ]
%22 = fmul double %21, 5.000000e-01
%23 = tail call double @truncation(double %22, double 0.000000e+00)
%24 = fcmp ugt double %23, %1
%25 = select i1 %24, double %21, double %22
%26 = fdiv double %25, 1.400000e+00
%27 = tail call double @truncation(double %26, double 0.000000e+00)
%28 = fcmp ugt double %27, %1
%29 = select i1 %28, double %25, double %26
%30 = fdiv double %29, 1.200000e+00
%31 = tail call double @truncation(double %30, double 0.000000e+00)
%32 = fcmp ugt double %31, %1
%33 = select i1 %32, double %29, double %30
%34 = fdiv double %33, 1.100000e+00
%35 = tail call double @truncation(double %34, double 0.000000e+00)
%36 = fcmp ugt double %35, %1
%37 = select i1 %36, double %33, double %34
store double %37, double* %0
ret void
}