#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 */
int /*<<< orphan*/ EXIT_FAILURE;
double atof(char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
double frexp(double, unsigned int *);
double my_frexp(double, unsigned int *);
int /*<<< orphan*/ printf(char *, double, unsigned int);
double union_frexp(double, unsigned int *);
int main(int argc, char *argv[]) {
  unsigned int e;
  double input;
  double q;
  if (argc < 2)
    exit(EXIT_FAILURE);
  input = atof(argv[1]);
  q = my_frexp(input, &e);
  printf("\tmyfrexp: %f * 2^%d\n\n", q, e);
  q = union_frexp(input, &e);
  printf("\tunion_frexp: %f * 2^%d\n\n", q, e);
  q = frexp(input, &e);
  printf("\tREAL frexp: %f * 2^%d\n\n", q, e);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    118e <main+0x2e>
mov    0x2e59(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <atof@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
lea    -0x14(%rbp),%rdi
call   1070 <my_frexp@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
mov    -0x14(%rbp),%esi
lea    0xe3e(%rip),%rdi
call   1040 <printf@plt>
movsd  -0x20(%rbp),%xmm0
lea    -0x14(%rbp),%rdi
call   1060 <union_frexp@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
mov    -0x14(%rbp),%esi
lea    0xe2d(%rip),%rdi
call   1040 <printf@plt>
movsd  -0x20(%rbp),%xmm0
lea    -0x14(%rbp),%rdi
call   1050 <frexp@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
mov    -0x14(%rbp),%esi
lea    0xe20(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
cmp    $0x1,%edi
jle    11da <main+0x7a>
mov    0x8(%rsi),%rdi
call   1030 <atof@plt>
movsd  %xmm0,0x8(%rsp)
lea    0x4(%rsp),%rbx
mov    %rbx,%rdi
call   1070 <my_frexp@plt>
mov    0x4(%rsp),%esi
lea    0xe6f(%rip),%rdi
call   1040 <printf@plt>
movsd  0x8(%rsp),%xmm0
mov    %rbx,%rdi
call   1060 <union_frexp@plt>
mov    0x4(%rsp),%esi
lea    0xe67(%rip),%rdi
call   1040 <printf@plt>
movsd  0x8(%rsp),%xmm0
mov    %rbx,%rdi
call   1050 <frexp@plt>
mov    0x4(%rsp),%esi
lea    0xe63(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret
mov    0x2dff(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@EXIT_FAILURE = global i32 0
@.str = [22 x i8] c"\09myfrexp: %f * 2^%d\0A\0A\00"
@.str.1 = [26 x i8] c"\09union_frexp: %f * 2^%d\0A\0A\00"
@.str.2 = [25 x i8] c"\09REAL frexp: %f * 2^%d\0A\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca double
%8 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 2
br i1 %10, label %11, label %14
11: ; preds = %2
%12 = load i32, i32* @EXIT_FAILURE
%13 = call i32 @exit(i32 %12)
unreachable
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call double @atof(i8* %17)
store double %18, double* %7
%19 = load double, double* %7
%20 = call double @my_frexp(double %19, i32* %6)
store double %20, double* %8
%21 = load double, double* %8
%22 = load i32, i32* %6
%23 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), double %21, i32 %22)
%24 = load double, double* %7
%25 = call double @union_frexp(double %24, i32* %6)
store double %25, double* %8
%26 = load double, double* %8
%27 = load i32, i32* %6
%28 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), double %26, i32 %27)
%29 = load double, double* %7
%30 = call double @frexp(double %29, i32* %6)
store double %30, double* %8
%31 = load double, double* %8
%32 = load i32, i32* %6
%33 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), double %31, i32 %32)
ret i32 0
}

LLVM IR (-O2):
@EXIT_FAILURE = global i32 0
@.str = [22 x i8] c"\09myfrexp: %f * 2^%d\0A\0A\00"
@.str.1 = [26 x i8] c"\09union_frexp: %f * 2^%d\0A\0A\00"
@.str.2 = [25 x i8] c"\09REAL frexp: %f * 2^%d\0A\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = icmp slt i32 %0, 2
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = load i32, i32* @EXIT_FAILURE
%8 = tail call i32 @exit(i32 %7)
unreachable
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = tail call double @atof(i8* %11)
%13 = call double @my_frexp(double %12, i32* %3)
%14 = load i32, i32* %3
%15 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), double %13, i32 %14)
%16 = call double @union_frexp(double %12, i32* %3)
%17 = load i32, i32* %3
%18 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), double %16, i32 %17)
%19 = call double @frexp(double %12, i32* %3)
%20 = load i32, i32* %3
%21 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), double %19, i32 %20)
ret i32 0
}