#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*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int getfloat(float *);
int /*<<< orphan*/ printf(char *, float);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ stdout;
int main(void) {
  int ret;
  do {
    float f;
    fputs("Enter a number: ", stdout);
    fflush(stdout);
    ret = getfloat(&f);
    if (ret > 0) {
      printf("You entered: %f\n", f);
    }
  } while (ret > 0);
  if (ret == EOF) {
    puts("Stopped by EOF.");
  } else {
    puts("Stopped by bad input.");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e72(%rip),%rax
mov    (%rax),%esi
lea    0xe91(%rip),%rdi
call   1050 <fputs@plt>
mov    0x2e5d(%rip),%rax
mov    (%rax),%edi
call   1060 <fflush@plt>
lea    -0xc(%rbp),%rdi
call   1070 <getfloat@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jle    11a9 <main+0x59>
movss  -0xc(%rbp),%xmm0
lea    0xe6d(%rip),%rdi
call   1040 <printf@plt>
jmp    11ae <main+0x5e>
cmpl   $0x0,-0x8(%rbp)
jg     115f <main+0xf>
mov    -0x8(%rbp),%eax
mov    0x2e26(%rip),%rcx
cmp    (%rcx),%eax
jne    11db <main+0x8b>
lea    0xe51(%rip),%rdi
call   1030 <puts@plt>
jmp    11e7 <main+0x97>
lea    0xe50(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    0x2e79(%rip),%rbx
mov    (%rbx),%esi
lea    0xe98(%rip),%rdi
call   1050 <fputs@plt>
mov    (%rbx),%edi
call   1060 <fflush@plt>
lea    0x4(%rsp),%rdi
call   1070 <getfloat@plt>
test   %eax,%eax
jle    11cb <main+0x7b>
lea    0xe88(%rip),%r14
lea    0xe70(%rip),%r15
lea    0x4(%rsp),%r12
cs nopw 0x0(%rax,%rax,1)
nop
movss  0x4(%rsp),%xmm0
mov    %r14,%rdi
call   1040 <printf@plt>
mov    (%rbx),%esi
mov    %r15,%rdi
call   1050 <fputs@plt>
mov    (%rbx),%edi
call   1060 <fflush@plt>
mov    %r12,%rdi
call   1070 <getfloat@plt>
test   %eax,%eax
jg     11a0 <main+0x50>
mov    0x2e16(%rip),%rcx
cmp    (%rcx),%eax
lea    0xe47(%rip),%rax
lea    0xe50(%rip),%rdi
cmove  %rax,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [17 x i8] c"Enter a number: \00"
@stdout = global i32 0
@.str.1 = [17 x i8] c"You entered: %f\0A\00"
@EOF = global i32 0
@.str.2 = [16 x i8] c"Stopped by EOF.\00"
@.str.3 = [22 x i8] c"Stopped by bad input.\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca float
store i32 0, i32* %1
br label %4
4: ; preds = %16, %0
%5 = load i32, i32* @stdout
%6 = call i32 @fputs(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = load i32, i32* @stdout
%8 = call i32 @fflush(i32 %7)
%9 = call i32 @getfloat(float* %3)
store i32 %9, i32* %2
%10 = load i32, i32* %2
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %4
%13 = load float, float* %3
%14 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), float %13)
br label %15
15: ; preds = %12, %4
br label %16
16: ; preds = %15
%17 = load i32, i32* %2
%18 = icmp sgt i32 %17, 0
br i1 %18, label %4, label %19
19: ; preds = %16
%20 = load i32, i32* %2
%21 = load i32, i32* @EOF
%22 = icmp eq i32 %20, %21
br i1 %22, label %23, label %25
23: ; preds = %19
%24 = call i32 @puts(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
br label %27
25: ; preds = %19
%26 = call i32 @puts(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
br label %27
27: ; preds = %25, %23
ret i32 0
}

LLVM IR (-O2):
@.str = [17 x i8] c"Enter a number: \00"
@stdout = global i32 0
@.str.1 = [17 x i8] c"You entered: %f\0A\00"
@EOF = global i32 0
@.str.2 = [16 x i8] c"Stopped by EOF.\00"
@.str.3 = [22 x i8] c"Stopped by bad input.\00"
define i32 @main() {
%1 = alloca float
%2 = bitcast float* %1 to i8*
%3 = load i32, i32* @stdout
%4 = call i32 @fputs(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = load i32, i32* @stdout
%6 = call i32 @fflush(i32 %5)
%7 = call i32 @getfloat(float* %1)
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %18
9: ; preds = %0, %9
%10 = load float, float* %1
%11 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), float %10)
%12 = load i32, i32* @stdout
%13 = call i32 @fputs(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %12)
%14 = load i32, i32* @stdout
%15 = call i32 @fflush(i32 %14)
%16 = call i32 @getfloat(float* %1)
%17 = icmp sgt i32 %16, 0
br i1 %17, label %9, label %18
18: ; preds = %9, %0
%19 = phi i32 [ %7, %0 ], [ %16, %9 ]
%20 = load i32, i32* @EOF
%21 = icmp eq i32 %19, %20
%22 = select i1 %21, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0)
%23 = call i32 @puts(i8* dereferenceable(1) %22)
ret i32 0
}