#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 random(int, int);
double getHumidity() {
  static double humidity = 50;
  humidity += random(-100, +100) / 10;
  if (humidity < 0)
    humidity = 0;
  else if (humidity > 100)
    humidity = 100;
  return humidity;
}


x86 assembly (clang, -O0):
<getHumidity>:
push   %rbp
mov    %rsp,%rbp
mov    $0xffffff9c,%edi
mov    $0x64,%esi
call   1030 <random@plt>
mov    $0xa,%ecx
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm0
addsd  0x2ef1(%rip),%xmm0
movsd  %xmm0,0x2ee9(%rip)
xorps  %xmm0,%xmm0
ucomisd 0x2ede(%rip),%xmm0
jbe    1160 <getHumidity+0x50>
xorps  %xmm0,%xmm0
movsd  %xmm0,0x2ecd(%rip)
jmp    118f <getHumidity+0x7f>
movsd  0x2ec0(%rip),%xmm0
movsd  0xe90(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    118a <getHumidity+0x7a>
movsd  0xe7e(%rip),%xmm0
movsd  %xmm0,0x2e9e(%rip)
jmp    118f <getHumidity+0x7f>
movsd  0x2e91(%rip),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<getHumidity>:
push   %rax
mov    $0xffffff9c,%edi
mov    $0x64,%esi
call   1030 <random@plt>
cltq
imul   $0x66666667,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
cvtsi2sd %eax,%xmm0
addsd  0x2ee6(%rip),%xmm0
movsd  %xmm0,0x2ede(%rip)
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
ja     1162 <getHumidity+0x52>
movsd  0xea4(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    116e <getHumidity+0x5e>
movsd  %xmm1,0x2ebe(%rip)
movapd %xmm1,%xmm0
pop    %rax
ret

LLVM IR (-O0):
@getHumidity.humidity = internal global double 5.000000e+01
define double @getHumidity() {
%1 = call i32 @random(i32 -100, i32 100)
%2 = sdiv i32 %1, 10
%3 = sitofp i32 %2 to double
%4 = load double, double* @getHumidity.humidity
%5 = fadd double %4, %3
store double %5, double* @getHumidity.humidity
%6 = load double, double* @getHumidity.humidity
%7 = fcmp olt double %6, 0.000000e+00
br i1 %7, label %8, label %9
8: ; preds = %0
store double 0.000000e+00, double* @getHumidity.humidity
br label %14
9: ; preds = %0
%10 = load double, double* @getHumidity.humidity
%11 = fcmp ogt double %10, 1.000000e+02
br i1 %11, label %12, label %13
12: ; preds = %9
store double 1.000000e+02, double* @getHumidity.humidity
br label %13
13: ; preds = %12, %9
br label %14
14: ; preds = %13, %8
%15 = load double, double* @getHumidity.humidity
ret double %15
}

LLVM IR (-O2):
@getHumidity.humidity = internal unnamed_addr global double 5.000000e+01
define double @getHumidity() {
%1 = tail call i32 @random(i32 -100, i32 100)
%2 = sdiv i32 %1, 10
%3 = sitofp i32 %2 to double
%4 = load double, double* @getHumidity.humidity
%5 = fadd double %4, %3
store double %5, double* @getHumidity.humidity
%6 = fcmp olt double %5, 0.000000e+00
br i1 %6, label %9, label %7
7: ; preds = %0
%8 = fcmp ogt double %5, 1.000000e+02
br i1 %8, label %9, label %11
9: ; preds = %7, %0
%10 = phi double [ 0.000000e+00, %0 ], [ 1.000000e+02, %7 ]
store double %10, double* @getHumidity.humidity
br label %11
11: ; preds = %9, %7
%12 = phi double [ %5, %7 ], [ %10, %9 ]
ret double %12
}