#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 getchar();
scalar_t__ putchar(int, int);
main() {
  for (int c, b = 0, m = 8; 0 <= (c = getchar());)
    b <<= 1, b |= c & 1, !--m && putchar(b & 127, m = 8);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x8,-0x10(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,%ecx
mov    %ecx,-0x8(%rbp)
xor    %eax,%eax
cmp    %ecx,%eax
jg     11a8 <main+0x88>
mov    -0xc(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
and    $0x1,%eax
or     -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x10(%rbp)
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x11(%rbp)
jne    11a0 <main+0x80>
mov    -0xc(%rbp),%edi
and    $0x7f,%edi
movl   $0x8,-0x10(%rbp)
mov    $0x8,%esi
call   1030 <putchar@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
jmp    113d <main+0x1d>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
xor    %eax,%eax
call   1040 <getchar@plt>
test   %eax,%eax
js     116c <main+0x4c>
mov    $0x8,%ebp
xor    %ebx,%ebx
jmp    114b <main+0x2b>
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <getchar@plt>
test   %eax,%eax
js     116c <main+0x4c>
and    $0x1,%eax
lea    (%rax,%rbx,2),%ebx
add    $0xffffffff,%ebp
jne    1140 <main+0x20>
mov    %ebx,%edi
and    $0x7f,%edi
mov    $0x8,%ebp
mov    $0x8,%esi
call   1030 <putchar@plt>
jmp    1140 <main+0x20>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
store i32 8, i32* %4
br label %5
5: ; preds = %23, %0
%6 = call i32 (...) @getchar()
store i32 %6, i32* %2
%7 = icmp sle i32 0, %6
br i1 %7, label %8, label %26
8: ; preds = %5
%9 = load i32, i32* %3
%10 = shl i32 %9, 1
store i32 %10, i32* %3
%11 = load i32, i32* %2
%12 = and i32 %11, 1
%13 = load i32, i32* %3
%14 = or i32 %13, %12
store i32 %14, i32* %3
%15 = load i32, i32* %4
%16 = add nsw i32 %15, -1
store i32 %16, i32* %4
%17 = icmp ne i32 %16, 0
br i1 %17, label %23, label %18
18: ; preds = %8
%19 = load i32, i32* %3
%20 = and i32 %19, 127
store i32 8, i32* %4
%21 = call i64 @putchar(i32 %20, i32 8)
%22 = icmp ne i64 %21, 0
br label %23
23: ; preds = %18, %8
%24 = phi i1 [ false, %8 ], [ %22, %18 ]
%25 = zext i1 %24 to i32
br label %5
26: ; preds = %5
%27 = load i32, i32* %1
ret i32 %27
}

LLVM IR (-O2):
define i32 @main() {
%1 = tail call i32 (...) @getchar()
%2 = icmp sgt i32 %1, -1
br i1 %2, label %4, label %3
3: ; preds = %16, %0
ret i32 0
4: ; preds = %0, %16
%5 = phi i32 [ %18, %16 ], [ %1, %0 ]
%6 = phi i32 [ %17, %16 ], [ 8, %0 ]
%7 = phi i32 [ %10, %16 ], [ 0, %0 ]
%8 = shl i32 %7, 1
%9 = and i32 %5, 1
%10 = or i32 %9, %8
%11 = add nsw i32 %6, -1
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %4
%14 = and i32 %10, 127
%15 = tail call i64 @putchar(i32 %14, i32 8)
br label %16
16: ; preds = %13, %4
%17 = phi i32 [ %11, %4 ], [ 8, %13 ]
%18 = tail call i32 (...) @getchar()
%19 = icmp sgt i32 %18, -1
br i1 %19, label %4, label %3
}