#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*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, double *);
double get_double(char *prompt, double min, double max) {
  double input;
  do {
    printf("%s\n", prompt);
    scanf("%lf", &input);
    if (input < min)
      printf("Must be at least %lf\n", min);
    if (input > max)
      printf("Must be < %lf\n", max);
  } while (input < min || input > max);
  return input;
}


x86 assembly (clang, -O0):
<get_double>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xebf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb5(%rip),%rdi
lea    -0x20(%rbp),%rsi
call   1040 <scanf@plt>
movsd  -0x20(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    117f <get_double+0x5f>
movsd  -0x10(%rbp),%xmm0
lea    0xe90(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  -0x20(%rbp),%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    11a2 <get_double+0x82>
movsd  -0x18(%rbp),%xmm0
lea    0xe83(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    11a7 <get_double+0x87>
movsd  -0x20(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm0
mov    $0x1,%al
ucomisd %xmm1,%xmm0
mov    %al,-0x21(%rbp)
ja     11d0 <get_double+0xb0>
movsd  -0x20(%rbp),%xmm0
ucomisd -0x18(%rbp),%xmm0
seta   %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    1136 <get_double+0x16>
movsd  -0x20(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_double>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x20,%rsp
movsd  %xmm1,0x8(%rsp)
movsd  %xmm0,0x10(%rsp)
mov    %rdi,%rbx
lea    0xead(%rip),%r14
lea    0x18(%rsp),%r15
lea    0xea5(%rip),%r12
lea    0xeb4(%rip),%r13
cs nopw 0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1050 <scanf@plt>
movsd  0x18(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
ucomisd %xmm0,%xmm1
jbe    11ab <get_double+0x7b>
mov    %r12,%rdi
movsd  0x10(%rsp),%xmm0
mov    $0x1,%al
call   1040 <printf@plt>
movsd  0x18(%rsp),%xmm0
ucomisd 0x8(%rsp),%xmm0
jbe    11c9 <get_double+0x99>
mov    %r13,%rdi
movsd  0x8(%rsp),%xmm0
mov    $0x1,%al
call   1040 <printf@plt>
movsd  0x18(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
ucomisd %xmm0,%xmm1
ja     1170 <get_double+0x40>
ucomisd 0x8(%rsp),%xmm0
ja     1170 <get_double+0x40>
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [22 x i8] c"Must be at least %lf\0A\00"
@.str.3 = [15 x i8] c"Must be < %lf\0A\00"
define double @get_double(i8* %0, double %1, double %2) {
%4 = alloca i8*
%5 = alloca double
%6 = alloca double
%7 = alloca double
store i8* %0, i8** %4
store double %1, double* %5
store double %2, double* %6
br label %8
8: ; preds = %34, %3
%9 = load i8*, i8** %4
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %7)
%12 = load double, double* %7
%13 = load double, double* %5
%14 = fcmp olt double %12, %13
br i1 %14, label %15, label %18
15: ; preds = %8
%16 = load double, double* %5
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), double %16)
br label %18
18: ; preds = %15, %8
%19 = load double, double* %7
%20 = load double, double* %6
%21 = fcmp ogt double %19, %20
br i1 %21, label %22, label %25
22: ; preds = %18
%23 = load double, double* %6
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), double %23)
br label %25
25: ; preds = %22, %18
br label %26
26: ; preds = %25
%27 = load double, double* %7
%28 = load double, double* %5
%29 = fcmp olt double %27, %28
br i1 %29, label %34, label %30
30: ; preds = %26
%31 = load double, double* %7
%32 = load double, double* %6
%33 = fcmp ogt double %31, %32
br label %34
34: ; preds = %30, %26
%35 = phi i1 [ true, %26 ], [ %33, %30 ]
br i1 %35, label %8, label %36
36: ; preds = %34
%37 = load double, double* %7
ret double %37
}

LLVM IR (-O2):
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [22 x i8] c"Must be at least %lf\0A\00"
@.str.3 = [15 x i8] c"Must be < %lf\0A\00"
define double @get_double(i8* nocapture %0, double %1, double %2) {
%4 = alloca double
%5 = bitcast double* %4 to i8*
br label %6
6: ; preds = %20, %3
%7 = call i32 @puts(i8* dereferenceable(1) %0)
%8 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %4)
%9 = load double, double* %4
%10 = fcmp olt double %9, %1
br i1 %10, label %11, label %14
11: ; preds = %6
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), double %1)
%13 = load double, double* %4
br label %14
14: ; preds = %11, %6
%15 = phi double [ %13, %11 ], [ %9, %6 ]
%16 = fcmp ogt double %15, %2
br i1 %16, label %17, label %20
17: ; preds = %14
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), double %2)
%19 = load double, double* %4
br label %20
20: ; preds = %14, %17
%21 = phi double [ %15, %14 ], [ %19, %17 ]
%22 = fcmp olt double %21, %1
%23 = fcmp ogt double %21, %2
%24 = or i1 %22, %23
br i1 %24, label %6, label %25
25: ; preds = %20
ret double %21
}