#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, size_t, int, int);
scalar_t__ isalnum(char);
scalar_t__ ispunct(char);
scalar_t__ isspace(char);
int /*<<< orphan*/ stderr;
int is_mostly_binary(size_t ct, char *buf) {
  int i, ok = 0, imb;
  if (ct < 100)
    return 0;
  for (i = 0; i < ct; i++)
    if (isalnum(buf[i]) || isspace(buf[i]) || ispunct(buf[i]))
      ok++;
  imb = (ok / (ct * 1.0)) < 0.8;
  if ((0 || 0))
    fprintf(stderr, "is_mostly_binary: %d %ld %f -> %d\n", ok, ct,
            ok / (ct * 1.0), imb);
  return imb;
}


x86 assembly (clang, -O0):
<is_mostly_binary>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x20(%rbp)
cmpq   $0x64,-0x10(%rbp)
jae    115e <is_mostly_binary+0x2e>
movl   $0x0,-0x4(%rbp)
jmp    1239 <is_mostly_binary+0x109>
movl   $0x0,-0x1c(%rbp)
movslq -0x1c(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    11e0 <is_mostly_binary+0xb0>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <isalnum@plt>
cmp    $0x0,%rax
jne    11c4 <is_mostly_binary+0x94>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1050 <isspace@plt>
cmp    $0x0,%rax
jne    11c4 <is_mostly_binary+0x94>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <ispunct@plt>
cmp    $0x0,%rax
je     11cd <is_mostly_binary+0x9d>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11d2 <is_mostly_binary+0xa2>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1165 <is_mostly_binary+0x35>
cvtsi2sdl -0x20(%rbp),%xmm1
movaps 0xe24(%rip),%xmm2
movq   -0x10(%rbp),%xmm0
punpckldq %xmm2,%xmm0
movapd 0xe23(%rip),%xmm2
subpd  %xmm2,%xmm0
movaps %xmm0,%xmm2
unpckhpd %xmm0,%xmm0
addsd  %xmm2,%xmm0
movsd  0xdf4(%rip),%xmm2
mulsd  %xmm2,%xmm0
divsd  %xmm0,%xmm1
movsd  0xddc(%rip),%xmm0
ucomisd %xmm1,%xmm0
seta   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_mostly_binary>:
xor    %eax,%eax
cmp    $0x64,%rdi
jb     11d0 <is_mostly_binary+0xa0>
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %rdi,%r14
xor    %ebx,%ebx
xor    %ebp,%ebp
nopl   (%rax)
movsbl (%r15,%rbx,1),%edi
call   1030 <isalnum@plt>
test   %rax,%rax
jne    1180 <is_mostly_binary+0x50>
movsbl (%r15,%rbx,1),%edi
call   1050 <isspace@plt>
test   %rax,%rax
jne    1180 <is_mostly_binary+0x50>
movsbl (%r15,%rbx,1),%edi
call   1040 <ispunct@plt>
test   %rax,%rax
je     1183 <is_mostly_binary+0x53>
nopl   (%rax)
add    $0x1,%ebp
add    $0x1,%rbx
cmp    %rbx,%r14
jne    1150 <is_mostly_binary+0x20>
cvtsi2sd %ebp,%xmm0
movq   %r14,%xmm1
punpckldq 0xe63(%rip),%xmm1
subpd  0xe6b(%rip),%xmm1
movapd %xmm1,%xmm2
unpckhpd %xmm1,%xmm2
addsd  %xmm1,%xmm2
divsd  %xmm2,%xmm0
movsd  0xe63(%rip),%xmm1
xor    %eax,%eax
ucomisd %xmm0,%xmm1
seta   %al
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
define i32 @is_mostly_binary(i64 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i64
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i64 %0, i64* %4
store i8* %1, i8** %5
store i32 0, i32* %7
%9 = load i64, i64* %4
%10 = icmp ult i64 %9, 100
br i1 %10, label %11, label %12
11: ; preds = %2
store i32 0, i32* %3
br label %59
12: ; preds = %2
store i32 0, i32* %6
br label %13
13: ; preds = %46, %12
%14 = load i32, i32* %6
%15 = sext i32 %14 to i64
%16 = load i64, i64* %4
%17 = icmp ult i64 %15, %16
br i1 %17, label %18, label %49
18: ; preds = %13
%19 = load i8*, i8** %5
%20 = load i32, i32* %6
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %19, i64 %21
%23 = load i8, i8* %22
%24 = call i64 @isalnum(i8 signext %23)
%25 = icmp ne i64 %24, 0
br i1 %25, label %42, label %26
26: ; preds = %18
%27 = load i8*, i8** %5
%28 = load i32, i32* %6
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %27, i64 %29
%31 = load i8, i8* %30
%32 = call i64 @isspace(i8 signext %31)
%33 = icmp ne i64 %32, 0
br i1 %33, label %42, label %34
34: ; preds = %26
%35 = load i8*, i8** %5
%36 = load i32, i32* %6
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8, i8* %35, i64 %37
%39 = load i8, i8* %38
%40 = call i64 @ispunct(i8 signext %39)
%41 = icmp ne i64 %40, 0
br i1 %41, label %42, label %45
42: ; preds = %34, %26, %18
%43 = load i32, i32* %7
%44 = add nsw i32 %43, 1
store i32 %44, i32* %7
br label %45
45: ; preds = %42, %34
br label %46
46: ; preds = %45
%47 = load i32, i32* %6
%48 = add nsw i32 %47, 1
store i32 %48, i32* %6
br label %13
49: ; preds = %13
%50 = load i32, i32* %7
%51 = sitofp i32 %50 to double
%52 = load i64, i64* %4
%53 = uitofp i64 %52 to double
%54 = fmul double %53, 1.000000e+00
%55 = fdiv double %51, %54
%56 = fcmp olt double %55, 8.000000e-01
%57 = zext i1 %56 to i32
store i32 %57, i32* %8
%58 = load i32, i32* %8
store i32 %58, i32* %3
br label %59
59: ; preds = %49, %11
%60 = load i32, i32* %3
ret i32 %60
}

LLVM IR (-O2):
@stderr = global i32 0
define i32 @is_mostly_binary(i64 %0, i8* nocapture %1) {
%3 = icmp ult i64 %0, 100
br i1 %3, label %31, label %4
4: ; preds = %2, %21
%5 = phi i64 [ %23, %21 ], [ 0, %2 ]
%6 = phi i32 [ %22, %21 ], [ 0, %2 ]
%7 = getelementptr inbounds i8, i8* %1, i64 %5
%8 = load i8, i8* %7
%9 = tail call i64 @isalnum(i8 signext %8)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %19
11: ; preds = %4
%12 = load i8, i8* %7
%13 = tail call i64 @isspace(i8 signext %12)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %19
15: ; preds = %11
%16 = load i8, i8* %7
%17 = tail call i64 @ispunct(i8 signext %16)
%18 = icmp eq i64 %17, 0
br i1 %18, label %21, label %19
19: ; preds = %15, %11, %4
%20 = add nsw i32 %6, 1
br label %21
21: ; preds = %15, %19
%22 = phi i32 [ %20, %19 ], [ %6, %15 ]
%23 = add nuw i64 %5, 1
%24 = icmp eq i64 %23, %0
br i1 %24, label %25, label %4
25: ; preds = %21
%26 = sitofp i32 %22 to double
%27 = uitofp i64 %0 to double
%28 = fdiv double %26, %27
%29 = fcmp olt double %28, 8.000000e-01
%30 = zext i1 %29 to i32
br label %31
31: ; preds = %2, %25
%32 = phi i32 [ %30, %25 ], [ 0, %2 ]
ret i32 %32
}