#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 */
typedef unsigned long long uint64_t;

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *);
int /*<<< orphan*/ stderr;
unsigned int strtoul(char const *, char **, int);
unsigned long long strtoull(char *, int /*<<< orphan*/, int);
double get_testfloat_double(const char *str) {
  char *endptr;
  unsigned exp;
  union {
    uint64_t uns64;
    double float64;
  } val;
  exp = strtoul(str, &endptr, 16);
  if (*endptr != '.') {
    fprintf(stderr, "%s: bad format\n", str);
    exit(-1);
  }
  val.uns64 = strtoull(endptr + 1, 0, 16);
  val.uns64 |= (unsigned long long)exp << 52;
  return val.float64;
}


x86 assembly (clang, -O0):
<get_testfloat_double>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x10,%edx
call   1050 <strtoul@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
je     1194 <get_testfloat_double+0x54>
mov    0x2e68(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe7b(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0xffffffff,%edi
call   1060 <exit@plt>
mov    -0x10(%rbp),%rdi
add    $0x1,%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1030 <strtoull@plt>
mov    %rax,-0x20(%rbp)
mov    -0x14(%rbp),%eax
shl    $0x34,%rax
or     -0x20(%rbp),%rax
mov    %rax,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_testfloat_double>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    %rsp,%rsi
mov    $0x10,%edx
call   1050 <strtoul@plt>
mov    (%rsp),%rdi
cmpb   $0x2e,(%rdi)
jne    1183 <get_testfloat_double+0x43>
mov    %eax,%ebx
add    $0x1,%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1030 <strtoull@plt>
shl    $0x34,%rbx
or     %rax,%rbx
movq   %rbx,%xmm0
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    0x2e56(%rip),%rax
mov    (%rax),%edi
lea    0xe6d(%rip),%rsi
mov    %r14,%rdx
call   1040 <fprintf@plt>
mov    $0xffffffff,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
%union.anon = type { i64 }
@stderr = global i32 0
@.str = [16 x i8] c"%s: bad format\0A\00"
define double @get_testfloat_double(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
%5 = alloca %union.anon
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = call i32 @strtoul(i8* %6, i8** %3, i32 16)
store i32 %7, i32* %4
%8 = load i8*, i8** %3
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = icmp ne i32 %10, 46
br i1 %11, label %12, label %17
12: ; preds = %1
%13 = load i32, i32* @stderr
%14 = load i8*, i8** %2
%15 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %14)
%16 = call i32 @exit(i32 -1)
unreachable
17: ; preds = %1
%18 = load i8*, i8** %3
%19 = getelementptr inbounds i8, i8* %18, i64 1
%20 = call i64 @strtoull(i8* %19, i32 0, i32 16)
%21 = bitcast %union.anon* %5 to i64*
store i64 %20, i64* %21
%22 = load i32, i32* %4
%23 = zext i32 %22 to i64
%24 = shl i64 %23, 52
%25 = bitcast %union.anon* %5 to i64*
%26 = load i64, i64* %25
%27 = or i64 %26, %24
store i64 %27, i64* %25
%28 = bitcast %union.anon* %5 to double*
%29 = load double, double* %28
ret double %29
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [16 x i8] c"%s: bad format\0A\00"
define double @get_testfloat_double(i8* %0) {
%2 = alloca i8*
%3 = bitcast i8** %2 to i8*
%4 = call i32 @strtoul(i8* %0, i8** %2, i32 16)
%5 = load i8*, i8** %2
%6 = load i8, i8* %5
%7 = icmp eq i8 %6, 46
br i1 %7, label %12, label %8
8: ; preds = %1
%9 = load i32, i32* @stderr
%10 = tail call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %0)
%11 = tail call i32 @exit(i32 -1)
unreachable
12: ; preds = %1
%13 = getelementptr inbounds i8, i8* %5, i64 1
%14 = tail call i64 @strtoull(i8* %13, i32 0, i32 16)
%15 = zext i32 %4 to i64
%16 = shl i64 %15, 52
%17 = or i64 %14, %16
%18 = bitcast i64 %17 to double
ret double %18
}