#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 */
typedef int uint8_t;
typedef int uint16_t;

/* Variables and functions */
int parity(int);
void word2bin(uint16_t w, uint8_t *b) {
  for (int i = 2; i >= 0; i--) {
    b[i] = (w & 0b00111111) | 0b01000000;
    b[i] |= parity(b[i]) << 7;
    w >>= 6;
  }
}


x86 assembly (clang, -O0):
<word2bin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x2,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jl     117e <word2bin+0x6e>
mov    -0x4(%rbp),%edx
and    $0x3f,%edx
or     $0x40,%edx
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
call   1030 <parity@plt>
mov    %eax,%edx
shl    $0x7,%edx
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
or     (%rax,%rcx,4),%edx
mov    %edx,(%rax,%rcx,4)
mov    -0x4(%rbp),%eax
sar    $0x6,%eax
mov    %eax,-0x4(%rbp)
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    1126 <word2bin+0x16>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<word2bin>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
and    $0x3f,%edi
or     $0x40,%edi
mov    %edi,0x8(%rsi)
call   1030 <parity@plt>
shl    $0x7,%eax
or     %eax,0x8(%rbx)
mov    %ebp,%edi
shr    $0x6,%edi
and    $0x3f,%edi
or     $0x40,%edi
mov    %edi,0x4(%rbx)
call   1030 <parity@plt>
shl    $0x7,%eax
or     %eax,0x4(%rbx)
shr    $0xc,%ebp
and    $0x3f,%ebp
or     $0x40,%ebp
mov    %ebp,(%rbx)
mov    %ebp,%edi
call   1030 <parity@plt>
shl    $0x7,%eax
or     %eax,(%rbx)
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define void @word2bin(i32 %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32
store i32 %0, i32* %3
store i32* %1, i32** %4
store i32 2, i32* %5
br label %6
6: ; preds = %32, %2
%7 = load i32, i32* %5
%8 = icmp sge i32 %7, 0
br i1 %8, label %9, label %35
9: ; preds = %6
%10 = load i32, i32* %3
%11 = and i32 %10, 63
%12 = or i32 %11, 64
%13 = load i32*, i32** %4
%14 = load i32, i32* %5
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i32, i32* %13, i64 %15
store i32 %12, i32* %16
%17 = load i32*, i32** %4
%18 = load i32, i32* %5
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i32, i32* %17, i64 %19
%21 = load i32, i32* %20
%22 = call i32 @parity(i32 %21)
%23 = shl i32 %22, 7
%24 = load i32*, i32** %4
%25 = load i32, i32* %5
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i32, i32* %24, i64 %26
%28 = load i32, i32* %27
%29 = or i32 %28, %23
store i32 %29, i32* %27
%30 = load i32, i32* %3
%31 = ashr i32 %30, 6
store i32 %31, i32* %3
br label %32
32: ; preds = %9
%33 = load i32, i32* %5
%34 = add nsw i32 %33, -1
store i32 %34, i32* %5
br label %6
35: ; preds = %6
ret void
}

LLVM IR (-O2):
define void @word2bin(i32 %0, i32* nocapture %1) {
%3 = and i32 %0, 63
%4 = or i32 %3, 64
%5 = getelementptr inbounds i32, i32* %1, i64 2
store i32 %4, i32* %5
%6 = tail call i32 @parity(i32 %4)
%7 = shl i32 %6, 7
%8 = load i32, i32* %5
%9 = or i32 %8, %7
store i32 %9, i32* %5
%10 = lshr i32 %0, 6
%11 = and i32 %10, 63
%12 = or i32 %11, 64
%13 = getelementptr inbounds i32, i32* %1, i64 1
store i32 %12, i32* %13
%14 = tail call i32 @parity(i32 %12)
%15 = shl i32 %14, 7
%16 = load i32, i32* %13
%17 = or i32 %16, %15
store i32 %17, i32* %13
%18 = lshr i32 %0, 12
%19 = and i32 %18, 63
%20 = or i32 %19, 64
store i32 %20, i32* %1
%21 = tail call i32 @parity(i32 %20)
%22 = shl i32 %21, 7
%23 = load i32, i32* %1
%24 = or i32 %23, %22
store i32 %24, i32* %1
ret void
}