#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 /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int i, x;
  int b[8];
  scanf("%d", &x);
  for (i = 0; i < 8; i++) {
    b[i] = x & 1;
    x = x >> 1;
  }
  for (i = 0; i < 8; i++) {
    printf("%d", b[7 - i]);
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x8,-0x8(%rbp)
jge    1175 <main+0x55>
mov    -0xc(%rbp),%ecx
and    $0x1,%ecx
movslq -0x8(%rbp),%rax
mov    %ecx,-0x30(%rbp,%rax,4)
mov    -0xc(%rbp),%eax
sar    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1146 <main+0x26>
movl   $0x0,-0x8(%rbp)
cmpl   $0x8,-0x8(%rbp)
jge    11b0 <main+0x90>
mov    $0x7,%eax
sub    -0x8(%rbp),%eax
cltq
mov    -0x30(%rbp,%rax,4),%esi
lea    0xe65(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    117c <main+0x5c>
lea    0xe4c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xebe(%rip),%rdi
mov    %rsp,%rsi
call   1050 <scanf@plt>
mov    (%rsp),%eax
mov    %eax,%ecx
and    $0x1,%ecx
mov    %ecx,0x4(%rsp)
mov    %eax,%r12d
shr    %r12d
and    $0x1,%r12d
mov    %eax,%r13d
shr    $0x2,%r13d
and    $0x1,%r13d
mov    %eax,%ebp
shr    $0x3,%ebp
and    $0x1,%ebp
mov    %eax,%ebx
shr    $0x4,%ebx
and    $0x1,%ebx
mov    %eax,%r14d
shr    $0x5,%r14d
and    $0x1,%r14d
mov    %eax,%r15d
shr    $0x6,%r15d
and    $0x1,%r15d
mov    %eax,%esi
shr    $0x7,%esi
and    $0x1,%esi
sar    $0x8,%eax
mov    %eax,(%rsp)
lea    0xe5a(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe4c(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe3b(%rip),%r15
mov    %r15,%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    0x4(%rsp),%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%4 = load i32, i32* %1
%5 = and i32 %4, 1
%6 = lshr i32 %4, 1
%7 = and i32 %6, 1
%8 = lshr i32 %4, 2
%9 = and i32 %8, 1
%10 = lshr i32 %4, 3
%11 = and i32 %10, 1
%12 = lshr i32 %4, 4
%13 = and i32 %12, 1
%14 = lshr i32 %4, 5
%15 = and i32 %14, 1
%16 = lshr i32 %4, 6
%17 = and i32 %16, 1
%18 = lshr i32 %4, 7
%19 = and i32 %18, 1
%20 = ashr i32 %4, 8
store i32 %20, i32* %1
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %19)
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %17)
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %15)
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %13)
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %11)
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %9)
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %7)
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %5)
%29 = call i32 @putchar(i32 10)
ret i32 0
}