#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 n, c, k;
  printf("Enter an integer in decimal number system\n");
  scanf("%d", &n);
  printf("%d in binary number system is:\n", n);
  for (c = 31; c >= 0; c--) {
    k = n >> c;
    if (k & 1)
      printf("1");
    else
      printf("0");
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee7(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%esi
lea    0xed7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1f,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jl     11bd <main+0x9d>
mov    -0x8(%rbp),%eax
mov    -0xc(%rbp),%ecx
sar    %cl,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     119c <main+0x7c>
lea    0xebe(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11aa <main+0x8a>
lea    0xead(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11af <main+0x8f>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    1165 <main+0x45>
lea    0xe88(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xed7(%rip),%rdi
call   1040 <puts@plt>
lea    0xea8(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
mov    0xc(%rsp),%esi
lea    0xe96(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1f,%ebx
nopl   0x0(%rax)
mov    0xc(%rsp),%eax
bt     %ebx,%eax
mov    $0x31,%edi
adc    $0xffffffff,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebx
jb     1180 <main+0x40>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [43 x i8] c"Enter an integer in decimal number system\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [32 x i8] c"%d in binary number system is:\0A\00"
@.str.3 = [2 x i8] c"1\00"
@.str.4 = [2 x i8] c"0\00"
@.str.5 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 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)
%7 = load i32, i32* %2
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i32 %7)
store i32 31, i32* %3
br label %9
9: ; preds = %24, %0
%10 = load i32, i32* %3
%11 = icmp sge i32 %10, 0
br i1 %11, label %12, label %27
12: ; preds = %9
%13 = load i32, i32* %2
%14 = load i32, i32* %3
%15 = ashr i32 %13, %14
store i32 %15, i32* %4
%16 = load i32, i32* %4
%17 = and i32 %16, 1
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %12
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %23
21: ; preds = %12
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %23
23: ; preds = %21, %19
br label %24
24: ; preds = %23
%25 = load i32, i32* %3
%26 = add nsw i32 %25, -1
store i32 %26, i32* %3
br label %9
27: ; preds = %9
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [32 x i8] c"%d in binary number system is:\0A\00"
@str = [42 x i8] c"Enter an integer in decimal number system\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 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 = load i32, i32* %1
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i32 %5)
br label %7
7: ; preds = %0, %7
%8 = phi i32 [ 31, %0 ], [ %15, %7 ]
%9 = load i32, i32* %1
%10 = shl nuw i32 1, %8
%11 = and i32 %9, %10
%12 = icmp eq i32 %11, 0
%13 = select i1 %12, i32 48, i32 49
%14 = call i32 @putchar(i32 %13)
%15 = add nsw i32 %8, -1
%16 = icmp eq i32 %8, 0
br i1 %16, label %17, label %7
17: ; preds = %7
%18 = call i32 @putchar(i32 10)
ret i32 0
}