#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 */
double ReadDouble();
char getchar();
int /*<<< orphan*/ printf(char *, ...);
int main(void) {
  char c = 0;
  double num = 0.0;
  printf("Please enter a floating-point number: \n");
  while (1) {
    printf(">>> ");
    num = ReadDouble();
    while (c != '\n') {
      c = getchar();
    }
    c = 0;
    printf("%.14g\n", num);
  }
  getchar();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movb   $0x0,-0x5(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
lea    0xeae(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1050 <ReadDouble@plt>
movsd  %xmm0,-0x10(%rbp)
movsbl -0x5(%rbp),%eax
cmp    $0xa,%eax
je     118f <main+0x5f>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x5(%rbp)
jmp    1173 <main+0x43>
movb   $0x0,-0x5(%rbp)
movsd  -0x10(%rbp),%xmm0
lea    0xe8e(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    1159 <main+0x29>

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xec1(%rip),%rdi
call   1030 <puts@plt>
lea    0xea9(%rip),%r14
lea    0xea7(%rip),%rbx
xchg   %ax,%ax
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1060 <ReadDouble@plt>
movsd  %xmm0,(%rsp)
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0xa,%al
jne    1180 <main+0x40>
mov    %rbx,%rdi
movsd  (%rsp),%xmm0
mov    $0x1,%al
call   1040 <printf@plt>
jmp    1160 <main+0x20>

LLVM IR (-O0):
@.str = [40 x i8] c"Please enter a floating-point number: \0A\00"
@.str.1 = [5 x i8] c">>> \00"
@.str.2 = [7 x i8] c"%.14g\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca double
store i32 0, i32* %1
store i8 0, i8* %2
store double 0.000000e+00, double* %3
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
br label %5
5: ; preds = %0, %14
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%7 = call double (...) @ReadDouble()
store double %7, double* %3
br label %8
8: ; preds = %12, %5
%9 = load i8, i8* %2
%10 = sext i8 %9 to i32
%11 = icmp ne i32 %10, 10
br i1 %11, label %12, label %14
12: ; preds = %8
%13 = call signext i8 (...) @getchar()
store i8 %13, i8* %2
br label %8
14: ; preds = %8
store i8 0, i8* %2
%15 = load double, double* %3
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), double %15)
br label %5
}

LLVM IR (-O2):
@.str.1 = [5 x i8] c">>> \00"
@.str.2 = [7 x i8] c"%.14g\0A\00"
@str = [39 x i8] c"Please enter a floating-point number: \00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str, i64 0, i64 0))
br label %2
2: ; preds = %8, %0
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%4 = tail call double (...) @ReadDouble()
br label %5
5: ; preds = %2, %5
%6 = tail call signext i8 (...) @getchar()
%7 = icmp eq i8 %6, 10
br i1 %7, label %8, label %5
8: ; preds = %5
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), double %4)
br label %2
}