#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 */
typedef int uint64_t;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int, double);
int /*<<< orphan*/ memcpy(double *, int *, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ test_one_float(double);
int test_floats(void) {
  const uint64_t max_counter = ((uint64_t)0x7ff) << 52;
  const uint64_t min_counter = 0;
  uint64_t counter;
  int prev_pct = 0;
  for (counter = min_counter; counter < max_counter;
       counter += ((1LL << 42) - 1)) {
    double v;
    int pct;
    memcpy(&v, &counter, sizeof(double));
    test_one_float(v);
    pct = (int)(counter >> 48) * 100 / (1 << 15);
    if (pct != prev_pct) {
      fprintf(stderr, "%d%% %.17g\n", pct, v);
      prev_pct = pct;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<test_floats>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %eax,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x80000000,-0xc(%rbp)
jge    11de <test_floats+0xae>
lea    -0x18(%rbp),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x8,%edx
call   1040 <memcpy@plt>
movsd  -0x18(%rbp),%xmm0
call   1050 <test_one_float@plt>
mov    -0xc(%rbp),%eax
mov    $0x30,%ecx
sar    %cl,%eax
imul   $0x64,%eax,%eax
mov    $0x8000,%ecx
cltd
idiv   %ecx
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x10(%rbp),%eax
je     11c0 <test_floats+0x90>
mov    0x2e3c(%rip),%rax
mov    (%rax),%edi
mov    -0x1c(%rbp),%edx
movsd  -0x18(%rbp),%xmm0
lea    0xe4b(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    11c5 <test_floats+0x95>
movslq -0xc(%rbp),%rax
movabs $0x3ffffffffff,%rcx
add    %rcx,%rax
mov    %eax,-0xc(%rbp)
jmp    1150 <test_floats+0x20>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_floats>:
xor    %eax,%eax
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [12 x i8] c"%d%% %.17g\0A\00"
define i32 @test_floats() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca double
%6 = alloca i32
store i32 poison, i32* %1
store i32 0, i32* %2
store i32 0, i32* %4
store i32 0, i32* %3
br label %7
7: ; preds = %28, %0
%8 = load i32, i32* %3
%9 = icmp slt i32 %8, -2147483648
br i1 %9, label %10, label %33
10: ; preds = %7
%11 = call i32 @memcpy(double* %5, i32* %3, i32 8)
%12 = load double, double* %5
%13 = call i32 @test_one_float(double %12)
%14 = load i32, i32* %3
%15 = ashr i32 %14, 48
%16 = mul nsw i32 %15, 100
%17 = sdiv i32 %16, 32768
store i32 %17, i32* %6
%18 = load i32, i32* %6
%19 = load i32, i32* %4
%20 = icmp ne i32 %18, %19
br i1 %20, label %21, label %27
21: ; preds = %10
%22 = load i32, i32* @stderr
%23 = load i32, i32* %6
%24 = load double, double* %5
%25 = call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %23, double %24)
%26 = load i32, i32* %6
store i32 %26, i32* %4
br label %27
27: ; preds = %21, %10
br label %28
28: ; preds = %27
%29 = load i32, i32* %3
%30 = sext i32 %29 to i64
%31 = add nsw i64 %30, 4398046511103
%32 = trunc i64 %31 to i32
store i32 %32, i32* %3
br label %7
33: ; preds = %7
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
define i32 @test_floats() {
ret i32 0
}