double getfltpar(s) const char *s;
{
  int i;
  double d;
  while (1) {
    if (testnl() && s)
      printf("%s: ", s);
    i = scanf("%lf", &d);
    if (i < 0)
      exit(1);
    if (i > 0 && testterm())
      return (d);
    printf("invalid input; please enter a double\n");
    skiptonl(0);
  }
}


x86 assembly (clang, -O0):
<getfltpar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x0,%al
call   1080 <testnl@plt>
cmp    $0x0,%eax
je     1199 <getfltpar+0x39>
cmpq   $0x0,-0x8(%rbp)
je     1199 <getfltpar+0x39>
mov    -0x8(%rbp),%rsi
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe65(%rip),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    11c2 <getfltpar+0x62>
mov    $0x1,%edi
call   1070 <exit@plt>
cmpl   $0x0,-0xc(%rbp)
jle    11e7 <getfltpar+0x87>
mov    $0x0,%al
call   1030 <testterm@plt>
cmp    $0x0,%eax
je     11e7 <getfltpar+0x87>
movsd  -0x18(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret
lea    0xe1b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %edi,%edi
mov    $0x0,%al
call   1040 <skiptonl@plt>
jmp    116c <getfltpar+0xc>

x86 assembly (clang, -O2):
<getfltpar>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
lea    0xe79(%rip),%r14
lea    0xe77(%rip),%r15
lea    0x8(%rsp),%r12
lea    0xe6f(%rip),%r13
jmp    11b1 <getfltpar+0x41>
nopl   0x0(%rax)
mov    %r13,%rdi
call   1040 <puts@plt>
xor    %edi,%edi
xor    %eax,%eax
call   1050 <skiptonl@plt>
xor    %eax,%eax
call   1090 <testnl@plt>
test   %rbx,%rbx
je     11ce <getfltpar+0x5e>
test   %eax,%eax
je     11ce <getfltpar+0x5e>
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
test   %eax,%eax
js     1200 <getfltpar+0x90>
je     11a0 <getfltpar+0x30>
xor    %eax,%eax
call   1030 <testterm@plt>
test   %eax,%eax
je     11a0 <getfltpar+0x30>
movsd  0x8(%rsp),%xmm0
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"%s: \00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [38 x i8] c"invalid input; please enter a double\0A\00"
define double @getfltpar(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca double
store i8* %0, i8** %2
br label %5
5: ; preds = %1, %27
%6 = call i32 (...) @testnl()
%7 = icmp ne i32 %6, 0
br i1 %7, label %8, label %14
8: ; preds = %5
%9 = load i8*, i8** %2
%10 = icmp ne i8* %9, null
br i1 %10, label %11, label %14
11: ; preds = %8
%12 = load i8*, i8** %2
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %12)
br label %14
14: ; preds = %11, %8, %5
%15 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %4)
store i32 %15, i32* %3
%16 = load i32, i32* %3
%17 = icmp slt i32 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %14
unreachable
19: ; preds = %14
%20 = load i32, i32* %3
%21 = icmp sgt i32 %20, 0
br i1 %21, label %22, label %27
22: ; preds = %19
%23 = call i32 (...) @testterm()
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %22
%26 = load double, double* %4
ret double %26
27: ; preds = %22, %19
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0))
%29 = call i32 (i32, ...) bitcast (i32 (...)* @skiptonl to i32 (i32, ...)*)(i32 0)
br label %5
}

LLVM IR (-O2):
@.str = [5 x i8] c"%s: \00"
@.str.1 = [4 x i8] c"%lf\00"
@str = [37 x i8] c"invalid input; please enter a double\00"
define double @getfltpar(i8* %0) {
%2 = alloca double
%3 = bitcast double* %2 to i8*
%4 = icmp ne i8* %0, null
br label %5
5: ; preds = %22, %1
%6 = call i32 (...) @testnl()
%7 = icmp ne i32 %6, 0
%8 = and i1 %4, %7
br i1 %8, label %9, label %11
9: ; preds = %5
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %11
11: ; preds = %9, %5
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %2)
%13 = icmp slt i32 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %11
unreachable
15: ; preds = %11
%16 = icmp eq i32 %12, 0
br i1 %16, label %22, label %17
17: ; preds = %15
%18 = call i32 (...) @testterm()
%19 = icmp eq i32 %18, 0
br i1 %19, label %22, label %20
20: ; preds = %17
%21 = load double, double* %2
ret double %21
22: ; preds = %17, %15
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str, i64 0, i64 0))
%24 = call i32 (i32, ...) bitcast (i32 (...)* @skiptonl to i32 (i32, ...)*)(i32 0)
br label %5
}