#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 cc608_parity(unsigned int);
void cc608_build_parity_table(int *parity_table) {
  unsigned int byte;
  int parity_v;
  for (byte = 0; byte <= 127; byte++) {
    parity_v = cc608_parity(byte);
    parity_table[byte] = parity_v;
    parity_table[byte | 0x80] = !parity_v;
  }
}


x86 assembly (clang, -O0):
<cc608_build_parity_table>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x7f,-0xc(%rbp)
ja     1173 <cc608_build_parity_table+0x63>
mov    -0xc(%rbp),%edi
call   1030 <cc608_parity@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%edx
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
mov    %edx,(%rax,%rcx,4)
cmpl   $0x0,-0x10(%rbp)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edx
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
or     $0x80,%ecx
mov    %ecx,%ecx
mov    %edx,(%rax,%rcx,4)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1123 <cc608_build_parity_table+0x13>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cc608_build_parity_table>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    %ebx,%edi
call   1030 <cc608_parity@plt>
mov    %eax,(%r14,%rbx,4)
xor    %ecx,%ecx
test   %eax,%eax
sete   %cl
mov    %ebx,%eax
shl    $0x2,%rax
or     $0x200,%rax
mov    %ecx,(%r14,%rax,1)
add    $0x1,%rbx
cmp    $0x80,%rbx
jne    1120 <cc608_build_parity_table+0x10>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @cc608_build_parity_table(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
store i32* %0, i32** %2
store i32 0, i32* %3
br label %5
5: ; preds = %25, %1
%6 = load i32, i32* %3
%7 = icmp ule i32 %6, 127
br i1 %7, label %8, label %28
8: ; preds = %5
%9 = load i32, i32* %3
%10 = call i32 @cc608_parity(i32 %9)
store i32 %10, i32* %4
%11 = load i32, i32* %4
%12 = load i32*, i32** %2
%13 = load i32, i32* %3
%14 = zext i32 %13 to i64
%15 = getelementptr inbounds i32, i32* %12, i64 %14
store i32 %11, i32* %15
%16 = load i32, i32* %4
%17 = icmp ne i32 %16, 0
%18 = xor i1 %17, true
%19 = zext i1 %18 to i32
%20 = load i32*, i32** %2
%21 = load i32, i32* %3
%22 = or i32 %21, 128
%23 = zext i32 %22 to i64
%24 = getelementptr inbounds i32, i32* %20, i64 %23
store i32 %19, i32* %24
br label %25
25: ; preds = %8
%26 = load i32, i32* %3
%27 = add i32 %26, 1
store i32 %27, i32* %3
br label %5
28: ; preds = %5
ret void
}

LLVM IR (-O2):
define void @cc608_build_parity_table(i32* nocapture writeonly %0) {
br label %2
2: ; preds = %1, %2
%3 = phi i64 [ 0, %1 ], [ %12, %2 ]
%4 = trunc i64 %3 to i32
%5 = tail call i32 @cc608_parity(i32 %4)
%6 = getelementptr inbounds i32, i32* %0, i64 %3
store i32 %5, i32* %6
%7 = icmp eq i32 %5, 0
%8 = zext i1 %7 to i32
%9 = and i64 %3, 4294967167
%10 = or i64 %9, 128
%11 = getelementptr inbounds i32, i32* %0, i64 %10
store i32 %8, i32* %11
%12 = add nuw nsw i64 %3, 1
%13 = icmp eq i64 %12, 128
br i1 %13, label %14, label %2
14: ; preds = %2
ret void
}