#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 */
size_t ULLONG_MAX;
unsigned long long pack_abs_754(long double source, size_t exponent_size,
                                size_t significand_size) {
  unsigned long long x = 0;
  while (source >= 2.0) {
    source /= 2.0;
    x++;
  }
  while (source < 1.0) {
    source *= 2.0;
    x--;
  }
  source -= 1.0;
  source *= (1ULL << significand_size) + 0.5f;
  x += ~(ULLONG_MAX << exponent_size - 1);
  x <<= significand_size;
  x |= (unsigned long long)source;
  return x;
}


x86 assembly (clang, -O0):
<pack_abs_754>:
push   %rbp
mov    %rsp,%rbp
fldt   0x10(%rbp)
fstpt  -0x10(%rbp)
mov    %rdi,-0x18(%rbp)
mov    %rsi,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
fldt   -0x10(%rbp)
flds   0xedd(%rip)
fxch   %st(1)
fucomip %st(1),%st
fstp   %st(0)
jb     1153 <pack_abs_754+0x53>
jmp    1134 <pack_abs_754+0x34>
fldt   -0x10(%rbp)
flds   0xec3(%rip)
fdivrp %st,%st(1)
fstpt  -0x10(%rbp)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    111a <pack_abs_754+0x1a>
jmp    1158 <pack_abs_754+0x58>
fldt   -0x10(%rbp)
fld1
fucomip %st(1),%st
fstp   %st(0)
jbe    1185 <pack_abs_754+0x85>
jmp    116c <pack_abs_754+0x6c>
fldt   -0x10(%rbp)
fadd   %st,%st(0)
fstpt  -0x10(%rbp)
mov    -0x28(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x28(%rbp)
jmp    1158 <pack_abs_754+0x58>
fldt   -0x10(%rbp)
fld1
fchs
faddp  %st,%st(1)
fstpt  -0x10(%rbp)
mov    -0x20(%rbp),%cl
mov    $0x1,%eax
shl    %cl,%rax
mov    %rax,%rdx
shr    %rdx
mov    %eax,%ecx
and    $0x1,%ecx
or     %rdx,%rcx
cvtsi2ss %rcx,%xmm0
addss  %xmm0,%xmm0
cvtsi2ss %rax,%xmm1
movss  %xmm1,-0x40(%rbp)
test   %rax,%rax
movss  %xmm0,-0x3c(%rbp)
js     11d5 <pack_abs_754+0xd5>
movss  -0x40(%rbp),%xmm0
movss  %xmm0,-0x3c(%rbp)
movss  -0x3c(%rbp),%xmm0
movss  0xe22(%rip),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x34(%rbp)
flds   -0x34(%rbp)
fldt   -0x10(%rbp)
fmulp  %st,%st(1)
fstpt  -0x10(%rbp)
mov    0x2deb(%rip),%rax
mov    (%rax),%rax
mov    -0x18(%rbp),%cl
add    $0xff,%cl
shl    %cl,%rax
mov    %rax,%rcx
not    %rcx
mov    -0x28(%rbp),%rax
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%cl
mov    -0x28(%rbp),%rax
shl    %cl,%rax
mov    %rax,-0x28(%rbp)
fldt   -0x10(%rbp)
flds   0xdd7(%rip)
fucomi %st(1),%st
setbe  %al
fldz
fcmovbe %st(1),%st
fstp   %st(1)
fsubrp %st,%st(1)
fnstcw -0x36(%rbp)
movzwl -0x36(%rbp),%ecx
or     $0xc00,%ecx
mov    %cx,-0x38(%rbp)
fldcw  -0x38(%rbp)
fistpll -0x30(%rbp)
fldcw  -0x36(%rbp)
movzbl %al,%eax
mov    %eax,%ecx
shl    $0x3f,%rcx
mov    -0x30(%rbp),%rax
xor    %rcx,%rax
or     -0x28(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<pack_abs_754>:
fldt   0x8(%rsp)
flds   0xef6(%rip)
fxch   %st(1)
fucomi %st(1),%st
fstp   %st(1)
jae    1118 <pack_abs_754+0x18>
xor    %edx,%edx
fldz
jmp    1132 <pack_abs_754+0x32>
xor    %edx,%edx
flds   0xee0(%rip)
fxch   %st(1)
fmuls  0xedc(%rip)
add    $0x1,%rdx
fucomi %st(1),%st
fxch   %st(1)
jae    1120 <pack_abs_754+0x20>
fstp   %st(0)
fld1
fucomip %st(1),%st
jbe    1150 <pack_abs_754+0x50>
fld1
nopl   0x0(%rax)
fxch   %st(1)
fadd   %st,%st(0)
add    $0xffffffffffffffff,%rdx
fxch   %st(1)
fucomi %st(1),%st
ja     1140 <pack_abs_754+0x40>
jmp    1152 <pack_abs_754+0x52>
fldz
fstp   %st(0)
fld1
fchs
faddp  %st,%st(1)
mov    $0x1,%eax
mov    %esi,%ecx
shl    %cl,%rax
test   %rax,%rax
js     1170 <pack_abs_754+0x70>
cvtsi2ss %rax,%xmm0
jmp    1185 <pack_abs_754+0x85>
mov    %rax,%rcx
shr    %rcx
and    $0x1,%eax
or     %rcx,%rax
cvtsi2ss %rax,%xmm0
addss  %xmm0,%xmm0
addss  0xe77(%rip),%xmm0
movss  %xmm0,-0xc(%rsp)
fmuls  -0xc(%rsp)
mov    0x2e4a(%rip),%rax
mov    (%rax),%rax
add    $0xff,%dil
mov    %edi,%ecx
shl    %cl,%rax
not    %rax
add    %rax,%rdx
mov    %esi,%ecx
shl    %cl,%rdx
flds   0xe4d(%rip)
xor    %eax,%eax
fxch   %st(1)
fucomi %st(1),%st
fldz
fcmovnb %st(2),%st
fstp   %st(2)
fsubp  %st,%st(1)
setae  %al
fnstcw -0x10(%rsp)
movzwl -0x10(%rsp),%ecx
or     $0xc00,%ecx
mov    %cx,-0xe(%rsp)
fldcw  -0xe(%rsp)
fistpll -0x8(%rsp)
fldcw  -0x10(%rsp)
shl    $0x3f,%rax
xor    -0x8(%rsp),%rax
or     %rdx,%rax
ret

LLVM IR (-O0):
@ULLONG_MAX = global i64 0
define i64 @pack_abs_754(x86_fp80 %0, i64 %1, i64 %2) {
%4 = alloca x86_fp80
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
store x86_fp80 %0, x86_fp80* %4
store i64 %1, i64* %5
store i64 %2, i64* %6
store i64 0, i64* %7
br label %8
8: ; preds = %11, %3
%9 = load x86_fp80, x86_fp80* %4
%10 = fcmp oge x86_fp80 %9, 0xK40008000000000000000
br i1 %10, label %11, label %16
11: ; preds = %8
%12 = load x86_fp80, x86_fp80* %4
%13 = fdiv x86_fp80 %12, 0xK40008000000000000000
store x86_fp80 %13, x86_fp80* %4
%14 = load i64, i64* %7
%15 = add i64 %14, 1
store i64 %15, i64* %7
br label %8
16: ; preds = %8
br label %17
17: ; preds = %20, %16
%18 = load x86_fp80, x86_fp80* %4
%19 = fcmp olt x86_fp80 %18, 0xK3FFF8000000000000000
br i1 %19, label %20, label %25
20: ; preds = %17
%21 = load x86_fp80, x86_fp80* %4
%22 = fmul x86_fp80 %21, 0xK40008000000000000000
store x86_fp80 %22, x86_fp80* %4
%23 = load i64, i64* %7
%24 = add i64 %23, -1
store i64 %24, i64* %7
br label %17
25: ; preds = %17
%26 = load x86_fp80, x86_fp80* %4
%27 = fsub x86_fp80 %26, 0xK3FFF8000000000000000
store x86_fp80 %27, x86_fp80* %4
%28 = load i64, i64* %6
%29 = shl i64 1, %28
%30 = uitofp i64 %29 to float
%31 = fadd float %30, 5.000000e-01
%32 = fpext float %31 to x86_fp80
%33 = load x86_fp80, x86_fp80* %4
%34 = fmul x86_fp80 %33, %32
store x86_fp80 %34, x86_fp80* %4
%35 = load i64, i64* @ULLONG_MAX
%36 = load i64, i64* %5
%37 = sub i64 %36, 1
%38 = shl i64 %35, %37
%39 = xor i64 %38, -1
%40 = load i64, i64* %7
%41 = add i64 %40, %39
store i64 %41, i64* %7
%42 = load i64, i64* %6
%43 = load i64, i64* %7
%44 = shl i64 %43, %42
store i64 %44, i64* %7
%45 = load x86_fp80, x86_fp80* %4
%46 = fptoui x86_fp80 %45 to i64
%47 = load i64, i64* %7
%48 = or i64 %47, %46
store i64 %48, i64* %7
%49 = load i64, i64* %7
ret i64 %49
}

LLVM IR (-O2):
@ULLONG_MAX = global i64 0
define i64 @pack_abs_754(x86_fp80 %0, i64 %1, i64 %2) {
%4 = fcmp ult x86_fp80 %0, 0xK40008000000000000000
br i1 %4, label %5, label %9
5: ; preds = %9, %3
%6 = phi x86_fp80 [ %0, %3 ], [ %12, %9 ]
%7 = phi i64 [ 0, %3 ], [ %13, %9 ]
%8 = fcmp olt x86_fp80 %6, 0xK3FFF8000000000000000
br i1 %8, label %15, label %21
9: ; preds = %3, %9
%10 = phi i64 [ %13, %9 ], [ 0, %3 ]
%11 = phi x86_fp80 [ %12, %9 ], [ %0, %3 ]
%12 = fmul x86_fp80 %11, 0xK3FFE8000000000000000
%13 = add i64 %10, 1
%14 = fcmp ult x86_fp80 %12, 0xK40008000000000000000
br i1 %14, label %5, label %9
15: ; preds = %5, %15
%16 = phi i64 [ %19, %15 ], [ %7, %5 ]
%17 = phi x86_fp80 [ %18, %15 ], [ %6, %5 ]
%18 = fmul x86_fp80 %17, 0xK40008000000000000000
%19 = add i64 %16, -1
%20 = fcmp olt x86_fp80 %18, 0xK3FFF8000000000000000
br i1 %20, label %15, label %21
21: ; preds = %15, %5
%22 = phi x86_fp80 [ %6, %5 ], [ %18, %15 ]
%23 = phi i64 [ %7, %5 ], [ %19, %15 ]
%24 = fadd x86_fp80 %22, 0xKBFFF8000000000000000
%25 = shl nuw i64 1, %2
%26 = uitofp i64 %25 to float
%27 = fadd float %26, 5.000000e-01
%28 = fpext float %27 to x86_fp80
%29 = fmul x86_fp80 %24, %28
%30 = load i64, i64* @ULLONG_MAX
%31 = add i64 %1, -1
%32 = shl i64 %30, %31
%33 = xor i64 %32, -1
%34 = add i64 %23, %33
%35 = shl i64 %34, %2
%36 = fptoui x86_fp80 %29 to i64
%37 = or i64 %35, %36
ret i64 %37
}