#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 bin2num(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int num;
  printf("\n Enter the Decimal num: ");
  scanf("%d", &num);
  int num_bin;
  num_bin = bin2num(num);
  printf("\n 32 bit Binary of Decimal num is : %d", num_bin);
  puts("\n *************************");
  int c;
  c = num | 15;
  c = bin2num(c);
  printf("\nDecimal Number with all bits set is: %d ", c);
  c = num & 0;
  c = bin2num(c);
  printf("\nDecimal Number with all bits reset is: %d ", c);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeda(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x8(%rbp),%edi
call   1060 <bin2num@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe98(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeb1(%rip),%rdi
call   1030 <puts@plt>
mov    -0x8(%rbp),%eax
or     $0xf,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%edi
call   1060 <bin2num@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%esi
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
and    $0x0,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%edi
call   1060 <bin2num@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%esi
lea    0xeaf(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xeb8(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xee8(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%edi
call   1060 <bin2num@plt>
lea    0xeaa(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec1(%rip),%rdi
call   1030 <puts@plt>
mov    0x4(%rsp),%edi
or     $0xf,%edi
call   1060 <bin2num@plt>
lea    0xec5(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %edi,%edi
call   1060 <bin2num@plt>
lea    0xed8(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [26 x i8] c"\0A Enter the Decimal num: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [39 x i8] c"\0A 32 bit Binary of Decimal num is : %d\00"
@.str.3 = [28 x i8] c"\0A *************************\00"
@.str.4 = [42 x i8] c"\0ADecimal Number with all bits set is: %d \00"
@.str.5 = [44 x i8] c"\0ADecimal Number with all bits reset is: %d \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 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 = call i32 @bin2num(i32 %7)
store i32 %8, i32* %3
%9 = load i32, i32* %3
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i32 %9)
%11 = call i32 @puts(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
%12 = load i32, i32* %2
%13 = or i32 %12, 15
store i32 %13, i32* %4
%14 = load i32, i32* %4
%15 = call i32 @bin2num(i32 %14)
store i32 %15, i32* %4
%16 = load i32, i32* %4
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.4, i64 0, i64 0), i32 %16)
%18 = load i32, i32* %2
%19 = and i32 %18, 0
store i32 %19, i32* %4
%20 = load i32, i32* %4
%21 = call i32 @bin2num(i32 %20)
store i32 %21, i32* %4
%22 = load i32, i32* %4
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.5, i64 0, i64 0), i32 %22)
ret i32 0
}

LLVM IR (-O2):
@.str = [26 x i8] c"\0A Enter the Decimal num: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [39 x i8] c"\0A 32 bit Binary of Decimal num is : %d\00"
@.str.3 = [28 x i8] c"\0A *************************\00"
@.str.4 = [42 x i8] c"\0ADecimal Number with all bits set is: %d \00"
@.str.5 = [44 x i8] c"\0ADecimal Number with all bits reset 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 ([26 x i8], [26 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 @bin2num(i32 %5)
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i32 %6)
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
%9 = load i32, i32* %1
%10 = or i32 %9, 15
%11 = call i32 @bin2num(i32 %10)
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.4, i64 0, i64 0), i32 %11)
%13 = call i32 @bin2num(i32 0)
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.5, i64 0, i64 0), i32 %13)
ret i32 0
}