#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 */
char getchar();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ putchar(char);
double scanf(char *, float *);
float get_float() {
  float input;
  char ch;
  while (scanf("%f", &input) != 1.0) {
    while ((ch = getchar()) != '\n') {
      putchar(ch);
    }
    printf(" is not valid\n"
           "Please enter a float or int value such as 5.5, 2.0 or 1: ");
  }
  return input;
}


x86 assembly (clang, -O0):
<get_float>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xeb9(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1060 <scanf@plt>
movsd  0xea0(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    1175 <get_float+0x35>
jp     1175 <get_float+0x35>
jmp    11af <get_float+0x6f>
jmp    117a <get_float+0x3a>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %al,-0x5(%rbp)
movsbl %al,%eax
cmp    $0xa,%eax
je     119e <get_float+0x5e>
movsbl -0x5(%rbp),%edi
call   1030 <putchar@plt>
jmp    117a <get_float+0x3a>
lea    0xe66(%rip),%rdi
call   1040 <printf@plt>
jmp    1148 <get_float+0x8>
movss  -0x4(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_float>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xeb8(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
ucomisd 0xe9e(%rip),%xmm0
jne    1166 <get_float+0x26>
jnp    11b2 <get_float+0x72>
lea    0xe9e(%rip),%r14
lea    0xe94(%rip),%r15
lea    0xc(%rsp),%rbx
jmp    1188 <get_float+0x48>
nopl   0x0(%rax,%rax,1)
movsbl %al,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0xa,%al
jne    1180 <get_float+0x40>
mov    %r14,%rdi
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
ucomisd 0xe52(%rip),%xmm0
jne    1188 <get_float+0x48>
jp     1188 <get_float+0x48>
movss  0xc(%rsp),%xmm0
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%f\00"
@.str.1 = [72 x i8] c" is not valid\0APlease enter a float or int value such as 5.5, 2.0 or 1: \00"
define float @get_float() {
%1 = alloca float
%2 = alloca i8
br label %3
3: ; preds = %14, %0
%4 = call double @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), float* %1)
%5 = fcmp une double %4, 1.000000e+00
br i1 %5, label %6, label %16
6: ; preds = %3
br label %7
7: ; preds = %11, %6
%8 = call signext i8 (...) @getchar()
store i8 %8, i8* %2
%9 = sext i8 %8 to i32
%10 = icmp ne i32 %9, 10
br i1 %10, label %11, label %14
11: ; preds = %7
%12 = load i8, i8* %2
%13 = call i32 @putchar(i8 signext %12)
br label %7
14: ; preds = %7
%15 = call i32 @printf(i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str.1, i64 0, i64 0))
br label %3
16: ; preds = %3
%17 = load float, float* %1
ret float %17
}

LLVM IR (-O2):
@.str = [3 x i8] c"%f\00"
@.str.1 = [72 x i8] c" is not valid\0APlease enter a float or int value such as 5.5, 2.0 or 1: \00"
define float @get_float() {
%1 = alloca float
%2 = bitcast float* %1 to i8*
%3 = call double @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), float* %1)
%4 = fcmp une double %3, 1.000000e+00
br i1 %4, label %5, label %17
5: ; preds = %0, %13
%6 = call signext i8 (...) @getchar()
%7 = icmp eq i8 %6, 10
br i1 %7, label %13, label %8
8: ; preds = %5, %8
%9 = phi i8 [ %11, %8 ], [ %6, %5 ]
%10 = call i32 @putchar(i8 signext %9)
%11 = call signext i8 (...) @getchar()
%12 = icmp eq i8 %11, 10
br i1 %12, label %13, label %8
13: ; preds = %8, %5
%14 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([72 x i8], [72 x i8]* @.str.1, i64 0, i64 0))
%15 = call double @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), float* %1)
%16 = fcmp une double %15, 1.000000e+00
br i1 %16, label %5, label %17
17: ; preds = %13, %0
%18 = load float, float* %1
ret float %18
}