#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 EXIT_FAILURE;
int EXIT_SUCCESS;
unsigned int count_bytes(unsigned int *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
double log(double);
int /*<<< orphan*/ memset(unsigned int *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  if (argc != 1) {
    fprintf(stderr, "%s: no arguments accepted, read from stdin\n", argv[0]);
    return EXIT_FAILURE;
  }
  unsigned int byte_cnts[256];
  memset(byte_cnts, 0, 256 * sizeof(unsigned int));
  unsigned int in_size = count_bytes(byte_cnts);
  double ent = 0;
  for (int i = 0; i < 256; ++i) {
    if (byte_cnts[i]) {
      double prob = (double)byte_cnts[i] / in_size;
      ent -= prob * log(prob) / 0.69314718055994530942;
    }
  }
  printf("%f\n", 100. - 100. * (ent / 8));
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x440,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
je     11a0 <main+0x50>
mov    0x2e66(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe96(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2e42(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12d3 <main+0x183>
lea    -0x410(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1050 <memset@plt>
lea    -0x410(%rbp),%rdi
call   1030 <count_bytes@plt>
mov    %eax,-0x414(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x420(%rbp)
ff
movl   $0x0,-0x424(%rbp)
cmpl   $0x100,-0x424(%rbp)
jge    128b <main+0x13b>
movslq -0x424(%rbp),%rax
cmpl   $0x0,-0x410(%rbp,%rax,4)
je     1272 <main+0x122>
movslq -0x424(%rbp),%rax
mov    -0x410(%rbp,%rax,4),%eax
cvtsi2sd %rax,%xmm0
mov    -0x414(%rbp),%eax
cvtsi2sd %rax,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x430(%rbp)
ff
movsd  -0x430(%rbp),%xmm0
ff
movsd  %xmm0,-0x438(%rbp)
ff
movsd  -0x430(%rbp),%xmm0
ff
call   1070 <log@plt>
movsd  -0x438(%rbp),%xmm1
ff
mulsd  %xmm0,%xmm1
movsd  0xdbe(%rip),%xmm0
divsd  %xmm0,%xmm1
movsd  -0x420(%rbp),%xmm0
ff
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x420(%rbp)
ff
jmp    1277 <main+0x127>
mov    -0x424(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x424(%rbp)
jmp    11da <main+0x8a>
movsd  -0x420(%rbp),%xmm0
ff
movsd  0xd75(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xd59(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xd55(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%esi
lea    0xd8a(%rip),%rdi
call   1040 <printf@plt>
mov    0x2d02(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x440,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x428,%rsp
cmp    $0x1,%edi
jne    11fc <main+0xac>
lea    0x20(%rsp),%r14
xor    %ebx,%ebx
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1050 <memset@plt>
mov    %r14,%rdi
call   1030 <count_bytes@plt>
mov    %eax,%eax
cvtsi2sd %rax,%xmm0
movsd  %xmm0,0x10(%rsp)
xorpd  %xmm1,%xmm1
jmp    11ad <main+0x5d>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%rbx
cmp    $0x100,%rbx
je     121d <main+0xcd>
mov    0x20(%rsp,%rbx,4),%eax
test   %eax,%eax
je     11a0 <main+0x50>
mov    %eax,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
divsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x18(%rsp)
movsd  %xmm1,0x8(%rsp)
call   1070 <log@plt>
mulsd  0x18(%rsp),%xmm0
divsd  0xe1c(%rip),%xmm0
movsd  0x8(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  0x8(%rsp),%xmm1
jmp    11a0 <main+0x50>
mov    0x2ddd(%rip),%rax
mov    (%rax),%edi
mov    (%rsi),%rdx
lea    0xe11(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2dbd(%rip),%rax
jmp    124c <main+0xfc>
mulsd  0xde3(%rip),%xmm1
mulsd  0xde3(%rip),%xmm1
addsd  0xde3(%rip),%xmm1
cvttsd2si %xmm1,%esi
lea    0xe0c(%rip),%rdi
call   1040 <printf@plt>
mov    0x2d84(%rip),%rax
mov    (%rax),%eax
add    $0x428,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [44 x i8] c"%s: no arguments accepted, read from stdin\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [4 x i8] c"%f\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [256 x i32]
%7 = alloca i32
%8 = alloca double
%9 = alloca i32
%10 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = icmp ne i32 %11, 1
br i1 %12, label %13, label %20
13: ; preds = %2
%14 = load i32, i32* @stderr
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 0
%17 = load i8*, i8** %16
%18 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i8* %17)
%19 = load i32, i32* @EXIT_FAILURE
store i32 %19, i32* %3
br label %61
20: ; preds = %2
%21 = getelementptr inbounds [256 x i32], [256 x i32]* %6, i64 0, i64 0
%22 = call i32 @memset(i32* %21, i32 0, i32 1024)
%23 = getelementptr inbounds [256 x i32], [256 x i32]* %6, i64 0, i64 0
%24 = call i32 @count_bytes(i32* %23)
store i32 %24, i32* %7
store double 0.000000e+00, double* %8
store i32 0, i32* %9
br label %25
25: ; preds = %51, %20
%26 = load i32, i32* %9
%27 = icmp slt i32 %26, 256
br i1 %27, label %28, label %54
28: ; preds = %25
%29 = load i32, i32* %9
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [256 x i32], [256 x i32]* %6, i64 0, i64 %30
%32 = load i32, i32* %31
%33 = icmp ne i32 %32, 0
br i1 %33, label %34, label %50
34: ; preds = %28
%35 = load i32, i32* %9
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [256 x i32], [256 x i32]* %6, i64 0, i64 %36
%38 = load i32, i32* %37
%39 = uitofp i32 %38 to double
%40 = load i32, i32* %7
%41 = uitofp i32 %40 to double
%42 = fdiv double %39, %41
store double %42, double* %10
%43 = load double, double* %10
%44 = load double, double* %10
%45 = call double @log(double %44)
%46 = fmul double %43, %45
%47 = fdiv double %46, 0x3FE62E42FEFA39EF
%48 = load double, double* %8
%49 = fsub double %48, %47
store double %49, double* %8
br label %50
50: ; preds = %34, %28
br label %51
51: ; preds = %50
%52 = load i32, i32* %9
%53 = add nsw i32 %52, 1
store i32 %53, i32* %9
br label %25
54: ; preds = %25
%55 = load double, double* %8
%56 = fdiv double %55, 8.000000e+00
%57 = call double @llvm.fmuladd.f64(double -1.000000e+02, double %56, double 1.000000e+02)
%58 = fptosi double %57 to i32
%59 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %58)
%60 = load i32, i32* @EXIT_SUCCESS
store i32 %60, i32* %3
br label %61
61: ; preds = %54, %13
%62 = load i32, i32* %3
ret i32 %62
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [44 x i8] c"%s: no arguments accepted, read from stdin\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [4 x i8] c"%f\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [256 x i32]
%4 = icmp eq i32 %0, 1
br i1 %4, label %10, label %5
5: ; preds = %2
%6 = load i32, i32* @stderr
%7 = load i8*, i8** %1
%8 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i8* %7)
%9 = load i32, i32* @EXIT_FAILURE
br label %39
10: ; preds = %2
%11 = bitcast [256 x i32]* %3 to i8*
%12 = getelementptr inbounds [256 x i32], [256 x i32]* %3, i64 0, i64 0
%13 = call i32 @memset(i32* %12, i32 0, i32 1024)
%14 = call i32 @count_bytes(i32* %12)
%15 = uitofp i32 %14 to double
br label %22
16: ; preds = %35
%17 = fmul double %36, 1.250000e-01
%18 = call double @llvm.fmuladd.f64(double %17, double -1.000000e+02, double 1.000000e+02)
%19 = fptosi double %18 to i32
%20 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %19)
%21 = load i32, i32* @EXIT_SUCCESS
br label %39
22: ; preds = %10, %35
%23 = phi i64 [ 0, %10 ], [ %37, %35 ]
%24 = phi double [ 0.000000e+00, %10 ], [ %36, %35 ]
%25 = getelementptr inbounds [256 x i32], [256 x i32]* %3, i64 0, i64 %23
%26 = load i32, i32* %25
%27 = icmp eq i32 %26, 0
br i1 %27, label %35, label %28
28: ; preds = %22
%29 = uitofp i32 %26 to double
%30 = fdiv double %29, %15
%31 = call double @log(double %30)
%32 = fmul double %30, %31
%33 = fdiv double %32, 0x3FE62E42FEFA39EF
%34 = fsub double %24, %33
br label %35
35: ; preds = %22, %28
%36 = phi double [ %34, %28 ], [ %24, %22 ]
%37 = add nuw nsw i64 %23, 1
%38 = icmp eq i64 %37, 256
br i1 %38, label %16, label %22
39: ; preds = %16, %5
%40 = phi i32 [ %9, %5 ], [ %21, %16 ]
ret i32 %40
}