#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__ random();
int errorgen() {
  static int burst = 0;
  float burstber = 0.01 / 2 / 100;
  float prob = ((float)random() / (RAND_MAX));
  if (burst > 0) {
    burst--;
    return 1;
  } else if (prob <= burstber) {
    burst = 2 - 1;
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<errorgen>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movss  0xee0(%rip),%xmm0
movss  %xmm0,-0x8(%rbp)
mov    $0x0,%al
call   1030 <random@plt>
cvtsi2ss %rax,%xmm0
mov    0x2eb0(%rip),%rax
divss  (%rax),%xmm0
movss  %xmm0,-0xc(%rbp)
cmpl   $0x0,0x2ee4(%rip)
jle    1169 <errorgen+0x59>
mov    0x2ed8(%rip),%eax
add    $0xffffffff,%eax
mov    %eax,0x2ecf(%rip)
movl   $0x1,-0x4(%rbp)
jmp    119e <errorgen+0x8e>
movss  -0xc(%rbp),%xmm1
movss  -0x8(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jb     1192 <errorgen+0x82>
movl   $0x1,0x2ea6(%rip)
movl   $0x1,-0x4(%rbp)
jmp    119e <errorgen+0x8e>
jmp    1197 <errorgen+0x87>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<errorgen>:
push   %rbx
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <random@plt>
mov    0x2f0c(%rip),%cl
test   %cl,%cl
jne    1141 <errorgen+0x31>
cvtsi2ss %rax,%xmm0
mov    0x2eb8(%rip),%rax
divss  (%rax),%xmm0
movss  0xec4(%rip),%xmm1
ucomiss %xmm0,%xmm1
jb     114f <errorgen+0x3f>
xor    $0x1,%cl
mov    %cl,0x2ee2(%rip)
mov    $0x1,%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@errorgen.burst = internal global i32 0
@RAND_MAX = global float 0.000000e+00
define i32 @errorgen() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
store float 0x3F0A36E2E0000000, float* %2
%4 = call i64 (...) @random()
%5 = sitofp i64 %4 to float
%6 = load float, float* @RAND_MAX
%7 = fdiv float %5, %6
store float %7, float* %3
%8 = load i32, i32* @errorgen.burst
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %0
%11 = load i32, i32* @errorgen.burst
%12 = add nsw i32 %11, -1
store i32 %12, i32* @errorgen.burst
store i32 1, i32* %1
br label %20
13: ; preds = %0
%14 = load float, float* %3
%15 = load float, float* %2
%16 = fcmp ole float %14, %15
br i1 %16, label %17, label %18
17: ; preds = %13
store i32 1, i32* @errorgen.burst
store i32 1, i32* %1
br label %20
18: ; preds = %13
br label %19
19: ; preds = %18
store i32 0, i32* %1
br label %20
20: ; preds = %19, %17, %10
%21 = load i32, i32* %1
ret i32 %21
}

LLVM IR (-O2):
@errorgen.burst = internal unnamed_addr global i1 false
@RAND_MAX = global float 0.000000e+00
define i32 @errorgen() {
%1 = tail call i64 (...) @random()
%2 = load i1, i1* @errorgen.burst
br i1 %2, label %8, label %3
3: ; preds = %0
%4 = sitofp i64 %1 to float
%5 = load float, float* @RAND_MAX
%6 = fdiv float %4, %5
%7 = fcmp ugt float %6, 0x3F0A36E2E0000000
br i1 %7, label %10, label %8
8: ; preds = %3, %0
%9 = xor i1 %2, true
store i1 %9, i1* @errorgen.burst
br label %10
10: ; preds = %8, %3
%11 = phi i32 [ 0, %3 ], [ 1, %8 ]
ret i32 %11
}