#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 num, i = 1, bin = 0, quo, rem;
  printf("\n Enter the num: ");
  scanf("%d", &num);
  printf("\n number is :%d", num);
  quo = num;
  printf("\n\t");
  while (quo != 0) {
    rem = quo % 2;
    quo = quo / 2;
    bin = bin + (rem * i);
    i = i * 10;
  }
  printf("\n Binary of num is : %d", bin);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee8(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%esi
lea    0xead(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
lea    0xea9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0x14(%rbp)
je     11c1 <main+0xa1>
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %edx,-0x18(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
mov    -0x18(%rbp),%ecx
imul   -0xc(%rbp),%ecx
add    %ecx,%eax
mov    %eax,-0x10(%rbp)
imul   $0xa,-0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    1180 <main+0x60>
mov    -0x10(%rbp),%esi
lea    0xe5a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
lea    0xed6(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf00(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%esi
lea    0xec3(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x4(%rsp),%ebp
lea    0xec1(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
test   %ebp,%ebp
je     11a6 <main+0x86>
xor    %ebx,%ebx
mov    $0x1,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %ebp,%ecx
shr    $0x1f,%ecx
add    %ebp,%ecx
mov    %ecx,%edx
sar    %edx
and    $0xfffffffe,%ecx
mov    %ebp,%esi
sub    %ecx,%esi
imul   %eax,%esi
add    %esi,%ebx
add    %eax,%eax
lea    (%rax,%rax,4),%eax
add    $0x1,%ebp
cmp    $0x2,%ebp
mov    %edx,%ebp
ja     1180 <main+0x60>
lea    0xe78(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

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