#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 /*<<< orphan*/ system(char *);
int main(void) {
  int number, i = 0, cnt = 0;
  static int array[8];
  printf("Enter a number: ");
  scanf("%d", &number);
  printf("Processing your number........\n");
  system("sleep 3");
  while (number != 0) {
    array[i] = number % 2;
    i++;
    number = number / 2;
  }
  printf("\n\nThe number in binary form is: ");
  for (i = 8 - 1; i >= 0; i--)
    printf("%d ", array[i]);
  for (i = 0; i < 8; i++) {
    if (array[i] == 1)
      cnt++;
  }
  printf("\n\nCounting the number of 1's........\n");
  system("sleep 3");
  printf("\n\nThe number of 1's in the bit string is %d.\n", cnt);
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
lea    0xeac(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeaf(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeb4(%rip),%rdi
call   1030 <system@plt>
cmpl   $0x0,-0x8(%rbp)
je     11c4 <main+0x94>
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
movslq -0xc(%rbp),%rcx
lea    0x2eab(%rip),%rax
mov    %edx,(%rax,%rcx,4)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
jmp    1185 <main+0x55>
lea    0xe71(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x7,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jl     120d <main+0xdd>
movslq -0xc(%rbp),%rcx
lea    0x2e62(%rip),%rax
mov    (%rax,%rcx,4),%esi
lea    0xe65(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    11d9 <main+0xa9>
movl   $0x0,-0xc(%rbp)
cmpl   $0x8,-0xc(%rbp)
jge    124f <main+0x11f>
movslq -0xc(%rbp),%rcx
lea    0x2e27(%rip),%rax
cmpl   $0x1,(%rax,%rcx,4)
jne    123c <main+0x10c>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1241 <main+0x111>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1214 <main+0xe4>
lea    0xe0b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xdd0(%rip),%rdi
call   1030 <system@plt>
mov    -0x10(%rbp),%esi
lea    0xe14(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xdb1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xeb4(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xeb7(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1070 <scanf@plt>
lea    0xf04(%rip),%rdi
call   1040 <puts@plt>
lea    0xe9d(%rip),%rdi
call   1050 <system@plt>
mov    0xc(%rsp),%eax
test   %eax,%eax
je     11c4 <main+0x74>
lea    0x2ee5(%rip),%rcx
nopl   0x0(%rax,%rax,1)
mov    %eax,%edx
shr    $0x1f,%eax
add    %edx,%eax
mov    %eax,%esi
and    $0xfffffffe,%esi
mov    %edx,%edi
sub    %esi,%edi
mov    %edi,(%rcx)
sar    %eax
add    $0x1,%edx
add    $0x4,%rcx
cmp    $0x2,%edx
ja     11a0 <main+0x50>
mov    %eax,0xc(%rsp)
lea    0xe61(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x2ec4(%rip),%esi
lea    0xe6e(%rip),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x2ea9(%rip),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x2e95(%rip),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x2e81(%rip),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x2e6d(%rip),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x2e59(%rip),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x2e45(%rip),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x2e31(%rip),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
movdqa 0xd9f(%rip),%xmm0
movdqa 0x2e27(%rip),%xmm1
pcmpeqd %xmm0,%xmm1
pcmpeqd 0x2e0b(%rip),%xmm0
packssdw %xmm1,%xmm0
packsswb %xmm0,%xmm0
pmovmskb %xmm0,%eax
mov    %eax,%ecx
shr    %cl
and    $0x55,%cl
sub    %cl,%al
mov    %eax,%ecx
and    $0x33,%cl
shr    $0x2,%al
and    $0x33,%al
add    %cl,%al
mov    %eax,%ecx
shr    $0x4,%cl
add    %al,%cl
and    $0xf,%cl
movzbl %cl,%ebx
lea    0xdf4(%rip),%rdi
call   1040 <puts@plt>
lea    0xd6e(%rip),%rdi
call   1050 <system@plt>
lea    0xd8f(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@main.array = internal global [8 x i32] zeroinitializer
@.str = [17 x i8] c"Enter a number: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [32 x i8] c"Processing your number........\0A\00"
@.str.3 = [8 x i8] c"sleep 3\00"
@.str.4 = [33 x i8] c"\0A\0AThe number in binary form is: \00"
@.str.5 = [4 x i8] c"%d \00"
@.str.6 = [38 x i8] c"\0A\0ACounting the number of 1's........\0A\00"
@.str.7 = [46 x i8] c"\0A\0AThe number of 1's in the bit string is %d.\0A\00"
@.str.8 = [2 x i8] c"\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 ([17 x i8], [17 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 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 @system(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
br label %9
9: ; preds = %12, %0
%10 = load i32, i32* %2
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %22
12: ; preds = %9
%13 = load i32, i32* %2
%14 = srem i32 %13, 2
%15 = load i32, i32* %3
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [8 x i32], [8 x i32]* @main.array, i64 0, i64 %16
store i32 %14, i32* %17
%18 = load i32, i32* %3
%19 = add nsw i32 %18, 1
store i32 %19, i32* %3
%20 = load i32, i32* %2
%21 = sdiv i32 %20, 2
store i32 %21, i32* %2
br label %9
22: ; preds = %9
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0))
store i32 7, i32* %3
br label %24
24: ; preds = %33, %22
%25 = load i32, i32* %3
%26 = icmp sge i32 %25, 0
br i1 %26, label %27, label %36
27: ; preds = %24
%28 = load i32, i32* %3
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [8 x i32], [8 x i32]* @main.array, i64 0, i64 %29
%31 = load i32, i32* %30
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %31)
br label %33
33: ; preds = %27
%34 = load i32, i32* %3
%35 = add nsw i32 %34, -1
store i32 %35, i32* %3
br label %24
36: ; preds = %24
store i32 0, i32* %3
br label %37
37: ; preds = %50, %36
%38 = load i32, i32* %3
%39 = icmp slt i32 %38, 8
br i1 %39, label %40, label %53
40: ; preds = %37
%41 = load i32, i32* %3
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [8 x i32], [8 x i32]* @main.array, i64 0, i64 %42
%44 = load i32, i32* %43
%45 = icmp eq i32 %44, 1
br i1 %45, label %46, label %49
46: ; preds = %40
%47 = load i32, i32* %4
%48 = add nsw i32 %47, 1
store i32 %48, i32* %4
br label %49
49: ; preds = %46, %40
br label %50
50: ; preds = %49
%51 = load i32, i32* %3
%52 = add nsw i32 %51, 1
store i32 %52, i32* %3
br label %37
53: ; preds = %37
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.6, i64 0, i64 0))
%55 = call i32 @system(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%56 = load i32, i32* %4
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.7, i64 0, i64 0), i32 %56)
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@main.array = internal unnamed_addr global [8 x i32] zeroinitializer
@.str = [17 x i8] c"Enter a number: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [8 x i8] c"sleep 3\00"
@.str.4 = [33 x i8] c"\0A\0AThe number in binary form is: \00"
@.str.5 = [4 x i8] c"%d \00"
@.str.7 = [46 x i8] c"\0A\0AThe number of 1's in the bit string is %d.\0A\00"
@str = [31 x i8] c"Processing your number........\00"
@str.9 = [37 x i8] c"\0A\0ACounting the number of 1's........\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 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 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str, i64 0, i64 0))
%6 = call i32 @system(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%7 = load i32, i32* %1
%8 = icmp eq i32 %7, 0
br i1 %8, label %19, label %9
9: ; preds = %0, %9
%10 = phi i64 [ %14, %9 ], [ 0, %0 ]
%11 = phi i32 [ %15, %9 ], [ %7, %0 ]
%12 = srem i32 %11, 2
%13 = getelementptr inbounds [8 x i32], [8 x i32]* @main.array, i64 0, i64 %10
store i32 %12, i32* %13
%14 = add nuw i64 %10, 1
%15 = sdiv i32 %11, 2
%16 = add i32 %11, 1
%17 = icmp ult i32 %16, 3
br i1 %17, label %18, label %9
18: ; preds = %9
store i32 %15, i32* %1
br label %19
19: ; preds = %18, %0
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0))
%21 = load i32, i32* getelementptr inbounds ([8 x i32], [8 x i32]* @main.array, i64 0, i64 7)
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %21)
%23 = load i32, i32* getelementptr inbounds ([8 x i32], [8 x i32]* @main.array, i64 0, i64 6)
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %23)
%25 = load i32, i32* getelementptr inbounds ([8 x i32], [8 x i32]* @main.array, i64 0, i64 5)
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %25)
%27 = load i32, i32* getelementptr inbounds ([8 x i32], [8 x i32]* @main.array, i64 0, i64 4)
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %27)
%29 = load i32, i32* getelementptr inbounds ([8 x i32], [8 x i32]* @main.array, i64 0, i64 3)
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %29)
%31 = load i32, i32* getelementptr inbounds ([8 x i32], [8 x i32]* @main.array, i64 0, i64 2)
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %31)
%33 = load i32, i32* getelementptr inbounds ([8 x i32], [8 x i32]* @main.array, i64 0, i64 1)
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %33)
%35 = load i32, i32* getelementptr inbounds ([8 x i32], [8 x i32]* @main.array, i64 0, i64 0)
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %35)
%37 = load <8 x i32>, <8 x i32>* bitcast ([8 x i32]* @main.array to <8 x i32>*)
%38 = icmp eq <8 x i32> %37, <i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1>
%39 = bitcast <8 x i1> %38 to i8
%40 = call i8 @llvm.ctpop.i8(i8 %39)
%41 = zext i8 %40 to i32
%42 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.9, i64 0, i64 0))
%43 = call i32 @system(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.7, i64 0, i64 0), i32 %41)
%45 = call i32 @putchar(i32 10)
ret i32 0
}