#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*/ memcpy(void *, void *, int);
double hex_char_to_double(unsigned char *c) {
  double d = 0.0;
  unsigned long long t = 0;
  t |= (unsigned long long)(*(c + (sizeof(unsigned char) * 0))) << 56;
  t |= (unsigned long long)(*(c + (sizeof(unsigned char) * 1))) << 48;
  t |= (unsigned long long)(*(c + (sizeof(unsigned char) * 2))) << 40;
  t |= (unsigned long long)(*(c + (sizeof(unsigned char) * 3))) << 32;
  t |= (*(c + (sizeof(unsigned char) * 4))) << 24;
  t |= (*(c + (sizeof(unsigned char) * 5))) << 16;
  t |= (*(c + (sizeof(unsigned char) * 6))) << 8;
  t |= (*(c + (sizeof(unsigned char) * 7))) << 0;
  memcpy((void *)&d, (void *)&t, sizeof(double));
  return d;
}


x86 assembly (clang, -O0):
<hex_char_to_double>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movzbl (%rax),%eax
shl    $0x38,%rax
or     -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movzbl 0x1(%rax),%eax
shl    $0x30,%rax
or     -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movzbl 0x2(%rax),%eax
shl    $0x28,%rax
or     -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movzbl 0x3(%rax),%eax
shl    $0x20,%rax
or     -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movzbl 0x4(%rax),%eax
shl    $0x18,%eax
cltq
or     -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movzbl 0x5(%rax),%eax
shl    $0x10,%eax
cltq
or     -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movzbl 0x6(%rax),%eax
shl    $0x8,%eax
cltq
or     -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movzbl 0x7(%rax),%eax
shl    $0x0,%eax
cltq
or     -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
lea    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x8,%edx
call   1030 <memcpy@plt>
movsd  -0x10(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hex_char_to_double>:
sub    $0x18,%rsp
movq   $0x0,0x8(%rsp)
movzbl (%rdi),%eax
shl    $0x38,%rax
movzbl 0x1(%rdi),%ecx
shl    $0x30,%rcx
or     %rax,%rcx
movzbl 0x2(%rdi),%eax
shl    $0x28,%rax
or     %rcx,%rax
movzbl 0x3(%rdi),%ecx
shl    $0x20,%rcx
or     %rax,%rcx
movzbl 0x4(%rdi),%eax
shl    $0x18,%eax
cltq
or     %rcx,%rax
movzbl 0x5(%rdi),%ecx
shl    $0x10,%rcx
or     %rax,%rcx
movzbl 0x6(%rdi),%eax
shl    $0x8,%rax
or     %rcx,%rax
movzbl 0x7(%rdi),%ecx
or     %rax,%rcx
mov    %rcx,0x10(%rsp)
lea    0x8(%rsp),%rdi
lea    0x10(%rsp),%rsi
mov    $0x8,%edx
call   1030 <memcpy@plt>
movsd  0x8(%rsp),%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define double @hex_char_to_double(i8* %0) {
%2 = alloca i8*
%3 = alloca double
%4 = alloca i64
store i8* %0, i8** %2
store double 0.000000e+00, double* %3
store i64 0, i64* %4
%5 = load i8*, i8** %2
%6 = getelementptr inbounds i8, i8* %5, i64 0
%7 = load i8, i8* %6
%8 = zext i8 %7 to i64
%9 = shl i64 %8, 56
%10 = load i64, i64* %4
%11 = or i64 %10, %9
store i64 %11, i64* %4
%12 = load i8*, i8** %2
%13 = getelementptr inbounds i8, i8* %12, i64 1
%14 = load i8, i8* %13
%15 = zext i8 %14 to i64
%16 = shl i64 %15, 48
%17 = load i64, i64* %4
%18 = or i64 %17, %16
store i64 %18, i64* %4
%19 = load i8*, i8** %2
%20 = getelementptr inbounds i8, i8* %19, i64 2
%21 = load i8, i8* %20
%22 = zext i8 %21 to i64
%23 = shl i64 %22, 40
%24 = load i64, i64* %4
%25 = or i64 %24, %23
store i64 %25, i64* %4
%26 = load i8*, i8** %2
%27 = getelementptr inbounds i8, i8* %26, i64 3
%28 = load i8, i8* %27
%29 = zext i8 %28 to i64
%30 = shl i64 %29, 32
%31 = load i64, i64* %4
%32 = or i64 %31, %30
store i64 %32, i64* %4
%33 = load i8*, i8** %2
%34 = getelementptr inbounds i8, i8* %33, i64 4
%35 = load i8, i8* %34
%36 = zext i8 %35 to i32
%37 = shl i32 %36, 24
%38 = sext i32 %37 to i64
%39 = load i64, i64* %4
%40 = or i64 %39, %38
store i64 %40, i64* %4
%41 = load i8*, i8** %2
%42 = getelementptr inbounds i8, i8* %41, i64 5
%43 = load i8, i8* %42
%44 = zext i8 %43 to i32
%45 = shl i32 %44, 16
%46 = sext i32 %45 to i64
%47 = load i64, i64* %4
%48 = or i64 %47, %46
store i64 %48, i64* %4
%49 = load i8*, i8** %2
%50 = getelementptr inbounds i8, i8* %49, i64 6
%51 = load i8, i8* %50
%52 = zext i8 %51 to i32
%53 = shl i32 %52, 8
%54 = sext i32 %53 to i64
%55 = load i64, i64* %4
%56 = or i64 %55, %54
store i64 %56, i64* %4
%57 = load i8*, i8** %2
%58 = getelementptr inbounds i8, i8* %57, i64 7
%59 = load i8, i8* %58
%60 = zext i8 %59 to i32
%61 = shl i32 %60, 0
%62 = sext i32 %61 to i64
%63 = load i64, i64* %4
%64 = or i64 %63, %62
store i64 %64, i64* %4
%65 = bitcast double* %3 to i8*
%66 = bitcast i64* %4 to i8*
%67 = call i32 @memcpy(i8* %65, i8* %66, i32 8)
%68 = load double, double* %3
ret double %68
}

LLVM IR (-O2):
define double @hex_char_to_double(i8* nocapture %0) {
%2 = alloca double
%3 = alloca i64
%4 = bitcast double* %2 to i8*
store double 0.000000e+00, double* %2
%5 = bitcast i64* %3 to i8*
%6 = load i8, i8* %0
%7 = zext i8 %6 to i64
%8 = shl nuw i64 %7, 56
%9 = getelementptr inbounds i8, i8* %0, i64 1
%10 = load i8, i8* %9
%11 = zext i8 %10 to i64
%12 = shl nuw nsw i64 %11, 48
%13 = or i64 %12, %8
%14 = getelementptr inbounds i8, i8* %0, i64 2
%15 = load i8, i8* %14
%16 = zext i8 %15 to i64
%17 = shl nuw nsw i64 %16, 40
%18 = or i64 %17, %13
%19 = getelementptr inbounds i8, i8* %0, i64 3
%20 = load i8, i8* %19
%21 = zext i8 %20 to i64
%22 = shl nuw nsw i64 %21, 32
%23 = or i64 %22, %18
%24 = getelementptr inbounds i8, i8* %0, i64 4
%25 = load i8, i8* %24
%26 = zext i8 %25 to i32
%27 = shl nuw i32 %26, 24
%28 = sext i32 %27 to i64
%29 = or i64 %23, %28
%30 = getelementptr inbounds i8, i8* %0, i64 5
%31 = load i8, i8* %30
%32 = zext i8 %31 to i64
%33 = shl nuw nsw i64 %32, 16
%34 = or i64 %29, %33
%35 = getelementptr inbounds i8, i8* %0, i64 6
%36 = load i8, i8* %35
%37 = zext i8 %36 to i64
%38 = shl nuw nsw i64 %37, 8
%39 = or i64 %38, %34
%40 = getelementptr inbounds i8, i8* %0, i64 7
%41 = load i8, i8* %40
%42 = zext i8 %41 to i64
%43 = or i64 %39, %42
store i64 %43, i64* %3
%44 = call i32 @memcpy(i8* %4, i8* %5, i32 8)
%45 = load double, double* %2
ret double %45
}