#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*/ emit_bit(int);
void emit_byte(int val) {
  int i, parity = 1;
  emit_bit(0);
  for (i = 0; i < 8; i++, val >>= 1) {
    parity += val & 1;
    emit_bit(val & 1);
  }
  emit_bit(parity & 1);
  emit_bit(1);
  emit_bit(1);
  emit_bit(1);
  emit_bit(1);
}


x86 assembly (clang, -O0):
<emit_byte>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x1,-0xc(%rbp)
xor    %edi,%edi
call   1030 <emit_bit@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x8,-0x8(%rbp)
jge    1168 <emit_byte+0x58>
mov    -0x4(%rbp),%eax
and    $0x1,%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%edi
and    $0x1,%edi
call   1030 <emit_bit@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
sar    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1130 <emit_byte+0x20>
mov    -0xc(%rbp),%edi
and    $0x1,%edi
call   1030 <emit_bit@plt>
mov    $0x1,%edi
call   1030 <emit_bit@plt>
mov    $0x1,%edi
call   1030 <emit_bit@plt>
mov    $0x1,%edi
call   1030 <emit_bit@plt>
mov    $0x1,%edi
call   1030 <emit_bit@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<emit_byte>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edi,%r14d
xor    %edi,%edi
call   1030 <emit_bit@plt>
mov    %r14d,%edi
and    $0x1,%edi
mov    %r14d,%ebx
shr    %ebx
and    $0x1,%ebx
lea    (%rdi,%rbx,1),%r15d
call   1030 <emit_bit@plt>
mov    %r14d,%ebp
shr    $0x2,%ebp
and    $0x1,%ebp
add    %ebp,%r15d
mov    %ebx,%edi
call   1030 <emit_bit@plt>
mov    %r14d,%ebx
shr    $0x3,%ebx
and    $0x1,%ebx
add    %ebx,%r15d
mov    %ebp,%edi
call   1030 <emit_bit@plt>
mov    %r14d,%ebp
sar    $0x4,%ebp
add    %ebp,%r15d
mov    %ebx,%edi
call   1030 <emit_bit@plt>
and    $0x1,%ebp
mov    %r14d,%ebx
sar    $0x5,%ebx
add    %ebx,%r15d
mov    %ebp,%edi
call   1030 <emit_bit@plt>
and    $0x1,%ebx
mov    %r14d,%ebp
sar    $0x6,%ebp
add    %ebp,%r15d
mov    %ebx,%edi
call   1030 <emit_bit@plt>
and    $0x1,%ebp
mov    %ebp,%edi
call   1030 <emit_bit@plt>
shr    $0x7,%r14d
mov    %r14d,%edi
and    $0x1,%edi
lea    (%r14,%r15,1),%ebx
add    $0x1,%ebx
call   1030 <emit_bit@plt>
and    $0x1,%ebx
mov    %ebx,%edi
call   1030 <emit_bit@plt>
mov    $0x1,%edi
call   1030 <emit_bit@plt>
mov    $0x1,%edi
call   1030 <emit_bit@plt>
mov    $0x1,%edi
call   1030 <emit_bit@plt>
mov    $0x1,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <emit_bit@plt>

LLVM IR (-O0):
define void @emit_byte(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %2
store i32 1, i32* %4
%5 = call i32 @emit_bit(i32 0)
store i32 0, i32* %3
br label %6
6: ; preds = %17, %1
%7 = load i32, i32* %3
%8 = icmp slt i32 %7, 8
br i1 %8, label %9, label %22
9: ; preds = %6
%10 = load i32, i32* %2
%11 = and i32 %10, 1
%12 = load i32, i32* %4
%13 = add nsw i32 %12, %11
store i32 %13, i32* %4
%14 = load i32, i32* %2
%15 = and i32 %14, 1
%16 = call i32 @emit_bit(i32 %15)
br label %17
17: ; preds = %9
%18 = load i32, i32* %3
%19 = add nsw i32 %18, 1
store i32 %19, i32* %3
%20 = load i32, i32* %2
%21 = ashr i32 %20, 1
store i32 %21, i32* %2
br label %6
22: ; preds = %6
%23 = load i32, i32* %4
%24 = and i32 %23, 1
%25 = call i32 @emit_bit(i32 %24)
%26 = call i32 @emit_bit(i32 1)
%27 = call i32 @emit_bit(i32 1)
%28 = call i32 @emit_bit(i32 1)
%29 = call i32 @emit_bit(i32 1)
ret void
}

LLVM IR (-O2):
define void @emit_byte(i32 %0) {
%2 = tail call i32 @emit_bit(i32 0)
%3 = and i32 %0, 1
%4 = add nuw nsw i32 %3, 1
%5 = tail call i32 @emit_bit(i32 %3)
%6 = lshr i32 %0, 1
%7 = and i32 %6, 1
%8 = add nuw nsw i32 %4, %7
%9 = tail call i32 @emit_bit(i32 %7)
%10 = lshr i32 %0, 2
%11 = and i32 %10, 1
%12 = add nuw nsw i32 %8, %11
%13 = tail call i32 @emit_bit(i32 %11)
%14 = lshr i32 %0, 3
%15 = and i32 %14, 1
%16 = add nuw nsw i32 %12, %15
%17 = tail call i32 @emit_bit(i32 %15)
%18 = ashr i32 %0, 4
%19 = and i32 %18, 1
%20 = add nsw i32 %16, %18
%21 = tail call i32 @emit_bit(i32 %19)
%22 = ashr i32 %0, 5
%23 = and i32 %22, 1
%24 = add nsw i32 %20, %22
%25 = tail call i32 @emit_bit(i32 %23)
%26 = ashr i32 %0, 6
%27 = and i32 %26, 1
%28 = add nsw i32 %24, %26
%29 = tail call i32 @emit_bit(i32 %27)
%30 = lshr i32 %0, 7
%31 = and i32 %30, 1
%32 = add nsw i32 %28, %30
%33 = tail call i32 @emit_bit(i32 %31)
%34 = and i32 %32, 1
%35 = tail call i32 @emit_bit(i32 %34)
%36 = tail call i32 @emit_bit(i32 1)
%37 = tail call i32 @emit_bit(i32 1)
%38 = tail call i32 @emit_bit(i32 1)
%39 = tail call i32 @emit_bit(i32 1)
ret void
}