#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 */
scalar_t__ ERANGE;
int /*<<< orphan*/ assert(int);
scalar_t__ errno;
int /*<<< orphan*/ opt_err(char *);
double strtod(char *, char **);
int opt_store_double(char *arg, void *data) {
  char *end;
  double val;
  assert(arg && data);
  errno = 0;
  val = strtod(arg, &end);
  if (end == arg || end[0])
    opt_err("the value of %s must be a number");
  if (errno == ERANGE)
    opt_err("the value of %s is too large");
  *(double *)data = val;
  return 0;
}


x86 assembly (clang, -O0):
<opt_store_double>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x8(%rbp)
mov    %al,-0x21(%rbp)
je     115b <opt_store_double+0x2b>
cmpq   $0x0,-0x10(%rbp)
setne  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    0x2e69(%rip),%rax
movq   $0x0,(%rax)
mov    -0x8(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1030 <strtod@plt>
movsd  %xmm0,-0x20(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x8(%rbp),%rax
je     11a6 <opt_store_double+0x76>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11b2 <opt_store_double+0x82>
lea    0xe53(%rip),%rdi
call   1050 <opt_err@plt>
mov    0x2e1f(%rip),%rax
mov    (%rax),%rax
mov    0x2e25(%rip),%rcx
cmp    (%rcx),%rax
jne    11d8 <opt_store_double+0xa8>
lea    0xe4e(%rip),%rdi
call   1050 <opt_err@plt>
movsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<opt_store_double>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
test   %rdi,%rdi
setne  %al
test   %rsi,%rsi
setne  %cl
and    %al,%cl
movzbl %cl,%edi
call   1040 <assert@plt>
mov    0x2e7c(%rip),%r15
movq   $0x0,(%r15)
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1030 <strtod@plt>
movsd  %xmm0,(%rsp)
mov    0x8(%rsp),%rax
cmp    %rbx,%rax
je     1184 <opt_store_double+0x54>
cmpb   $0x0,(%rax)
je     1190 <opt_store_double+0x60>
lea    0xe75(%rip),%rdi
call   1050 <opt_err@plt>
mov    (%r15),%rax
mov    0x2e4e(%rip),%rcx
cmp    (%rcx),%rax
jne    11ab <opt_store_double+0x7b>
lea    0xe7b(%rip),%rdi
call   1050 <opt_err@plt>
movsd  (%rsp),%xmm0
movsd  %xmm0,(%r14)
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@errno = global i64 0
@.str = [33 x i8] c"the value of %s must be a number\00"
@ERANGE = global i64 0
@.str.1 = [29 x i8] c"the value of %s is too large\00"
define i32 @opt_store_double(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca double
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = load i8*, i8** %3
%8 = icmp ne i8* %7, null
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = load i8*, i8** %4
%11 = icmp ne i8* %10, null
br label %12
12: ; preds = %9, %2
%13 = phi i1 [ false, %2 ], [ %11, %9 ]
%14 = zext i1 %13 to i32
%15 = call i32 @assert(i32 %14)
store i64 0, i64* @errno
%16 = load i8*, i8** %3
%17 = call double @strtod(i8* %16, i8** %5)
store double %17, double* %6
%18 = load i8*, i8** %5
%19 = load i8*, i8** %3
%20 = icmp eq i8* %18, %19
br i1 %20, label %27, label %21
21: ; preds = %12
%22 = load i8*, i8** %5
%23 = getelementptr inbounds i8, i8* %22, i64 0
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp ne i32 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %21, %12
%28 = call i32 @opt_err(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
br label %29
29: ; preds = %27, %21
%30 = load i64, i64* @errno
%31 = load i64, i64* @ERANGE
%32 = icmp eq i64 %30, %31
br i1 %32, label %33, label %35
33: ; preds = %29
%34 = call i32 @opt_err(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
br label %35
35: ; preds = %33, %29
%36 = load double, double* %6
%37 = load i8*, i8** %4
%38 = bitcast i8* %37 to double*
store double %36, double* %38
ret i32 0
}

LLVM IR (-O2):
@errno = global i64 0
@.str = [33 x i8] c"the value of %s must be a number\00"
@ERANGE = global i64 0
@.str.1 = [29 x i8] c"the value of %s is too large\00"
define i32 @opt_store_double(i8* %0, i8* writeonly %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
%5 = icmp ne i8* %0, null
%6 = icmp ne i8* %1, null
%7 = and i1 %5, %6
%8 = zext i1 %7 to i32
%9 = tail call i32 @assert(i32 %8)
store i64 0, i64* @errno
%10 = call double @strtod(i8* %0, i8** %3)
%11 = load i8*, i8** %3
%12 = icmp eq i8* %11, %0
br i1 %12, label %16, label %13
13: ; preds = %2
%14 = load i8, i8* %11
%15 = icmp eq i8 %14, 0
br i1 %15, label %18, label %16
16: ; preds = %13, %2
%17 = tail call i32 @opt_err(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
br label %18
18: ; preds = %16, %13
%19 = load i64, i64* @errno
%20 = load i64, i64* @ERANGE
%21 = icmp eq i64 %19, %20
br i1 %21, label %22, label %24
22: ; preds = %18
%23 = tail call i32 @opt_err(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
br label %24
24: ; preds = %22, %18
%25 = bitcast i8* %1 to double*
store double %10, double* %25
ret i32 0
}