#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 /*<<< orphan*/ FILE;

/* Variables and functions */
double DBL_MAX;
int ferror(int /*<<< orphan*/ *);
int /*<<< orphan*/ fputc(unsigned long, int /*<<< orphan*/ *);
int fwriteieee754(double x, FILE *fp, int bigendian) {
  int shift;
  unsigned long sign, exp, hibits, hilong, lowlong;
  double fnorm, significand;
  int expbits = 11;
  int significandbits = 52;
  if (x == 0) {
    hilong = 0;
    lowlong = 0;
    goto writedata;
  }
  if (x > DBL_MAX) {
    hilong = 1024 + ((1 << (expbits - 1)) - 1);
    hilong <<= (31 - expbits);
    lowlong = 0;
    goto writedata;
  }
  if (x < -DBL_MAX) {
    hilong = 1024 + ((1 << (expbits - 1)) - 1);
    hilong <<= (31 - expbits);
    hilong |= (1 << 31);
    lowlong = 0;
    goto writedata;
  }
  if (x != x) {
    hilong = 1024 + ((1 << (expbits - 1)) - 1);
    hilong <<= (31 - expbits);
    lowlong = 1234;
    goto writedata;
  }
  if (x < 0) {
    sign = 1;
    fnorm = -x;
  } else {
    sign = 0;
    fnorm = x;
  }
  shift = 0;
  while (fnorm >= 2.0) {
    fnorm /= 2.0;
    shift++;
  }
  while (fnorm < 1.0) {
    fnorm *= 2.0;
    shift--;
  }
  if (shift < -1022) {
    while (shift < -1022) {
      fnorm /= 2.0;
      shift++;
    }
    shift = -1023;
  } else if (shift > 1023) {
    hilong = 1024 + ((1 << (expbits - 1)) - 1);
    hilong <<= (31 - expbits);
    hilong |= (sign << 31);
    lowlong = 0;
    goto writedata;
  } else
    fnorm = fnorm - 1.0;
  significand = fnorm * ((1LL << significandbits) + 0.5f);
  exp = shift + ((1 << (expbits - 1)) - 1);
  hibits = (long)(significand / 4294967296);
  hilong = (sign << 31) | (exp << (31 - expbits)) | hibits;
  lowlong = (unsigned long)(significand - hibits * 4294967296);
writedata:
  if (bigendian) {
    fputc((hilong >> 24) & 0xFF, fp);
    fputc((hilong >> 16) & 0xFF, fp);
    fputc((hilong >> 8) & 0xFF, fp);
    fputc(hilong & 0xFF, fp);
    fputc((lowlong >> 24) & 0xFF, fp);
    fputc((lowlong >> 16) & 0xFF, fp);
    fputc((lowlong >> 8) & 0xFF, fp);
    fputc(lowlong & 0xFF, fp);
  } else {
    fputc(lowlong & 0xFF, fp);
    fputc((lowlong >> 8) & 0xFF, fp);
    fputc((lowlong >> 16) & 0xFF, fp);
    fputc((lowlong >> 24) & 0xFF, fp);
    fputc(hilong & 0xFF, fp);
    fputc((hilong >> 8) & 0xFF, fp);
    fputc((hilong >> 16) & 0xFF, fp);
    fputc((hilong >> 24) & 0xFF, fp);
  }
  return ferror(fp);
}


