#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 */
typedef int uint8_t;

/* Variables and functions */
size_t fread(int *, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ fwrite(int *, int, size_t, int /*<<< orphan*/);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
int main(void) {
  static uint8_t inbuf[8192 * 8];
  static uint8_t outbuf[8192];
  size_t n;
  while ((n = fread(inbuf, 8, 8192, stdin))) {
    uint8_t *p = inbuf;
    for (size_t i = 0; i < n; i++) {
      uint8_t pack = 0;
      for (int j = 0; j < 8; j++) {
        pack <<= 1;
        pack |= (*p++) >> 7;
      }
      outbuf[i] = pack;
    }
    fwrite(outbuf, 1, n, stdout);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2eb2(%rip),%rax
mov    (%rax),%ecx
lea    0x2f01(%rip),%rdi
mov    $0x8,%esi
mov    $0x2000,%edx
call   1030 <fread@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     120b <main+0xeb>
lea    0x2edd(%rip),%rax
mov    %rax,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    11e8 <main+0xc8>
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
cmpl   $0x8,-0x28(%rbp)
jge    11c6 <main+0xa6>
mov    -0x24(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x18(%rbp)
mov    (%rax),%eax
sar    $0x7,%eax
or     -0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    118b <main+0x6b>
mov    -0x24(%rbp),%edx
mov    -0x20(%rbp),%rcx
lea    0x42e6c(%rip),%rax
mov    %edx,(%rax,%rcx,4)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    116f <main+0x4f>
mov    -0x10(%rbp),%rdx
mov    0x2de5(%rip),%rax
mov    (%rax),%ecx
lea    0x42e44(%rip),%rdi
mov    $0x1,%esi
call   1040 <fwrite@plt>
jmp    112f <main+0xf>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    0x2eb8(%rip),%r15
mov    (%r15),%ecx
lea    0x2f06(%rip),%r14
mov    %r14,%rdi
mov    $0x8,%esi
mov    $0x2000,%edx
call   1030 <fread@plt>
test   %rax,%rax
je     121d <main+0xfd>
lea    0x42ee4(%rip),%r13
mov    0x2e75(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r13,%rcx
mov    %rax,%r8
mov    %r14,%rsi
nopl   0x0(%rax)
mov    (%rsi),%edi
mov    0x4(%rsi),%ebx
sar    $0x6,%edi
and    $0xffffffe,%edi
sar    $0x7,%ebx
or     %edi,%ebx
mov    0x8(%rsi),%edi
shl    $0x2,%ebx
sar    $0x6,%edi
and    $0x3ffffffe,%edi
mov    0xc(%rsi),%edx
sar    $0x7,%edx
or     %edi,%edx
or     %ebx,%edx
mov    0x10(%rsi),%edi
shl    $0x2,%edx
sar    $0x6,%edi
and    $0x3ffffffe,%edi
mov    0x14(%rsi),%ebx
sar    $0x7,%ebx
or     %edi,%ebx
or     %edx,%ebx
mov    0x18(%rsi),%edx
shl    $0x2,%ebx
sar    $0x6,%edx
and    $0xfffffffe,%edx
mov    0x1c(%rsi),%edi
sar    $0x7,%edi
or     %edx,%edi
or     %ebx,%edi
mov    %edi,(%rcx)
add    $0x4,%rcx
add    $0x20,%rsi
add    $0xffffffffffffffff,%r8
jne    1180 <main+0x60>
mov    (%r12),%ecx
mov    %r13,%rdi
mov    $0x1,%esi
mov    %rax,%rdx
call   1040 <fwrite@plt>
mov    (%r15),%ecx
mov    %r14,%rdi
mov    $0x8,%esi
mov    $0x2000,%edx
call   1030 <fread@plt>
test   %rax,%rax
jne    1170 <main+0x50>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@main.inbuf = internal global [65536 x i32] zeroinitializer
@main.outbuf = internal global [8192 x i32] zeroinitializer
@stdin = global i32 0
@stdout = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i32*
%4 = alloca i64
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
br label %7
7: ; preds = %39, %0
%8 = load i32, i32* @stdin
%9 = call i64 @fread(i32* getelementptr inbounds ([65536 x i32], [65536 x i32]* @main.inbuf, i64 0, i64 0), i32 8, i32 8192, i32 %8)
store i64 %9, i64* %2
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %43
11: ; preds = %7
store i32* getelementptr inbounds ([65536 x i32], [65536 x i32]* @main.inbuf, i64 0, i64 0), i32** %3
store i64 0, i64* %4
br label %12
12: ; preds = %36, %11
%13 = load i64, i64* %4
%14 = load i64, i64* %2
%15 = icmp ult i64 %13, %14
br i1 %15, label %16, label %39
16: ; preds = %12
store i32 0, i32* %5
store i32 0, i32* %6
br label %17
17: ; preds = %29, %16
%18 = load i32, i32* %6
%19 = icmp slt i32 %18, 8
br i1 %19, label %20, label %32
20: ; preds = %17
%21 = load i32, i32* %5
%22 = shl i32 %21, 1
store i32 %22, i32* %5
%23 = load i32*, i32** %3
%24 = getelementptr inbounds i32, i32* %23, i32 1
store i32* %24, i32** %3
%25 = load i32, i32* %23
%26 = ashr i32 %25, 7
%27 = load i32, i32* %5
%28 = or i32 %27, %26
store i32 %28, i32* %5
br label %29
29: ; preds = %20
%30 = load i32, i32* %6
%31 = add nsw i32 %30, 1
store i32 %31, i32* %6
br label %17
32: ; preds = %17
%33 = load i32, i32* %5
%34 = load i64, i64* %4
%35 = getelementptr inbounds [8192 x i32], [8192 x i32]* @main.outbuf, i64 0, i64 %34
store i32 %33, i32* %35
br label %36
36: ; preds = %32
%37 = load i64, i64* %4
%38 = add i64 %37, 1
store i64 %38, i64* %4
br label %12
39: ; preds = %12
%40 = load i64, i64* %2
%41 = load i32, i32* @stdout
%42 = call i32 @fwrite(i32* getelementptr inbounds ([8192 x i32], [8192 x i32]* @main.outbuf, i64 0, i64 0), i32 1, i64 %40, i32 %41)
br label %7
43: ; preds = %7
%44 = load i32, i32* %1
ret i32 %44
}

LLVM IR (-O2):
@main.inbuf = internal global [65536 x i32] zeroinitializer
@main.outbuf = internal global [8192 x i32] zeroinitializer
@stdin = global i32 0
@stdout = global i32 0
define i32 @main() {
%1 = load i32, i32* @stdin
%2 = tail call i64 @fread(i32* getelementptr inbounds ([65536 x i32], [65536 x i32]* @main.inbuf, i64 0, i64 0), i32 8, i32 8192, i32 %1)
%3 = icmp eq i64 %2, 0
br i1 %3, label %56, label %4
4: ; preds = %0, %50
%5 = phi i64 [ %54, %50 ], [ %2, %0 ]
br label %6
6: ; preds = %4, %6
%7 = phi i64 [ 0, %4 ], [ %48, %6 ]
%8 = phi i32* [ getelementptr inbounds ([65536 x i32], [65536 x i32]* @main.inbuf, i64 0, i64 0), %4 ], [ %46, %6 ]
%9 = getelementptr inbounds i32, i32* %8, i64 1
%10 = load i32, i32* %8
%11 = ashr i32 %10, 6
%12 = and i32 %11, 268435454
%13 = getelementptr inbounds i32, i32* %8, i64 2
%14 = load i32, i32* %9
%15 = ashr i32 %14, 7
%16 = or i32 %15, %12
%17 = getelementptr inbounds i32, i32* %8, i64 3
%18 = load i32, i32* %13
%19 = shl nsw i32 %16, 2
%20 = ashr i32 %18, 6
%21 = and i32 %20, 1073741822
%22 = or i32 %19, %21
%23 = getelementptr inbounds i32, i32* %8, i64 4
%24 = load i32, i32* %17
%25 = ashr i32 %24, 7
%26 = or i32 %25, %22
%27 = getelementptr inbounds i32, i32* %8, i64 5
%28 = load i32, i32* %23
%29 = shl i32 %26, 2
%30 = ashr i32 %28, 6
%31 = and i32 %30, 1073741822
%32 = or i32 %29, %31
%33 = getelementptr inbounds i32, i32* %8, i64 6
%34 = load i32, i32* %27
%35 = ashr i32 %34, 7
%36 = or i32 %35, %32
%37 = getelementptr inbounds i32, i32* %8, i64 7
%38 = load i32, i32* %33
%39 = shl i32 %36, 2
%40 = ashr i32 %38, 6
%41 = and i32 %40, -2
%42 = or i32 %39, %41
%43 = load i32, i32* %37
%44 = ashr i32 %43, 7
%45 = or i32 %44, %42
%46 = getelementptr i32, i32* %8, i64 8
%47 = getelementptr inbounds [8192 x i32], [8192 x i32]* @main.outbuf, i64 0, i64 %7
store i32 %45, i32* %47
%48 = add nuw i64 %7, 1
%49 = icmp eq i64 %48, %5
br i1 %49, label %50, label %6
50: ; preds = %6
%51 = load i32, i32* @stdout
%52 = tail call i32 @fwrite(i32* getelementptr inbounds ([8192 x i32], [8192 x i32]* @main.outbuf, i64 0, i64 0), i32 1, i64 %5, i32 %51)
%53 = load i32, i32* @stdin
%54 = tail call i64 @fread(i32* getelementptr inbounds ([65536 x i32], [65536 x i32]* @main.inbuf, i64 0, i64 0), i32 8, i32 8192, i32 %53)
%55 = icmp eq i64 %54, 0
br i1 %55, label %56, label %4
56: ; preds = %50, %0
ret i32 0
}