#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*/ printf(char *);
int /*<<< orphan*/ scanf(char *, float *);
float getDuration(void) {
  printf("Enter duration of flight to London from Seattle in hours: \n");
  float duration = 0.0;
  scanf("%f", &duration);
  while (duration <= 0) {
    printf("Please enter a valid duration.\n");
    scanf("%f", &duration);
  }
  return duration;
}


x86 assembly (clang, -O0):
<getDuration>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xed1(%rip),%rdi
call   1030 <printf@plt>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
lea    0xef9(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1040 <scanf@plt>
xorps  %xmm0,%xmm0
ucomiss -0x4(%rbp),%xmm0
jb     117a <getDuration+0x5a>
lea    0xedf(%rip),%rdi
call   1030 <printf@plt>
lea    0xed0(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1040 <scanf@plt>
jmp    114c <getDuration+0x2c>
movss  -0x4(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getDuration>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xed3(%rip),%rdi
call   1030 <puts@plt>
movl   $0x0,0xc(%rsp)
lea    0xebc(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
movss  0xc(%rsp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm0,%xmm1
jb     1191 <getDuration+0x71>
lea    0xedb(%rip),%r14
lea    0xe96(%rip),%r15
lea    0xc(%rsp),%rbx
nop
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
xorps  %xmm1,%xmm1
movss  0xc(%rsp),%xmm0
ucomiss %xmm0,%xmm1
jae    1170 <getDuration+0x50>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [60 x i8] c"Enter duration of flight to London from Seattle in hours: \0A\00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [32 x i8] c"Please enter a valid duration.\0A\00"
define float @getDuration() {
%1 = alloca float
%2 = call i32 @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str, i64 0, i64 0))
store float 0.000000e+00, float* %1
%3 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %1)
br label %4
4: ; preds = %7, %0
%5 = load float, float* %1
%6 = fcmp ole float %5, 0.000000e+00
br i1 %6, label %7, label %10
7: ; preds = %4
%8 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %1)
br label %4
10: ; preds = %4
%11 = load float, float* %1
ret float %11
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%f\00"
@str = [59 x i8] c"Enter duration of flight to London from Seattle in hours: \00"
@str.3 = [31 x i8] c"Please enter a valid duration.\00"
define float @getDuration() {
%1 = alloca float
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @str, i64 0, i64 0))
%3 = bitcast float* %1 to i8*
store float 0.000000e+00, float* %1
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %1)
%5 = load float, float* %1
%6 = fcmp ugt float %5, 0.000000e+00
br i1 %6, label %12, label %7
7: ; preds = %0, %7
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.3, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %1)
%10 = load float, float* %1
%11 = fcmp ugt float %10, 0.000000e+00
br i1 %11, label %12, label %7
12: ; preds = %7, %0
%13 = phi float [ %5, %0 ], [ %10, %7 ]
ret float %13
}