#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 */
typedef int /*<<< orphan*/ st;

/* Variables and functions */
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int sscanf(char *, char *, double *);
int /*<<< orphan*/ stdin;
double double_input(const double lower, const double upper, const char *text) {
  char st[200];
  int result;
  double number;
  printf("%s", text);
  do {
    fgets(st, sizeof(st), stdin);
    result = sscanf(st, "%lf", &number);
    if (result < 1 || (number < lower || number > upper)) {
      printf("Invalid input. Enter a number between [%.1lf, %.1lf]: ", lower,
             upper);
    }
  } while (result < 1 || (number < lower || number > upper));
  return number;
}


x86 assembly (clang, -O0):
<double_input>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
mov    %rdi,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xeac(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0xe0(%rbp),%rdi
mov    0x2e7f(%rip),%rax
mov    (%rax),%edx
mov    $0xc8,%esi
call   1040 <fgets@plt>
lea    -0xe0(%rbp),%rdi
lea    0xe80(%rip),%rsi
lea    -0xf0(%rbp),%rdx
call   1050 <sscanf@plt>
mov    %eax,-0xe4(%rbp)
cmpl   $0x1,-0xe4(%rbp)
jl     11cc <double_input+0x9c>
movsd  -0xf0(%rbp),%xmm1
ff
movsd  -0x8(%rbp),%xmm0
ucomisd %xmm1,%xmm0
ja     11cc <double_input+0x9c>
movsd  -0xf0(%rbp),%xmm0
ff
ucomisd -0x10(%rbp),%xmm0
jbe    11e4 <double_input+0xb4>
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
lea    0xe2a(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
jmp    11e9 <double_input+0xb9>
mov    $0x1,%al
cmpl   $0x1,-0xe4(%rbp)
mov    %al,-0xf1(%rbp)
jl     123f <double_input+0x10f>
movsd  -0xf0(%rbp),%xmm1
ff
movsd  -0x8(%rbp),%xmm0
mov    $0x1,%al
ucomisd %xmm1,%xmm0
mov    %al,-0xf2(%rbp)
ja     1233 <double_input+0x103>
movsd  -0xf0(%rbp),%xmm0
ff
ucomisd -0x10(%rbp),%xmm0
seta   %al
mov    %al,-0xf2(%rbp)
mov    -0xf2(%rbp),%al
mov    %al,-0xf1(%rbp)
mov    -0xf1(%rbp),%al
test   $0x1,%al
jne    115b <double_input+0x2b>
movsd  -0xf0(%rbp),%xmm0
ff
add    $0x100,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<double_input>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xf0,%rsp
mov    %rdi,%rsi
movsd  %xmm1,0x8(%rsp)
movsd  %xmm0,0x10(%rsp)
lea    0xeaa(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x2e84(%rip),%r13
lea    0x20(%rsp),%rbx
lea    0xe93(%rip),%r14
lea    0x18(%rsp),%r15
lea    0xe8b(%rip),%r12
jmp    1196 <double_input+0x66>
xchg   %ax,%ax
mov    %r12,%rdi
movsd  0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
mov    $0x2,%al
call   1030 <printf@plt>
mov    0x0(%r13),%edx
mov    %rbx,%rdi
mov    $0xc8,%esi
call   1040 <fgets@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1050 <sscanf@plt>
test   %eax,%eax
jle    1180 <double_input+0x50>
movsd  0x18(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
ucomisd %xmm0,%xmm1
ja     11d3 <double_input+0xa3>
ucomisd 0x8(%rsp),%xmm0
jbe    11ef <double_input+0xbf>
mov    %r12,%rdi
movsd  0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
mov    $0x2,%al
call   1030 <printf@plt>
movsd  0x18(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
ucomisd %xmm0,%xmm1
ja     1196 <double_input+0x66>
ucomisd 0x8(%rsp),%xmm0
ja     1196 <double_input+0x66>
add    $0xf0,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@stdin = global i32 0
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [55 x i8] c"Invalid input. Enter a number between [%.1lf, %.1lf]: \00"
define double @double_input(double %0, double %1, i8* %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca i8*
%7 = alloca [200 x i8]
%8 = alloca i32
%9 = alloca double
store double %0, double* %4
store double %1, double* %5
store i8* %2, i8** %6
%10 = load i8*, i8** %6
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %10)
br label %12
12: ; preds = %46, %3
%13 = getelementptr inbounds [200 x i8], [200 x i8]* %7, i64 0, i64 0
%14 = load i32, i32* @stdin
%15 = call i32 @fgets(i8* %13, i32 200, i32 %14)
%16 = getelementptr inbounds [200 x i8], [200 x i8]* %7, i64 0, i64 0
%17 = call i32 @sscanf(i8* %16, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %9)
store i32 %17, i32* %8
%18 = load i32, i32* %8
%19 = icmp slt i32 %18, 1
br i1 %19, label %28, label %20
20: ; preds = %12
%21 = load double, double* %9
%22 = load double, double* %4
%23 = fcmp olt double %21, %22
br i1 %23, label %28, label %24
24: ; preds = %20
%25 = load double, double* %9
%26 = load double, double* %5
%27 = fcmp ogt double %25, %26
br i1 %27, label %28, label %32
28: ; preds = %24, %20, %12
%29 = load double, double* %4
%30 = load double, double* %5
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.2, i64 0, i64 0), double %29, double %30)
br label %32
32: ; preds = %28, %24
br label %33
33: ; preds = %32
%34 = load i32, i32* %8
%35 = icmp slt i32 %34, 1
br i1 %35, label %46, label %36
36: ; preds = %33
%37 = load double, double* %9
%38 = load double, double* %4
%39 = fcmp olt double %37, %38
br i1 %39, label %44, label %40
40: ; preds = %36
%41 = load double, double* %9
%42 = load double, double* %5
%43 = fcmp ogt double %41, %42
br label %44
44: ; preds = %40, %36
%45 = phi i1 [ true, %36 ], [ %43, %40 ]
br label %46
46: ; preds = %44, %33
%47 = phi i1 [ true, %33 ], [ %45, %44 ]
br i1 %47, label %12, label %48
48: ; preds = %46
%49 = load double, double* %9
ret double %49
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@stdin = global i32 0
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [55 x i8] c"Invalid input. Enter a number between [%.1lf, %.1lf]: \00"
define double @double_input(double %0, double %1, i8* %2) {
%4 = alloca [200 x i8]
%5 = alloca double
%6 = getelementptr inbounds [200 x i8], [200 x i8]* %4, i64 0, i64 0
%7 = bitcast double* %5 to i8*
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %2)
br label %9
9: ; preds = %29, %3
%10 = load i32, i32* @stdin
%11 = call i32 @fgets(i8* %6, i32 200, i32 %10)
%12 = call i32 @sscanf(i8* %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %5)
%13 = icmp slt i32 %12, 1
br i1 %13, label %22, label %14
14: ; preds = %9
%15 = load double, double* %5
%16 = fcmp olt double %15, %0
%17 = fcmp ogt double %15, %1
%18 = or i1 %16, %17
br i1 %18, label %19, label %24
19: ; preds = %14
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @.str.2, i64 0, i64 0), double %0, double %1)
%21 = load double, double* %5
br label %24
22: ; preds = %9
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @.str.2, i64 0, i64 0), double %0, double %1)
br label %29
24: ; preds = %14, %19
%25 = phi double [ %15, %14 ], [ %21, %19 ]
%26 = fcmp olt double %25, %0
%27 = fcmp ogt double %25, %1
%28 = or i1 %26, %27
br i1 %28, label %29, label %30
29: ; preds = %24, %22
br label %9
30: ; preds = %24
ret double %25
}