void summary_info(char *fname, unsigned char *vec, int npg) {
  int i, width = 60, pgc, err, de, slope;
  const long long SCALE = 1024;
  char out[] = " _.oOX";
  int grads = sizeof(out) - 3;
  int extrawidth = 0;
  if (width > npg) {
    extrawidth = width - npg + 1;
    width = npg;
  }
  putchar('|');
  slope = npg / width;
  pgc = err = 0;
  de = ((SCALE * npg) / width) % SCALE;
  for (i = 0; i < width; i++) {
    int chunk = slope;
    int x;
    if (err > SCALE / 2) {
      chunk++;
      err -= SCALE;
    }
    x = count_present(vec + pgc, chunk, 0);
    pgc += chunk;
    err += de;
    if (x == 0)
      x = 0;
    else if (x == chunk)
      x = grads + 1;
    else
      x = (x * grads) / chunk + 1;
    putchar(out[x]);
  }
  printf("|%*s%s\n", extrawidth, fname ? " " : "", fname);
}


x86 assembly (clang, -O0):
<summary_info>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x3c,-0x1c(%rbp)
movq   $0x400,-0x38(%rbp)
mov    0xea8(%rip),%eax
mov    %eax,-0x3f(%rbp)
mov    0xea2(%rip),%ax
mov    %ax,-0x3b(%rbp)
mov    0xe9a(%rip),%al
mov    %al,-0x39(%rbp)
movl   $0x4,-0x44(%rbp)
movl   $0x0,-0x48(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jle    119b <summary_info+0x6b>
mov    -0x1c(%rbp),%eax
sub    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    $0x7c,%edi
mov    $0x0,%al
call   1030 <putchar@plt>
mov    -0x14(%rbp),%eax
cltd
idivl  -0x1c(%rbp)
mov    %eax,-0x2c(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x20(%rbp)
movslq -0x14(%rbp),%rax
shl    $0xa,%rax
movslq -0x1c(%rbp),%rcx
cqto
idiv   %rcx
mov    $0x400,%ecx
cqto
idiv   %rcx
mov    %edx,%eax
mov    %eax,-0x28(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    12ae <summary_info+0x17e>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x4c(%rbp)
movslq -0x24(%rbp),%rax
cmp    $0x200,%rax
jle    121e <summary_info+0xee>
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
movslq -0x24(%rbp),%rax
sub    $0x400,%rax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
movslq -0x20(%rbp),%rax
add    %rax,%rdi
mov    -0x4c(%rbp),%esi
xor    %edx,%edx
mov    $0x0,%al
call   1050 <count_present@plt>
mov    %eax,-0x50(%rbp)
mov    -0x4c(%rbp),%eax
add    -0x20(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x28(%rbp),%eax
add    -0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x50(%rbp)
jne    1260 <summary_info+0x130>
movl   $0x0,-0x50(%rbp)
jmp    1290 <summary_info+0x160>
mov    -0x50(%rbp),%eax
cmp    -0x4c(%rbp),%eax
jne    127a <summary_info+0x14a>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
jmp    128b <summary_info+0x15b>
mov    -0x50(%rbp),%eax
imul   -0x44(%rbp),%eax
cltd
idivl  -0x4c(%rbp)
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
jmp    1290 <summary_info+0x160>
movslq -0x50(%rbp),%rax
movsbl -0x3f(%rbp,%rax,1),%edi
mov    $0x0,%al
call   1030 <putchar@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11e6 <summary_info+0xb6>
mov    -0x48(%rbp),%esi
mov    -0x8(%rbp),%rcx
lea    0xd52(%rip),%rdx
lea    0xd4c(%rip),%rax
cmp    $0x0,%rcx
cmovne %rax,%rdx
mov    -0x8(%rbp),%rcx
lea    0xd31(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<summary_info>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %edx,%ebp
mov    %rsi,0x10(%rsp)
mov    %rdi,0x8(%rsp)
cmp    $0x3c,%edx
mov    $0x3c,%r15d
cmovl  %edx,%r15d
mov    $0x7c,%edi
xor    %eax,%eax
call   1030 <putchar@plt>
mov    %ebp,%eax
cltd
idiv   %r15d
mov    %eax,%r13d
movslq %ebp,%rax
shl    $0xa,%rax
movslq %r15d,%rcx
mov    %rax,%rdx
or     %rcx,%rdx
shr    $0x20,%rdx
je     118c <summary_info+0x5c>
cqto
idiv   %rcx
mov    %rax,%rbx
jmp    1193 <summary_info+0x63>
xor    %edx,%edx
div    %r15d
mov    %eax,%ebx
lea    0x3ff(%rbx),%eax
test   %rbx,%rbx
cmovns %ebx,%eax
mov    %ebp,0x4(%rsp)
test   %ebp,%ebp
jle    1240 <summary_info+0x110>
and    $0xfffffc00,%eax
sub    %eax,%ebx
cmp    $0x2,%r15d
mov    $0x1,%r14d
cmovge %r15d,%r14d
xor    %r15d,%r15d
xor    %r12d,%r12d
jmp    11f0 <summary_info+0xc0>
nopl   0x0(%rax,%rax,1)
add    %ebp,%r15d
add    %ebx,%r12d
cltq
lea    0xe21(%rip),%rcx
movsbl (%rax,%rcx,1),%edi
xor    %eax,%eax
call   1030 <putchar@plt>
add    $0xffffffff,%r14d
je     1240 <summary_info+0x110>
mov    %r12d,%eax
lea    -0x400(%rax),%r12d
xor    %ebp,%ebp
cmp    $0x201,%eax
cmovl  %eax,%r12d
setge  %bpl
add    %r13d,%ebp
movslq %r15d,%rdi
add    0x10(%rsp),%rdi
mov    %ebp,%esi
xor    %edx,%edx
xor    %eax,%eax
call   1050 <count_present@plt>
mov    %eax,%ecx
mov    $0x0,%eax
test   %ecx,%ecx
je     11d0 <summary_info+0xa0>
mov    $0x5,%eax
cmp    %ebp,%ecx
je     11d0 <summary_info+0xa0>
shl    $0x2,%ecx
mov    %ecx,%eax
cltd
idiv   %ebp
add    $0x1,%eax
jmp    11d0 <summary_info+0xa0>
mov    $0x3d,%esi
mov    0x4(%rsp),%ecx
sub    %ecx,%esi
xor    %eax,%eax
cmp    $0x3c,%ecx
cmovge %eax,%esi
mov    0x8(%rsp),%rcx
test   %rcx,%rcx
lea    0xdac(%rip),%rax
lea    0xda6(%rip),%rdx
cmove  %rax,%rdx
lea    0xd93(%rip),%rdi
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <printf@plt>

LLVM IR (-O0):
@__const.summary_info.out = [7 x i8] c" _.oOX\00"
@.str = [8 x i8] c"|%*s%s\0A\00"
@.str.1 = [2 x i8] c" \00"
@.str.2 = [1 x i8] zeroinitializer
define void @summary_info(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i64
%14 = alloca [7 x i8]
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
store i32 60, i32* %8
store i64 1024, i64* %13
%19 = bitcast [7 x i8]* %14 to i8*
store i32 4, i32* %15
store i32 0, i32* %16
%20 = load i32, i32* %8
%21 = load i32, i32* %6
%22 = icmp sgt i32 %20, %21
br i1 %22, label %23, label %29
23: ; preds = %3
%24 = load i32, i32* %8
%25 = load i32, i32* %6
%26 = sub nsw i32 %24, %25
%27 = add nsw i32 %26, 1
store i32 %27, i32* %16
%28 = load i32, i32* %6
store i32 %28, i32* %8
br label %29
29: ; preds = %23, %3
%30 = call i32 (i32, ...) bitcast (i32 (...)* @putchar to i32 (i32, ...)*)(i32 124)
%31 = load i32, i32* %6
%32 = load i32, i32* %8
%33 = sdiv i32 %31, %32
store i32 %33, i32* %12
store i32 0, i32* %10
store i32 0, i32* %9
%34 = load i32, i32* %6
%35 = sext i32 %34 to i64
%36 = mul nsw i64 1024, %35
%37 = load i32, i32* %8
%38 = sext i32 %37 to i64
%39 = sdiv i64 %36, %38
%40 = srem i64 %39, 1024
%41 = trunc i64 %40 to i32
store i32 %41, i32* %11
store i32 0, i32* %7
br label %42
42: ; preds = %96, %29
%43 = load i32, i32* %7
%44 = load i32, i32* %8
%45 = icmp slt i32 %43, %44
br i1 %45, label %46, label %99
46: ; preds = %42
%47 = load i32, i32* %12
store i32 %47, i32* %17
%48 = load i32, i32* %10
%49 = sext i32 %48 to i64
%50 = icmp sgt i64 %49, 512
br i1 %50, label %51, label %58
51: ; preds = %46
%52 = load i32, i32* %17
%53 = add nsw i32 %52, 1
store i32 %53, i32* %17
%54 = load i32, i32* %10
%55 = sext i32 %54 to i64
%56 = sub nsw i64 %55, 1024
%57 = trunc i64 %56 to i32
store i32 %57, i32* %10
br label %58
58: ; preds = %51, %46
%59 = load i8*, i8** %5
%60 = load i32, i32* %9
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds i8, i8* %59, i64 %61
%63 = load i32, i32* %17
%64 = call i32 (i8*, i32, i32, ...) bitcast (i32 (...)* @count_present to i32 (i8*, i32, i32, ...)*)(i8* %62, i32 %63, i32 0)
store i32 %64, i32* %18
%65 = load i32, i32* %17
%66 = load i32, i32* %9
%67 = add nsw i32 %66, %65
store i32 %67, i32* %9
%68 = load i32, i32* %11
%69 = load i32, i32* %10
%70 = add nsw i32 %69, %68
store i32 %70, i32* %10
%71 = load i32, i32* %18
%72 = icmp eq i32 %71, 0
br i1 %72, label %73, label %74
73: ; preds = %58
store i32 0, i32* %18
br label %89
74: ; preds = %58
%75 = load i32, i32* %18
%76 = load i32, i32* %17
%77 = icmp eq i32 %75, %76
br i1 %77, label %78, label %81
78: ; preds = %74
%79 = load i32, i32* %15
%80 = add nsw i32 %79, 1
store i32 %80, i32* %18
br label %88
81: ; preds = %74
%82 = load i32, i32* %18
%83 = load i32, i32* %15
%84 = mul nsw i32 %82, %83
%85 = load i32, i32* %17
%86 = sdiv i32 %84, %85
%87 = add nsw i32 %86, 1
store i32 %87, i32* %18
br label %88
88: ; preds = %81, %78
br label %89
89: ; preds = %88, %73
%90 = load i32, i32* %18
%91 = sext i32 %90 to i64
%92 = getelementptr inbounds [7 x i8], [7 x i8]* %14, i64 0, i64 %91
%93 = load i8, i8* %92
%94 = sext i8 %93 to i32
%95 = call i32 (i32, ...) bitcast (i32 (...)* @putchar to i32 (i32, ...)*)(i32 %94)
br label %96
96: ; preds = %89
%97 = load i32, i32* %7
%98 = add nsw i32 %97, 1
store i32 %98, i32* %7
br label %42
99: ; preds = %42
%100 = load i32, i32* %16
%101 = load i8*, i8** %4
%102 = icmp ne i8* %101, null
%103 = zext i1 %102 to i64
%104 = select i1 %102, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0)
%105 = load i8*, i8** %4
%106 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %100, i8* %104, i8* %105)
ret void
}

LLVM IR (-O2):
@__const.summary_info.out = [7 x i8] c" _.oOX\00"
@.str = [8 x i8] c"|%*s%s\0A\00"
@.str.1 = [2 x i8] c" \00"
@.str.2 = [1 x i8] zeroinitializer
define void @summary_info(i8* %0, i8* %1, i32 %2) {
%4 = icmp slt i32 %2, 60
%5 = select i1 %4, i32 %2, i32 60
%6 = tail call i32 (i32, ...) bitcast (i32 (...)* @putchar to i32 (i32, ...)*)(i32 124)
%7 = sdiv i32 %2, %5
%8 = sext i32 %2 to i64
%9 = shl nsw i64 %8, 10
%10 = sext i32 %5 to i64
%11 = sdiv i64 %9, %10
%12 = srem i64 %11, 1024
%13 = trunc i64 %12 to i32
%14 = icmp sgt i32 %2, 0
br i1 %14, label %15, label %47
15: ; preds = %3
%16 = call i32 @llvm.smax.i32(i32 %5, i32 1)
br label %17
17: ; preds = %15, %38
%18 = phi i32 [ %45, %38 ], [ 0, %15 ]
%19 = phi i32 [ %29, %38 ], [ 0, %15 ]
%20 = phi i32 [ %30, %38 ], [ 0, %15 ]
%21 = icmp sgt i32 %20, 512
%22 = add i32 %20, -1024
%23 = select i1 %21, i32 %22, i32 %20
%24 = zext i1 %21 to i32
%25 = add nsw i32 %7, %24
%26 = sext i32 %19 to i64
%27 = getelementptr inbounds i8, i8* %1, i64 %26
%28 = tail call i32 (i8*, i32, i32, ...) bitcast (i32 (...)* @count_present to i32 (i8*, i32, i32, ...)*)(i8* %27, i32 %25, i32 0)
%29 = add nsw i32 %25, %19
%30 = add nsw i32 %23, %13
%31 = icmp eq i32 %28, 0
br i1 %31, label %38, label %32
32: ; preds = %17
%33 = icmp eq i32 %28, %25
br i1 %33, label %38, label %34
34: ; preds = %32
%35 = shl nsw i32 %28, 2
%36 = sdiv i32 %35, %25
%37 = add nsw i32 %36, 1
br label %38
38: ; preds = %32, %17, %34
%39 = phi i32 [ %37, %34 ], [ 0, %17 ], [ 5, %32 ]
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [7 x i8], [7 x i8]* @__const.summary_info.out, i64 0, i64 %40
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = tail call i32 (i32, ...) bitcast (i32 (...)* @putchar to i32 (i32, ...)*)(i32 %43)
%45 = add nuw nsw i32 %18, 1
%46 = icmp eq i32 %45, %16
br i1 %46, label %47, label %17
47: ; preds = %38, %3
%48 = sub i32 61, %2
%49 = select i1 %4, i32 %48, i32 0
%50 = icmp eq i8* %0, null
%51 = select i1 %50, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0)
%52 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %49, i8* %51, i8* %0)
ret void
}