#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*/ printf(char *, ...);
int main(int argc, char **argv) {
  printf("An examination of rounding error in 32-bit floats:\n");
  printf("10.001: %f\n", 10.001f);
  printf("100.001: %f\n", 100.001f);
  printf("1000.001: %f\n", 1000.001f);
  printf("10000.001: %f\n", 10000.001f);
  printf("\n");
  printf("100,000 is already too large to represent a tolerance of 0.001:\n");
  printf("100000.001: %f\n", 100000.001f);
  printf("\n");
  printf("One million could be ten times outside of tolerance, undetected:\n");
  printf("1000000.01: %f\n", 1000000.01f);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xf0a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf30(%rip),%rdi
movsd  0xeec(%rip),%xmm0
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xf26(%rip),%rdi
movsd  0xece(%rip),%xmm0
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xf1d(%rip),%rdi
movsd  0xeb0(%rip),%xmm0
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xf15(%rip),%rdi
movsd  0xe92(%rip),%xmm0
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xf4d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf00(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf33(%rip),%rdi
movsd  0xe58(%rip),%xmm0
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xf1b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf1f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf53(%rip),%rdi
movsd  0xe1e(%rip),%xmm0
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xf4e(%rip),%rdi
call   1040 <puts@plt>
lea    0xeec(%rip),%rdi
movsd  0xeb4(%rip),%xmm0
mov    $0x1,%al
call   1050 <printf@plt>
lea    0xee2(%rip),%rdi
movsd  0xea6(%rip),%xmm0
mov    $0x1,%al
call   1050 <printf@plt>
lea    0xed9(%rip),%rdi
movsd  0xe98(%rip),%xmm0
mov    $0x1,%al
call   1050 <printf@plt>
lea    0xed1(%rip),%rdi
movsd  0xe8a(%rip),%xmm0
mov    $0x1,%al
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xf13(%rip),%rdi
call   1040 <puts@plt>
lea    0xeb4(%rip),%rdi
movsd  0xe66(%rip),%xmm0
mov    $0x1,%al
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xf27(%rip),%rdi
call   1040 <puts@plt>
lea    0xe98(%rip),%rdi
movsd  0xe42(%rip),%xmm0
mov    $0x1,%al
call   1050 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [52 x i8] c"An examination of rounding error in 32-bit floats:\0A\00"
@.str.1 = [12 x i8] c"10.001: %f\0A\00"
@.str.2 = [13 x i8] c"100.001: %f\0A\00"
@.str.3 = [14 x i8] c"1000.001: %f\0A\00"
@.str.4 = [15 x i8] c"10000.001: %f\0A\00"
@.str.5 = [2 x i8] c"\0A\00"
@.str.6 = [65 x i8] c"100,000 is already too large to represent a tolerance of 0.001:\0A\00"
@.str.7 = [16 x i8] c"100000.001: %f\0A\00"
@.str.8 = [66 x i8] c"One million could be ten times outside of tolerance, undetected:\0A\00"
@.str.9 = [16 x i8] c"1000000.01: %f\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
store i32 %0, i32* %3
store i8** %1, i8*** %4
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0))
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), double 0x4024008320000000)
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), double 0x4059001060000000)
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), double 0x408F400200000000)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), double 0x40C3880020000000)
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.6, i64 0, i64 0))
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0), double 1.000000e+05)
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.8, i64 0, i64 0))
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0), double 1.000000e+06)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [12 x i8] c"10.001: %f\0A\00"
@.str.2 = [13 x i8] c"100.001: %f\0A\00"
@.str.3 = [14 x i8] c"1000.001: %f\0A\00"
@.str.4 = [15 x i8] c"10000.001: %f\0A\00"
@.str.7 = [16 x i8] c"100000.001: %f\0A\00"
@.str.9 = [16 x i8] c"1000000.01: %f\0A\00"
@str = [51 x i8] c"An examination of rounding error in 32-bit floats:\00"
@str.10 = [64 x i8] c"100,000 is already too large to represent a tolerance of 0.001:\00"
@str.11 = [65 x i8] c"One million could be ten times outside of tolerance, undetected:\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), double 0x4024008320000000)
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), double 0x4059001060000000)
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), double 0x408F400200000000)
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), double 0x40C3880020000000)
%8 = tail call i32 @putchar(i32 10)
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([64 x i8], [64 x i8]* @str.10, i64 0, i64 0))
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0), double 1.000000e+05)
%11 = tail call i32 @putchar(i32 10)
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([65 x i8], [65 x i8]* @str.11, i64 0, i64 0))
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0), double 1.000000e+06)
ret i32 0
}