#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 atof(char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ scanf(char *, char *);
double get_probability(char *desc) {
  double p = -1.0;
  char s[21];
  while (p < 0.0 || p > 100.0) {
    printf("Please enter probability for %s (in percent, float): ", desc);
    scanf("%20s", s);
    p = atof(s);
  }
  return p / 100.0;
}


x86 assembly (clang, -O0):
<get_probability>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
movsd  0xebc(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    $0x1,%al
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
mov    %al,-0x31(%rbp)
ja     1173 <get_probability+0x43>
movsd  -0x10(%rbp),%xmm0
movsd  0xe9f(%rip),%xmm1
ucomisd %xmm1,%xmm0
seta   %al
mov    %al,-0x31(%rbp)
mov    -0x31(%rbp),%al
test   $0x1,%al
jne    1183 <get_probability+0x53>
jmp    11b6 <get_probability+0x86>
mov    -0x8(%rbp),%rsi
lea    0xe82(%rip),%rdi
call   1040 <printf@plt>
lea    -0x30(%rbp),%rsi
lea    0xea8(%rip),%rdi
call   1050 <scanf@plt>
lea    -0x30(%rbp),%rdi
call   1030 <atof@plt>
movsd  %xmm0,-0x10(%rbp)
jmp    1149 <get_probability+0x19>
movsd  -0x10(%rbp),%xmm0
movsd  0xe45(%rip),%xmm1
divsd  %xmm1,%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_probability>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%r12
lea    0xecb(%rip),%r14
lea    0xefa(%rip),%r15
mov    %rsp,%rbx
nop
mov    %r14,%rdi
mov    %r12,%rsi
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
mov    %rbx,%rdi
call   1030 <atof@plt>
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
ja     1150 <get_probability+0x20>
ucomisd 0xe80(%rip),%xmm0
ja     1150 <get_probability+0x20>
divsd  0xe76(%rip),%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [54 x i8] c"Please enter probability for %s (in percent, float): \00"
@.str.1 = [5 x i8] c"%20s\00"
define double @get_probability(i8* %0) {
%2 = alloca i8*
%3 = alloca double
%4 = alloca [21 x i8]
store i8* %0, i8** %2
store double -1.000000e+00, double* %3
br label %5
5: ; preds = %13, %1
%6 = load double, double* %3
%7 = fcmp olt double %6, 0.000000e+00
br i1 %7, label %11, label %8
8: ; preds = %5
%9 = load double, double* %3
%10 = fcmp ogt double %9, 1.000000e+02
br label %11
11: ; preds = %8, %5
%12 = phi i1 [ true, %5 ], [ %10, %8 ]
br i1 %12, label %13, label %20
13: ; preds = %11
%14 = load i8*, i8** %2
%15 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0), i8* %14)
%16 = getelementptr inbounds [21 x i8], [21 x i8]* %4, i64 0, i64 0
%17 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %16)
%18 = getelementptr inbounds [21 x i8], [21 x i8]* %4, i64 0, i64 0
%19 = call double @atof(i8* %18)
store double %19, double* %3
br label %5
20: ; preds = %11
%21 = load double, double* %3
%22 = fdiv double %21, 1.000000e+02
ret double %22
}

LLVM IR (-O2):
@.str = [54 x i8] c"Please enter probability for %s (in percent, float): \00"
@.str.1 = [5 x i8] c"%20s\00"
define double @get_probability(i8* %0) {
%2 = alloca [21 x i8]
%3 = getelementptr inbounds [21 x i8], [21 x i8]* %2, i64 0, i64 0
br label %4
4: ; preds = %1, %4
%5 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0), i8* %0)
%6 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%7 = call double @atof(i8* %3)
%8 = fcmp olt double %7, 0.000000e+00
%9 = fcmp ogt double %7, 1.000000e+02
%10 = or i1 %8, %9
br i1 %10, label %4, label %11
11: ; preds = %4
%12 = fdiv double %7, 1.000000e+02
ret double %12
}