#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 pow(int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int decimal, binary = 0, place = 0;
  printf("Enter the base-10 number: ");
  scanf("%d", &decimal);
  while (decimal) {
    binary += (decimal % 2) * pow(10, place);
    decimal /= 2;
    place++;
  }
  printf("Its Binary: %d\n", binary);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
lea    0xeac(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb9(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
je     11ba <main+0x8a>
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %edx,-0x14(%rbp)
mov    -0x10(%rbp),%esi
mov    $0xa,%edi
call   1050 <pow@plt>
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
imul   %ecx,%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    116b <main+0x3b>
mov    -0xc(%rbp),%esi
lea    0xe5a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xec1(%rip),%rdi
xor    %r14d,%r14d
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xecb(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%ebx
test   %ebx,%ebx
je     11aa <main+0x7a>
xor    %ebp,%ebp
xor    %r14d,%r14d
nopw   0x0(%rax,%rax,1)
mov    %ebx,%eax
shr    $0x1f,%eax
add    %ebx,%eax
and    $0xfffffffe,%eax
sub    %eax,%ebx
mov    $0xa,%edi
mov    %ebp,%esi
call   1050 <pow@plt>
imul   %ebx,%eax
add    %eax,%r14d
mov    0xc(%rsp),%eax
mov    %eax,%ebx
shr    $0x1f,%ebx
add    %eax,%ebx
sar    %ebx
mov    %ebx,0xc(%rsp)
add    $0x1,%ebp
add    $0x1,%eax
cmp    $0x2,%eax
ja     1170 <main+0x40>
lea    0xe6d(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [27 x i8] c"Enter the base-10 number: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [16 x i8] c"Its Binary: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
store i32 0, i32* %4
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 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)
br label %7
7: ; preds = %10, %0
%8 = load i32, i32* %2
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %22
10: ; preds = %7
%11 = load i32, i32* %2
%12 = srem i32 %11, 2
%13 = load i32, i32* %4
%14 = call i32 @pow(i32 10, i32 %13)
%15 = mul nsw i32 %12, %14
%16 = load i32, i32* %3
%17 = add nsw i32 %16, %15
store i32 %17, i32* %3
%18 = load i32, i32* %2
%19 = sdiv i32 %18, 2
store i32 %19, i32* %2
%20 = load i32, i32* %4
%21 = add nsw i32 %20, 1
store i32 %21, i32* %4
br label %7
22: ; preds = %7
%23 = load i32, i32* %3
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32 %23)
%25 = load i32, i32* %1
ret i32 %25
}

LLVM IR (-O2):
@.str = [27 x i8] c"Enter the base-10 number: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [16 x i8] c"Its Binary: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 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 = icmp eq i32 %5, 0
br i1 %6, label %20, label %7
7: ; preds = %0, %7
%8 = phi i32 [ %17, %7 ], [ 0, %0 ]
%9 = phi i32 [ %14, %7 ], [ 0, %0 ]
%10 = phi i32 [ %16, %7 ], [ %5, %0 ]
%11 = srem i32 %10, 2
%12 = call i32 @pow(i32 10, i32 %8)
%13 = mul nsw i32 %12, %11
%14 = add nsw i32 %13, %9
%15 = load i32, i32* %1
%16 = sdiv i32 %15, 2
store i32 %16, i32* %1
%17 = add nuw nsw i32 %8, 1
%18 = add i32 %15, 1
%19 = icmp ult i32 %18, 3
br i1 %19, label %20, label %7
20: ; preds = %7, %0
%21 = phi i32 [ 0, %0 ], [ %14, %7 ]
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32 %21)
ret i32 0
}