#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*/ exit(int);
int /*<<< orphan*/ printf(char *, ...);
int sscanf(char *, char *, double *);
scalar_t__ strcmp(char *, char const *);
int strlen(char *);
void parsedbl(int argc, char *argv[], const char *name, double *p,
              unsigned hasdef, double defval) {
  int i, res;
  for (i = 1; i < argc; i++) {
    if (strcmp(argv[i], "--help") == 0 || strcmp(argv[i], "-h") == 0) {
      printf("--%s <double>", name);
      if (hasdef)
        printf(" (DEFAULT:%f)", defval);
      printf("\n");
      return;
    }
  }
  for (i = 1; i < argc; i++) {
    if (strlen(argv[i]) < 3)
      continue;
    if (argv[i][0] != '-' || argv[i][1] != '-' ||
        strcmp(argv[i] + 2, name) != 0)
      continue;
    if (i == argc - 1) {
      printf("option %s value missing\n", name);
      exit(1);
    }
    res = sscanf(argv[i + 1], "%lf", p);
    if (res != 1) {
      printf("option %s failed to parse value\n", name);
      exit(1);
    }
    break;
  }
  if (i == argc) {
    if (hasdef) {
      *p = defval;
    } else {
      printf("option %s is required\n", name);
      exit(1);
    }
  }
}


