#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 */
long fabsl(long double);
long double frexpl(long double x, int *ex) {
  *ex = 0;
  while (fabsl(x) < .5L) {
    x *= 2.L;
    (*ex)--;
  }
  while (fabsl(x) >= 1.L) {
    x /= 2.L;
    (*ex)++;
  }
  return x;
}


x86 assembly (clang, -O0):
<frexpl>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
fldt   0x10(%rbp)
fstpt  -0x10(%rbp)
mov    %rdi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
fldt   -0x10(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
call   1030 <fabsl@plt>
mov    %rax,-0x20(%rbp)
fildll -0x20(%rbp)
flds   0xeba(%rip)
fucomip %st(1),%st
fstp   %st(0)
jbe    116d <frexpl+0x5d>
jmp    1155 <frexpl+0x45>
fldt   -0x10(%rbp)
fadd   %st,%st(0)
fstpt  -0x10(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
add    $0xffffffff,%ecx
mov    %ecx,(%rax)
jmp    112c <frexpl+0x1c>
jmp    1172 <frexpl+0x62>
fldt   -0x10(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
call   1030 <fabsl@plt>
mov    %rax,-0x28(%rbp)
fildll -0x28(%rbp)
fld1
fxch   %st(1)
fucomip %st(1),%st
fstp   %st(0)
jb     11b7 <frexpl+0xa7>
jmp    1199 <frexpl+0x89>
fldt   -0x10(%rbp)
flds   0xe62(%rip)
fdivrp %st,%st(1)
fstpt  -0x10(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
jmp    1172 <frexpl+0x62>
fldt   -0x10(%rbp)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<frexpl>:
push   %rbx
sub    $0x20,%rsp
mov    %rdi,%rbx
fldt   0x30(%rsp)
movl   $0x0,(%rdi)
fld    %st(0)
fstpt  0x14(%rsp)
fstpt  (%rsp)
call   1030 <fabsl@plt>
test   %rax,%rax
jle    113b <frexpl+0x2b>
fldt   0x14(%rsp)
jmp    115c <frexpl+0x4c>
fldt   0x14(%rsp)
nop
fadd   %st,%st(0)
fld    %st(0)
fstpt  0x14(%rsp)
addl   $0xffffffff,(%rbx)
fstpt  (%rsp)
call   1030 <fabsl@plt>
fldt   0x14(%rsp)
test   %rax,%rax
jle    1140 <frexpl+0x30>
fld    %st(0)
fstpt  0x14(%rsp)
fstpt  (%rsp)
call   1030 <fabsl@plt>
test   %rax,%rax
jle    11a2 <frexpl+0x92>
fldt   0x14(%rsp)
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
fmuls  0xe7a(%rip)
fld    %st(0)
fstpt  0x14(%rsp)
addl   $0x1,(%rbx)
fstpt  (%rsp)
call   1030 <fabsl@plt>
fldt   0x14(%rsp)
test   %rax,%rax
jg     1180 <frexpl+0x70>
jmp    11a6 <frexpl+0x96>
fldt   0x14(%rsp)
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define x86_fp80 @frexpl(x86_fp80 %0, i32* %1) {
%3 = alloca x86_fp80
%4 = alloca i32*
store x86_fp80 %0, x86_fp80* %3
store i32* %1, i32** %4
%5 = load i32*, i32** %4
store i32 0, i32* %5
br label %6
6: ; preds = %11, %2
%7 = load x86_fp80, x86_fp80* %3
%8 = call i64 @fabsl(x86_fp80 %7)
%9 = sitofp i64 %8 to x86_fp80
%10 = fcmp olt x86_fp80 %9, 0xK3FFE8000000000000000
br i1 %10, label %11, label %17
11: ; preds = %6
%12 = load x86_fp80, x86_fp80* %3
%13 = fmul x86_fp80 %12, 0xK40008000000000000000
store x86_fp80 %13, x86_fp80* %3
%14 = load i32*, i32** %4
%15 = load i32, i32* %14
%16 = add nsw i32 %15, -1
store i32 %16, i32* %14
br label %6
17: ; preds = %6
br label %18
18: ; preds = %23, %17
%19 = load x86_fp80, x86_fp80* %3
%20 = call i64 @fabsl(x86_fp80 %19)
%21 = sitofp i64 %20 to x86_fp80
%22 = fcmp oge x86_fp80 %21, 0xK3FFF8000000000000000
br i1 %22, label %23, label %29
23: ; preds = %18
%24 = load x86_fp80, x86_fp80* %3
%25 = fdiv x86_fp80 %24, 0xK40008000000000000000
store x86_fp80 %25, x86_fp80* %3
%26 = load i32*, i32** %4
%27 = load i32, i32* %26
%28 = add nsw i32 %27, 1
store i32 %28, i32* %26
br label %18
29: ; preds = %18
%30 = load x86_fp80, x86_fp80* %3
ret x86_fp80 %30
}

LLVM IR (-O2):
define x86_fp80 @frexpl(x86_fp80 %0, i32* nocapture %1) {
store i32 0, i32* %1
%3 = tail call i64 @fabsl(x86_fp80 %0)
%4 = icmp slt i64 %3, 1
br i1 %4, label %9, label %5
5: ; preds = %9, %2
%6 = phi x86_fp80 [ %0, %2 ], [ %11, %9 ]
%7 = tail call i64 @fabsl(x86_fp80 %6)
%8 = icmp sgt i64 %7, 0
br i1 %8, label %16, label %23
9: ; preds = %2, %9
%10 = phi x86_fp80 [ %11, %9 ], [ %0, %2 ]
%11 = fmul x86_fp80 %10, 0xK40008000000000000000
%12 = load i32, i32* %1
%13 = add nsw i32 %12, -1
store i32 %13, i32* %1
%14 = tail call i64 @fabsl(x86_fp80 %11)
%15 = icmp slt i64 %14, 1
br i1 %15, label %9, label %5
16: ; preds = %5, %16
%17 = phi x86_fp80 [ %18, %16 ], [ %6, %5 ]
%18 = fmul x86_fp80 %17, 0xK3FFE8000000000000000
%19 = load i32, i32* %1
%20 = add nsw i32 %19, 1
store i32 %20, i32* %1
%21 = tail call i64 @fabsl(x86_fp80 %18)
%22 = icmp sgt i64 %21, 0
br i1 %22, label %16, label %23
23: ; preds = %16, %5
%24 = phi x86_fp80 [ %6, %5 ], [ %18, %16 ]
ret x86_fp80 %24
}