#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);
int getTemperature() {
  static double temp = 25;
  temp += random(-100, +100) / 20;
  if (temp < 0)
    temp = 0;
  else if (temp > 100)
    temp = 100;
  return temp;
}


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

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

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

LLVM IR (-O2):
@getTemperature.temp = internal unnamed_addr global double 2.500000e+01
define i32 @getTemperature() {
%1 = tail call i32 @random(i32 -100, i32 100)
%2 = sdiv i32 %1, 20
%3 = sitofp i32 %2 to double
%4 = load double, double* @getTemperature.temp
%5 = fadd double %4, %3
store double %5, double* @getTemperature.temp
%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* @getTemperature.temp
br label %11
11: ; preds = %9, %7
%12 = phi double [ %5, %7 ], [ %10, %9 ]
%13 = fptosi double %12 to i32
ret i32 %13
}