#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*/ exit(int);
int /*<<< orphan*/ printf(char *, ...);
int scanf(char *, double *);
int /*<<< orphan*/ skiptonl(int /*<<< orphan*/);
scalar_t__ testnl();
scalar_t__ testterm();
double getfltpar(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,%rax
je     119a <getfltpar+0x3a>
cmpq   $0x0,-0x8(%rbp)
je     119a <getfltpar+0x3a>
mov    -0x8(%rbp),%rsi
lea    0xe6d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe64(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1060 <scanf@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    11c1 <getfltpar+0x61>
mov    $0x1,%edi
call   1070 <exit@plt>
cmpl   $0x0,-0xc(%rbp)
jle    11e7 <getfltpar+0x87>
mov    $0x0,%al
call   1030 <testterm@plt>
cmp    $0x0,%rax
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
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    11af <getfltpar+0x3f>
nopl   0x0(%rax)
mov    %r13,%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   1050 <skiptonl@plt>
xor    %eax,%eax
call   1090 <testnl@plt>
test   %rbx,%rbx
je     11cd <getfltpar+0x5d>
test   %rax,%rax
je     11cd <getfltpar+0x5d>
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1070 <scanf@plt>
test   %eax,%eax
js     11fe <getfltpar+0x8e>
je     11a0 <getfltpar+0x30>
xor    %eax,%eax
call   1030 <testterm@plt>
test   %rax,%rax
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, %28
%6 = call i64 (...) @testnl()
%7 = icmp ne i64 %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 @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 %20
18: ; preds = %14
%19 = call i32 @exit(i32 1)
unreachable
20: ; preds = %14
%21 = load i32, i32* %3
%22 = icmp sgt i32 %21, 0
br i1 %22, label %23, label %28
23: ; preds = %20
%24 = call i64 (...) @testterm()
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %23
%27 = load double, double* %4
ret double %27
28: ; preds = %23, %20
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0))
%30 = call i32 @skiptonl(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 = %23, %1
%6 = call i64 (...) @testnl()
%7 = icmp ne i64 %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 @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 %16
14: ; preds = %11
%15 = call i32 @exit(i32 1)
unreachable
16: ; preds = %11
%17 = icmp eq i32 %12, 0
br i1 %17, label %23, label %18
18: ; preds = %16
%19 = call i64 (...) @testterm()
%20 = icmp eq i64 %19, 0
br i1 %20, label %23, label %21
21: ; preds = %18
%22 = load double, double* %2
ret double %22
23: ; preds = %18, %16
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str, i64 0, i64 0))
%25 = call i32 @skiptonl(i32 0)
br label %5
}