#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 */
struct htrace_log {
  int dummy;
};
struct htrace_conf {
  int dummy;
};

/* Variables and functions */
double htrace_conf_get_double(struct htrace_log *, struct htrace_conf const *,
                              char *);
int /*<<< orphan*/ htrace_log(struct htrace_log *, char *);
double get_prob_sampler_threshold(struct htrace_log *lg,
                                  const struct htrace_conf *conf) {
  double fraction = htrace_conf_get_double(lg, conf, "prob.sampler.fraction");
  if (fraction < 0) {
    htrace_log(lg, "sampler_create: can't have a sampling fraction "
                   "less than 0.  Setting fraction to 0.\n");
    fraction = 0.0;
  } else if (fraction > 1.0) {
    htrace_log(lg, "sampler_create: can't have a sampling fraction "
                   "greater than 1.  Setting fraction to 1.\n");
    fraction = 1.0;
  }
  return fraction;
}


x86 assembly (clang, -O0):
<get_prob_sampler_threshold>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
lea    0xec9(%rip),%rdx
call   1030 <htrace_conf_get_double@plt>
movsd  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    1174 <get_prob_sampler_threshold+0x54>
mov    -0x8(%rbp),%rdi
lea    0xebc(%rip),%rsi
call   1040 <htrace_log@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    11ad <get_prob_sampler_threshold+0x8d>
movsd  -0x18(%rbp),%xmm0
movsd  0xe7f(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11a8 <get_prob_sampler_threshold+0x88>
mov    -0x8(%rbp),%rdi
lea    0xedd(%rip),%rsi
call   1040 <htrace_log@plt>
movsd  0xe5d(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    11ad <get_prob_sampler_threshold+0x8d>
movsd  -0x18(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_prob_sampler_threshold>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
lea    0xed9(%rip),%rdx
call   1030 <htrace_conf_get_double@plt>
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
jbe    1151 <get_prob_sampler_threshold+0x31>
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x8(%rsp)
lea    0xecf(%rip),%rsi
jmp    116c <get_prob_sampler_threshold+0x4c>
movsd  0xea7(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    117a <get_prob_sampler_threshold+0x5a>
movsd  %xmm1,0x8(%rsp)
lea    0xf07(%rip),%rsi
mov    %rbx,%rdi
call   1040 <htrace_log@plt>
movsd  0x8(%rsp),%xmm0
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.htrace_log = type { i32 }
%struct.htrace_conf = type { i32 }
@.str = [22 x i8] c"prob.sampler.fraction\00"
@.str.1 = [85 x i8] c"sampler_create: can't have a sampling fraction less than 0. Setting fraction to 0.\0A\00"
@.str.2 = [88 x i8] c"sampler_create: can't have a sampling fraction greater than 1. Setting fraction to 1.\0A\00"
define double @get_prob_sampler_threshold(%struct.htrace_log* %0, %struct.htrace_conf* %1) {
%3 = alloca %struct.htrace_log*
%4 = alloca %struct.htrace_conf*
%5 = alloca double
store %struct.htrace_log* %0, %struct.htrace_log** %3
store %struct.htrace_conf* %1, %struct.htrace_conf** %4
%6 = load %struct.htrace_log*, %struct.htrace_log** %3
%7 = load %struct.htrace_conf*, %struct.htrace_conf** %4
%8 = call double @htrace_conf_get_double(%struct.htrace_log* %6, %struct.htrace_conf* %7, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
store double %8, double* %5
%9 = load double, double* %5
%10 = fcmp olt double %9, 0.000000e+00
br i1 %10, label %11, label %14
11: ; preds = %2
%12 = load %struct.htrace_log*, %struct.htrace_log** %3
%13 = call i32 @htrace_log(%struct.htrace_log* %12, i8* getelementptr inbounds ([85 x i8], [85 x i8]* @.str.1, i64 0, i64 0))
store double 0.000000e+00, double* %5
br label %21
14: ; preds = %2
%15 = load double, double* %5
%16 = fcmp ogt double %15, 1.000000e+00
br i1 %16, label %17, label %20
17: ; preds = %14
%18 = load %struct.htrace_log*, %struct.htrace_log** %3
%19 = call i32 @htrace_log(%struct.htrace_log* %18, i8* getelementptr inbounds ([88 x i8], [88 x i8]* @.str.2, i64 0, i64 0))
store double 1.000000e+00, double* %5
br label %20
20: ; preds = %17, %14
br label %21
21: ; preds = %20, %11
%22 = load double, double* %5
ret double %22
}

LLVM IR (-O2):
%struct.htrace_log = type { i32 }
%struct.htrace_conf = type { i32 }
@.str = [22 x i8] c"prob.sampler.fraction\00"
@.str.1 = [85 x i8] c"sampler_create: can't have a sampling fraction less than 0. Setting fraction to 0.\0A\00"
@.str.2 = [88 x i8] c"sampler_create: can't have a sampling fraction greater than 1. Setting fraction to 1.\0A\00"
define double @get_prob_sampler_threshold(%struct.htrace_log* %0, %struct.htrace_conf* %1) {
%3 = tail call double @htrace_conf_get_double(%struct.htrace_log* %0, %struct.htrace_conf* %1, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%4 = fcmp olt double %3, 0.000000e+00
br i1 %4, label %7, label %5
5: ; preds = %2
%6 = fcmp ogt double %3, 1.000000e+00
br i1 %6, label %7, label %11
7: ; preds = %5, %2
%8 = phi i8* [ getelementptr inbounds ([85 x i8], [85 x i8]* @.str.1, i64 0, i64 0), %2 ], [ getelementptr inbounds ([88 x i8], [88 x i8]* @.str.2, i64 0, i64 0), %5 ]
%9 = phi double [ 0.000000e+00, %2 ], [ 1.000000e+00, %5 ]
%10 = tail call i32 @htrace_log(%struct.htrace_log* %0, i8* %8)
br label %11
11: ; preds = %7, %5
%12 = phi double [ %3, %5 ], [ %9, %7 ]
ret double %12
}