#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*/ EXIT_FAILURE;
int EXIT_SUCCESS;
double calc_ic(char *, size_t, unsigned long);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ preprocess(char *);
int /*<<< orphan*/ printf(char *, unsigned long, double);
int /*<<< orphan*/ putchar(char);
int /*<<< orphan*/ stderr;
size_t strlen(char *);
unsigned long strtoul(char *, int /*<<< orphan*/ *, int);
int main(int argc, char **argv) {
  char *text;
  size_t length;
  unsigned long max;
  if (argc != 3) {
    fprintf(stderr, "Usage: %s <text> <max>\a\n", argv[0]);
    exit(EXIT_FAILURE);
  }
  text = argv[1];
  max = strtoul(argv[2], NULL, 10);
  preprocess(text);
  length = strlen(text);
  for (unsigned long spacing = 1; spacing <= max; spacing++) {
    double ic = calc_ic(text, length, spacing);
    unsigned barlen;
    if (ic > 0.8 && ic < 4)
      barlen = (ic - 0.8) / 3.2 * 40.0;
    else
      barlen = ic <= 0.8 ? 0 : 40;
    printf("%3lu - %6.3f ", spacing, ic);
    for (unsigned i = 0; i < barlen; i++)
      putchar('#');
    putchar('\n');
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     11ca <main+0x4a>
mov    0x2e39(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe71(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2e15(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1080 <strtoul@plt>
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1070 <preprocess@plt>
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x20(%rbp)
movq   $0x1,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x28(%rbp),%rax
ja     130b <main+0x18b>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x30(%rbp),%rdx
call   10a0 <calc_ic@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  0xdc1(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1292 <main+0x112>
movsd  0xdb7(%rip),%xmm0
ucomisd -0x38(%rbp),%xmm0
jbe    1292 <main+0x112>
movsd  -0x38(%rbp),%xmm0
movsd  0xda7(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  0xda3(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xd9f(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rax
mov    %eax,-0x3c(%rbp)
jmp    12b0 <main+0x130>
movsd  -0x38(%rbp),%xmm1
movsd  0xd61(%rip),%xmm0
mov    $0x28,%eax
xor    %ecx,%ecx
ucomisd %xmm1,%xmm0
cmovae %ecx,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x30(%rbp),%rsi
movsd  -0x38(%rbp),%xmm0
lea    0xd81(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x40(%rbp)
mov    -0x40(%rbp),%eax
cmp    -0x3c(%rbp),%eax
jae    12f0 <main+0x170>
mov    $0x23,%edi
call   1030 <putchar@plt>
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    12cc <main+0x14c>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    120e <main+0x8e>
mov    0x2cbe(%rip),%rax
mov    (%rax),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x3,%edi
jne    12bc <main+0x13c>
mov    0x8(%rsi),%r14
mov    0x10(%rsi),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1080 <strtoul@plt>
mov    %rax,%r15
mov    %r14,%rdi
call   1070 <preprocess@plt>
mov    %r14,%rdi
call   1040 <strlen@plt>
test   %r15,%r15
je     12a4 <main+0x124>
mov    %rax,%r12
mov    $0x1,%ebx
lea    0xe6e(%rip),%r13
jmp    11f7 <main+0x77>
cs nopw 0x0(%rax,%rax,1)
nop
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
cmp    %r15,%rbx
ja     12a4 <main+0x124>
mov    %r14,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
call   10a0 <calc_ic@plt>
movapd %xmm0,%xmm1
ucomisd 0xdef(%rip),%xmm0
jbe    1260 <main+0xe0>
movsd  0xded(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1260 <main+0xe0>
movapd %xmm1,%xmm0
addsd  0xde3(%rip),%xmm0
divsd  0xde3(%rip),%xmm0
mulsd  0xde3(%rip),%xmm0
cvttsd2si %xmm0,%rbp
mov    %r13,%rdi
mov    %rbx,%rsi
movapd %xmm1,%xmm0
call   1050 <printf@plt>
test   %ebp,%ebp
jne    1290 <main+0x110>
jmp    11e0 <main+0x60>
nopw   0x0(%rax,%rax,1)
mov    %r13,%rdi
mov    %rbx,%rsi
movapd %xmm1,%xmm0
movsd  %xmm1,(%rsp)
call   1050 <printf@plt>
movsd  0xd84(%rip),%xmm0
ucomisd (%rsp),%xmm0
mov    $0x28,%ebp
jae    11e0 <main+0x60>
nopl   0x0(%rax)
mov    $0x23,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
jne    1290 <main+0x110>
jmp    11e0 <main+0x60>
mov    0x2d25(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d1d(%rip),%rax
mov    (%rax),%edi
mov    (%rsi),%rdx
lea    0xd59(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2cfd(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [25 x i8] c"Usage: %s <text> <max>\07\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [14 x i8] c"%3lu - %6.3f \00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
%10 = alloca double
%11 = alloca i32
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = load i32, i32* %4
%14 = icmp ne i32 %13, 3
br i1 %14, label %15, label %23
15: ; preds = %2
%16 = load i32, i32* @stderr
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 0
%19 = load i8*, i8** %18
%20 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %19)
%21 = load i32, i32* @EXIT_FAILURE
%22 = call i32 @exit(i32 %21)
unreachable
23: ; preds = %2
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
store i8* %26, i8** %6
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 2
%29 = load i8*, i8** %28
%30 = call i64 @strtoul(i8* %29, i32* null, i32 10)
store i64 %30, i64* %8
%31 = load i8*, i8** %6
%32 = call i32 @preprocess(i8* %31)
%33 = load i8*, i8** %6
%34 = call i64 @strlen(i8* %33)
store i64 %34, i64* %7
store i64 1, i64* %9
br label %35
35: ; preds = %75, %23
%36 = load i64, i64* %9
%37 = load i64, i64* %8
%38 = icmp ule i64 %36, %37
br i1 %38, label %39, label %78
39: ; preds = %35
%40 = load i8*, i8** %6
%41 = load i64, i64* %7
%42 = load i64, i64* %9
%43 = call double @calc_ic(i8* %40, i64 %41, i64 %42)
store double %43, double* %10
%44 = load double, double* %10
%45 = fcmp ogt double %44, 8.000000e-01
br i1 %45, label %46, label %55
46: ; preds = %39
%47 = load double, double* %10
%48 = fcmp olt double %47, 4.000000e+00
br i1 %48, label %49, label %55
49: ; preds = %46
%50 = load double, double* %10
%51 = fsub double %50, 8.000000e-01
%52 = fdiv double %51, 3.200000e+00
%53 = fmul double %52, 4.000000e+01
%54 = fptoui double %53 to i32
store i32 %54, i32* %11
br label %60
55: ; preds = %46, %39
%56 = load double, double* %10
%57 = fcmp ole double %56, 8.000000e-01
%58 = zext i1 %57 to i64
%59 = select i1 %57, i32 0, i32 40
store i32 %59, i32* %11
br label %60
60: ; preds = %55, %49
%61 = load i64, i64* %9
%62 = load double, double* %10
%63 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i64 %61, double %62)
store i32 0, i32* %12
br label %64
64: ; preds = %70, %60
%65 = load i32, i32* %12
%66 = load i32, i32* %11
%67 = icmp ult i32 %65, %66
br i1 %67, label %68, label %73
68: ; preds = %64
%69 = call i32 @putchar(i8 signext 35)
br label %70
70: ; preds = %68
%71 = load i32, i32* %12
%72 = add i32 %71, 1
store i32 %72, i32* %12
br label %64
73: ; preds = %64
%74 = call i32 @putchar(i8 signext 10)
br label %75
75: ; preds = %73
%76 = load i64, i64* %9
%77 = add i64 %76, 1
store i64 %77, i64* %9
br label %35
78: ; preds = %35
%79 = load i32, i32* @EXIT_SUCCESS
ret i32 %79
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [25 x i8] c"Usage: %s <text> <max>\07\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [14 x i8] c"%3lu - %6.3f \00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 3
br i1 %3, label %10, label %4
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = load i8*, i8** %1
%7 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = load i32, i32* @EXIT_FAILURE
%9 = tail call i32 @exit(i32 %8)
unreachable
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = getelementptr inbounds i8*, i8** %1, i64 2
%14 = load i8*, i8** %13
%15 = tail call i64 @strtoul(i8* nocapture %14, i32* null, i32 10)
%16 = tail call i32 @preprocess(i8* %12)
%17 = tail call i64 @strlen(i8* dereferenceable(1) %12)
%18 = icmp eq i64 %15, 0
br i1 %18, label %19, label %21
19: ; preds = %39, %10
%20 = load i32, i32* @EXIT_SUCCESS
ret i32 %20
21: ; preds = %10, %39
%22 = phi i64 [ %41, %39 ], [ 1, %10 ]
%23 = tail call double @calc_ic(i8* %12, i64 %17, i64 %22)
%24 = fcmp ogt double %23, 8.000000e-01
%25 = fcmp olt double %23, 4.000000e+00
%26 = and i1 %24, %25
br i1 %26, label %30, label %27
27: ; preds = %21
%28 = fcmp ugt double %23, 8.000000e-01
%29 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i64 %22, double %23)
br i1 %28, label %37, label %39
30: ; preds = %21
%31 = fadd double %23, -8.000000e-01
%32 = fdiv double %31, 3.200000e+00
%33 = fmul double %32, 4.000000e+01
%34 = fptoui double %33 to i32
%35 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i64 %22, double %23)
%36 = icmp eq i32 %34, 0
br i1 %36, label %39, label %37
37: ; preds = %27, %30
%38 = phi i32 [ %34, %30 ], [ 40, %27 ]
br label %43
39: ; preds = %43, %27, %30
%40 = tail call i32 @putchar(i8 signext 10)
%41 = add i64 %22, 1
%42 = icmp ugt i64 %41, %15
br i1 %42, label %19, label %21
43: ; preds = %37, %43
%44 = phi i32 [ %46, %43 ], [ 0, %37 ]
%45 = tail call i32 @putchar(i8 signext 35)
%46 = add nuw i32 %44, 1
%47 = icmp eq i32 %46, %38
br i1 %47, label %39, label %43
}