#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 EOF;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ gets(char *);
int sscanf(char *, char *, float *);
int /*<<< orphan*/ stdout;
double getreal(char *instr, double minx, double maxx, double def) {
  int status;
  float ret;
  char line[1024];
  while (1) {
    fprintf(stdout, "%s (%.1f-%.1f)   [%.1f]: ", instr, minx, maxx, def);
    gets(line);
    status = sscanf(line, "%f", &ret);
    if (status == EOF)
      return def;
    if (ret > maxx) {
      fprintf(stdout, "ERROR: Max. value=%.1f\n\n", maxx);
      continue;
    }
    if (ret < minx) {
      fprintf(stdout, "ERROR: Min. value=%.1f\n\n", minx);
      continue;
    }
    break;
  }
  return (double)ret;
}


x86 assembly (clang, -O0):
<getreal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
mov    %rdi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
movsd  %xmm1,-0x20(%rbp)
movsd  %xmm2,-0x28(%rbp)
mov    0x2e83(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm2
lea    0xe8f(%rip),%rsi
mov    $0x3,%al
call   1030 <fprintf@plt>
lea    -0x430(%rbp),%rdi
call   1040 <gets@plt>
lea    -0x430(%rbp),%rdi
lea    0xe88(%rip),%rsi
lea    -0x30(%rbp),%rdx
call   1050 <sscanf@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    0x2e40(%rip),%rcx
cmp    (%rcx),%eax
jne    11bf <getreal+0x8f>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1240 <getreal+0x110>
movss  -0x30(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    11f4 <getreal+0xc4>
mov    0x2dfe(%rip),%rax
mov    (%rax),%edi
movsd  -0x20(%rbp),%xmm0
lea    0xe35(%rip),%rsi
mov    $0x1,%al
call   1030 <fprintf@plt>
jmp    114e <getreal+0x1e>
movss  -0x30(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  -0x18(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    122d <getreal+0xfd>
mov    0x2dc5(%rip),%rax
mov    (%rax),%edi
movsd  -0x18(%rbp),%xmm0
lea    0xe15(%rip),%rsi
mov    $0x1,%al
call   1030 <fprintf@plt>
jmp    114e <getreal+0x1e>
jmp    1232 <getreal+0x102>
movss  -0x30(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getreal>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x428,%rsp
mov    %rdi,%r12
mov    0x2e8d(%rip),%r14
mov    (%r14),%edi
lea    0xeab(%rip),%rsi
mov    %r12,%rdx
movsd  %xmm0,0x10(%rsp)
movsd  %xmm1,0x18(%rsp)
movsd  %xmm2,0x8(%rsp)
mov    $0x3,%al
call   1030 <fprintf@plt>
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <gets@plt>
lea    0xe95(%rip),%rsi
lea    0x4(%rsp),%rdx
mov    %rbx,%rdi
call   1050 <sscanf@plt>
mov    0x2e4f(%rip),%r15
cmp    (%r15),%eax
jne    11b6 <getreal+0x86>
movsd  0x8(%rsp),%xmm0
add    $0x428,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x20(%rsp),%rbx
lea    0xe58(%rip),%r13
lea    0x4(%rsp),%rbp
jmp    122a <getreal+0xfa>
nopl   0x0(%rax)
mov    (%r14),%edi
lea    0xe43(%rip),%rsi
movapd %xmm1,%xmm0
mov    $0x1,%al
call   1030 <fprintf@plt>
movsd  0x10(%rsp),%xmm0
mov    (%r14),%edi
lea    0xe0b(%rip),%rsi
mov    %r12,%rdx
movsd  0x18(%rsp),%xmm1
movsd  0x8(%rsp),%xmm2
mov    $0x3,%al
call   1030 <fprintf@plt>
mov    %rbx,%rdi
call   1040 <gets@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
mov    %rbp,%rdx
call   1050 <sscanf@plt>
cmp    (%r15),%eax
je     119e <getreal+0x6e>
movss  0x4(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0x18(%rsp),%xmm1
ucomisd %xmm1,%xmm0
ja     11d0 <getreal+0xa0>
movsd  0x10(%rsp),%xmm2
ucomisd %xmm0,%xmm2
jbe    11a4 <getreal+0x74>
mov    (%r14),%edi
lea    0xddc(%rip),%rsi
movapd %xmm2,%xmm0
jmp    11de <getreal+0xae>

LLVM IR (-O0):
@stdout = global i32 0
@.str = [26 x i8] c"%s (%.1f-%.1f) [%.1f]: \00"
@.str.1 = [3 x i8] c"%f\00"
@EOF = global i32 0
@.str.2 = [25 x i8] c"ERROR: Max. value=%.1f\0A\0A\00"
@.str.3 = [25 x i8] c"ERROR: Min. value=%.1f\0A\0A\00"
define double @getreal(i8* %0, double %1, double %2, double %3) {
%5 = alloca double
%6 = alloca i8*
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca i32
%11 = alloca float
%12 = alloca [1024 x i8]
store i8* %0, i8** %6
store double %1, double* %7
store double %2, double* %8
store double %3, double* %9
br label %13
13: ; preds = %4, %34, %43
%14 = load i32, i32* @stdout
%15 = load i8*, i8** %6
%16 = load double, double* %7
%17 = load double, double* %8
%18 = load double, double* %9
%19 = call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %15, double %16, double %17, double %18)
%20 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%21 = call i32 @gets(i8* %20)
%22 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%23 = call i32 @sscanf(i8* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %11)
store i32 %23, i32* %10
%24 = load i32, i32* %10
%25 = load i32, i32* @EOF
%26 = icmp eq i32 %24, %25
br i1 %26, label %27, label %29
27: ; preds = %13
%28 = load double, double* %9
store double %28, double* %5
br label %51
29: ; preds = %13
%30 = load float, float* %11
%31 = fpext float %30 to double
%32 = load double, double* %8
%33 = fcmp ogt double %31, %32
br i1 %33, label %34, label %38
34: ; preds = %29
%35 = load i32, i32* @stdout
%36 = load double, double* %8
%37 = call i32 (i32, i8*, ...) @fprintf(i32 %35, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), double %36)
br label %13
38: ; preds = %29
%39 = load float, float* %11
%40 = fpext float %39 to double
%41 = load double, double* %7
%42 = fcmp olt double %40, %41
br i1 %42, label %43, label %47
43: ; preds = %38
%44 = load i32, i32* @stdout
%45 = load double, double* %7
%46 = call i32 (i32, i8*, ...) @fprintf(i32 %44, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), double %45)
br label %13
47: ; preds = %38
br label %48
48: ; preds = %47
%49 = load float, float* %11
%50 = fpext float %49 to double
store double %50, double* %5
br label %51
51: ; preds = %48, %27
%52 = load double, double* %5
ret double %52
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [26 x i8] c"%s (%.1f-%.1f) [%.1f]: \00"
@.str.1 = [3 x i8] c"%f\00"
@EOF = global i32 0
@.str.2 = [25 x i8] c"ERROR: Max. value=%.1f\0A\0A\00"
@.str.3 = [25 x i8] c"ERROR: Min. value=%.1f\0A\0A\00"
define double @getreal(i8* %0, double %1, double %2, double %3) {
%5 = alloca float
%6 = alloca [1024 x i8]
%7 = bitcast float* %5 to i8*
%8 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%9 = load i32, i32* @stdout
%10 = call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %0, double %1, double %2, double %3)
%11 = call i32 @gets(i8* %8)
%12 = call i32 @sscanf(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %5)
%13 = load i32, i32* @EOF
%14 = icmp eq i32 %12, %13
br i1 %14, label %34, label %15
15: ; preds = %4, %22
%16 = load float, float* %5
%17 = fpext float %16 to double
%18 = fcmp ogt double %17, %2
br i1 %18, label %19, label %29
19: ; preds = %15
%20 = load i32, i32* @stdout
%21 = call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), double %2)
br label %22
22: ; preds = %19, %31
%23 = load i32, i32* @stdout
%24 = call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %0, double %1, double %2, double %3)
%25 = call i32 @gets(i8* %8)
%26 = call i32 @sscanf(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %5)
%27 = load i32, i32* @EOF
%28 = icmp eq i32 %26, %27
br i1 %28, label %34, label %15
29: ; preds = %15
%30 = fcmp olt double %17, %1
br i1 %30, label %31, label %34
31: ; preds = %29
%32 = load i32, i32* @stdout
%33 = call i32 (i32, i8*, ...) @fprintf(i32 %32, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), double %1)
br label %22
34: ; preds = %22, %29, %4
%35 = phi double [ %3, %4 ], [ %17, %29 ], [ %3, %22 ]
ret double %35
}