#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__ argcmpTestOptions(char *, char *);
char *assert_malloc(scalar_t__);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strlen(char *);
double strtod(char *, char **);
double argcmpassdouble(char *options, const int argc, char *argv[],
                       int *argindex, double *dest) {
  char *opt = argv[*argindex];
  char *opts = assert_malloc(strlen(options) + 1);
  strcpy(opts, options);
  if (argcmpTestOptions(opt, opts)) {
    if (*argindex >= argc - 1) {
      fprintf(stderr,
              "error: Invalid argument, expected value after option \"%s\"\n",
              options);
      exit(1);
    }
    (*argindex)++;
    char *endptr, *value = argv[*argindex];
    double parsed = strtod(value, &endptr);
    if (value == endptr || *endptr != '\0') {
      fprintf(stderr, "error: Invalid number in option \"%s\".\n", opt);
      exit(1);
    } else
      *dest = parsed;
    return 1;
  } else
    return 0;
}


x86 assembly (clang, -O0):
<argcmpassdouble>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,%rdi
add    $0x1,%rdi
call   1070 <assert_malloc@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x38(%rbp),%rdi
mov    -0x40(%rbp),%rsi
call   1060 <argcmpTestOptions@plt>
cmp    $0x0,%rax
je     12a2 <argcmpassdouble+0x132>
mov    -0x28(%rbp),%rax
mov    (%rax),%eax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jl     1212 <argcmpassdouble+0xa2>
mov    0x2dea(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe05(%rip),%rsi
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x28(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rdi
lea    -0x48(%rbp),%rsi
call   1040 <strtod@plt>
movsd  %xmm0,-0x58(%rbp)
mov    -0x50(%rbp),%rax
cmp    -0x48(%rbp),%rax
je     1260 <argcmpassdouble+0xf0>
mov    -0x48(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1283 <argcmpassdouble+0x113>
mov    0x2d79(%rip),%rax
mov    (%rax),%edi
mov    -0x38(%rbp),%rdx
lea    0xdcf(%rip),%rsi
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
movsd  -0x58(%rbp),%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  0xd68(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12aa <argcmpassdouble+0x13a>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<argcmpassdouble>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r8,0x8(%rsp)
mov    %rcx,%rbx
mov    %rdx,%r12
mov    %esi,%ebp
mov    %rdi,%r13
movslq (%rcx),%rax
mov    (%rdx,%rax,8),%r15
call   1050 <strlen@plt>
lea    0x1(%rax),%rdi
call   1070 <assert_malloc@plt>
mov    %rax,%r14
mov    %rax,%rdi
mov    %r13,%rsi
call   1030 <strcpy@plt>
mov    %r15,%rdi
mov    %r14,%rsi
call   1060 <argcmpTestOptions@plt>
test   %rax,%rax
je     1205 <argcmpassdouble+0x95>
movslq (%rbx),%rax
add    $0xffffffff,%ebp
cmp    %ebp,%eax
jge    122c <argcmpassdouble+0xbc>
lea    0x1(%rax),%rcx
mov    %ecx,(%rbx)
mov    0x8(%r12,%rax,8),%rbx
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <strtod@plt>
mov    0x10(%rsp),%rax
cmp    %rax,%rbx
je     1217 <argcmpassdouble+0xa7>
cmpb   $0x0,(%rax)
jne    1217 <argcmpassdouble+0xa7>
mov    0x8(%rsp),%rax
movsd  %xmm0,(%rax)
movsd  0xdfd(%rip),%xmm0
jmp    1208 <argcmpassdouble+0x98>
xorps  %xmm0,%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2dc2(%rip),%rax
mov    (%rax),%edi
lea    0xe1c(%rip),%rsi
mov    %r15,%rdx
jmp    123f <argcmpassdouble+0xcf>
mov    0x2dad(%rip),%rax
mov    (%rax),%edi
lea    0xdcc(%rip),%rsi
mov    %r13,%rdx
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [59 x i8] c"error: Invalid argument, expected value after option \22%s\22\0A\00"
@.str.1 = [39 x i8] c"error: Invalid number in option \22%s\22.\0A\00"
define double @argcmpassdouble(i8* %0, i32 %1, i8** %2, i32* %3, double* %4) {
%6 = alloca double
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i8**
%10 = alloca i32*
%11 = alloca double*
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca i8*
%16 = alloca double
store i8* %0, i8** %7
store i32 %1, i32* %8
store i8** %2, i8*** %9
store i32* %3, i32** %10
store double* %4, double** %11
%17 = load i8**, i8*** %9
%18 = load i32*, i32** %10
%19 = load i32, i32* %18
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8*, i8** %17, i64 %20
%22 = load i8*, i8** %21
store i8* %22, i8** %12
%23 = load i8*, i8** %7
%24 = call i64 @strlen(i8* %23)
%25 = add nsw i64 %24, 1
%26 = call i8* @assert_malloc(i64 %25)
store i8* %26, i8** %13
%27 = load i8*, i8** %13
%28 = load i8*, i8** %7
%29 = call i32 @strcpy(i8* %27, i8* %28)
%30 = load i8*, i8** %12
%31 = load i8*, i8** %13
%32 = call i64 @argcmpTestOptions(i8* %30, i8* %31)
%33 = icmp ne i64 %32, 0
br i1 %33, label %34, label %74
34: ; preds = %5
%35 = load i32*, i32** %10
%36 = load i32, i32* %35
%37 = load i32, i32* %8
%38 = sub nsw i32 %37, 1
%39 = icmp sge i32 %36, %38
br i1 %39, label %40, label %45
40: ; preds = %34
%41 = load i32, i32* @stderr
%42 = load i8*, i8** %7
%43 = call i32 @fprintf(i32 %41, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str, i64 0, i64 0), i8* %42)
%44 = call i32 @exit(i32 1)
unreachable
45: ; preds = %34
%46 = load i32*, i32** %10
%47 = load i32, i32* %46
%48 = add nsw i32 %47, 1
store i32 %48, i32* %46
%49 = load i8**, i8*** %9
%50 = load i32*, i32** %10
%51 = load i32, i32* %50
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds i8*, i8** %49, i64 %52
%54 = load i8*, i8** %53
store i8* %54, i8** %15
%55 = load i8*, i8** %15
%56 = call double @strtod(i8* %55, i8** %14)
store double %56, double* %16
%57 = load i8*, i8** %15
%58 = load i8*, i8** %14
%59 = icmp eq i8* %57, %58
br i1 %59, label %65, label %60
60: ; preds = %45
%61 = load i8*, i8** %14
%62 = load i8, i8* %61
%63 = sext i8 %62 to i32
%64 = icmp ne i32 %63, 0
br i1 %64, label %65, label %70
65: ; preds = %60, %45
%66 = load i32, i32* @stderr
%67 = load i8*, i8** %12
%68 = call i32 @fprintf(i32 %66, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0), i8* %67)
%69 = call i32 @exit(i32 1)
unreachable
70: ; preds = %60
%71 = load double, double* %16
%72 = load double*, double** %11
store double %71, double* %72
br label %73
73: ; preds = %70
store double 1.000000e+00, double* %6
br label %75
74: ; preds = %5
store double 0.000000e+00, double* %6
br label %75
75: ; preds = %74, %73
%76 = load double, double* %6
ret double %76
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [59 x i8] c"error: Invalid argument, expected value after option \22%s\22\0A\00"
@.str.1 = [39 x i8] c"error: Invalid number in option \22%s\22.\0A\00"
define double @argcmpassdouble(i8* %0, i32 %1, i8** nocapture %2, i32* nocapture %3, double* nocapture writeonly %4) {
%6 = alloca i8*
%7 = load i32, i32* %3
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i8*, i8** %2, i64 %8
%10 = load i8*, i8** %9
%11 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%12 = add nsw i64 %11, 1
%13 = tail call i8* @assert_malloc(i64 %12)
%14 = tail call i32 @strcpy(i8* %13, i8* %0)
%15 = tail call i64 @argcmpTestOptions(i8* %10, i8* %13)
%16 = icmp eq i64 %15, 0
br i1 %16, label %42, label %17
17: ; preds = %5
%18 = load i32, i32* %3
%19 = add nsw i32 %1, -1
%20 = icmp slt i32 %18, %19
br i1 %20, label %25, label %21
21: ; preds = %17
%22 = load i32, i32* @stderr
%23 = tail call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str, i64 0, i64 0), i8* %0)
%24 = tail call i32 @exit(i32 1)
unreachable
25: ; preds = %17
%26 = add nsw i32 %18, 1
store i32 %26, i32* %3
%27 = bitcast i8** %6 to i8*
%28 = sext i32 %26 to i64
%29 = getelementptr inbounds i8*, i8** %2, i64 %28
%30 = load i8*, i8** %29
%31 = call double @strtod(i8* %30, i8** %6)
%32 = load i8*, i8** %6
%33 = icmp eq i8* %30, %32
br i1 %33, label %37, label %34
34: ; preds = %25
%35 = load i8, i8* %32
%36 = icmp eq i8 %35, 0
br i1 %36, label %41, label %37
37: ; preds = %34, %25
%38 = load i32, i32* @stderr
%39 = tail call i32 @fprintf(i32 %38, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0), i8* %10)
%40 = tail call i32 @exit(i32 1)
unreachable
41: ; preds = %34
store double %31, double* %4
br label %42
42: ; preds = %5, %41
%43 = phi double [ 1.000000e+00, %41 ], [ 0.000000e+00, %5 ]
ret double %43
}