#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 dectobin() {
  long int num, a;
  int arr[100], i = 1, j;
  printf("\nEnter a decimal number: ");
  scanf("%ld", &num);
  a = num;
  while (a != 0) {
    arr[i++] = a % 2;
    a = a / 2;
  }
  printf("\nThe number in binary: ");
  for (j = i - 1; j > 0; j--)
    printf("%d", arr[j]);
}


x86 assembly (clang, -O0):
<dectobin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1c0,%rsp
movl   $0x1,-0x1b4(%rbp)
lea    0xec4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed0(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11a7 <dectobin+0x87>
mov    -0x18(%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    -0x18(%rbp),%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
mov    %rax,-0x18(%rbp)
jmp    115b <dectobin+0x3b>
lea    0xe70(%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    1201 <dectobin+0xe1>
movslq -0x1b8(%rbp),%rax
mov    -0x1b0(%rbp,%rax,4),%esi
lea    0xe50(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1b8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1b8(%rbp)
jmp    11c4 <dectobin+0xa4>
mov    -0x4(%rbp),%eax
add    $0x1c0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dectobin>:
push   %r14
push   %rbx
sub    $0x1a8,%rsp
lea    0xecf(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xedb(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x8(%rsp),%rax
test   %rax,%rax
je     11cd <dectobin+0xad>
mov    $0x1,%ebx
mov    %rax,%rcx
nopl   0x0(%rax,%rax,1)
shr    $0x3f,%rcx
add    %rax,%rcx
mov    %ecx,%edx
and    $0xfffffffe,%edx
mov    %eax,%esi
sub    %edx,%esi
mov    %esi,0x10(%rsp,%rbx,4)
add    $0x1,%rbx
sar    %rcx
add    $0x1,%rax
cmp    $0x2,%rax
mov    %rcx,%rax
ja     1160 <dectobin+0x40>
lea    0xe8f(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
cmp    $0x2,%ebx
jl     11db <dectobin+0xbb>
mov    %ebx,%ebx
add    $0x1,%rbx
lea    0xe8e(%rip),%r14
nopl   0x0(%rax,%rax,1)
lea    -0x2(%rbx),%eax
mov    0x10(%rsp,%rax,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0xffffffffffffffff,%rbx
cmp    $0x2,%rbx
ja     11b0 <dectobin+0x90>
jmp    11db <dectobin+0xbb>
lea    0xe4a(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1a8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@.str = [26 x i8] c"\0AEnter a decimal number: \00"
@.str.1 = [4 x i8] c"%ld\00"
@.str.2 = [24 x i8] c"\0AThe number in binary: \00"
@.str.3 = [3 x i8] c"%d\00"
define i32 @dectobin() {
%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 ([26 x i8], [26 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 ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
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 ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%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
ret i32 undef
}