#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*/ contains_double_const(double *, double *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, double *);
double *errorcheck_double(char *prompt, double *legal) {
  double container;
  double *response = &container;
  printf("%s", prompt);
  scanf(" %lf", response);
  while (!contains_double_const(legal, response)) {
    printf("INVALID ENTRY\n");
    printf("%s", prompt);
    scanf(" %lf", response);
  }
  return response;
}


x86 assembly (clang, -O0):
<errorcheck_double>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xead(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rsi
lea    0xe9e(%rip),%rdi
call   1050 <scanf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <contains_double_const@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    118c <errorcheck_double+0x5c>
jmp    11c1 <errorcheck_double+0x91>
lea    0xe75(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rsi
lea    0xe5b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rsi
lea    0xe4c(%rip),%rdi
call   1050 <scanf@plt>
jmp    116a <errorcheck_double+0x3a>
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<errorcheck_double>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xea8(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe9a(%rip),%rdi
mov    %rsp,%rbp
mov    %rbp,%rsi
call   1060 <scanf@plt>
mov    %r14,%rdi
mov    %rbp,%rsi
call   1050 <contains_double_const@plt>
test   %eax,%eax
jne    11cf <errorcheck_double+0x8f>
lea    0xe7e(%rip),%r15
lea    0xe6f(%rip),%r12
lea    0xe6b(%rip),%r13
mov    %rsp,%rbp
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
call   1030 <puts@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r13,%rdi
mov    %rbp,%rsi
call   1060 <scanf@plt>
mov    %r14,%rdi
mov    %rbp,%rsi
call   1050 <contains_double_const@plt>
test   %eax,%eax
je     11a0 <errorcheck_double+0x60>
mov    %rsp,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [5 x i8] c" %lf\00"
@.str.2 = [15 x i8] c"INVALID ENTRY\0A\00"
define double* @errorcheck_double(i8* %0, double* %1) {
%3 = alloca i8*
%4 = alloca double*
%5 = alloca double
%6 = alloca double*
store i8* %0, i8** %3
store double* %1, double** %4
store double* %5, double** %6
%7 = load i8*, i8** %3
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %7)
%9 = load double*, double** %6
%10 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), double* %9)
br label %11
11: ; preds = %17, %2
%12 = load double*, double** %4
%13 = load double*, double** %6
%14 = call i32 @contains_double_const(double* %12, double* %13)
%15 = icmp ne i32 %14, 0
%16 = xor i1 %15, true
br i1 %16, label %17, label %23
17: ; preds = %11
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%19 = load i8*, i8** %3
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %19)
%21 = load double*, double** %6
%22 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), double* %21)
br label %11
23: ; preds = %11
%24 = load double*, double** %6
ret double* %24
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [5 x i8] c" %lf\00"
@str = [14 x i8] c"INVALID ENTRY\00"
define double* @errorcheck_double(i8* %0, double* %1) {
%3 = alloca double
%4 = bitcast double* %3 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %0)
%6 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), double* %3)
%7 = call i32 @contains_double_const(double* %1, double* %3)
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %15
9: ; preds = %2, %9
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %0)
%12 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), double* %3)
%13 = call i32 @contains_double_const(double* %1, double* %3)
%14 = icmp eq i32 %13, 0
br i1 %14, label %9, label %15
15: ; preds = %9, %2
ret double* %3
}