#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 */
char EOF;
char getchar();
int /*<<< orphan*/ printf(char *, ...);
int main() {
  char c;
  int x = 0;
  while ((c = getchar()) != EOF) {
    int mask = 0x80;
    while (mask > 0) {
      printf("%d", (c & mask) > 0);
      mask >>= 1;
    }
    x++;
    if (x == 2) {
      x = 0;
      printf("\n");
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x5(%rbp)
movsbl %al,%eax
mov    0x2e9e(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     11c1 <main+0xa1>
movl   $0x80,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jle    1194 <main+0x74>
movsbl -0x5(%rbp),%eax
and    -0x10(%rbp),%eax
cmp    $0x0,%eax
setg   %al
and    $0x1,%al
movzbl %al,%esi
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
sar    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    115c <main+0x3c>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x2,-0xc(%rbp)
jne    11bc <main+0x9c>
movl   $0x0,-0xc(%rbp)
lea    0xe4e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1136 <main+0x16>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1050 <getchar@plt>
mov    0x2ea3(%rip),%r14
cmp    (%r14),%al
jne    1157 <main+0x27>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xea2(%rip),%r15
xor    %ebx,%ebx
jmp    117e <main+0x4e>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %ebp,%ebx
cmp    (%r14),%al
je     114a <main+0x1a>
movzbl %al,%ebp
mov    %ebp,%esi
shr    $0x7,%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebp,%esi
shr    $0x6,%esi
and    $0x1,%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebp,%esi
shr    $0x5,%esi
and    $0x1,%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebp,%esi
shr    $0x4,%esi
and    $0x1,%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebp,%esi
shr    $0x3,%esi
and    $0x1,%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebp,%esi
shr    $0x2,%esi
and    $0x1,%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebp,%esi
shr    %esi
and    $0x1,%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
and    $0x1,%ebp
mov    %r15,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%ebp
cmp    $0x1,%ebx
jne    1170 <main+0x40>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %ebp,%ebp
jmp    1170 <main+0x40>

LLVM IR (-O0):
@EOF = global i8 0
@.str = [3 x i8] c"%d\00"
@.str.1 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
br label %5
5: ; preds = %32, %0
%6 = call signext i8 (...) @getchar()
store i8 %6, i8* %2
%7 = sext i8 %6 to i32
%8 = load i8, i8* @EOF
%9 = sext i8 %8 to i32
%10 = icmp ne i32 %7, %9
br i1 %10, label %11, label %33
11: ; preds = %5
store i32 128, i32* %4
br label %12
12: ; preds = %15, %11
%13 = load i32, i32* %4
%14 = icmp sgt i32 %13, 0
br i1 %14, label %15, label %25
15: ; preds = %12
%16 = load i8, i8* %2
%17 = sext i8 %16 to i32
%18 = load i32, i32* %4
%19 = and i32 %17, %18
%20 = icmp sgt i32 %19, 0
%21 = zext i1 %20 to i32
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %21)
%23 = load i32, i32* %4
%24 = ashr i32 %23, 1
store i32 %24, i32* %4
br label %12
25: ; preds = %12
%26 = load i32, i32* %3
%27 = add nsw i32 %26, 1
store i32 %27, i32* %3
%28 = load i32, i32* %3
%29 = icmp eq i32 %28, 2
br i1 %29, label %30, label %32
30: ; preds = %25
store i32 0, i32* %3
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %32
32: ; preds = %30, %25
br label %5
33: ; preds = %5
%34 = load i32, i32* %1
ret i32 %34
}

LLVM IR (-O2):
@EOF = global i8 0
@.str = [3 x i8] c"%d\00"
define i32 @main() {
%1 = tail call signext i8 (...) @getchar()
%2 = load i8, i8* @EOF
%3 = icmp eq i8 %1, %2
br i1 %3, label %38, label %4
4: ; preds = %0, %33
%5 = phi i8 [ %35, %33 ], [ %1, %0 ]
%6 = phi i32 [ %34, %33 ], [ 0, %0 ]
%7 = zext i8 %5 to i32
%8 = lshr i32 %7, 7
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = lshr i32 %7, 6
%11 = and i32 %10, 1
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = lshr i32 %7, 5
%14 = and i32 %13, 1
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %14)
%16 = lshr i32 %7, 4
%17 = and i32 %16, 1
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %17)
%19 = lshr i32 %7, 3
%20 = and i32 %19, 1
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %20)
%22 = lshr i32 %7, 2
%23 = and i32 %22, 1
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %23)
%25 = lshr i32 %7, 1
%26 = and i32 %25, 1
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %26)
%28 = and i32 %7, 1
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %28)
%30 = icmp eq i32 %6, 1
br i1 %30, label %31, label %33
31: ; preds = %4
%32 = tail call i32 @putchar(i32 10)
br label %33
33: ; preds = %31, %4
%34 = phi i32 [ 0, %31 ], [ 1, %4 ]
%35 = tail call signext i8 (...) @getchar()
%36 = load i8, i8* @EOF
%37 = icmp eq i8 %35, %36
br i1 %37, label %38, label %4
38: ; preds = %33, %0
ret i32 0
}