#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 EOF;
int getchar();
int /*<<< orphan*/ putchar(int);
int main() {
  int c, mask = 128, out = 0, total = 0;
  while ((c = getchar()) != EOF) {
    if (c >= 128)
      out |= mask;
    if (mask != 1)
      mask >>= 1;
    else {
      mask = 128;
      putchar(out);
      total++;
      out = 0;
    }
  }
  while (total % 128 > 0) {
    putchar(0);
    total++;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x80,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x8(%rbp)
mov    0x2e93(%rip),%rcx
cmp    (%rcx),%eax
je     11af <main+0x8f>
cmpl   $0x80,-0x8(%rbp)
jl     1173 <main+0x53>
mov    -0xc(%rbp),%eax
or     -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x1,-0xc(%rbp)
je     118b <main+0x6b>
mov    -0xc(%rbp),%eax
sar    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11aa <main+0x8a>
movl   $0x80,-0xc(%rbp)
mov    -0x10(%rbp),%edi
call   1030 <putchar@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x10(%rbp)
jmp    1144 <main+0x24>
jmp    11b4 <main+0x94>
mov    -0x14(%rbp),%eax
mov    $0x80,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jle    11dd <main+0xbd>
xor    %edi,%edi
call   1030 <putchar@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11b4 <main+0x94>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1040 <getchar@plt>
mov    0x2eb3(%rip),%r15
cmp    (%r15),%eax
je     11b7 <main+0x97>
mov    $0x80,%ebp
xor    %r14d,%r14d
xor    %ecx,%ecx
jmp    1160 <main+0x40>
cs nopw 0x0(%rax,%rax,1)
sar    %ebp
xor    %eax,%eax
call   1040 <getchar@plt>
mov    %ebx,%ecx
cmp    (%r15),%eax
je     1186 <main+0x66>
cmp    $0x7f,%eax
mov    $0x0,%ebx
cmovg  %ebp,%ebx
or     %ecx,%ebx
cmp    $0x1,%ebp
jne    1150 <main+0x30>
mov    %ebx,%edi
call   1030 <putchar@plt>
add    $0x1,%r14d
xor    %ebx,%ebx
mov    $0x80,%ebp
jmp    1152 <main+0x32>
test   $0x8000007f,%r14d
jle    11b7 <main+0x97>
add    $0x1,%r14d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %edi,%edi
call   1030 <putchar@plt>
lea    0x1(%r14),%eax
test   $0x8000007f,%r14d
mov    %eax,%r14d
jg     11a0 <main+0x80>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@EOF = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 128, i32* %3
store i32 0, i32* %4
store i32 0, i32* %5
br label %6
6: ; preds = %28, %0
%7 = call i32 (...) @getchar()
store i32 %7, i32* %2
%8 = load i32, i32* @EOF
%9 = icmp ne i32 %7, %8
br i1 %9, label %10, label %29
10: ; preds = %6
%11 = load i32, i32* %2
%12 = icmp sge i32 %11, 128
br i1 %12, label %13, label %17
13: ; preds = %10
%14 = load i32, i32* %3
%15 = load i32, i32* %4
%16 = or i32 %15, %14
store i32 %16, i32* %4
br label %17
17: ; preds = %13, %10
%18 = load i32, i32* %3
%19 = icmp ne i32 %18, 1
br i1 %19, label %20, label %23
20: ; preds = %17
%21 = load i32, i32* %3
%22 = ashr i32 %21, 1
store i32 %22, i32* %3
br label %28
23: ; preds = %17
store i32 128, i32* %3
%24 = load i32, i32* %4
%25 = call i32 @putchar(i32 %24)
%26 = load i32, i32* %5
%27 = add nsw i32 %26, 1
store i32 %27, i32* %5
store i32 0, i32* %4
br label %28
28: ; preds = %23, %20
br label %6
29: ; preds = %6
br label %30
30: ; preds = %34, %29
%31 = load i32, i32* %5
%32 = srem i32 %31, 128
%33 = icmp sgt i32 %32, 0
br i1 %33, label %34, label %38
34: ; preds = %30
%35 = call i32 @putchar(i32 0)
%36 = load i32, i32* %5
%37 = add nsw i32 %36, 1
store i32 %37, i32* %5
br label %30
38: ; preds = %30
%39 = load i32, i32* %1
ret i32 %39
}

LLVM IR (-O2):
@EOF = global i32 0
define i32 @main() {
%1 = tail call i32 (...) @getchar()
%2 = load i32, i32* @EOF
%3 = icmp eq i32 %1, %2
br i1 %3, label %34, label %7
4: ; preds = %21
%5 = and i32 %24, -2147483521
%6 = icmp sgt i32 %5, 0
br i1 %6, label %28, label %34
7: ; preds = %0, %21
%8 = phi i32 [ %25, %21 ], [ %1, %0 ]
%9 = phi i32 [ %24, %21 ], [ 0, %0 ]
%10 = phi i32 [ %23, %21 ], [ 0, %0 ]
%11 = phi i32 [ %22, %21 ], [ 128, %0 ]
%12 = icmp sgt i32 %8, 127
%13 = select i1 %12, i32 %11, i32 0
%14 = or i32 %13, %10
%15 = icmp eq i32 %11, 1
br i1 %15, label %18, label %16
16: ; preds = %7
%17 = ashr i32 %11, 1
br label %21
18: ; preds = %7
%19 = tail call i32 @putchar(i32 %14)
%20 = add nsw i32 %9, 1
br label %21
21: ; preds = %18, %16
%22 = phi i32 [ %17, %16 ], [ 128, %18 ]
%23 = phi i32 [ %14, %16 ], [ 0, %18 ]
%24 = phi i32 [ %9, %16 ], [ %20, %18 ]
%25 = tail call i32 (...) @getchar()
%26 = load i32, i32* @EOF
%27 = icmp eq i32 %25, %26
br i1 %27, label %4, label %7
28: ; preds = %4, %28
%29 = phi i32 [ %31, %28 ], [ %24, %4 ]
%30 = tail call i32 @putchar(i32 0)
%31 = add nsw i32 %29, 1
%32 = and i32 %31, -2147483521
%33 = icmp sgt i32 %32, 0
br i1 %33, label %28, label %34
34: ; preds = %28, %0, %4
ret i32 0
}