#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 U4(unsigned char *);
double R8(unsigned char *p) {
  double value;
  unsigned char *q = (unsigned char *)&value;
  int i;
  if (U4(p + 4) == 0x7FF80000 && U4(p) == 0)
    return 0.0;
  for (i = 0; i < 8; i++)
    *q++ = *p++;
  return value;
}


x86 assembly (clang, -O0):
<R8>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
lea    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
add    $0x4,%rdi
call   1030 <U4@plt>
cmp    $0x7ff80000,%eax
jne    115b <R8+0x4b>
mov    -0x10(%rbp),%rdi
call   1030 <U4@plt>
cmp    $0x0,%eax
jne    115b <R8+0x4b>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11a6 <R8+0x96>
movl   $0x0,-0x24(%rbp)
cmpl   $0x8,-0x24(%rbp)
jge    119c <R8+0x8c>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%cl
mov    -0x20(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x20(%rbp)
mov    %cl,(%rax)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1162 <R8+0x52>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<R8>:
push   %rbx
mov    %rdi,%rbx
add    $0x4,%rdi
call   1030 <U4@plt>
cmp    $0x7ff80000,%eax
jne    1130 <R8+0x20>
mov    %rbx,%rdi
call   1030 <U4@plt>
test   %eax,%eax
je     1136 <R8+0x26>
movsd  (%rbx),%xmm0
pop    %rbx
ret
xorps  %xmm0,%xmm0
pop    %rbx
ret

LLVM IR (-O0):
define double @R8(i8* %0) {
%2 = alloca double
%3 = alloca i8*
%4 = alloca double
%5 = alloca i8*
%6 = alloca i32
store i8* %0, i8** %3
%7 = bitcast double* %4 to i8*
store i8* %7, i8** %5
%8 = load i8*, i8** %3
%9 = getelementptr inbounds i8, i8* %8, i64 4
%10 = call i32 @U4(i8* %9)
%11 = icmp eq i32 %10, 2146959360
br i1 %11, label %12, label %17
12: ; preds = %1
%13 = load i8*, i8** %3
%14 = call i32 @U4(i8* %13)
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %12
store double 0.000000e+00, double* %2
br label %32
17: ; preds = %12, %1
store i32 0, i32* %6
br label %18
18: ; preds = %27, %17
%19 = load i32, i32* %6
%20 = icmp slt i32 %19, 8
br i1 %20, label %21, label %30
21: ; preds = %18
%22 = load i8*, i8** %3
%23 = getelementptr inbounds i8, i8* %22, i32 1
store i8* %23, i8** %3
%24 = load i8, i8* %22
%25 = load i8*, i8** %5
%26 = getelementptr inbounds i8, i8* %25, i32 1
store i8* %26, i8** %5
store i8 %24, i8* %25
br label %27
27: ; preds = %21
%28 = load i32, i32* %6
%29 = add nsw i32 %28, 1
store i32 %29, i32* %6
br label %18
30: ; preds = %18
%31 = load double, double* %4
store double %31, double* %2
br label %32
32: ; preds = %30, %16
%33 = load double, double* %2
ret double %33
}

LLVM IR (-O2):
define double @R8(i8* %0) {
%2 = getelementptr inbounds i8, i8* %0, i64 4
%3 = tail call i32 @U4(i8* %2)
%4 = icmp eq i32 %3, 2146959360
br i1 %4, label %5, label %8
5: ; preds = %1
%6 = tail call i32 @U4(i8* %0)
%7 = icmp eq i32 %6, 0
br i1 %7, label %11, label %8
8: ; preds = %5, %1
%9 = bitcast i8* %0 to double*
%10 = load double, double* %9
br label %11
11: ; preds = %5, %8
%12 = phi double [ %10, %8 ], [ 0.000000e+00, %5 ]
ret double %12
}