#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 *, long *);
int main() {
  long int decNum, remainder, quotient;
  int binNum[100];
  int c = 1;
  int j = 0;
  printf("Enter a Decimal Number: ");
  scanf("%ld", &decNum);
  quotient = decNum;
  while (quotient != 0) {
    binNum[c++] = quotient % 2;
    quotient /= 2;
  }
  printf("Binary Value of your Decimal Number %ld: ", decNum);
  for (j = (c - 1); j > 0; j--) {
    printf("%d", binNum[j]);
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1c0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x1b4(%rbp)
movl   $0x0,-0x1b8(%rbp)
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xebe(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11b8 <main+0x98>
mov    -0x20(%rbp),%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
mov    %edx,%ecx
mov    -0x1b4(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x1b4(%rbp)
cltq
mov    %ecx,-0x1b0(%rbp,%rax,4)
mov    -0x20(%rbp),%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
mov    %rax,-0x20(%rbp)
jmp    116c <main+0x4c>
mov    -0x10(%rbp),%rsi
lea    0xe5a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1b4(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x1b8(%rbp)
cmpl   $0x0,-0x1b8(%rbp)
jle    1216 <main+0xf6>
movslq -0x1b8(%rbp),%rax
mov    -0x1b0(%rbp,%rax,4),%esi
lea    0xe4c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1b8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1b8(%rbp)
jmp    11d9 <main+0xb9>
lea    0xe2d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x1c0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x1a8,%rsp
lea    0xebf(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeca(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x8(%rsp),%rsi
test   %rsi,%rsi
je     11dd <main+0xad>
mov    $0x1,%ebx
mov    %rsi,%rcx
mov    %rsi,%rax
xchg   %ax,%ax
shr    $0x3f,%rax
add    %rcx,%rax
mov    %eax,%edx
and    $0xfffffffe,%edx
mov    %ecx,%edi
sub    %edx,%edi
mov    %edi,0x10(%rsp,%rbx,4)
add    $0x1,%rbx
sar    %rax
add    $0x1,%rcx
cmp    $0x2,%rcx
mov    %rax,%rcx
ja     1170 <main+0x40>
lea    0xe7e(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x2,%ebx
jl     11eb <main+0xbb>
mov    %ebx,%ebx
add    $0x1,%rbx
lea    0xe8f(%rip),%r14
nopl   0x0(%rax,%rax,1)
lea    -0x2(%rbx),%eax
mov    0x10(%rsp,%rax,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0xffffffffffffffff,%rbx
cmp    $0x2,%rbx
ja     11c0 <main+0x90>
jmp    11eb <main+0xbb>
lea    0xe39(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x1a8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@.str = [25 x i8] c"Enter a Decimal Number: \00"
@.str.1 = [4 x i8] c"%ld\00"
@.str.2 = [42 x i8] c"Binary Value of your Decimal Number %ld: \00"
@.str.3 = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i64
%2 = alloca [100 x i32]
%3 = bitcast i64* %1 to i8*
%4 = bitcast [100 x i32]* %2 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64* %1)
%7 = load i64, i64* %1
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %0
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0), i64 %7)
br label %35
11: ; preds = %0, %11
%12 = phi i64 [ %16, %11 ], [ 1, %0 ]
%13 = phi i64 [ %18, %11 ], [ %7, %0 ]
%14 = srem i64 %13, 2
%15 = trunc i64 %14 to i32
%16 = add nuw i64 %12, 1
%17 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %12
store i32 %15, i32* %17
%18 = sdiv i64 %13, 2
%19 = add i64 %13, 1
%20 = icmp ult i64 %19, 3
br i1 %20, label %21, label %11
21: ; preds = %11
%22 = trunc i64 %16 to i32
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0), i64 %7)
%24 = icmp sgt i32 %22, 1
br i1 %24, label %25, label %35
25: ; preds = %21
%26 = and i64 %16, 4294967295
br label %27
27: ; preds = %25, %27
%28 = phi i64 [ %26, %25 ], [ %29, %27 ]
%29 = add nsw i64 %28, -1
%30 = and i64 %29, 4294967295
%31 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %30
%32 = load i32, i32* %31
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %32)
%34 = icmp ugt i64 %28, 2
br i1 %34, label %27, label %35
35: ; preds = %27, %9, %21
%36 = call i32 @putchar(i32 10)
ret i32 0
}