#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 */
double modf(double x, double *iptr) {
  union {
    double x;
    uint64_t n;
  } u = {x};
  uint64_t mask;
  int e;
  e = (int)(u.n >> 52 & 0x7ff) - 0x3ff;
  if (e >= 52) {
    *iptr = x;
    if (e == 0x400 && u.n << 12 != 0)
      return x;
    u.n &= (uint64_t)1 << 63;
    return u.x;
  }
  if (e < 0) {
    u.n &= (uint64_t)1 << 63;
    *iptr = u.x;
    return x;
  }
  mask = (uint64_t)-1 >> 12 >> e;
  if ((u.n & mask) == 0) {
    *iptr = x;
    u.n &= (uint64_t)1 << 63;
    return u.x;
  }
  u.n &= ~mask;
  *iptr = u.x;
  return x - *iptr;
}


x86 assembly (clang, -O0):
<modf>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x10(%rbp)
mov    %rdi,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    $0x34,%ecx
sar    %cl,%eax
and    $0x7ff,%eax
sub    $0x3ff,%eax
mov    %eax,-0x28(%rbp)
cmpl   $0x34,-0x28(%rbp)
jl     1185 <modf+0x85>
movsd  -0x10(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
cmpl   $0x400,-0x28(%rbp)
jne    1170 <modf+0x70>
mov    -0x20(%rbp),%eax
shl    $0xc,%eax
cmp    $0x0,%eax
je     1170 <modf+0x70>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    121a <modf+0x11a>
and    -0x20(%rbp),%eax
mov    %eax,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    121a <modf+0x11a>
cmpl   $0x0,-0x28(%rbp)
jge    11b1 <modf+0xb1>
and    -0x20(%rbp),%eax
mov    %eax,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    121a <modf+0x11a>
mov    -0x28(%rbp),%ecx
mov    $0xffffffff,%eax
sar    %cl,%eax
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%eax
and    -0x24(%rbp),%eax
cmp    $0x0,%eax
jne    11ef <modf+0xef>
movsd  -0x10(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
and    -0x20(%rbp),%eax
mov    %eax,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    121a <modf+0x11a>
mov    -0x24(%rbp),%eax
xor    $0xffffffff,%eax
and    -0x20(%rbp),%eax
mov    %eax,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x10(%rbp),%xmm0
mov    -0x18(%rbp),%rax
subsd  (%rax),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<modf>:
ret

LLVM IR (-O0):
%union.anon = type { double }
define double @modf(double %0, double* %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double*
%6 = alloca %union.anon
%7 = alloca i32
%8 = alloca i32
store double %0, double* %4
store double* %1, double** %5
%9 = bitcast %union.anon* %6 to double*
%10 = load double, double* %4
store double %10, double* %9
%11 = bitcast %union.anon* %6 to i32*
%12 = load i32, i32* %11
%13 = ashr i32 %12, 52
%14 = and i32 %13, 2047
%15 = sub nsw i32 %14, 1023
store i32 %15, i32* %8
%16 = load i32, i32* %8
%17 = icmp sge i32 %16, 52
br i1 %17, label %18, label %36
18: ; preds = %2
%19 = load double, double* %4
%20 = load double*, double** %5
store double %19, double* %20
%21 = load i32, i32* %8
%22 = icmp eq i32 %21, 1024
br i1 %22, label %23, label %30
23: ; preds = %18
%24 = bitcast %union.anon* %6 to i32*
%25 = load i32, i32* %24
%26 = shl i32 %25, 12
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %23
%29 = load double, double* %4
store double %29, double* %3
br label %76
30: ; preds = %23, %18
%31 = bitcast %union.anon* %6 to i32*
%32 = load i32, i32* %31
%33 = and i32 %32, poison
store i32 %33, i32* %31
%34 = bitcast %union.anon* %6 to double*
%35 = load double, double* %34
store double %35, double* %3
br label %76
36: ; preds = %2
%37 = load i32, i32* %8
%38 = icmp slt i32 %37, 0
br i1 %38, label %39, label %47
39: ; preds = %36
%40 = bitcast %union.anon* %6 to i32*
%41 = load i32, i32* %40
%42 = and i32 %41, poison
store i32 %42, i32* %40
%43 = bitcast %union.anon* %6 to double*
%44 = load double, double* %43
%45 = load double*, double** %5
store double %44, double* %45
%46 = load double, double* %4
store double %46, double* %3
br label %76
47: ; preds = %36
%48 = load i32, i32* %8
%49 = ashr i32 -1, %48
store i32 %49, i32* %7
%50 = bitcast %union.anon* %6 to i32*
%51 = load i32, i32* %50
%52 = load i32, i32* %7
%53 = and i32 %51, %52
%54 = icmp eq i32 %53, 0
br i1 %54, label %55, label %63
55: ; preds = %47
%56 = load double, double* %4
%57 = load double*, double** %5
store double %56, double* %57
%58 = bitcast %union.anon* %6 to i32*
%59 = load i32, i32* %58
%60 = and i32 %59, poison
store i32 %60, i32* %58
%61 = bitcast %union.anon* %6 to double*
%62 = load double, double* %61
store double %62, double* %3
br label %76
63: ; preds = %47
%64 = load i32, i32* %7
%65 = xor i32 %64, -1
%66 = bitcast %union.anon* %6 to i32*
%67 = load i32, i32* %66
%68 = and i32 %67, %65
store i32 %68, i32* %66
%69 = bitcast %union.anon* %6 to double*
%70 = load double, double* %69
%71 = load double*, double** %5
store double %70, double* %71
%72 = load double, double* %4
%73 = load double*, double** %5
%74 = load double, double* %73
%75 = fsub double %72, %74
store double %75, double* %3
br label %76
76: ; preds = %63, %55, %39, %30, %28
%77 = load double, double* %3
ret double %77
}

LLVM IR (-O2):
define double @modf(double %0, double* nocapture readnone %1) {
ret double poison
}