#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 /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int logdual(long double);
int /*<<< orphan*/ printnumber(long double);
long prob(int, int);
int /*<<< orphan*/ stderr;
void eval(int right) {
  static int count = 0;
  static int okay = 0;
  long double val;
  count++;
  okay += right;
  val = 1.L / prob(okay, count);
  fprintf(stderr, "   %s %5u/%-5u ", right ? "OK" : "- ", okay, count);
  printnumber(val);
  if (count > 1)
    fprintf(stderr, "   %4.2f bit",
            0.01 * (int)(logdual(val) / (count - 1) * 100.));
  fprintf(stderr, "\n");
}


x86 assembly (clang, -O0):
<eval>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    0x2ef3(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2eea(%rip)
mov    -0x4(%rbp),%ecx
mov    0x2ee5(%rip),%eax
add    %ecx,%eax
mov    %eax,0x2edd(%rip)
mov    0x2ed7(%rip),%edi
mov    0x2ecd(%rip),%esi
call   1060 <prob@plt>
mov    %rax,-0x28(%rbp)
fildll -0x28(%rbp)
fld1
fdivp  %st,%st(1)
fstpt  -0x20(%rbp)
mov    0x2e4f(%rip),%rax
mov    (%rax),%edi
mov    -0x4(%rbp),%eax
test   %eax,%eax
lea    0xe81(%rip),%rax
lea    0xe7d(%rip),%rdx
cmovne %rax,%rdx
mov    0x2e98(%rip),%ecx
mov    0x2e8d(%rip),%r8d
lea    0xe52(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
fldt   -0x20(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
call   1040 <printnumber@plt>
cmpl   $0x1,0x2e6b(%rip)
jle    1239 <eval+0xf9>
mov    0x2dfa(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
fldt   -0x20(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
call   1030 <logdual@plt>
mov    -0x2c(%rbp),%edi
mov    0x2e43(%rip),%ecx
sub    $0x1,%ecx
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm0
movsd  0xdf5(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
cvtsi2sd %eax,%xmm1
movsd  0xdd9(%rip),%xmm0
mulsd  %xmm1,%xmm0
lea    0xdf4(%rip),%rsi
mov    $0x1,%al
call   1050 <fprintf@plt>
mov    0x2da0(%rip),%rax
mov    (%rax),%edi
lea    0xdea(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<eval>:
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %edi,%ebx
mov    0x2ef5(%rip),%esi
add    $0x1,%esi
mov    %esi,0x2eec(%rip)
mov    0x2eea(%rip),%edi
add    %ebx,%edi
mov    %edi,0x2ee2(%rip)
call   1060 <prob@plt>
mov    %rax,0x20(%rsp)
fildll 0x20(%rsp)
fld1
fdivp  %st,%st(1)
fstpt  0x14(%rsp)
mov    0x2e5d(%rip),%r14
mov    (%r14),%edi
test   %ebx,%ebx
lea    0xe8c(%rip),%rax
lea    0xe82(%rip),%rdx
cmove  %rax,%rdx
mov    0x2ea8(%rip),%ecx
mov    0x2e9d(%rip),%r8d
lea    0xe5a(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
fldt   0x14(%rsp)
fstpt  (%rsp)
call   1040 <printnumber@plt>
cmpl   $0x2,0x2e7c(%rip)
jl     1204 <eval+0xc4>
mov    (%r14),%ebx
fldt   0x14(%rsp)
fstpt  (%rsp)
call   1030 <logdual@plt>
mov    0x2e65(%rip),%ecx
add    $0xffffffff,%ecx
cltd
idiv   %ecx
imul   $0x64,%eax,%eax
cvtsi2sd %eax,%xmm0
mulsd  0xe0c(%rip),%xmm0
lea    0xe23(%rip),%rsi
mov    %ebx,%edi
mov    $0x1,%al
call   1050 <fprintf@plt>
mov    (%r14),%edi
lea    0xe1d(%rip),%rsi
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
jmp    1050 <fprintf@plt>

LLVM IR (-O0):
@eval.count = internal global i32 0
@eval.okay = internal global i32 0
@stderr = global i32 0
@.str = [16 x i8] c" %s %5u/%-5u \00"
@.str.1 = [3 x i8] c"OK\00"
@.str.2 = [3 x i8] c"- \00"
@.str.3 = [13 x i8] c" %4.2f bit\00"
@.str.4 = [2 x i8] c"\0A\00"
define void @eval(i32 %0) {
%2 = alloca i32
%3 = alloca x86_fp80
store i32 %0, i32* %2
%4 = load i32, i32* @eval.count
%5 = add nsw i32 %4, 1
store i32 %5, i32* @eval.count
%6 = load i32, i32* %2
%7 = load i32, i32* @eval.okay
%8 = add nsw i32 %7, %6
store i32 %8, i32* @eval.okay
%9 = load i32, i32* @eval.okay
%10 = load i32, i32* @eval.count
%11 = call i64 @prob(i32 %9, i32 %10)
%12 = sitofp i64 %11 to x86_fp80
%13 = fdiv x86_fp80 0xK3FFF8000000000000000, %12
store x86_fp80 %13, x86_fp80* %3
%14 = load i32, i32* @stderr
%15 = load i32, i32* %2
%16 = icmp ne i32 %15, 0
%17 = zext i1 %16 to i64
%18 = select i1 %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0)
%19 = load i32, i32* @eval.okay
%20 = load i32, i32* @eval.count
%21 = call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %18, i32 %19, i32 %20)
%22 = load x86_fp80, x86_fp80* %3
%23 = call i32 @printnumber(x86_fp80 %22)
%24 = load i32, i32* @eval.count
%25 = icmp sgt i32 %24, 1
br i1 %25, label %26, label %39
26: ; preds = %1
%27 = load i32, i32* @stderr
%28 = load x86_fp80, x86_fp80* %3
%29 = call i32 @logdual(x86_fp80 %28)
%30 = load i32, i32* @eval.count
%31 = sub nsw i32 %30, 1
%32 = sdiv i32 %29, %31
%33 = sitofp i32 %32 to double
%34 = fmul double %33, 1.000000e+02
%35 = fptosi double %34 to i32
%36 = sitofp i32 %35 to double
%37 = fmul double 1.000000e-02, %36
%38 = call i32 (i32, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), double %37)
br label %39
39: ; preds = %26, %1
%40 = load i32, i32* @stderr
%41 = call i32 (i32, i8*, ...) @fprintf(i32 %40, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@eval.count = internal unnamed_addr global i32 0
@eval.okay = internal unnamed_addr global i32 0
@stderr = global i32 0
@.str = [16 x i8] c" %s %5u/%-5u \00"
@.str.1 = [3 x i8] c"OK\00"
@.str.2 = [3 x i8] c"- \00"
@.str.3 = [13 x i8] c" %4.2f bit\00"
@.str.4 = [2 x i8] c"\0A\00"
define void @eval(i32 %0) {
%2 = load i32, i32* @eval.count
%3 = add nsw i32 %2, 1
store i32 %3, i32* @eval.count
%4 = load i32, i32* @eval.okay
%5 = add nsw i32 %4, %0
store i32 %5, i32* @eval.okay
%6 = tail call i64 @prob(i32 %5, i32 %3)
%7 = sitofp i64 %6 to x86_fp80
%8 = fdiv x86_fp80 0xK3FFF8000000000000000, %7
%9 = load i32, i32* @stderr
%10 = icmp eq i32 %0, 0
%11 = select i1 %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0)
%12 = load i32, i32* @eval.okay
%13 = load i32, i32* @eval.count
%14 = tail call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %11, i32 %12, i32 %13)
%15 = tail call i32 @printnumber(x86_fp80 %8)
%16 = load i32, i32* @eval.count
%17 = icmp sgt i32 %16, 1
br i1 %17, label %18, label %28
18: ; preds = %1
%19 = load i32, i32* @stderr
%20 = tail call i32 @logdual(x86_fp80 %8)
%21 = load i32, i32* @eval.count
%22 = add nsw i32 %21, -1
%23 = sdiv i32 %20, %22
%24 = mul i32 %23, 100
%25 = sitofp i32 %24 to double
%26 = fmul double %25, 1.000000e-02
%27 = tail call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), double %26)
br label %28
28: ; preds = %18, %1
%29 = load i32, i32* @stderr
%30 = tail call i32 (i32, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
ret void
}