x86 assembly (clang, -O0):
<parsedbl>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
movsd  %xmm0,-0x30(%rbp)
movl   $0x1,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    121c <parsedbl+0xcc>
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe6a(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     11c7 <parsedbl+0x77>
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe4f(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1209 <parsedbl+0xb9>
mov    -0x18(%rbp),%rsi
lea    0xe38(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x0,-0x24(%rbp)
je     11f6 <parsedbl+0xa6>
movsd  -0x30(%rbp),%xmm0
lea    0xe29(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xe7c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    137a <parsedbl+0x22a>
jmp    120e <parsedbl+0xbe>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1177 <parsedbl+0x27>
movl   $0x1,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1331 <parsedbl+0x1e1>
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <strlen@plt>
cmp    $0x3,%eax
jge    124e <parsedbl+0xfe>
jmp    1323 <parsedbl+0x1d3>
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    12a2 <parsedbl+0x152>
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsbl 0x1(%rax),%eax
cmp    $0x2d,%eax
jne    12a2 <parsedbl+0x152>
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
add    $0x2,%rdi
mov    -0x18(%rbp),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     12a7 <parsedbl+0x157>
jmp    1323 <parsedbl+0x1d3>
mov    -0x34(%rbp),%eax
mov    -0x4(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    12d4 <parsedbl+0x184>
mov    -0x18(%rbp),%rsi
lea    0xd63(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rax
mov    -0x34(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x20(%rbp),%rdx
lea    0xd4f(%rip),%rsi
call   1060 <sscanf@plt>
mov    %eax,-0x38(%rbp)
cmpl   $0x1,-0x38(%rbp)
je     131e <parsedbl+0x1ce>
mov    -0x18(%rbp),%rsi
lea    0xd36(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
jmp    1331 <parsedbl+0x1e1>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1223 <parsedbl+0xd3>
mov    -0x34(%rbp),%eax
cmp    -0x4(%rbp),%eax
jne    137a <parsedbl+0x22a>
cmpl   $0x0,-0x24(%rbp)
je     1359 <parsedbl+0x209>
movsd  -0x30(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    1375 <parsedbl+0x225>
mov    -0x18(%rbp),%rsi
lea    0xd00(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
jmp    137a <parsedbl+0x22a>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parsedbl>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
movsd  %xmm0,0x18(%rsp)
mov    %r8d,%ebx
mov    %rcx,%r13
mov    %rdx,%r14
mov    $0x1,%r15d
cmp    $0x2,%edi
jl     1289 <parsedbl+0x129>
mov    %rsi,%rbp
mov    %r13,0x20(%rsp)
mov    %ebx,0xc(%rsp)
mov    %r14,0x10(%rsp)
mov    %edi,0x8(%rsp)
mov    %edi,%r12d
mov    $0x1,%r13d
lea    0xe4f(%rip),%rbx
lea    0xe4f(%rip),%r14
nopl   0x0(%rax,%rax,1)
mov    0x0(%rbp,%r13,8),%rdi
mov    %rbx,%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     12ad <parsedbl+0x14d>
mov    0x0(%rbp,%r13,8),%rdi
mov    %r14,%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     12ad <parsedbl+0x14d>
add    $0x1,%r13
cmp    %r13,%r12
jne    11c0 <parsedbl+0x60>
mov    0x8(%rsp),%edi
cmp    $0x2,%edi
mov    0x10(%rsp),%r14
mov    0xc(%rsp),%ebx
mov    0x20(%rsp),%r13
jl     1289 <parsedbl+0x129>
mov    $0x1,%r15d
jmp    122e <parsedbl+0xce>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%r15
add    $0xffffffffffffffff,%r12
cmp    $0x1,%r12
je     128e <parsedbl+0x12e>
mov    0x0(%rbp,%r15,8),%rdi
call   1040 <strlen@plt>
cmp    $0x3,%eax
jl     1220 <parsedbl+0xc0>
mov    0x0(%rbp,%r15,8),%rdi
cmpb   $0x2d,(%rdi)
jne    1220 <parsedbl+0xc0>
cmpb   $0x2d,0x1(%rdi)
jne    1220 <parsedbl+0xc0>
add    $0x2,%rdi
mov    %r14,%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
jne    1220 <parsedbl+0xc0>
cmp    $0x2,%r12d
je     130e <parsedbl+0x1ae>
mov    0x8(%rbp,%r15,8),%rdi
lea    0xdcb(%rip),%rsi
mov    %r13,%rdx
call   1070 <sscanf@plt>
cmp    $0x1,%eax
jne    1317 <parsedbl+0x1b7>
mov    0x8(%rsp),%edi
cmp    %edi,%r15d
jne    129e <parsedbl+0x13e>
test   %ebx,%ebx
je     12f3 <parsedbl+0x193>
movsd  0x18(%rsp),%xmm0
movsd  %xmm0,0x0(%r13)
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd56(%rip),%rdi
mov    0x10(%rsp),%rsi
xor    %eax,%eax
call   1050 <printf@plt>
cmpl   $0x0,0xc(%rsp)
je     12db <parsedbl+0x17b>
lea    0xd4a(%rip),%rdi
movsd  0x18(%rsp),%xmm0
mov    $0x1,%al
call   1050 <printf@plt>
mov    $0xa,%edi
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>
lea    0xd6a(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
lea    0xd11(%rip),%rdi
jmp    12fa <parsedbl+0x19a>
lea    0xd25(%rip),%rdi
jmp    12fa <parsedbl+0x19a>

LLVM IR (-O0):
@.str = [7 x i8] c"--help\00"
@.str.1 = [3 x i8] c"-h\00"
@.str.2 = [14 x i8] c"--%s <double>\00"
@.str.3 = [14 x i8] c" (DEFAULT:%f)\00"
@.str.4 = [2 x i8] c"\0A\00"
@.str.5 = [25 x i8] c"option %s value missing\0A\00"
@.str.6 = [4 x i8] c"%lf\00"
@.str.7 = [33 x i8] c"option %s failed to parse value\0A\00"
@.str.8 = [23 x i8] c"option %s is required\0A\00"
define void @parsedbl(i32 %0, i8** %1, i8* %2, double* %3, i32 %4, double %5) {
%7 = alloca i32
%8 = alloca i8**
%9 = alloca i8*
%10 = alloca double*
%11 = alloca i32
%12 = alloca double
%13 = alloca i32
%14 = alloca i32
store i32 %0, i32* %7
store i8** %1, i8*** %8
store i8* %2, i8** %9
store double* %3, double** %10
store i32 %4, i32* %11
store double %5, double* %12
store i32 1, i32* %13
br label %15
15: ; preds = %46, %6
%16 = load i32, i32* %13
%17 = load i32, i32* %7
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %49
19: ; preds = %15
%20 = load i8**, i8*** %8
%21 = load i32, i32* %13
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8*, i8** %20, i64 %22
%24 = load i8*, i8** %23
%25 = call i64 @strcmp(i8* %24, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%26 = icmp eq i64 %25, 0
br i1 %26, label %35, label %27
27: ; preds = %19
%28 = load i8**, i8*** %8
%29 = load i32, i32* %13
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8*, i8** %28, i64 %30
%32 = load i8*, i8** %31
%33 = call i64 @strcmp(i8* %32, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %45
35: ; preds = %27, %19
%36 = load i8*, i8** %9
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %36)
%38 = load i32, i32* %11
%39 = icmp ne i32 %38, 0
br i1 %39, label %40, label %43
40: ; preds = %35
%41 = load double, double* %12
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), double %41)
br label %43
43: ; preds = %40, %35
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %137
45: ; preds = %27
br label %46
46: ; preds = %45
%47 = load i32, i32* %13
%48 = add nsw i32 %47, 1
store i32 %48, i32* %13
br label %15
49: ; preds = %15
store i32 1, i32* %13
br label %50
50: ; preds = %119, %49
%51 = load i32, i32* %13
%52 = load i32, i32* %7
%53 = icmp slt i32 %51, %52
br i1 %53, label %54, label %122
54: ; preds = %50
%55 = load i8**, i8*** %8
%56 = load i32, i32* %13
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds i8*, i8** %55, i64 %57
%59 = load i8*, i8** %58
%60 = call i32 @strlen(i8* %59)
%61 = icmp slt i32 %60, 3
br i1 %61, label %62, label %63
62: ; preds = %54
br label %119
63: ; preds = %54
%64 = load i8**, i8*** %8
%65 = load i32, i32* %13
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds i8*, i8** %64, i64 %66
%68 = load i8*, i8** %67
%69 = getelementptr inbounds i8, i8* %68, i64 0
%70 = load i8, i8* %69
%71 = sext i8 %70 to i32
%72 = icmp ne i32 %71, 45
br i1 %72, label %93, label %73
73: ; preds = %63
%74 = load i8**, i8*** %8
%75 = load i32, i32* %13
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds i8*, i8** %74, i64 %76
%78 = load i8*, i8** %77
%79 = getelementptr inbounds i8, i8* %78, i64 1
%80 = load i8, i8* %79
%81 = sext i8 %80 to i32
%82 = icmp ne i32 %81, 45
br i1 %82, label %93, label %83
83: ; preds = %73
%84 = load i8**, i8*** %8
%85 = load i32, i32* %13
%86 = sext i32 %85 to i64
%87 = getelementptr inbounds i8*, i8** %84, i64 %86
%88 = load i8*, i8** %87
%89 = getelementptr inbounds i8, i8* %88, i64 2
%90 = load i8*, i8** %9
%91 = call i64 @strcmp(i8* %89, i8* %90)
%92 = icmp ne i64 %91, 0
br i1 %92, label %93, label %94
93: ; preds = %83, %73, %63
br label %119
94: ; preds = %83
%95 = load i32, i32* %13
%96 = load i32, i32* %7
%97 = sub nsw i32 %96, 1
%98 = icmp eq i32 %95, %97
br i1 %98, label %99, label %103
99: ; preds = %94
%100 = load i8*, i8** %9
%101 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i8* %100)
%102 = call i32 @exit(i32 1)
unreachable
103: ; preds = %94
%104 = load i8**, i8*** %8
%105 = load i32, i32* %13
%106 = add nsw i32 %105, 1
%107 = sext i32 %106 to i64
%108 = getelementptr inbounds i8*, i8** %104, i64 %107
%109 = load i8*, i8** %108
%110 = load double*, double** %10
%111 = call i32 @sscanf(i8* %109, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), double* %110)
store i32 %111, i32* %14
%112 = load i32, i32* %14
%113 = icmp ne i32 %112, 1
br i1 %113, label %114, label %118
114: ; preds = %103
%115 = load i8*, i8** %9
%116 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.7, i64 0, i64 0), i8* %115)
%117 = call i32 @exit(i32 1)
unreachable
118: ; preds = %103
br label %122
119: ; preds = %93, %62
%120 = load i32, i32* %13
%121 = add nsw i32 %120, 1
store i32 %121, i32* %13
br label %50
122: ; preds = %118, %50
%123 = load i32, i32* %13
%124 = load i32, i32* %7
%125 = icmp eq i32 %123, %124
br i1 %125, label %126, label %137
126: ; preds = %122
%127 = load i32, i32* %11
%128 = icmp ne i32 %127, 0
br i1 %128, label %129, label %132
129: ; preds = %126
%130 = load double, double* %12
%131 = load double*, double** %10
store double %130, double* %131
br label %136
132: ; preds = %126
%133 = load i8*, i8** %9
%134 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0), i8* %133)
%135 = call i32 @exit(i32 1)
unreachable
136: ; preds = %129
br label %137
137: ; preds = %43, %136, %122
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"--help\00"
@.str.1 = [3 x i8] c"-h\00"
@.str.2 = [14 x i8] c"--%s <double>\00"
@.str.3 = [14 x i8] c" (DEFAULT:%f)\00"
@.str.5 = [25 x i8] c"option %s value missing\0A\00"
@.str.6 = [4 x i8] c"%lf\00"
@.str.7 = [33 x i8] c"option %s failed to parse value\0A\00"
@.str.8 = [23 x i8] c"option %s is required\0A\00"
define void @parsedbl(i32 %0, i8** nocapture %1, i8* %2, double* %3, i32 %4, double %5) {
%7 = icmp sgt i32 %0, 1
br i1 %7, label %8, label %71
8: ; preds = %6
%9 = zext i32 %0 to i64
br label %15
10: ; preds = %21
%11 = icmp eq i64 %25, %9
br i1 %11, label %12, label %15
12: ; preds = %10
br i1 %7, label %13, label %71
13: ; preds = %12
%14 = zext i32 %0 to i64
br label %33
15: ; preds = %8, %10
%16 = phi i64 [ 1, %8 ], [ %25, %10 ]
%17 = getelementptr inbounds i8*, i8** %1, i64 %16
%18 = load i8*, i8** %17
%19 = tail call i64 @strcmp(i8* %18, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %26, label %21
21: ; preds = %15
%22 = load i8*, i8** %17
%23 = tail call i64 @strcmp(i8* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
%25 = add nuw nsw i64 %16, 1
br i1 %24, label %26, label %10
26: ; preds = %21, %15
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %2)
%28 = icmp eq i32 %4, 0
br i1 %28, label %31, label %29
29: ; preds = %26
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), double %5)
br label %31
31: ; preds = %29, %26
%32 = tail call i32 @putchar(i32 10)
br label %80
33: ; preds = %13, %68
%34 = phi i64 [ 1, %13 ], [ %69, %68 ]
%35 = getelementptr inbounds i8*, i8** %1, i64 %34
%36 = load i8*, i8** %35
%37 = tail call i32 @strlen(i8* %36)
%38 = icmp slt i32 %37, 3
br i1 %38, label %68, label %39
39: ; preds = %33
%40 = load i8*, i8** %35
%41 = load i8, i8* %40
%42 = icmp eq i8 %41, 45
br i1 %42, label %43, label %68
43: ; preds = %39
%44 = getelementptr inbounds i8, i8* %40, i64 1
%45 = load i8, i8* %44
%46 = icmp eq i8 %45, 45
br i1 %46, label %47, label %68
47: ; preds = %43
%48 = getelementptr inbounds i8, i8* %40, i64 2
%49 = tail call i64 @strcmp(i8* %48, i8* %2)
%50 = icmp eq i64 %49, 0
br i1 %50, label %51, label %68
51: ; preds = %47
%52 = trunc i64 %34 to i32
%53 = add nsw i32 %0, -1
%54 = icmp eq i32 %53, %52
br i1 %54, label %55, label %58
55: ; preds = %51
%56 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i8* %2)
%57 = tail call i32 @exit(i32 1)
unreachable
58: ; preds = %51
%59 = add nuw i64 %34, 1
%60 = and i64 %59, 4294967295
%61 = getelementptr inbounds i8*, i8** %1, i64 %60
%62 = load i8*, i8** %61
%63 = tail call i32 @sscanf(i8* %62, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), double* %3)
%64 = icmp eq i32 %63, 1
br i1 %64, label %71, label %65
65: ; preds = %58
%66 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.7, i64 0, i64 0), i8* %2)
%67 = tail call i32 @exit(i32 1)
unreachable
68: ; preds = %39, %43, %47, %33
%69 = add nuw nsw i64 %34, 1
%70 = icmp eq i64 %69, %14
br i1 %70, label %74, label %33
71: ; preds = %6, %12, %58
%72 = phi i32 [ %52, %58 ], [ 1, %12 ], [ 1, %6 ]
%73 = icmp eq i32 %72, %0
br i1 %73, label %74, label %80
74: ; preds = %68, %71
%75 = icmp eq i32 %4, 0
br i1 %75, label %77, label %76
76: ; preds = %74
store double %5, double* %3
br label %80
77: ; preds = %74
%78 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0), i8* %2)
%79 = tail call i32 @exit(i32 1)
unreachable
80: ; preds = %71, %76, %31
ret void
}