#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);
int /*<<< orphan*/ scanf(char *, int *);
int main(void) {
  const int bitsInInt = sizeof(int) * 8;
  int bitMask = 0x80000000, number = 0, i = 0;
  scanf("%d", &number);
  for (i = 0; i < bitsInInt; ++i) {
    printf("%d", number & bitMask ? 1 : 0);
    bitMask = (bitMask >> 1) & ~bitMask;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x20,-0x8(%rbp)
movl   $0x80000000,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xeae(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x20,-0x14(%rbp)
jge    11aa <main+0x8a>
mov    -0x10(%rbp),%ecx
and    -0xc(%rbp),%ecx
xor    %esi,%esi
mov    $0x1,%eax
cmp    $0x0,%ecx
cmovne %eax,%esi
lea    0xe7a(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
sar    $0x1,%eax
mov    -0xc(%rbp),%ecx
xor    $0xffffffff,%ecx
and    %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1162 <main+0x42>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
movl   $0x0,0xc(%rsp)
lea    0xec9(%rip),%r14
lea    0xc(%rsp),%rsi
mov    %r14,%rdi
call   1040 <scanf@plt>
mov    $0x80000000,%ebp
mov    $0x20,%ebx
xchg   %ax,%ax
xor    %esi,%esi
mov    0xc(%rsp),%eax
and    %ebp,%eax
setne  %sil
mov    %r14,%rdi
call   1030 <printf@plt>
mov    %ebp,%eax
sar    %eax
not    %ebp
and    %eax,%ebp
add    $0xffffffff,%ebx
jne    1150 <main+0x30>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
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 32, i32* %2
store i32 -2147483648, i32* %3
store i32 0, i32* %4
store i32 0, i32* %5
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
store i32 0, i32* %5
br label %7
7: ; preds = %23, %0
%8 = load i32, i32* %5
%9 = icmp slt i32 %8, 32
br i1 %9, label %10, label %26
10: ; preds = %7
%11 = load i32, i32* %4
%12 = load i32, i32* %3
%13 = and i32 %11, %12
%14 = icmp ne i32 %13, 0
%15 = zext i1 %14 to i64
%16 = select i1 %14, i32 1, i32 0
%17 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %16)
%18 = load i32, i32* %3
%19 = ashr i32 %18, 1
%20 = load i32, i32* %3
%21 = xor i32 %20, -1
%22 = and i32 %19, %21
store i32 %22, i32* %3
br label %23
23: ; preds = %10
%24 = load i32, i32* %5
%25 = add nsw i32 %24, 1
store i32 %25, i32* %5
br label %7
26: ; preds = %7
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*
store i32 0, i32* %1
%3 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
br label %4
4: ; preds = %0, %4
%5 = phi i32 [ 0, %0 ], [ %15, %4 ]
%6 = phi i32 [ -2147483648, %0 ], [ %14, %4 ]
%7 = load i32, i32* %1
%8 = and i32 %7, %6
%9 = icmp ne i32 %8, 0
%10 = zext i1 %9 to i32
%11 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = ashr i32 %6, 1
%13 = xor i32 %6, -1
%14 = and i32 %12, %13
%15 = add nuw nsw i32 %5, 1
%16 = icmp eq i32 %15, 32
br i1 %16, label %17, label %4
17: ; preds = %4
ret i32 0
}