#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*/ FE_ALL_EXCEPT;
int /*<<< orphan*/ feclearexcept(int /*<<< orphan*/);
scalar_t__ fetestexcept(int /*<<< orphan*/);
scalar_t__ isfinite(float);
scalar_t__ memcmp(float *, float *, int);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char **argv) {
  float largest, small, t, inf_float;
  largest = small = 1;
  while (1) {
    t = largest + small;
    if (memcmp(&t, &largest, sizeof(float)) == 0)
      break;
    if (isfinite(t)) {
      largest = t;
      small *= 2;
      continue;
    }
    small /= 2;
  }
  inf_float = largest + largest;
  feclearexcept(FE_ALL_EXCEPT);
  if (fetestexcept(FE_ALL_EXCEPT))
    printf("\n");
  else
    printf("no math exceptions raised\n");
  printf("%.40g\n", t);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movss  0xe92(%rip),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  0xe85(%rip),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
addss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
lea    -0x1c(%rbp),%rdi
lea    -0x14(%rbp),%rsi
mov    $0x4,%edx
call   1050 <memcmp@plt>
cmp    $0x0,%rax
jne    11b0 <main+0x60>
jmp    1200 <main+0xb0>
movss  -0x1c(%rbp),%xmm0
call   1060 <isfinite@plt>
cmp    $0x0,%rax
je     11e5 <main+0x95>
movss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  0xe2e(%rip),%xmm0
mulss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
jmp    1180 <main+0x30>
movss  -0x18(%rbp),%xmm0
movss  0xe12(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
jmp    1180 <main+0x30>
movss  -0x14(%rbp),%xmm0
addss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
mov    0x2dca(%rip),%rax
mov    (%rax),%edi
call   1070 <feclearexcept@plt>
mov    0x2dbc(%rip),%rax
mov    (%rax),%edi
call   1030 <fetestexcept@plt>
cmp    $0x0,%rax
je     1248 <main+0xf8>
lea    0xde5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1256 <main+0x106>
lea    0xdb9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdbd(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
movl   $0x3f800000,0x10(%rsp)
3f
movl   $0x40000000,0xc(%rsp)
40
lea    0xc(%rsp),%rdi
lea    0x10(%rsp),%rsi
mov    $0x4,%edx
call   1070 <memcmp@plt>
test   %rax,%rax
je     1221 <main+0xb1>
movss  0xe54(%rip),%xmm0
movss  %xmm0,0x14(%rsp)
lea    0xc(%rsp),%r14
lea    0x10(%rsp),%rbx
jmp    11fb <main+0x8b>
xchg   %ax,%ax
movss  0xc(%rsp),%xmm0
movss  %xmm0,0x10(%rsp)
movss  0x14(%rsp),%xmm1
addss  %xmm1,%xmm1
movss  %xmm1,0x14(%rsp)
addss  %xmm1,%xmm0
movss  %xmm0,0xc(%rsp)
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x4,%edx
call   1070 <memcmp@plt>
test   %rax,%rax
je     1221 <main+0xb1>
movss  0xc(%rsp),%xmm0
call   1080 <isfinite@plt>
test   %rax,%rax
jne    11c0 <main+0x50>
movss  0x14(%rsp),%xmm1
mulss  0xdeb(%rip),%xmm1
movss  0x10(%rsp),%xmm0
jmp    11d6 <main+0x66>
mov    0x2db8(%rip),%rbx
mov    (%rbx),%edi
call   1090 <feclearexcept@plt>
mov    (%rbx),%edi
call   1030 <fetestexcept@plt>
test   %rax,%rax
je     1247 <main+0xd7>
mov    $0xa,%edi
call   1040 <putchar@plt>
jmp    1253 <main+0xe3>
lea    0xdc1(%rip),%rdi
call   1050 <puts@plt>
movss  0xc(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xda4(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@FE_ALL_EXCEPT = global i32 0
@.str = [2 x i8] c"\0A\00"
@.str.1 = [27 x i8] c"no math exceptions raised\0A\00"
@.str.2 = [7 x i8] c"%.40g\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca float
%7 = alloca float
%8 = alloca float
%9 = alloca float
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store float 1.000000e+00, float* %7
store float 1.000000e+00, float* %6
br label %10
10: ; preds = %2, %21, %25
%11 = load float, float* %6
%12 = load float, float* %7
%13 = fadd float %11, %12
store float %13, float* %8
%14 = call i64 @memcmp(float* %8, float* %6, i32 4)
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %10
br label %28
17: ; preds = %10
%18 = load float, float* %8
%19 = call i64 @isfinite(float %18)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %25
21: ; preds = %17
%22 = load float, float* %8
store float %22, float* %6
%23 = load float, float* %7
%24 = fmul float %23, 2.000000e+00
store float %24, float* %7
br label %10
25: ; preds = %17
%26 = load float, float* %7
%27 = fdiv float %26, 2.000000e+00
store float %27, float* %7
br label %10
28: ; preds = %16
%29 = load float, float* %6
%30 = load float, float* %6
%31 = fadd float %29, %30
store float %31, float* %9
%32 = load i32, i32* @FE_ALL_EXCEPT
%33 = call i32 @feclearexcept(i32 %32)
%34 = load i32, i32* @FE_ALL_EXCEPT
%35 = call i64 @fetestexcept(i32 %34)
%36 = icmp ne i64 %35, 0
br i1 %36, label %37, label %39
37: ; preds = %28
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %41
39: ; preds = %28
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
br label %41
41: ; preds = %39, %37
%42 = load float, float* %8
%43 = fpext float %42 to double
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), double %43)
ret i32 0
}

LLVM IR (-O2):
@FE_ALL_EXCEPT = global i32 0
@.str.2 = [7 x i8] c"%.40g\0A\00"
@str = [26 x i8] c"no math exceptions raised\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca float
%4 = alloca float
%5 = bitcast float* %3 to i8*
%6 = bitcast float* %4 to i8*
store float 1.000000e+00, float* %3
store float 2.000000e+00, float* %4
%7 = call i64 @memcmp(float* %4, float* %3, i32 4)
%8 = icmp eq i64 %7, 0
br i1 %8, label %26, label %9
9: ; preds = %2, %17
%10 = phi float [ %19, %17 ], [ 1.000000e+00, %2 ]
%11 = load float, float* %4
%12 = call i64 @isfinite(float %11)
%13 = icmp eq i64 %12, 0
br i1 %13, label %23, label %14
14: ; preds = %9
%15 = load float, float* %4
store float %15, float* %3
%16 = fmul float %10, 2.000000e+00
br label %17
17: ; preds = %14, %23
%18 = phi float [ %15, %14 ], [ %25, %23 ]
%19 = phi float [ %16, %14 ], [ %24, %23 ]
%20 = fadd float %19, %18
store float %20, float* %4
%21 = call i64 @memcmp(float* %4, float* %3, i32 4)
%22 = icmp eq i64 %21, 0
br i1 %22, label %26, label %9
23: ; preds = %9
%24 = fmul float %10, 5.000000e-01
%25 = load float, float* %3
br label %17
26: ; preds = %17, %2
%27 = load i32, i32* @FE_ALL_EXCEPT
%28 = call i32 @feclearexcept(i32 %27)
%29 = load i32, i32* @FE_ALL_EXCEPT
%30 = call i64 @fetestexcept(i32 %29)
%31 = icmp eq i64 %30, 0
br i1 %31, label %34, label %32
32: ; preds = %26
%33 = call i32 @putchar(i32 10)
br label %36
34: ; preds = %26
%35 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
br label %36
36: ; preds = %34, %32
%37 = load float, float* %4
%38 = fpext float %37 to double
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), double %38)
ret i32 0
}