#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 */
double atof(char const *);
int /*<<< orphan*/ exit(int);
char *get_key_value(void *, char const *, char const *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, char const *, char const *);
double getconfloat(void *cfgdata, const char *section, const char *key,
                   int isnull, double notfound, double min, double max) {
  const char *cp;
  double v;
  cp = get_key_value(cfgdata, section, key, NULL);
  if (!cp && !isnull) {
    printf("Config Item: [%s] %s: not set\n", section, key);
    exit(1);
  } else if (!cp && isnull)
    return notfound;
  else {
    v = atof(cp);
    if (max && (v < min || v > max)) {
      printf("Config Item: [%s] %s: set error\n", section, key);
      exit(1);
    }
    return v;
  }
}


x86 assembly (clang, -O0):
<getconfloat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
movsd  %xmm0,-0x30(%rbp)
movsd  %xmm1,-0x38(%rbp)
movsd  %xmm2,-0x40(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
xor    %eax,%eax
mov    %eax,%ecx
call   1040 <get_key_value@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
jne    11b2 <getconfloat+0x72>
cmpl   $0x0,-0x24(%rbp)
jne    11b2 <getconfloat+0x72>
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
lea    0xe5d(%rip),%rdi
call   1050 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
cmpq   $0x0,-0x48(%rbp)
jne    11d6 <getconfloat+0x96>
cmpl   $0x0,-0x24(%rbp)
je     11d6 <getconfloat+0x96>
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    124d <getconfloat+0x10d>
mov    -0x48(%rbp),%rdi
call   1030 <atof@plt>
movsd  %xmm0,-0x50(%rbp)
movsd  -0x40(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1201 <getconfloat+0xc1>
jp     1201 <getconfloat+0xc1>
jmp    1243 <getconfloat+0x103>
movsd  -0x50(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm0
ucomisd %xmm1,%xmm0
ja     1225 <getconfloat+0xe5>
movsd  -0x50(%rbp),%xmm0
ucomisd -0x40(%rbp),%xmm0
jbe    1243 <getconfloat+0x103>
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
lea    0xdeb(%rip),%rdi
call   1050 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
movsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getconfloat>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
movsd  %xmm2,0x8(%rsp)
movsd  %xmm1,0x10(%rsp)
movsd  %xmm0,0x18(%rsp)
mov    %ecx,%ebp
mov    %rdx,%r14
mov    %rsi,%rbx
xor    %ecx,%ecx
call   1040 <get_key_value@plt>
test   %ebp,%ebp
jne    1172 <getconfloat+0x32>
test   %rax,%rax
je     11b8 <getconfloat+0x78>
test   %ebp,%ebp
movsd  0x18(%rsp),%xmm0
je     1181 <getconfloat+0x41>
test   %rax,%rax
je     11af <getconfloat+0x6f>
mov    %rax,%rdi
call   1030 <atof@plt>
xorpd  %xmm1,%xmm1
movsd  0x8(%rsp),%xmm2
ucomisd %xmm1,%xmm2
jne    119b <getconfloat+0x5b>
jnp    11af <getconfloat+0x6f>
movsd  0x10(%rsp),%xmm1
ucomisd %xmm0,%xmm1
ja     11c1 <getconfloat+0x81>
ucomisd 0x8(%rsp),%xmm0
ja     11c1 <getconfloat+0x81>
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0xe41(%rip),%rdi
jmp    11c8 <getconfloat+0x88>
lea    0xe57(%rip),%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1050 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [31 x i8] c"Config Item: [%s] %s: not set\0A\00"
@.str.1 = [33 x i8] c"Config Item: [%s] %s: set error\0A\00"
define double @getconfloat(i8* %0, i8* %1, i8* %2, i32 %3, double %4, double %5, double %6) {
%8 = alloca double
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i32
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca i8*
%17 = alloca double
store i8* %0, i8** %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
%18 = load i8*, i8** %9
%19 = load i8*, i8** %10
%20 = load i8*, i8** %11
%21 = call i8* @get_key_value(i8* %18, i8* %19, i8* %20, i32* null)
store i8* %21, i8** %16
%22 = load i8*, i8** %16
%23 = icmp ne i8* %22, null
br i1 %23, label %32, label %24
24: ; preds = %7
%25 = load i32, i32* %12
%26 = icmp ne i32 %25, 0
br i1 %26, label %32, label %27
27: ; preds = %24
%28 = load i8*, i8** %10
%29 = load i8*, i8** %11
%30 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %28, i8* %29)
%31 = call i32 @exit(i32 1)
unreachable
32: ; preds = %24, %7
%33 = load i8*, i8** %16
%34 = icmp ne i8* %33, null
br i1 %34, label %40, label %35
35: ; preds = %32
%36 = load i32, i32* %12
%37 = icmp ne i32 %36, 0
br i1 %37, label %38, label %40
38: ; preds = %35
%39 = load double, double* %13
store double %39, double* %8
br label %60
40: ; preds = %35, %32
%41 = load i8*, i8** %16
%42 = call double @atof(i8* %41)
store double %42, double* %17
%43 = load double, double* %15
%44 = fcmp une double %43, 0.000000e+00
br i1 %44, label %45, label %58
45: ; preds = %40
%46 = load double, double* %17
%47 = load double, double* %14
%48 = fcmp olt double %46, %47
br i1 %48, label %53, label %49
49: ; preds = %45
%50 = load double, double* %17
%51 = load double, double* %15
%52 = fcmp ogt double %50, %51
br i1 %52, label %53, label %58
53: ; preds = %49, %45
%54 = load i8*, i8** %10
%55 = load i8*, i8** %11
%56 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i8* %54, i8* %55)
%57 = call i32 @exit(i32 1)
unreachable
58: ; preds = %49, %40
%59 = load double, double* %17
store double %59, double* %8
br label %60
60: ; preds = %58, %38
%61 = load double, double* %8
ret double %61
}

LLVM IR (-O2):
@.str = [31 x i8] c"Config Item: [%s] %s: not set\0A\00"
@.str.1 = [33 x i8] c"Config Item: [%s] %s: set error\0A\00"
define double @getconfloat(i8* %0, i8* %1, i8* %2, i32 %3, double %4, double %5, double %6) {
%8 = tail call i8* @get_key_value(i8* %0, i8* %1, i8* %2, i32* null)
%9 = icmp ne i8* %8, null
%10 = icmp ne i32 %3, 0
%11 = or i1 %10, %9
br i1 %11, label %15, label %12
12: ; preds = %7
%13 = tail call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %1, i8* %2)
%14 = tail call i32 @exit(i32 1)
unreachable
15: ; preds = %7
%16 = icmp eq i8* %8, null
%17 = and i1 %10, %16
br i1 %17, label %28, label %18
18: ; preds = %15
%19 = tail call double @atof(i8* %8)
%20 = fcmp une double %6, 0.000000e+00
br i1 %20, label %21, label %28
21: ; preds = %18
%22 = fcmp olt double %19, %5
%23 = fcmp ogt double %19, %6
%24 = or i1 %22, %23
br i1 %24, label %25, label %28
25: ; preds = %21
%26 = tail call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i8* %1, i8* %2)
%27 = tail call i32 @exit(i32 1)
unreachable
28: ; preds = %18, %21, %15
%29 = phi double [ %4, %15 ], [ %19, %21 ], [ %19, %18 ]
ret double %29
}