#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*/ puts(char *);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int n;
  puts("Enter number");
  scanf("%d", &n);
  int t = 1;
  puts("Binary:");
  int i;
  for (i = 0; i < sizeof(int) * 8; i++) {
    printf("%d", (n & t) ? 1 : 0);
    t <<= 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
call   1030 <puts@plt>
lea    0xebb(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
movl   $0x1,-0xc(%rbp)
lea    0xea7(%rip),%rdi
call   1030 <puts@plt>
movl   $0x0,-0x10(%rbp)
movslq -0x10(%rbp),%rax
cmp    $0x20,%rax
jae    11b9 <main+0x89>
mov    -0x8(%rbp),%ecx
and    -0xc(%rbp),%ecx
xor    %esi,%esi
mov    $0x1,%eax
cmp    $0x0,%ecx
cmovne %eax,%esi
lea    0xe70(%rip),%rdi
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1175 <main+0x45>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xec1(%rip),%rdi
call   1030 <puts@plt>
lea    0xec2(%rip),%r14
lea    0xc(%rsp),%rsi
mov    %r14,%rdi
call   1050 <scanf@plt>
lea    0xeb1(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebp
mov    $0x20,%ebx
xchg   %ax,%ax
xor    %esi,%esi
mov    0xc(%rsp),%eax
and    %ebp,%eax
setne  %sil
mov    %r14,%rdi
call   1040 <printf@plt>
add    %ebp,%ebp
add    $0xffffffff,%ebx
jne    1170 <main+0x40>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [13 x i8] c"Enter number\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [8 x i8] c"Binary:\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 @puts(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
store i32 1, i32* %3
%7 = call i32 @puts(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %4
br label %8
8: ; preds = %22, %0
%9 = load i32, i32* %4
%10 = sext i32 %9 to i64
%11 = icmp ult i64 %10, 32
br i1 %11, label %12, label %25
12: ; preds = %8
%13 = load i32, i32* %2
%14 = load i32, i32* %3
%15 = and i32 %13, %14
%16 = icmp ne i32 %15, 0
%17 = zext i1 %16 to i64
%18 = select i1 %16, i32 1, i32 0
%19 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %18)
%20 = load i32, i32* %3
%21 = shl i32 %20, 1
store i32 %21, i32* %3
br label %22
22: ; preds = %12
%23 = load i32, i32* %4
%24 = add nsw i32 %23, 1
store i32 %24, i32* %4
br label %8
25: ; preds = %8
ret i32 0
}

LLVM IR (-O2):
@.str = [13 x i8] c"Enter number\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [8 x i8] c"Binary:\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
br label %6
6: ; preds = %0, %6
%7 = phi i32 [ 0, %0 ], [ %15, %6 ]
%8 = phi i32 [ 1, %0 ], [ %14, %6 ]
%9 = load i32, i32* %1
%10 = and i32 %9, %8
%11 = icmp ne i32 %10, 0
%12 = zext i1 %11 to i32
%13 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %12)
%14 = shl i32 %8, 1
%15 = add nuw nsw i32 %7, 1
%16 = icmp eq i32 %15, 32
br i1 %16, label %17, label %6
17: ; preds = %6
ret i32 0
}