#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 getStringParam(int, char **, char *, int *, char *);
double strtod(char *, int /*<<< orphan*/ *);
int getDoubleParam(int argc, char **argv, char *arg_str, int *mark_arg,
                   double *value, double min, double max) {
  char str[100];
  double temp, temp_value;
  int arg_num;
  arg_num = getStringParam(argc, argv, arg_str, mark_arg, str);
  if (arg_num == 0)
    return (0);
  temp_value = strtod(str, NULL);
  if ((min == 0.0) && (max == 0.0)) {
    *value = temp_value;
    return (1);
  }
  if (min > max) {
    temp = min;
    min = max;
    max = temp;
  }
  if ((temp_value < min) || (temp_value > max)) {
    mark_arg[arg_num + 1]--;
    return (0);
  }
  *value = temp_value;
  return (1);
}


x86 assembly (clang, -O0):
<getDoubleParam>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
movsd  %xmm0,-0x30(%rbp)
movsd  %xmm1,-0x38(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
lea    -0xa0(%rbp),%r8
call   1030 <getStringParam@plt>
mov    %eax,-0xb4(%rbp)
cmpl   $0x0,-0xb4(%rbp)
jne    1182 <getDoubleParam+0x62>
movl   $0x0,-0x4(%rbp)
jmp    1280 <getDoubleParam+0x160>
lea    -0xa0(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <strtod@plt>
movsd  %xmm0,-0xb0(%rbp)
ff
movsd  -0x30(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11e6 <getDoubleParam+0xc6>
jp     11e6 <getDoubleParam+0xc6>
movsd  -0x38(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11e6 <getDoubleParam+0xc6>
jp     11e6 <getDoubleParam+0xc6>
movsd  -0xb0(%rbp),%xmm0
ff
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    1280 <getDoubleParam+0x160>
movsd  -0x30(%rbp),%xmm0
ucomisd -0x38(%rbp),%xmm0
jbe    121a <getDoubleParam+0xfa>
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0xa8(%rbp)
ff
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0xa8(%rbp),%xmm0
ff
movsd  %xmm0,-0x38(%rbp)
movsd  -0xb0(%rbp),%xmm1
ff
movsd  -0x30(%rbp),%xmm0
ucomisd %xmm1,%xmm0
ja     1244 <getDoubleParam+0x124>
movsd  -0xb0(%rbp),%xmm0
ff
ucomisd -0x38(%rbp),%xmm0
jbe    1269 <getDoubleParam+0x149>
mov    -0x20(%rbp),%rax
mov    -0xb4(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%edx
add    $0xffffffff,%edx
mov    %edx,(%rax,%rcx,4)
movl   $0x0,-0x4(%rbp)
jmp    1280 <getDoubleParam+0x160>
movsd  -0xb0(%rbp),%xmm0
ff
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getDoubleParam>:
push   %rbp
push   %r14
push   %rbx
sub    $0x80,%rsp
movsd  %xmm1,0x8(%rsp)
movsd  %xmm0,(%rsp)
mov    %r8,%r14
mov    %rcx,%rbx
lea    0x10(%rsp),%r8
call   1030 <getStringParam@plt>
test   %eax,%eax
je     11a3 <getDoubleParam+0x83>
mov    %eax,%ebp
lea    0x10(%rsp),%rdi
xor    %esi,%esi
call   1040 <strtod@plt>
xorpd  %xmm1,%xmm1
movsd  (%rsp),%xmm2
ucomisd %xmm1,%xmm2
movsd  0x8(%rsp),%xmm3
jne    1177 <getDoubleParam+0x57>
jp     1177 <getDoubleParam+0x57>
ucomisd %xmm1,%xmm3
jne    1177 <getDoubleParam+0x57>
jnp    118f <getDoubleParam+0x6f>
movapd %xmm3,%xmm1
minsd  %xmm2,%xmm1
ucomisd %xmm0,%xmm1
ja     119b <getDoubleParam+0x7b>
maxsd  %xmm3,%xmm2
ucomisd %xmm2,%xmm0
ja     119b <getDoubleParam+0x7b>
movsd  %xmm0,(%r14)
mov    $0x1,%eax
jmp    11a5 <getDoubleParam+0x85>
movslq %ebp,%rax
addl   $0xffffffff,0x4(%rbx,%rax,4)
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @getDoubleParam(i32 %0, i8** %1, i8* %2, i32* %3, double* %4, double %5, double %6) {
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8**
%11 = alloca i8*
%12 = alloca i32*
%13 = alloca double*
%14 = alloca double
%15 = alloca double
%16 = alloca [100 x i8]
%17 = alloca double
%18 = alloca double
%19 = alloca i32
store i32 %0, i32* %9
store i8** %1, i8*** %10
store i8* %2, i8** %11
store i32* %3, i32** %12
store double* %4, double** %13
store double %5, double* %14
store double %6, double* %15
%20 = load i32, i32* %9
%21 = load i8**, i8*** %10
%22 = load i8*, i8** %11
%23 = load i32*, i32** %12
%24 = getelementptr inbounds [100 x i8], [100 x i8]* %16, i64 0, i64 0
%25 = call i32 @getStringParam(i32 %20, i8** %21, i8* %22, i32* %23, i8* %24)
store i32 %25, i32* %19
%26 = load i32, i32* %19
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %29
28: ; preds = %7
store i32 0, i32* %8
br label %67
29: ; preds = %7
%30 = getelementptr inbounds [100 x i8], [100 x i8]* %16, i64 0, i64 0
%31 = call double @strtod(i8* %30, i32* null)
store double %31, double* %18
%32 = load double, double* %14
%33 = fcmp oeq double %32, 0.000000e+00
br i1 %33, label %34, label %40
34: ; preds = %29
%35 = load double, double* %15
%36 = fcmp oeq double %35, 0.000000e+00
br i1 %36, label %37, label %40
37: ; preds = %34
%38 = load double, double* %18
%39 = load double*, double** %13
store double %38, double* %39
store i32 1, i32* %8
br label %67
40: ; preds = %34, %29
%41 = load double, double* %14
%42 = load double, double* %15
%43 = fcmp ogt double %41, %42
br i1 %43, label %44, label %48
44: ; preds = %40
%45 = load double, double* %14
store double %45, double* %17
%46 = load double, double* %15
store double %46, double* %14
%47 = load double, double* %17
store double %47, double* %15
br label %48
48: ; preds = %44, %40
%49 = load double, double* %18
%50 = load double, double* %14
%51 = fcmp olt double %49, %50
br i1 %51, label %56, label %52
52: ; preds = %48
%53 = load double, double* %18
%54 = load double, double* %15
%55 = fcmp ogt double %53, %54
br i1 %55, label %56, label %64
56: ; preds = %52, %48
%57 = load i32*, i32** %12
%58 = load i32, i32* %19
%59 = add nsw i32 %58, 1
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds i32, i32* %57, i64 %60
%62 = load i32, i32* %61
%63 = add nsw i32 %62, -1
store i32 %63, i32* %61
store i32 0, i32* %8
br label %67
64: ; preds = %52
%65 = load double, double* %18
%66 = load double*, double** %13
store double %65, double* %66
store i32 1, i32* %8
br label %67
67: ; preds = %64, %56, %37, %28
%68 = load i32, i32* %8
ret i32 %68
}

LLVM IR (-O2):
define i32 @getDoubleParam(i32 %0, i8** %1, i8* %2, i32* %3, double* nocapture writeonly %4, double %5, double %6) {
%8 = alloca [100 x i8]
%9 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%10 = call i32 @getStringParam(i32 %0, i8** %1, i8* %2, i32* %3, i8* %9)
%11 = icmp eq i32 %10, 0
br i1 %11, label %32, label %12
12: ; preds = %7
%13 = call double @strtod(i8* nocapture %9, i32* null)
%14 = fcmp oeq double %5, 0.000000e+00
%15 = fcmp oeq double %6, 0.000000e+00
%16 = and i1 %14, %15
br i1 %16, label %17, label %18
17: ; preds = %12
store double %13, double* %4
br label %32
18: ; preds = %12
%19 = fcmp ogt double %5, %6
%20 = select i1 %19, double %5, double %6
%21 = select i1 %19, double %6, double %5
%22 = fcmp olt double %13, %21
%23 = fcmp ogt double %13, %20
%24 = or i1 %22, %23
br i1 %24, label %25, label %31
25: ; preds = %18
%26 = add nsw i32 %10, 1
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i32, i32* %3, i64 %27
%29 = load i32, i32* %28
%30 = add nsw i32 %29, -1
store i32 %30, i32* %28
br label %32
31: ; preds = %18
store double %13, double* %4
br label %32
32: ; preds = %7, %31, %25, %17
%33 = phi i32 [ 1, %17 ], [ 0, %25 ], [ 1, %31 ], [ 0, %7 ]
ret i32 %33
}