#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*/ abort();
long long f1();
int f2();
scalar_t__ memcmp(long long *, double *, int);
int /*<<< orphan*/ memcpy(long long *, double *, int);
int main() {
  union {
    long long ll;
    double d;
  } u;
  if (sizeof(long long) != sizeof(double) || (-1021) != -1021)
    return 0;
  u.ll = f1();
  if (u.d != 0x0.fffffffffffff000p-1022)
    abort();
  u.d = f2();
  if (u.ll != 0x000fedcba9876543LL)
    abort();
  double b = 234.0;
  long long c;
  double d = b;
  memcpy(&c, &b, sizeof(double));
  long long e = c;
  if (memcmp(&e, &d, sizeof(double)) != 0)
    abort();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1070 <f1@plt>
mov    %rax,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xe89(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    118c <main+0x3c>
jp     118c <main+0x3c>
jmp    1193 <main+0x43>
mov    $0x0,%al
call   1040 <abort@plt>
mov    $0x0,%al
call   1030 <f2@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x10(%rbp)
movabs $0xfedcba9876543,%rax
cmp    %rax,-0x10(%rbp)
je     11be <main+0x6e>
mov    $0x0,%al
call   1040 <abort@plt>
movsd  0xe42(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
lea    -0x20(%rbp),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x8,%edx
call   1060 <memcpy@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
lea    -0x30(%rbp),%rdi
lea    -0x28(%rbp),%rsi
mov    $0x8,%edx
call   1050 <memcmp@plt>
cmp    $0x0,%rax
je     1212 <main+0xc2>
mov    $0x0,%al
call   1040 <abort@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x28,%rsp
xor    %eax,%eax
call   1070 <f1@plt>
movq   %rax,%xmm0
ucomisd 0xe98(%rip),%xmm0
jne    11e0 <main+0x90>
jp     11e0 <main+0x90>
xor    %eax,%eax
call   1030 <f2@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movq   %xmm0,%rax
movabs $0xfedcba9876543,%rcx
cmp    %rcx,%rax
jne    11e0 <main+0x90>
movabs $0x406d400000000000,%rax
40 6d 40
mov    %rax,0x20(%rsp)
mov    %rax,0x10(%rsp)
lea    0x18(%rsp),%rdi
lea    0x20(%rsp),%rsi
mov    $0x8,%edx
call   1060 <memcpy@plt>
mov    0x18(%rsp),%rax
mov    %rax,0x8(%rsp)
lea    0x8(%rsp),%rdi
lea    0x10(%rsp),%rsi
mov    $0x8,%edx
call   1050 <memcmp@plt>
test   %rax,%rax
jne    11e0 <main+0x90>
xor    %eax,%eax
add    $0x28,%rsp
ret
xor    %eax,%eax
call   1040 <abort@plt>

LLVM IR (-O0):
%union.anon = type { i64 }
define i32 @main() {
%1 = alloca i32
%2 = alloca %union.anon
%3 = alloca double
%4 = alloca i64
%5 = alloca double
%6 = alloca i64
store i32 0, i32* %1
%7 = call i64 (...) @f1()
%8 = bitcast %union.anon* %2 to i64*
store i64 %7, i64* %8
%9 = bitcast %union.anon* %2 to double*
%10 = load double, double* %9
%11 = fcmp une double %10, 0xFFFFFFFFFFFFF
br i1 %11, label %12, label %14
12: ; preds = %0
%13 = call i32 (...) @abort()
unreachable
14: ; preds = %0
%15 = call i32 (...) @f2()
%16 = sitofp i32 %15 to double
%17 = bitcast %union.anon* %2 to double*
store double %16, double* %17
%18 = bitcast %union.anon* %2 to i64*
%19 = load i64, i64* %18
%20 = icmp ne i64 %19, 4483583629026627
br i1 %20, label %21, label %23
21: ; preds = %14
%22 = call i32 (...) @abort()
unreachable
23: ; preds = %14
store double 2.340000e+02, double* %3
%24 = load double, double* %3
store double %24, double* %5
%25 = call i32 @memcpy(i64* %4, double* %3, i32 8)
%26 = load i64, i64* %4
store i64 %26, i64* %6
%27 = call i64 @memcmp(i64* %6, double* %5, i32 8)
%28 = icmp ne i64 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %23
%30 = call i32 (...) @abort()
unreachable
31: ; preds = %23
ret i32 0
}

LLVM IR (-O2):
define i32 @main() {
%1 = alloca double
%2 = alloca i64
%3 = alloca double
%4 = alloca i64
%5 = tail call i64 (...) @f1()
%6 = bitcast i64 %5 to double
%7 = fcmp une double %6, 0xFFFFFFFFFFFFF
br i1 %7, label %8, label %10
8: ; preds = %0
%9 = tail call i32 (...) @abort()
unreachable
10: ; preds = %0
%11 = tail call i32 (...) @f2()
%12 = sitofp i32 %11 to double
%13 = bitcast double %12 to i64
%14 = icmp eq i64 %13, 4483583629026627
br i1 %14, label %17, label %15
15: ; preds = %10
%16 = tail call i32 (...) @abort()
unreachable
17: ; preds = %10
%18 = bitcast double* %1 to i8*
store double 2.340000e+02, double* %1
%19 = bitcast i64* %2 to i8*
%20 = bitcast double* %3 to i8*
store double 2.340000e+02, double* %3
%21 = call i32 @memcpy(i64* %2, double* %1, i32 8)
%22 = bitcast i64* %4 to i8*
%23 = load i64, i64* %2
store i64 %23, i64* %4
%24 = call i64 @memcmp(i64* %4, double* %3, i32 8)
%25 = icmp eq i64 %24, 0
br i1 %25, label %28, label %26
26: ; preds = %17
%27 = call i32 (...) @abort()
unreachable
28: ; preds = %17
ret i32 0
}