#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 */
float RAND_MAX;
scalar_t__ rand();
int check_for_noise(int state, float hr, float Pn) {
  float rand_no;
  int rtn = 0;
  float Pa0 = 0.0004;
  float Pa1 = 0.0048;
  Pa1 = Pn;
  Pa0 = Pn / 12;
  if (Pn == 0)
    return (0);
  rand_no = ((float)rand() / RAND_MAX);
  if (state == 0.0) {
    if ((rand_no * 60 / hr) < Pa0)
      rtn = 1;
    else
      rtn = 0;
  }
  if (state != 0.0) {
    if ((rand_no * 60 / hr) < Pa1)
      rtn = 1;
    else
      rtn = 0;
  }
  return (rtn);
}


x86 assembly (clang, -O0):
<check_for_noise>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
movss  %xmm0,-0xc(%rbp)
movss  %xmm1,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
movss  0xed4(%rip),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  0xec3(%rip),%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x10(%rbp),%xmm0
movss  0xea3(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    1189 <check_for_noise+0x79>
jp     1189 <check_for_noise+0x79>
movl   $0x0,-0x4(%rbp)
jmp    1250 <check_for_noise+0x140>
mov    $0x0,%al
call   1030 <rand@plt>
cvtsi2ss %rax,%xmm0
mov    0x2e4c(%rip),%rax
divss  (%rax),%xmm0
movss  %xmm0,-0x14(%rbp)
cvtsi2sdl -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11f5 <check_for_noise+0xe5>
jp     11f5 <check_for_noise+0xe5>
movss  0xe47(%rip),%xmm1
mulss  -0x14(%rbp),%xmm1
divss  -0xc(%rbp),%xmm1
movss  -0x1c(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    11e9 <check_for_noise+0xd9>
movl   $0x1,-0x18(%rbp)
jmp    11f0 <check_for_noise+0xe0>
movl   $0x0,-0x18(%rbp)
jmp    11f5 <check_for_noise+0xe5>
cvtsi2sdl -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1212 <check_for_noise+0x102>
jp     1212 <check_for_noise+0x102>
jmp    124a <check_for_noise+0x13a>
movss  0xdf2(%rip),%xmm1
mulss  -0x14(%rbp),%xmm1
divss  -0xc(%rbp),%xmm1
movss  -0x20(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    123e <check_for_noise+0x12e>
movl   $0x1,-0x18(%rbp)
jmp    1245 <check_for_noise+0x135>
movl   $0x0,-0x18(%rbp)
jmp    124a <check_for_noise+0x13a>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_for_noise>:
push   %rbx
sub    $0x10,%rsp
xorps  %xmm2,%xmm2
ucomiss %xmm2,%xmm1
jne    1123 <check_for_noise+0x13>
jp     1123 <check_for_noise+0x13>
xor    %eax,%eax
jmp    1179 <check_for_noise+0x69>
mov    %edi,%ebx
movss  %xmm1,0x8(%rsp)
xor    %eax,%eax
movss  %xmm0,0xc(%rsp)
call   1030 <rand@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
mov    0x2ea1(%rip),%rax
divss  (%rax),%xmm0
mulss  0xeb1(%rip),%xmm0
divss  0xc(%rsp),%xmm0
test   %ebx,%ebx
je     1165 <check_for_noise+0x55>
movss  0x8(%rsp),%xmm1
jmp    1173 <check_for_noise+0x63>
movss  0x8(%rsp),%xmm1
divss  0xe8d(%rip),%xmm1
ucomiss %xmm0,%xmm1
seta   %al
movzbl %al,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@RAND_MAX = global float 0.000000e+00
define i32 @check_for_noise(i32 %0, float %1, float %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca float
%7 = alloca float
%8 = alloca float
%9 = alloca i32
%10 = alloca float
%11 = alloca float
store i32 %0, i32* %5
store float %1, float* %6
store float %2, float* %7
store i32 0, i32* %9
store float 0x3F3A36E2E0000000, float* %10
store float 0x3F73A92A40000000, float* %11
%12 = load float, float* %7
store float %12, float* %11
%13 = load float, float* %7
%14 = fdiv float %13, 1.200000e+01
store float %14, float* %10
%15 = load float, float* %7
%16 = fcmp oeq float %15, 0.000000e+00
br i1 %16, label %17, label %18
17: ; preds = %3
store i32 0, i32* %4
br label %52
18: ; preds = %3
%19 = call i64 (...) @rand()
%20 = sitofp i64 %19 to float
%21 = load float, float* @RAND_MAX
%22 = fdiv float %20, %21
store float %22, float* %8
%23 = load i32, i32* %5
%24 = sitofp i32 %23 to double
%25 = fcmp oeq double %24, 0.000000e+00
br i1 %25, label %26, label %36
26: ; preds = %18
%27 = load float, float* %8
%28 = fmul float %27, 6.000000e+01
%29 = load float, float* %6
%30 = fdiv float %28, %29
%31 = load float, float* %10
%32 = fcmp olt float %30, %31
br i1 %32, label %33, label %34
33: ; preds = %26
store i32 1, i32* %9
br label %35
34: ; preds = %26
store i32 0, i32* %9
br label %35
35: ; preds = %34, %33
br label %36
36: ; preds = %35, %18
%37 = load i32, i32* %5
%38 = sitofp i32 %37 to double
%39 = fcmp une double %38, 0.000000e+00
br i1 %39, label %40, label %50
40: ; preds = %36
%41 = load float, float* %8
%42 = fmul float %41, 6.000000e+01
%43 = load float, float* %6
%44 = fdiv float %42, %43
%45 = load float, float* %11
%46 = fcmp olt float %44, %45
br i1 %46, label %47, label %48
47: ; preds = %40
store i32 1, i32* %9
br label %49
48: ; preds = %40
store i32 0, i32* %9
br label %49
49: ; preds = %48, %47
br label %50
50: ; preds = %49, %36
%51 = load i32, i32* %9
store i32 %51, i32* %4
br label %52
52: ; preds = %50, %17
%53 = load i32, i32* %4
ret i32 %53
}

LLVM IR (-O2):
@RAND_MAX = global float 0.000000e+00
define i32 @check_for_noise(i32 %0, float %1, float %2) {
%4 = fdiv float %2, 1.200000e+01
%5 = fcmp oeq float %2, 0.000000e+00
br i1 %5, label %18, label %6
6: ; preds = %3
%7 = tail call i64 (...) @rand()
%8 = sitofp i64 %7 to float
%9 = load float, float* @RAND_MAX
%10 = fdiv float %8, %9
%11 = icmp eq i32 %0, 0
%12 = fmul float %10, 6.000000e+01
%13 = fdiv float %12, %1
br i1 %11, label %14, label %16
14: ; preds = %6
%15 = fcmp olt float %13, %4
br label %18
16: ; preds = %6
%17 = fcmp olt float %13, %2
br label %18
18: ; preds = %14, %16, %3
%19 = phi i1 [ false, %3 ], [ %17, %16 ], [ %15, %14 ]
%20 = zext i1 %19 to i32
ret i32 %20
}