#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 a[20];
  int d, dec, i = 0;
  printf("Enter the decimal number to find its binary number\n");
  scanf("%d", &dec);
  d = dec;
  while (dec > 0) {
    a[i] = dec % 2;
    i++;
    dec = dec / 2;
  }
  printf("Binary number of %d is = ", d);
  for (int j = i - 1; j >= 0; j--) {
    printf("%d", a[j]);
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x6c(%rbp)
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee9(%rip),%rdi
lea    -0x68(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x68(%rbp),%eax
mov    %eax,-0x64(%rbp)
cmpl   $0x0,-0x68(%rbp)
jle    1193 <main+0x73>
mov    -0x68(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
movslq -0x6c(%rbp),%rax
mov    %edx,-0x60(%rbp,%rax,4)
mov    -0x6c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x6c(%rbp)
mov    -0x68(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x68(%rbp)
jmp    115a <main+0x3a>
mov    -0x64(%rbp),%esi
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x6c(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x70(%rbp)
cmpl   $0x0,-0x70(%rbp)
jl     11db <main+0xbb>
movslq -0x70(%rbp),%rax
mov    -0x60(%rbp,%rax,4),%esi
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x70(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x70(%rbp)
jmp    11ad <main+0x8d>
lea    0xe50(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x68,%rsp
lea    0xecf(%rip),%rdi
call   1040 <puts@plt>
lea    0xea6(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
mov    0xc(%rsp),%esi
test   %esi,%esi
jle    11ca <main+0x8a>
xor    %ebx,%ebx
mov    %esi,%eax
mov    %eax,%ecx
mov    %eax,%edx
and    $0x1,%edx
mov    %edx,0x10(%rsp,%rbx,4)
add    $0x1,%rbx
shr    %eax
cmp    $0x1,%ecx
ja     1170 <main+0x30>
mov    %eax,0xc(%rsp)
lea    0xe72(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
test   %ebx,%ebx
jle    11d8 <main+0x98>
add    $0x1,%rbx
lea    0xe59(%rip),%r14
nopw   0x0(%rax,%rax,1)
mov    0x8(%rsp,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0xffffffffffffffff,%rbx
cmp    $0x1,%rbx
ja     11b0 <main+0x70>
jmp    11d8 <main+0x98>
lea    0xe32(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [52 x i8] c"Enter the decimal number to find its binary number\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [26 x i8] c"Binary number of %d is = \00"
@.str.3 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [20 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %5
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%9 = load i32, i32* %4
store i32 %9, i32* %3
br label %10
10: ; preds = %13, %0
%11 = load i32, i32* %4
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %23
13: ; preds = %10
%14 = load i32, i32* %4
%15 = srem i32 %14, 2
%16 = load i32, i32* %5
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 0, i64 %17
store i32 %15, i32* %18
%19 = load i32, i32* %5
%20 = add nsw i32 %19, 1
store i32 %20, i32* %5
%21 = load i32, i32* %4
%22 = sdiv i32 %21, 2
store i32 %22, i32* %4
br label %10
23: ; preds = %10
%24 = load i32, i32* %3
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 %24)
%26 = load i32, i32* %5
%27 = sub nsw i32 %26, 1
store i32 %27, i32* %6
br label %28
28: ; preds = %37, %23
%29 = load i32, i32* %6
%30 = icmp sge i32 %29, 0
br i1 %30, label %31, label %40
31: ; preds = %28
%32 = load i32, i32* %6
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 0, i64 %33
%35 = load i32, i32* %34
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %35)
br label %37
37: ; preds = %31
%38 = load i32, i32* %6
%39 = add nsw i32 %38, -1
store i32 %39, i32* %6
br label %28
40: ; preds = %28
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [26 x i8] c"Binary number of %d is = \00"
@str = [51 x i8] c"Enter the decimal number to find its binary number\00"
define i32 @main() {
%1 = alloca [20 x i32]
%2 = alloca i32
%3 = bitcast [20 x i32]* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 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 = icmp sgt i32 %7, 0
br i1 %8, label %11, label %9
9: ; preds = %0
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 %7)
br label %25
11: ; preds = %0, %11
%12 = phi i64 [ %16, %11 ], [ 0, %0 ]
%13 = phi i32 [ %17, %11 ], [ %7, %0 ]
%14 = and i32 %13, 1
%15 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 %12
store i32 %14, i32* %15
%16 = add nuw nsw i64 %12, 1
%17 = lshr i32 %13, 1
%18 = icmp ult i32 %13, 2
br i1 %18, label %19, label %11
19: ; preds = %11
%20 = trunc i64 %16 to i32
store i32 %17, i32* %2
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 %7)
%22 = icmp sgt i32 %20, 0
br i1 %22, label %23, label %25
23: ; preds = %19
%24 = and i64 %16, 4294967295
br label %27
25: ; preds = %27, %9, %19
%26 = call i32 @putchar(i32 10)
ret i32 0
27: ; preds = %23, %27
%28 = phi i64 [ %24, %23 ], [ %29, %27 ]
%29 = add nsw i64 %28, -1
%30 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 %29
%31 = load i32, i32* %30
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %31)
%33 = icmp ugt i64 %28, 1
br i1 %33, label %27, label %25
}