#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*/ BinaryBuild(int, int, int, int *, char);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int remainder[31];
  int decimal, binary, k, i = 0;
  char space;
  printf("\n Enter The Decimal Number: ");
  scanf("%d", &decimal);
  int Origindecimal = decimal;
  while (decimal > 0) {
    remainder[i] = decimal % 2;
    decimal = decimal / 2;
    i++;
  }
  printf("\n\n DECIMAL VALUE \t\t BINARY VALUE");
  printf("\n ------------- \t\t -------------");
  printf("\n %d", Origindecimal);
  BinaryBuild(i, k, decimal, remainder, space);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x90(%rbp)
lea    0xead(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf00(%rip),%rdi
lea    -0x84(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x84(%rbp),%eax
mov    %eax,-0x98(%rbp)
cmpl   $0x0,-0x84(%rbp)
jle    11c7 <main+0x97>
mov    -0x84(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
movslq -0x90(%rbp),%rax
mov    %edx,-0x80(%rbp,%rax,4)
mov    -0x84(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x84(%rbp)
mov    -0x90(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x90(%rbp)
jmp    1179 <main+0x49>
lea    0xe4f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe62(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x98(%rbp),%esi
lea    0xe6f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x90(%rbp),%edi
mov    -0x8c(%rbp),%esi
mov    -0x84(%rbp),%edx
lea    -0x80(%rbp),%rcx
movsbl -0x91(%rbp),%r8d
ff
call   1040 <BinaryBuild@plt>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x98,%rsp
lea    0xec0(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf11(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%ebp
test   %ebp,%ebp
jle    118a <main+0x5a>
xor    %ebx,%ebx
mov    %ebp,%eax
cs nopw 0x0(%rax,%rax,1)
mov    %eax,%ecx
mov    %eax,%edx
and    $0x1,%edx
mov    %edx,0x10(%rsp,%rbx,4)
shr    %eax
add    $0x1,%rbx
cmp    $0x1,%ecx
ja     1170 <main+0x40>
mov    %eax,0xc(%rsp)
lea    0xe8c(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe9f(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xeb2(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0xc(%rsp),%edx
lea    0x10(%rsp),%rcx
mov    %ebx,%edi
xor    %r8d,%r8d
call   1040 <BinaryBuild@plt>
xor    %eax,%eax
add    $0x98,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [29 x i8] c"\0A Enter The Decimal Number: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [33 x i8] c"\0A\0A DECIMAL VALUE \09\09 BINARY VALUE\00"
@.str.3 = [33 x i8] c"\0A ------------- \09\09 -------------\00"
@.str.4 = [5 x i8] c"\0A %d\00"
define i32 @main() {
%1 = alloca [31 x i32]
%2 = alloca i32
%3 = bitcast [31 x i32]* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 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 %9, label %19
9: ; preds = %0, %9
%10 = phi i64 [ %15, %9 ], [ 0, %0 ]
%11 = phi i32 [ %14, %9 ], [ %7, %0 ]
%12 = and i32 %11, 1
%13 = getelementptr inbounds [31 x i32], [31 x i32]* %1, i64 0, i64 %10
store i32 %12, i32* %13
%14 = lshr i32 %11, 1
%15 = add nuw nsw i64 %10, 1
%16 = icmp ult i32 %11, 2
br i1 %16, label %17, label %9
17: ; preds = %9
%18 = trunc i64 %15 to i32
store i32 %14, i32* %2
br label %19
19: ; preds = %17, %0
%20 = phi i32 [ %18, %17 ], [ 0, %0 ]
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0))
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 %7)
%24 = load i32, i32* %2
%25 = getelementptr inbounds [31 x i32], [31 x i32]* %1, i64 0, i64 0
%26 = call i32 @BinaryBuild(i32 %20, i32 undef, i32 %24, i32* %25, i8 signext undef)
ret i32 0
}