#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();
int /*<<< orphan*/ putchar(int);
main() {
  int c, i;
  while ((c = getchar()) >= 0) {
    for (i = 7; i >= 0; i--) {
      putchar(((c >> i) & 1) + 48);
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jl     1179 <main+0x59>
movl   $0x7,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jl     1174 <main+0x54>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%ecx
sar    %cl,%edi
and    $0x1,%edi
add    $0x30,%edi
call   1030 <putchar@plt>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    1149 <main+0x29>
jmp    112f <main+0xf>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   1040 <getchar@plt>
test   %eax,%eax
js     11cd <main+0xad>
mov    %eax,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %ebx,%edi
shr    $0x7,%edi
and    $0x1,%edi
or     $0x30,%edi
call   1030 <putchar@plt>
mov    %ebx,%edi
shr    $0x6,%edi
and    $0x1,%edi
or     $0x30,%edi
call   1030 <putchar@plt>
mov    %ebx,%edi
shr    $0x5,%edi
and    $0x1,%edi
or     $0x30,%edi
call   1030 <putchar@plt>
mov    %ebx,%edi
shr    $0x4,%edi
and    $0x1,%edi
or     $0x30,%edi
call   1030 <putchar@plt>
mov    %ebx,%edi
shr    $0x3,%edi
and    $0x1,%edi
or     $0x30,%edi
call   1030 <putchar@plt>
mov    %ebx,%edi
shr    $0x2,%edi
and    $0x1,%edi
or     $0x30,%edi
call   1030 <putchar@plt>
mov    %ebx,%edi
shr    %edi
and    $0x1,%edi
or     $0x30,%edi
call   1030 <putchar@plt>
and    $0x1,%ebx
or     $0x30,%ebx
mov    %ebx,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
mov    %eax,%ebx
test   %eax,%eax
jns    1140 <main+0x20>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
br label %4
4: ; preds = %21, %0
%5 = call i32 (...) @getchar()
store i32 %5, i32* %2
%6 = icmp sge i32 %5, 0
br i1 %6, label %7, label %22
7: ; preds = %4
store i32 7, i32* %3
br label %8
8: ; preds = %18, %7
%9 = load i32, i32* %3
%10 = icmp sge i32 %9, 0
br i1 %10, label %11, label %21
11: ; preds = %8
%12 = load i32, i32* %2
%13 = load i32, i32* %3
%14 = ashr i32 %12, %13
%15 = and i32 %14, 1
%16 = add nsw i32 %15, 48
%17 = call i32 @putchar(i32 %16)
br label %18
18: ; preds = %11
%19 = load i32, i32* %3
%20 = add nsw i32 %19, -1
store i32 %20, i32* %3
br label %8
21: ; preds = %8
br label %4
22: ; preds = %4
%23 = load i32, i32* %1
ret i32 %23
}

LLVM IR (-O2):
define i32 @main() {
%1 = tail call i32 (...) @getchar()
%2 = icmp sgt i32 %1, -1
br i1 %2, label %3, label %38
3: ; preds = %0, %3
%4 = phi i32 [ %36, %3 ], [ %1, %0 ]
%5 = lshr i32 %4, 7
%6 = and i32 %5, 1
%7 = or i32 %6, 48
%8 = tail call i32 @putchar(i32 %7)
%9 = lshr i32 %4, 6
%10 = and i32 %9, 1
%11 = or i32 %10, 48
%12 = tail call i32 @putchar(i32 %11)
%13 = lshr i32 %4, 5
%14 = and i32 %13, 1
%15 = or i32 %14, 48
%16 = tail call i32 @putchar(i32 %15)
%17 = lshr i32 %4, 4
%18 = and i32 %17, 1
%19 = or i32 %18, 48
%20 = tail call i32 @putchar(i32 %19)
%21 = lshr i32 %4, 3
%22 = and i32 %21, 1
%23 = or i32 %22, 48
%24 = tail call i32 @putchar(i32 %23)
%25 = lshr i32 %4, 2
%26 = and i32 %25, 1
%27 = or i32 %26, 48
%28 = tail call i32 @putchar(i32 %27)
%29 = lshr i32 %4, 1
%30 = and i32 %29, 1
%31 = or i32 %30, 48
%32 = tail call i32 @putchar(i32 %31)
%33 = and i32 %4, 1
%34 = or i32 %33, 48
%35 = tail call i32 @putchar(i32 %34)
%36 = tail call i32 (...) @getchar()
%37 = icmp sgt i32 %36, -1
br i1 %37, label %3, label %38
38: ; preds = %3, %0
ret i32 0
}