x86 assembly (clang, -O0):
<fwriteieee754>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
movl   $0xb,-0x54(%rbp)
movl   $0x34,-0x58(%rbp)
movsd  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    116f <fwriteieee754+0x4f>
jp     116f <fwriteieee754+0x4f>
movq   $0x0,-0x38(%rbp)
movq   $0x0,-0x40(%rbp)
jmp    1513 <fwriteieee754+0x3f3>
movsd  -0x8(%rbp),%xmm0
mov    0x2e65(%rip),%rax
ucomisd (%rax),%xmm0
jbe    11c2 <fwriteieee754+0xa2>
mov    -0x54(%rbp),%ecx
sub    $0x1,%ecx
mov    $0x1,%eax
shl    %cl,%eax
sub    $0x1,%eax
add    $0x400,%eax
cltq
mov    %rax,-0x38(%rbp)
mov    $0x1f,%ecx
sub    -0x54(%rbp),%ecx
mov    -0x38(%rbp),%rax
mov    %ecx,%ecx
shl    %cl,%rax
mov    %rax,-0x38(%rbp)
movq   $0x0,-0x40(%rbp)
jmp    1513 <fwriteieee754+0x3f3>
movsd  -0x8(%rbp),%xmm1
mov    0x2e12(%rip),%rax
movsd  (%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
ucomisd %xmm1,%xmm0
jbe    123e <fwriteieee754+0x11e>
mov    -0x54(%rbp),%ecx
sub    $0x1,%ecx
mov    $0x1,%eax
shl    %cl,%eax
sub    $0x1,%eax
add    $0x400,%eax
cltq
mov    %rax,-0x38(%rbp)
mov    $0x1f,%ecx
sub    -0x54(%rbp),%ecx
mov    -0x38(%rbp),%rax
mov    %ecx,%ecx
shl    %cl,%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
or     $0xffffffff80000000,%rax
mov    %rax,-0x38(%rbp)
movq   $0x0,-0x40(%rbp)
jmp    1513 <fwriteieee754+0x3f3>
movsd  -0x8(%rbp),%xmm0
ucomisd -0x8(%rbp),%xmm0
jne    1259 <fwriteieee754+0x139>
jp     1259 <fwriteieee754+0x139>
jmp    1296 <fwriteieee754+0x176>
mov    -0x54(%rbp),%ecx
sub    $0x1,%ecx
mov    $0x1,%eax
shl    %cl,%eax
sub    $0x1,%eax
add    $0x400,%eax
cltq
mov    %rax,-0x38(%rbp)
mov    $0x1f,%ecx
sub    -0x54(%rbp),%ecx
mov    -0x38(%rbp),%rax
mov    %ecx,%ecx
shl    %cl,%rax
mov    %rax,-0x38(%rbp)
movq   $0x4d2,-0x40(%rbp)
jmp    1513 <fwriteieee754+0x3f3>
xorps  %xmm0,%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    12d2 <fwriteieee754+0x1b2>
movq   $0x1,-0x20(%rbp)
movsd  -0x8(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x48(%rbp)
jmp    12e4 <fwriteieee754+0x1c4>
movq   $0x0,-0x20(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movl   $0x0,-0x18(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  0xd08(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     1326 <fwriteieee754+0x206>
movsd  -0x48(%rbp),%xmm0
movsd  0xcf1(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    12eb <fwriteieee754+0x1cb>
jmp    132b <fwriteieee754+0x20b>
movsd  0xcd5(%rip),%xmm0
ucomisd -0x48(%rbp),%xmm0
jbe    135e <fwriteieee754+0x23e>
movsd  0xcba(%rip),%xmm0
mulsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
jmp    132b <fwriteieee754+0x20b>
cmpl   $0xfffffc02,-0x18(%rbp)
jge    13ad <fwriteieee754+0x28d>
jmp    1370 <fwriteieee754+0x250>
cmpl   $0xfffffc02,-0x18(%rbp)
jge    13a1 <fwriteieee754+0x281>
movsd  -0x48(%rbp),%xmm0
movsd  0xc76(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1370 <fwriteieee754+0x250>
movl   $0xfffffc01,-0x18(%rbp)
jmp    1422 <fwriteieee754+0x302>
cmpl   $0x3ff,-0x18(%rbp)
jle    1407 <fwriteieee754+0x2e7>
mov    -0x54(%rbp),%ecx
sub    $0x1,%ecx
mov    $0x1,%eax
shl    %cl,%eax
sub    $0x1,%eax
add    $0x400,%eax
cltq
mov    %rax,-0x38(%rbp)
mov    $0x1f,%ecx
sub    -0x54(%rbp),%ecx
mov    -0x38(%rbp),%rax
mov    %ecx,%ecx
shl    %cl,%rax
mov    %rax,-0x38(%rbp)
mov    -0x20(%rbp),%rax
shl    $0x1f,%rax
or     -0x38(%rbp),%rax
mov    %rax,-0x38(%rbp)
movq   $0x0,-0x40(%rbp)
jmp    1513 <fwriteieee754+0x3f3>
movsd  -0x48(%rbp),%xmm0
movsd  0xbf4(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
jmp    1422 <fwriteieee754+0x302>
movsd  -0x48(%rbp),%xmm0
mov    -0x58(%rbp),%cl
mov    $0x1,%eax
shl    %cl,%rax
cvtsi2ss %rax,%xmm1
movss  0xbe1(%rip),%xmm2
addss  %xmm2,%xmm1
cvtss2sd %xmm1,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x54(%rbp),%cl
add    $0xff,%cl
mov    $0x1,%edx
shl    %cl,%edx
mov    %eax,%ecx
mov    %edx,%eax
lea    -0x1(%rax,%rcx,1),%eax
cltq
mov    %rax,-0x28(%rbp)
movsd  -0x50(%rbp),%xmm0
movsd  0xb95(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rax
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rax
shl    $0x1f,%rax
mov    -0x28(%rbp),%rdx
mov    -0x54(%rbp),%sil
mov    $0x1f,%cl
sub    %sil,%cl
shl    %cl,%rdx
mov    %rdx,%rcx
or     %rcx,%rax
mov    -0x30(%rbp),%rcx
or     %rcx,%rax
mov    %rax,-0x38(%rbp)
movsd  -0x50(%rbp),%xmm0
mov    -0x30(%rbp),%rax
shl    $0x20,%rax
movq   %rax,%xmm1
movaps 0xb66(%rip),%xmm2
punpckldq %xmm2,%xmm1
movapd 0xb6a(%rip),%xmm2
subpd  %xmm2,%xmm1
movaps %xmm1,%xmm2
unpckhpd %xmm1,%xmm1
addsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
movaps %xmm0,%xmm1
cvttsd2si %xmm1,%rax
mov    %rax,%rdx
sar    $0x3f,%rdx
movsd  0xb18(%rip),%xmm1
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rcx
and    %rdx,%rcx
or     %rcx,%rax
mov    %rax,-0x40(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     15da <fwriteieee754+0x4ba>
mov    -0x38(%rbp),%rdi
shr    $0x18,%rdi
and    $0xff,%rdi
mov    -0x10(%rbp),%rsi
call   1040 <fputc@plt>
mov    -0x38(%rbp),%rdi
shr    $0x10,%rdi
and    $0xff,%rdi
mov    -0x10(%rbp),%rsi
call   1040 <fputc@plt>
mov    -0x38(%rbp),%rdi
shr    $0x8,%rdi
and    $0xff,%rdi
mov    -0x10(%rbp),%rsi
call   1040 <fputc@plt>
mov    -0x38(%rbp),%rdi
and    $0xff,%rdi
mov    -0x10(%rbp),%rsi
call   1040 <fputc@plt>
mov    -0x40(%rbp),%rdi
shr    $0x18,%rdi
and    $0xff,%rdi
mov    -0x10(%rbp),%rsi
call   1040 <fputc@plt>
mov    -0x40(%rbp),%rdi
shr    $0x10,%rdi
and    $0xff,%rdi
mov    -0x10(%rbp),%rsi
call   1040 <fputc@plt>
mov    -0x40(%rbp),%rdi
shr    $0x8,%rdi
and    $0xff,%rdi
mov    -0x10(%rbp),%rsi
call   1040 <fputc@plt>
mov    -0x40(%rbp),%rdi
and    $0xff,%rdi
mov    -0x10(%rbp),%rsi
call   1040 <fputc@plt>
jmp    1692 <fwriteieee754+0x572>
mov    -0x40(%rbp),%rdi
and    $0xff,%rdi
mov    -0x10(%rbp),%rsi
call   1040 <fputc@plt>
mov    -0x40(%rbp),%rdi
shr    $0x8,%rdi
and    $0xff,%rdi
mov    -0x10(%rbp),%rsi
call   1040 <fputc@plt>
mov    -0x40(%rbp),%rdi
shr    $0x10,%rdi
and    $0xff,%rdi
mov    -0x10(%rbp),%rsi
call   1040 <fputc@plt>
mov    -0x40(%rbp),%rdi
shr    $0x18,%rdi
and    $0xff,%rdi
mov    -0x10(%rbp),%rsi
call   1040 <fputc@plt>
mov    -0x38(%rbp),%rdi
and    $0xff,%rdi
mov    -0x10(%rbp),%rsi
call   1040 <fputc@plt>
mov    -0x38(%rbp),%rdi
shr    $0x8,%rdi
and    $0xff,%rdi
mov    -0x10(%rbp),%rsi
call   1040 <fputc@plt>
mov    -0x38(%rbp),%rdi
shr    $0x10,%rdi
and    $0xff,%rdi
mov    -0x10(%rbp),%rsi
call   1040 <fputc@plt>
mov    -0x38(%rbp),%rdi
shr    $0x18,%rdi
and    $0xff,%rdi
mov    -0x10(%rbp),%rsi
call   1040 <fputc@plt>
mov    -0x10(%rbp),%rdi
call   1030 <ferror@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fwriteieee754>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11a9 <fwriteieee754+0x89>
jp     11a9 <fwriteieee754+0x89>
xor    %ebx,%ebx
xor    %edx,%edx
test   %esi,%esi
je     11e2 <fwriteieee754+0xc2>
mov    %edx,%edi
shr    $0x18,%edi
mov    %r14,%rsi
mov    %rbx,%r15
mov    %rdx,%rbx
call   1040 <fputc@plt>
mov    %ebx,%eax
shr    $0x10,%eax
movzbl %al,%edi
mov    %r14,%rsi
call   1040 <fputc@plt>
movzbl %bh,%edi
mov    %r14,%rsi
call   1040 <fputc@plt>
movzbl %bl,%edi
mov    %r15,%rbx
mov    %r14,%rsi
call   1040 <fputc@plt>
mov    %ebx,%edi
shr    $0x18,%edi
mov    %r14,%rsi
call   1040 <fputc@plt>
mov    %ebx,%eax
shr    $0x10,%eax
movzbl %al,%edi
mov    %r14,%rsi
call   1040 <fputc@plt>
movzbl %bh,%edi
mov    %r14,%rsi
call   1040 <fputc@plt>
jmp    1246 <fwriteieee754+0x126>
mov    0x2e30(%rip),%rax
movsd  (%rax),%xmm1
mov    $0x7ff00000,%edx
ucomisd %xmm1,%xmm0
ja     11d8 <fwriteieee754+0xb8>
xorpd  0xe39(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    125e <fwriteieee754+0x13e>
mov    $0xfffffffffff00000,%rdx
xor    %ebx,%ebx
test   %esi,%esi
jne    1140 <fwriteieee754+0x20>
movzbl %bl,%edi
mov    %r14,%rsi
mov    %rdx,%r15
call   1040 <fputc@plt>
movzbl %bh,%edi
mov    %r14,%rsi
call   1040 <fputc@plt>
mov    %ebx,%eax
shr    $0x10,%eax
movzbl %al,%edi
mov    %r14,%rsi
call   1040 <fputc@plt>
shr    $0x18,%ebx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <fputc@plt>
mov    %r15,%rbx
movzbl %bl,%edi
mov    %r14,%rsi
call   1040 <fputc@plt>
movzbl %bh,%edi
mov    %r14,%rsi
call   1040 <fputc@plt>
mov    %ebx,%eax
shr    $0x10,%eax
movzbl %al,%edi
mov    %r14,%rsi
call   1040 <fputc@plt>
shr    $0x18,%rbx
movzbl %bl,%edi
mov    %r14,%rsi
call   1040 <fputc@plt>
mov    %r14,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <ferror@plt>
ucomisd %xmm0,%xmm0
jp     1402 <fwriteieee754+0x2e2>
xorpd  %xmm1,%xmm1
xor    %edx,%edx
ucomisd %xmm0,%xmm1
seta   %al
jbe    127f <fwriteieee754+0x15f>
xorpd  0xd81(%rip),%xmm0
mov    %al,%dl
xor    %eax,%eax
ucomisd 0xda5(%rip),%xmm0
jb     12ad <fwriteieee754+0x18d>
xor    %eax,%eax
movsd  0xda1(%rip),%xmm1
movsd  0xd91(%rip),%xmm2
nop
mulsd  %xmm1,%xmm0
add    $0x1,%eax
ucomisd %xmm2,%xmm0
jae    12a0 <fwriteieee754+0x180>
movsd  0xd8b(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    12cd <fwriteieee754+0x1ad>
nopl   0x0(%rax,%rax,1)
addsd  %xmm0,%xmm0
add    $0xffffffff,%eax
ucomisd %xmm0,%xmm1
ja     12c0 <fwriteieee754+0x1a0>
shl    $0x1f,%rdx
cmp    $0xfffffc01,%eax
jg     1311 <fwriteieee754+0x1f1>
mov    $0x2,%ecx
sub    %eax,%ecx
mov    %rdx,%rdi
and    $0x7,%ecx
je     132e <fwriteieee754+0x20e>
neg    %ecx
xor    %edx,%edx
movsd  0xd45(%rip),%xmm1
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mulsd  %xmm1,%xmm0
add    $0xffffffff,%edx
cmp    %edx,%ecx
jne    1300 <fwriteieee754+0x1e0>
mov    %eax,%ecx
sub    %edx,%ecx
jmp    1330 <fwriteieee754+0x210>
cmp    $0x400,%eax
jl     1324 <fwriteieee754+0x204>
or     $0x7ff00000,%rdx
jmp    11d8 <fwriteieee754+0xb8>
addsd  0xd1c(%rip),%xmm0
jmp    1385 <fwriteieee754+0x265>
mov    %eax,%ecx
mov    %eax,%edx
add    $0x405,%edx
mov    $0xfffffc01,%eax
cmp    $0x7,%edx
jae    1347 <fwriteieee754+0x227>
mov    %rdi,%rdx
jmp    1385 <fwriteieee754+0x265>
add    $0x3fe,%ecx
movsd  0xce3(%rip),%xmm1
mov    %rdi,%rdx
nopl   0x0(%rax,%rax,1)
mulsd  %xmm1,%xmm0
mulsd  %xmm1,%xmm0
mulsd  %xmm1,%xmm0
mulsd  %xmm1,%xmm0
mulsd  %xmm1,%xmm0
mulsd  %xmm1,%xmm0
mulsd  %xmm1,%xmm0
mulsd  %xmm1,%xmm0
add    $0x8,%ecx
jne    1360 <fwriteieee754+0x240>
mulsd  0xcc3(%rip),%xmm0
add    $0x3ff,%eax
movsd  0xcbe(%rip),%xmm1
mulsd  %xmm0,%xmm1
cvttsd2si %xmm1,%rcx
or     %rcx,%rdx
shl    $0x20,%rcx
movq   %rcx,%xmm1
punpckldq 0xc59(%rip),%xmm1
shl    $0x14,%rax
subpd  0xc5d(%rip),%xmm1
movapd %xmm1,%xmm2
unpckhpd %xmm1,%xmm2
addsd  %xmm1,%xmm2
subsd  %xmm2,%xmm0
cvttsd2si %xmm0,%rcx
or     %rax,%rdx
mov    %rcx,%rax
sar    $0x3f,%rax
subsd  0xc76(%rip),%xmm0
cvttsd2si %xmm0,%rbx
and    %rax,%rbx
or     %rcx,%rbx
test   %esi,%esi
jne    1140 <fwriteieee754+0x20>
jmp    11e2 <fwriteieee754+0xc2>
mov    $0x4d2,%ebx
test   %esi,%esi
jne    1140 <fwriteieee754+0x20>
jmp    11e2 <fwriteieee754+0xc2>

LLVM IR (-O0):
@DBL_MAX = global double 0.000000e+00
define i32 @fwriteieee754(double %0, i32* %1, i32 %2) {
%4 = alloca double
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i64
%9 = alloca i64
%10 = alloca i64
%11 = alloca i64
%12 = alloca i64
%13 = alloca double
%14 = alloca double
%15 = alloca i32
%16 = alloca i32
store double %0, double* %4
store i32* %1, i32** %5
store i32 %2, i32* %6
store i32 11, i32* %15
store i32 52, i32* %16
%17 = load double, double* %4
%18 = fcmp oeq double %17, 0.000000e+00
br i1 %18, label %19, label %20
19: ; preds = %3
store i64 0, i64* %11
store i64 0, i64* %12
br label %168
20: ; preds = %3
%21 = load double, double* %4
%22 = load double, double* @DBL_MAX
%23 = fcmp ogt double %21, %22
br i1 %23, label %24, label %36
24: ; preds = %20
%25 = load i32, i32* %15
%26 = sub nsw i32 %25, 1
%27 = shl i32 1, %26
%28 = sub nsw i32 %27, 1
%29 = add nsw i32 1024, %28
%30 = sext i32 %29 to i64
store i64 %30, i64* %11
%31 = load i32, i32* %15
%32 = sub nsw i32 31, %31
%33 = load i64, i64* %11
%34 = zext i32 %32 to i64
%35 = shl i64 %33, %34
store i64 %35, i64* %11
store i64 0, i64* %12
br label %168
36: ; preds = %20
%37 = load double, double* %4
%38 = load double, double* @DBL_MAX
%39 = fneg double %38
%40 = fcmp olt double %37, %39
br i1 %40, label %41, label %55
41: ; preds = %36
%42 = load i32, i32* %15
%43 = sub nsw i32 %42, 1
%44 = shl i32 1, %43
%45 = sub nsw i32 %44, 1
%46 = add nsw i32 1024, %45
%47 = sext i32 %46 to i64
store i64 %47, i64* %11
%48 = load i32, i32* %15
%49 = sub nsw i32 31, %48
%50 = load i64, i64* %11
%51 = zext i32 %49 to i64
%52 = shl i64 %50, %51
store i64 %52, i64* %11
%53 = load i64, i64* %11
%54 = or i64 %53, -2147483648
store i64 %54, i64* %11
store i64 0, i64* %12
br label %168
55: ; preds = %36
%56 = load double, double* %4
%57 = load double, double* %4
%58 = fcmp une double %56, %57
br i1 %58, label %59, label %71
59: ; preds = %55
%60 = load i32, i32* %15
%61 = sub nsw i32 %60, 1
%62 = shl i32 1, %61
%63 = sub nsw i32 %62, 1
%64 = add nsw i32 1024, %63
%65 = sext i32 %64 to i64
store i64 %65, i64* %11
%66 = load i32, i32* %15
%67 = sub nsw i32 31, %66
%68 = load i64, i64* %11
%69 = zext i32 %67 to i64
%70 = shl i64 %68, %69
store i64 %70, i64* %11
store i64 1234, i64* %12
br label %168
71: ; preds = %55
%72 = load double, double* %4
%73 = fcmp olt double %72, 0.000000e+00
br i1 %73, label %74, label %77
74: ; preds = %71
store i64 1, i64* %8
%75 = load double, double* %4
%76 = fneg double %75
store double %76, double* %13
br label %79
77: ; preds = %71
store i64 0, i64* %8
%78 = load double, double* %4
store double %78, double* %13
br label %79
79: ; preds = %77, %74
store i32 0, i32* %7
br label %80
80: ; preds = %83, %79
%81 = load double, double* %13
%82 = fcmp oge double %81, 2.000000e+00
br i1 %82, label %83, label %88
83: ; preds = %80
%84 = load double, double* %13
%85 = fdiv double %84, 2.000000e+00
store double %85, double* %13
%86 = load i32, i32* %7
%87 = add nsw i32 %86, 1
store i32 %87, i32* %7
br label %80
88: ; preds = %80
br label %89
89: ; preds = %92, %88
%90 = load double, double* %13
%91 = fcmp olt double %90, 1.000000e+00
br i1 %91, label %92, label %97
92: ; preds = %89
%93 = load double, double* %13
%94 = fmul double %93, 2.000000e+00
store double %94, double* %13
%95 = load i32, i32* %7
%96 = add nsw i32 %95, -1
store i32 %96, i32* %7
br label %89
97: ; preds = %89
%98 = load i32, i32* %7
%99 = icmp slt i32 %98, -1022
br i1 %99, label %100, label %110
100: ; preds = %97
br label %101
101: ; preds = %104, %100
%102 = load i32, i32* %7
%103 = icmp slt i32 %102, -1022
br i1 %103, label %104, label %109
104: ; preds = %101
%105 = load double, double* %13
%106 = fdiv double %105, 2.000000e+00
store double %106, double* %13
%107 = load i32, i32* %7
%108 = add nsw i32 %107, 1
store i32 %108, i32* %7
br label %101
109: ; preds = %101
store i32 -1023, i32* %7
br label %133
110: ; preds = %97
%111 = load i32, i32* %7
%112 = icmp sgt i32 %111, 1023
br i1 %112, label %113, label %129
113: ; preds = %110
%114 = load i32, i32* %15
%115 = sub nsw i32 %114, 1
%116 = shl i32 1, %115
%117 = sub nsw i32 %116, 1
%118 = add nsw i32 1024, %117
%119 = sext i32 %118 to i64
store i64 %119, i64* %11
%120 = load i32, i32* %15
%121 = sub nsw i32 31, %120
%122 = load i64, i64* %11
%123 = zext i32 %121 to i64
%124 = shl i64 %122, %123
store i64 %124, i64* %11
%125 = load i64, i64* %8
%126 = shl i64 %125, 31
%127 = load i64, i64* %11
%128 = or i64 %127, %126
store i64 %128, i64* %11
store i64 0, i64* %12
br label %168
129: ; preds = %110
%130 = load double, double* %13
%131 = fsub double %130, 1.000000e+00
store double %131, double* %13
br label %132
132: ; preds = %129
br label %133
133: ; preds = %132, %109
%134 = load double, double* %13
%135 = load i32, i32* %16
%136 = zext i32 %135 to i64
%137 = shl i64 1, %136
%138 = sitofp i64 %137 to float
%139 = fadd float %138, 5.000000e-01
%140 = fpext float %139 to double
%141 = fmul double %134, %140
store double %141, double* %14
%142 = load i32, i32* %7
%143 = load i32, i32* %15
%144 = sub nsw i32 %143, 1
%145 = shl i32 1, %144
%146 = sub nsw i32 %145, 1
%147 = add nsw i32 %142, %146
%148 = sext i32 %147 to i64
store i64 %148, i64* %9
%149 = load double, double* %14
%150 = fdiv double %149, 0x41F0000000000000
%151 = fptosi double %150 to i64
store i64 %151, i64* %10
%152 = load i64, i64* %8
%153 = shl i64 %152, 31
%154 = load i64, i64* %9
%155 = load i32, i32* %15
%156 = sub nsw i32 31, %155
%157 = zext i32 %156 to i64
%158 = shl i64 %154, %157
%159 = or i64 %153, %158
%160 = load i64, i64* %10
%161 = or i64 %159, %160
store i64 %161, i64* %11
%162 = load double, double* %14
%163 = load i64, i64* %10
%164 = mul i64 %163, 4294967296
%165 = uitofp i64 %164 to double
%166 = fsub double %162, %165
%167 = fptoui double %166 to i64
store i64 %167, i64* %12
br label %168
168: ; preds = %133, %113, %59, %41, %24, %19
%169 = load i32, i32* %6
%170 = icmp ne i32 %169, 0
br i1 %170, label %171, label %210
171: ; preds = %168
%172 = load i64, i64* %11
%173 = lshr i64 %172, 24
%174 = and i64 %173, 255
%175 = load i32*, i32** %5
%176 = call i32 @fputc(i64 %174, i32* %175)
%177 = load i64, i64* %11
%178 = lshr i64 %177, 16
%179 = and i64 %178, 255
%180 = load i32*, i32** %5
%181 = call i32 @fputc(i64 %179, i32* %180)
%182 = load i64, i64* %11
%183 = lshr i64 %182, 8
%184 = and i64 %183, 255
%185 = load i32*, i32** %5
%186 = call i32 @fputc(i64 %184, i32* %185)
%187 = load i64, i64* %11
%188 = and i64 %187, 255
%189 = load i32*, i32** %5
%190 = call i32 @fputc(i64 %188, i32* %189)
%191 = load i64, i64* %12
%192 = lshr i64 %191, 24
%193 = and i64 %192, 255
%194 = load i32*, i32** %5
%195 = call i32 @fputc(i64 %193, i32* %194)
%196 = load i64, i64* %12
%197 = lshr i64 %196, 16
%198 = and i64 %197, 255
%199 = load i32*, i32** %5
%200 = call i32 @fputc(i64 %198, i32* %199)
%201 = load i64, i64* %12
%202 = lshr i64 %201, 8
%203 = and i64 %202, 255
%204 = load i32*, i32** %5
%205 = call i32 @fputc(i64 %203, i32* %204)
%206 = load i64, i64* %12
%207 = and i64 %206, 255
%208 = load i32*, i32** %5
%209 = call i32 @fputc(i64 %207, i32* %208)
br label %249
210: ; preds = %168
%211 = load i64, i64* %12
%212 = and i64 %211, 255
%213 = load i32*, i32** %5
%214 = call i32 @fputc(i64 %212, i32* %213)
%215 = load i64, i64* %12
%216 = lshr i64 %215, 8
%217 = and i64 %216, 255
%218 = load i32*, i32** %5
%219 = call i32 @fputc(i64 %217, i32* %218)
%220 = load i64, i64* %12
%221 = lshr i64 %220, 16
%222 = and i64 %221, 255
%223 = load i32*, i32** %5
%224 = call i32 @fputc(i64 %222, i32* %223)
%225 = load i64, i64* %12
%226 = lshr i64 %225, 24
%227 = and i64 %226, 255
%228 = load i32*, i32** %5
%229 = call i32 @fputc(i64 %227, i32* %228)
%230 = load i64, i64* %11
%231 = and i64 %230, 255
%232 = load i32*, i32** %5
%233 = call i32 @fputc(i64 %231, i32* %232)
%234 = load i64, i64* %11
%235 = lshr i64 %234, 8
%236 = and i64 %235, 255
%237 = load i32*, i32** %5
%238 = call i32 @fputc(i64 %236, i32* %237)
%239 = load i64, i64* %11
%240 = lshr i64 %239, 16
%241 = and i64 %240, 255
%242 = load i32*, i32** %5
%243 = call i32 @fputc(i64 %241, i32* %242)
%244 = load i64, i64* %11
%245 = lshr i64 %244, 24
%246 = and i64 %245, 255
%247 = load i32*, i32** %5
%248 = call i32 @fputc(i64 %246, i32* %247)
br label %249
249: ; preds = %210, %171
%250 = load i32*, i32** %5
%251 = call i32 @ferror(i32* %250)
ret i32 %251
}

LLVM IR (-O2):
@DBL_MAX = global double 0.000000e+00
define i32 @fwriteieee754(double %0, i32* nocapture %1, i32 %2) {
%4 = fcmp oeq double %0, 0.000000e+00
br i1 %4, label %91, label %5
5: ; preds = %3
%6 = load double, double* @DBL_MAX
%7 = fcmp olt double %6, %0
br i1 %7, label %91, label %8
8: ; preds = %5
%9 = fneg double %6
%10 = fcmp ogt double %9, %0
br i1 %10, label %91, label %11
11: ; preds = %8
%12 = fcmp uno double %0, 0.000000e+00
br i1 %12, label %91, label %13
13: ; preds = %11
%14 = fcmp olt double %0, 0.000000e+00
%15 = fneg double %0
%16 = select i1 %14, double %15, double %0
%17 = select i1 %14, i64 2147483648, i64 0
%18 = fcmp ult double %16, 2.000000e+00
br i1 %18, label %19, label %23
19: ; preds = %23, %13
%20 = phi double [ %16, %13 ], [ %26, %23 ]
%21 = phi i32 [ 0, %13 ], [ %27, %23 ]
%22 = fcmp olt double %20, 1.000000e+00
br i1 %22, label %29, label %35
23: ; preds = %13, %23
%24 = phi i32 [ %27, %23 ], [ 0, %13 ]
%25 = phi double [ %26, %23 ], [ %16, %13 ]
%26 = fmul double %25, 5.000000e-01
%27 = add nuw nsw i32 %24, 1
%28 = fcmp ult double %26, 2.000000e+00
br i1 %28, label %19, label %23
29: ; preds = %19, %29
%30 = phi i32 [ %33, %29 ], [ %21, %19 ]
%31 = phi double [ %32, %29 ], [ %20, %19 ]
%32 = fmul double %31, 2.000000e+00
%33 = add nsw i32 %30, -1
%34 = fcmp olt double %32, 1.000000e+00
br i1 %34, label %29, label %35
35: ; preds = %29, %19
%36 = phi double [ %20, %19 ], [ %32, %29 ]
%37 = phi i32 [ %21, %19 ], [ %33, %29 ]
%38 = icmp slt i32 %37, -1022
br i1 %38, label %39, label %70
39: ; preds = %35
%40 = sub i32 2, %37
%41 = and i32 %40, 7
%42 = icmp eq i32 %41, 0
br i1 %42, label %51, label %43
43: ; preds = %39, %43
%44 = phi i32 [ %48, %43 ], [ %37, %39 ]
%45 = phi double [ %47, %43 ], [ %36, %39 ]
%46 = phi i32 [ %49, %43 ], [ 0, %39 ]
%47 = fmul double %45, 5.000000e-01
%48 = add i32 %44, 1
%49 = add i32 %46, 1
%50 = icmp eq i32 %49, %41
br i1 %50, label %51, label %43
51: ; preds = %43, %39
%52 = phi double [ undef, %39 ], [ %47, %43 ]
%53 = phi i32 [ %37, %39 ], [ %48, %43 ]
%54 = phi double [ %36, %39 ], [ %47, %43 ]
%55 = add i32 %37, 1029
%56 = icmp ult i32 %55, 7
br i1 %56, label %76, label %57
57: ; preds = %51, %57
%58 = phi i32 [ %68, %57 ], [ %53, %51 ]
%59 = phi double [ %67, %57 ], [ %54, %51 ]
%60 = fmul double %59, 5.000000e-01
%61 = fmul double %60, 5.000000e-01
%62 = fmul double %61, 5.000000e-01
%63 = fmul double %62, 5.000000e-01
%64 = fmul double %63, 5.000000e-01
%65 = fmul double %64, 5.000000e-01
%66 = fmul double %65, 5.000000e-01
%67 = fmul double %66, 5.000000e-01
%68 = add i32 %58, 8
%69 = icmp eq i32 %68, -1022
br i1 %69, label %76, label %57
70: ; preds = %35
%71 = icmp sgt i32 %37, 1023
br i1 %71, label %72, label %74
72: ; preds = %70
%73 = or i64 %17, 2146435072
br label %91
74: ; preds = %70
%75 = fadd double %36, -1.000000e+00
br label %76
76: ; preds = %51, %57, %74
%77 = phi double [ %75, %74 ], [ %52, %51 ], [ %67, %57 ]
%78 = phi i32 [ %37, %74 ], [ -1023, %57 ], [ -1023, %51 ]
%79 = fmul double %77, 0x4330000000000000
%80 = add nsw i32 %78, 1023
%81 = zext i32 %80 to i64
%82 = fmul double %79, 0x3DF0000000000000
%83 = fptosi double %82 to i64
%84 = shl nuw nsw i64 %81, 20
%85 = or i64 %17, %83
%86 = or i64 %85, %84
%87 = shl i64 %83, 32
%88 = uitofp i64 %87 to double
%89 = fsub double %79, %88
%90 = fptoui double %89 to i64
br label %91
91: ; preds = %11, %8, %5, %3, %76, %72
%92 = phi i64 [ %90, %76 ], [ 0, %72 ], [ 0, %3 ], [ 0, %5 ], [ 0, %8 ], [ 1234, %11 ]
%93 = phi i64 [ %86, %76 ], [ %73, %72 ], [ 0, %3 ], [ 2146435072, %5 ], [ -1048576, %8 ], [ 2146435072, %11 ]
%94 = icmp eq i32 %2, 0
br i1 %94, label %116, label %95
95: ; preds = %91
%96 = lshr i64 %93, 24
%97 = and i64 %96, 255
%98 = tail call i32 @fputc(i64 %97, i32* %1)
%99 = lshr i64 %93, 16
%100 = and i64 %99, 255
%101 = tail call i32 @fputc(i64 %100, i32* %1)
%102 = lshr i64 %93, 8
%103 = and i64 %102, 255
%104 = tail call i32 @fputc(i64 %103, i32* %1)
%105 = and i64 %93, 255
%106 = tail call i32 @fputc(i64 %105, i32* %1)
%107 = lshr i64 %92, 24
%108 = and i64 %107, 255
%109 = tail call i32 @fputc(i64 %108, i32* %1)
%110 = lshr i64 %92, 16
%111 = and i64 %110, 255
%112 = tail call i32 @fputc(i64 %111, i32* %1)
%113 = lshr i64 %92, 8
%114 = and i64 %113, 255
%115 = tail call i32 @fputc(i64 %114, i32* %1)
br label %137
116: ; preds = %91
%117 = and i64 %92, 255
%118 = tail call i32 @fputc(i64 %117, i32* %1)
%119 = lshr i64 %92, 8
%120 = and i64 %119, 255
%121 = tail call i32 @fputc(i64 %120, i32* %1)
%122 = lshr i64 %92, 16
%123 = and i64 %122, 255
%124 = tail call i32 @fputc(i64 %123, i32* %1)
%125 = lshr i64 %92, 24
%126 = and i64 %125, 255
%127 = tail call i32 @fputc(i64 %126, i32* %1)
%128 = and i64 %93, 255
%129 = tail call i32 @fputc(i64 %128, i32* %1)
%130 = lshr i64 %93, 8
%131 = and i64 %130, 255
%132 = tail call i32 @fputc(i64 %131, i32* %1)
%133 = lshr i64 %93, 16
%134 = and i64 %133, 255
%135 = tail call i32 @fputc(i64 %134, i32* %1)
%136 = lshr i64 %93, 24
br label %137
137: ; preds = %116, %95
%138 = phi i64 [ %136, %116 ], [ %92, %95 ]
%139 = and i64 %138, 255
%140 = tail call i32 @fputc(i64 %139, i32* %1)
%141 = tail call i32 @ferror(i32* %1)
ret i32 %141
}