#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 */
double frexp(int, int *);
double ldexp(double, int);
double modf(double, double *);
int /*<<< orphan*/ printf(char *, double);
int main() {
  int exp;
  double ld;
  double ip;
  ld = frexp(123, &exp);
  printf("frac %lf\n", frexp(123, &exp));
  printf("exp %d\n", exp);
  printf("value %lf\n", ldexp(ld, exp));
  ld += 10.0;
  printf("ld %lf\n", ld);
  printf("lddp %lf\n", modf(ld, &ip));
  printf("ip %lf\n", ip);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x7b,%edi
lea    -0x8(%rbp),%rsi
call   1060 <frexp@plt>
movsd  %xmm0,-0x10(%rbp)
mov    $0x7b,%edi
lea    -0x8(%rbp),%rsi
call   1060 <frexp@plt>
lea    0xe91(%rip),%rdi
call   1040 <printf@plt>
cvtsi2sdl -0x8(%rbp),%xmm0
lea    0xe8a(%rip),%rdi
call   1040 <printf@plt>
movsd  -0x10(%rbp),%xmm0
mov    -0x8(%rbp),%edi
call   1030 <ldexp@plt>
lea    0xe79(%rip),%rdi
call   1040 <printf@plt>
movsd  0xe52(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
lea    0xe61(%rip),%rdi
call   1040 <printf@plt>
movsd  -0x10(%rbp),%xmm0
lea    -0x18(%rbp),%rdi
call   1050 <modf@plt>
lea    0xe4f(%rip),%rdi
call   1040 <printf@plt>
movsd  -0x18(%rbp),%xmm0
lea    0xe48(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
lea    0x14(%rsp),%rbx
mov    $0x7b,%edi
mov    %rbx,%rsi
call   1060 <frexp@plt>
movsd  %xmm0,0x8(%rsp)
mov    $0x7b,%edi
mov    %rbx,%rsi
call   1060 <frexp@plt>
lea    0xe97(%rip),%rdi
call   1040 <printf@plt>
mov    0x14(%rsp),%ebx
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
lea    0xe8a(%rip),%rdi
call   1040 <printf@plt>
movsd  0x8(%rsp),%xmm0
mov    %ebx,%edi
call   1030 <ldexp@plt>
lea    0xe79(%rip),%rdi
call   1040 <printf@plt>
movsd  0x8(%rsp),%xmm0
addsd  0xe4c(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
lea    0xe64(%rip),%rdi
call   1040 <printf@plt>
lea    0x18(%rsp),%rdi
movsd  0x8(%rsp),%xmm0
call   1050 <modf@plt>
lea    0xe50(%rip),%rdi
call   1040 <printf@plt>
movsd  0x18(%rsp),%xmm0
lea    0xe48(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [10 x i8] c"frac %lf\0A\00"
@.str.1 = [8 x i8] c"exp %d\0A\00"
@.str.2 = [11 x i8] c"value %lf\0A\00"
@.str.3 = [8 x i8] c"ld %lf\0A\00"
@.str.4 = [10 x i8] c"lddp %lf\0A\00"
@.str.5 = [8 x i8] c"ip %lf\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca double
%4 = alloca double
store i32 0, i32* %1
%5 = call double @frexp(i32 123, i32* %2)
store double %5, double* %3
%6 = call double @frexp(i32 123, i32* %2)
%7 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), double %6)
%8 = load i32, i32* %2
%9 = sitofp i32 %8 to double
%10 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), double %9)
%11 = load double, double* %3
%12 = load i32, i32* %2
%13 = call double @ldexp(double %11, i32 %12)
%14 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), double %13)
%15 = load double, double* %3
%16 = fadd double %15, 1.000000e+01
store double %16, double* %3
%17 = load double, double* %3
%18 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), double %17)
%19 = load double, double* %3
%20 = call double @modf(double %19, double* %4)
%21 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), double %20)
%22 = load double, double* %4
%23 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), double %22)
ret i32 0
}

LLVM IR (-O2):
@.str = [10 x i8] c"frac %lf\0A\00"
@.str.1 = [8 x i8] c"exp %d\0A\00"
@.str.2 = [11 x i8] c"value %lf\0A\00"
@.str.3 = [8 x i8] c"ld %lf\0A\00"
@.str.4 = [10 x i8] c"lddp %lf\0A\00"
@.str.5 = [8 x i8] c"ip %lf\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = bitcast i32* %1 to i8*
%4 = bitcast double* %2 to i8*
%5 = call double @frexp(i32 123, i32* %1)
%6 = call double @frexp(i32 123, i32* %1)
%7 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), double %6)
%8 = load i32, i32* %1
%9 = sitofp i32 %8 to double
%10 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), double %9)
%11 = tail call double @ldexp(double %5, i32 %8)
%12 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), double %11)
%13 = fadd double %5, 1.000000e+01
%14 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), double %13)
%15 = call double @modf(double %13, double* %2)
%16 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), double %15)
%17 = load double, double* %2
%18 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), double %17)
ret i32 0
}