#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*/ exit(int);
int pow(int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int i, x;
  int count = 0;
  scanf("%d", &x);
  if (x >= pow(2, 8)) {
    printf("Input data must be in the range from 1 to (2^8)-1.\n");
    exit(1);
  }
  for (i = 0; i < 8; i++) {
    if (x & 1) {
      count++;
    }
    x >>= 1;
  }
  printf("%d\n", count);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
lea    0xea3(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    $0x2,%edi
mov    $0x8,%esi
call   1050 <pow@plt>
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
cmp    %ecx,%eax
jl     11a0 <main+0x60>
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x8,-0x8(%rbp)
jge    11e0 <main+0xa0>
mov    -0xc(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     11c9 <main+0x89>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
sar    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11a7 <main+0x67>
mov    -0x10(%rbp),%esi
lea    0xe4d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xea4(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%ebx
mov    $0x2,%edi
mov    $0x8,%esi
call   1060 <pow@plt>
cmp    %eax,%ebx
jge    11e8 <main+0x98>
mov    0xc(%rsp),%eax
mov    %eax,%ecx
and    $0x1,%ecx
mov    %eax,%edx
shr    %edx
and    $0x1,%edx
add    %ecx,%edx
mov    %eax,%ecx
shr    $0x2,%ecx
and    $0x1,%ecx
add    %edx,%ecx
mov    %eax,%edx
shr    $0x3,%edx
and    $0x1,%edx
add    %ecx,%edx
mov    %eax,%ecx
shr    $0x4,%ecx
and    $0x1,%ecx
add    %edx,%ecx
mov    %eax,%edx
shr    $0x5,%edx
and    $0x1,%edx
add    %ecx,%edx
mov    %eax,%ecx
shr    $0x6,%ecx
and    $0x1,%ecx
add    %edx,%ecx
mov    %eax,%esi
shr    $0x7,%esi
and    $0x1,%esi
add    %ecx,%esi
sar    $0x8,%eax
mov    %eax,0xc(%rsp)
lea    0xe2a(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret
lea    0xe18(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [52 x i8] c"Input data must be in the range from 1 to (2^8)-1.\0A\00"
@.str.2 = [4 x i8] c"%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* %4
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%6 = load i32, i32* %3
%7 = call i32 @pow(i32 2, i32 8)
%8 = icmp sge i32 %6, %7
br i1 %8, label %9, label %12
9: ; preds = %0
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 @exit(i32 1)
unreachable
12: ; preds = %0
store i32 0, i32* %2
br label %13
13: ; preds = %26, %12
%14 = load i32, i32* %2
%15 = icmp slt i32 %14, 8
br i1 %15, label %16, label %29
16: ; preds = %13
%17 = load i32, i32* %3
%18 = and i32 %17, 1
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %16
%21 = load i32, i32* %4
%22 = add nsw i32 %21, 1
store i32 %22, i32* %4
br label %23
23: ; preds = %20, %16
%24 = load i32, i32* %3
%25 = ashr i32 %24, 1
store i32 %25, i32* %3
br label %26
26: ; preds = %23
%27 = load i32, i32* %2
%28 = add nsw i32 %27, 1
store i32 %28, i32* %2
br label %13
29: ; preds = %13
%30 = load i32, i32* %4
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %30)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.2 = [4 x i8] c"%d\0A\00"
@str = [51 x i8] c"Input data must be in the range from 1 to (2^8)-1.\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%4 = load i32, i32* %1
%5 = call i32 @pow(i32 2, i32 8)
%6 = icmp slt i32 %4, %5
br i1 %6, label %7, label %33
7: ; preds = %0
%8 = load i32, i32* %1
%9 = and i32 %8, 1
%10 = lshr i32 %8, 1
%11 = and i32 %10, 1
%12 = add nuw nsw i32 %11, %9
%13 = lshr i32 %8, 2
%14 = and i32 %13, 1
%15 = add nuw nsw i32 %14, %12
%16 = lshr i32 %8, 3
%17 = and i32 %16, 1
%18 = add nuw nsw i32 %17, %15
%19 = lshr i32 %8, 4
%20 = and i32 %19, 1
%21 = add nuw nsw i32 %20, %18
%22 = lshr i32 %8, 5
%23 = and i32 %22, 1
%24 = add nuw nsw i32 %23, %21
%25 = lshr i32 %8, 6
%26 = and i32 %25, 1
%27 = add nuw nsw i32 %26, %24
%28 = lshr i32 %8, 7
%29 = and i32 %28, 1
%30 = add nuw nsw i32 %29, %27
%31 = ashr i32 %8, 8
store i32 %31, i32* %1
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %30)
ret i32 0
33: ; preds = %0
%34 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @str, i64 0, i64 0))
%35 = call i32 @exit(i32 1)
unreachable
}