#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 count_ones(unsigned char);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  unsigned char c_ones_mod2[256];
  unsigned int b;
  for (b = 0; b < 256; b++)
    c_ones_mod2[b] = count_ones((unsigned char)b) % 2;
  printf("unsigned char c_ones_mod2[] = {\n    ");
  for (b = 0; b < 256; b++) {
    printf("%1u", c_ones_mod2[b]);
    if (b == 255)
      printf("\n");
    else if (((b + 1) % 16) == 0)
      printf(",\n    ");
    else
      printf(", ");
  }
  printf("};\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x114(%rbp)
cmpl   $0x100,-0x114(%rbp)
jae    1185 <main+0x65>
mov    -0x114(%rbp),%eax
movzbl %al,%edi
call   1030 <count_ones@plt>
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %dl,%cl
mov    -0x114(%rbp),%eax
mov    %cl,-0x110(%rbp,%rax,1)
mov    -0x114(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x114(%rbp)
jmp    113c <main+0x1c>
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x114(%rbp)
cmpl   $0x100,-0x114(%rbp)
jae    1240 <main+0x120>
mov    -0x114(%rbp),%eax
movzbl -0x110(%rbp,%rax,1),%esi
ff
lea    0xe63(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0xff,-0x114(%rbp)
jne    11ec <main+0xcc>
lea    0xe55(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1227 <main+0x107>
mov    -0x114(%rbp),%eax
add    $0x1,%eax
and    $0xf,%eax
cmp    $0x0,%eax
jne    1214 <main+0xf4>
lea    0xe21(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1222 <main+0x102>
lea    0xe15(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1227 <main+0x107>
jmp    122c <main+0x10c>
mov    -0x114(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x114(%rbp)
jmp    119d <main+0x7d>
lea    0xdec(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x108,%rsp
xor    %ebx,%ebx
movzbl %bl,%edi
call   1030 <count_ones@plt>
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
and    $0xfe,%ecx
sub    %ecx,%eax
mov    %al,(%rsp,%rbx,1)
add    $0x1,%rbx
cmp    $0x100,%rbx
jne    1150 <main+0x10>
lea    0xe82(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0xffffffffffffff00,%rbx
lea    0xe92(%rip),%r14
lea    0xe8f(%rip),%r15
lea    0xe8f(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movzbl 0x100(%rsp,%rbx,1),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
cmp    $0xffffffffffffffff,%rbx
je     11e5 <main+0xa5>
lea    0x101(%rbx),%eax
test   $0xf,%al
mov    %r12,%rdi
cmove  %r15,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
inc    %rbx
jne    11b0 <main+0x70>
jmp    11ef <main+0xaf>
mov    $0xa,%edi
call   1040 <putchar@plt>
lea    0xe3d(%rip),%rdi
call   1050 <puts@plt>
xor    %eax,%eax
add    $0x108,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [37 x i8] c"unsigned char c_ones_mod2[] = {\0A \00"
@.str.1 = [4 x i8] c"%1u\00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [7 x i8] c",\0A \00"
@.str.4 = [3 x i8] c", \00"
@.str.5 = [4 x i8] c"};\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [256 x i8]
%3 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
br label %4
4: ; preds = %16, %0
%5 = load i32, i32* %3
%6 = icmp ult i32 %5, 256
br i1 %6, label %7, label %19
7: ; preds = %4
%8 = load i32, i32* %3
%9 = trunc i32 %8 to i8
%10 = call i32 @count_ones(i8 zeroext %9)
%11 = srem i32 %10, 2
%12 = trunc i32 %11 to i8
%13 = load i32, i32* %3
%14 = zext i32 %13 to i64
%15 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 %14
store i8 %12, i8* %15
br label %16
16: ; preds = %7
%17 = load i32, i32* %3
%18 = add i32 %17, 1
store i32 %18, i32* %3
br label %4
19: ; preds = %4
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %21
21: ; preds = %46, %19
%22 = load i32, i32* %3
%23 = icmp ult i32 %22, 256
br i1 %23, label %24, label %49
24: ; preds = %21
%25 = load i32, i32* %3
%26 = zext i32 %25 to i64
%27 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 %26
%28 = load i8, i8* %27
%29 = zext i8 %28 to i32
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %29)
%31 = load i32, i32* %3
%32 = icmp eq i32 %31, 255
br i1 %32, label %33, label %35
33: ; preds = %24
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %45
35: ; preds = %24
%36 = load i32, i32* %3
%37 = add i32 %36, 1
%38 = urem i32 %37, 16
%39 = icmp eq i32 %38, 0
br i1 %39, label %40, label %42
40: ; preds = %35
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
br label %44
42: ; preds = %35
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
br label %44
44: ; preds = %42, %40
br label %45
45: ; preds = %44, %33
br label %46
46: ; preds = %45
%47 = load i32, i32* %3
%48 = add i32 %47, 1
store i32 %48, i32* %3
br label %21
49: ; preds = %21
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [37 x i8] c"unsigned char c_ones_mod2[] = {\0A \00"
@.str.1 = [4 x i8] c"%1u\00"
@.str.3 = [7 x i8] c",\0A \00"
@.str.4 = [3 x i8] c", \00"
@str = [3 x i8] c"};\00"
define i32 @main() {
%1 = alloca [256 x i8]
%2 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
br label %3
3: ; preds = %0, %3
%4 = phi i64 [ 0, %0 ], [ %10, %3 ]
%5 = trunc i64 %4 to i8
%6 = tail call i32 @count_ones(i8 zeroext %5)
%7 = srem i32 %6, 2
%8 = trunc i32 %7 to i8
%9 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 %4
store i8 %8, i8* %9
%10 = add nuw nsw i64 %4, 1
%11 = icmp eq i64 %10, 256
br i1 %11, label %12, label %3
12: ; preds = %3
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
br label %14
14: ; preds = %12, %23
%15 = phi i64 [ 0, %12 ], [ %24, %23 ]
%16 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 %15
%17 = load i8, i8* %16
%18 = zext i8 %17 to i32
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %18)
%20 = icmp eq i64 %15, 255
br i1 %20, label %21, label %23
21: ; preds = %14
%22 = tail call i32 @putchar(i32 10)
br label %30
23: ; preds = %14
%24 = add nuw nsw i64 %15, 1
%25 = and i64 %24, 15
%26 = icmp eq i64 %25, 0
%27 = select i1 %26, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0)
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %27)
%29 = icmp eq i64 %24, 256
br i1 %29, label %30, label %14
30: ; preds = %23, %21
%31 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str, i64 0, i64 0))
ret i32 0
}