#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*/ WriteFSK(int);
int /*<<< orphan*/ printf(char *, unsigned char);
void WriteByteManchester(unsigned char Byte, char flip) {
  unsigned char ByteFlip;
  if (flip == 1)
    ByteFlip = Byte ^ 0xFF;
  else
    ByteFlip = Byte;
  printf("%x", ByteFlip);
  for (int i = 7; i >= 0; i--) {
    if (((ByteFlip >> i) & 0x1) == 0) {
      WriteFSK(0);
      WriteFSK(1);
    } else {
      WriteFSK(1);
      WriteFSK(0);
    }
  }
}


x86 assembly (clang, -O0):
<WriteByteManchester>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %sil,%al
mov    %dil,%cl
mov    %cl,-0x1(%rbp)
mov    %al,-0x2(%rbp)
movsbl -0x2(%rbp),%eax
cmp    $0x1,%eax
jne    1152 <WriteByteManchester+0x32>
movzbl -0x1(%rbp),%eax
xor    $0xff,%eax
mov    %al,-0x3(%rbp)
jmp    1158 <WriteByteManchester+0x38>
mov    -0x1(%rbp),%al
mov    %al,-0x3(%rbp)
lea    0xea1(%rip),%rdi
movzbl -0x3(%rbp),%esi
call   1030 <printf@plt>
movl   $0x7,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jl     11c8 <WriteByteManchester+0xa8>
movzbl -0x3(%rbp),%eax
mov    -0x8(%rbp),%ecx
sar    %cl,%eax
and    $0x1,%eax
cmp    $0x0,%eax
jne    11a4 <WriteByteManchester+0x84>
xor    %edi,%edi
call   1040 <WriteFSK@plt>
mov    $0x1,%edi
call   1040 <WriteFSK@plt>
jmp    11b5 <WriteByteManchester+0x95>
mov    $0x1,%edi
call   1040 <WriteFSK@plt>
xor    %edi,%edi
call   1040 <WriteFSK@plt>
jmp    11ba <WriteByteManchester+0x9a>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
jmp    116f <WriteByteManchester+0x4f>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<WriteByteManchester>:
push   %rbp
push   %rbx
push   %rax
cmp    $0x1,%sil
sete   %al
neg    %al
xor    %dil,%al
movzbl %al,%ebx
lea    0xec7(%rip),%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
mov    %ebx,%edi
shr    $0x7,%edi
mov    %edi,%ebp
xor    $0x1,%ebp
call   1040 <WriteFSK@plt>
mov    %ebp,%edi
call   1040 <WriteFSK@plt>
mov    %ebx,%edi
and    $0x40,%edi
shr    $0x6,%edi
mov    %edi,%ebp
xor    $0x1,%ebp
call   1040 <WriteFSK@plt>
mov    %ebp,%edi
call   1040 <WriteFSK@plt>
mov    %ebx,%edi
and    $0x20,%edi
shr    $0x5,%edi
mov    %edi,%ebp
xor    $0x1,%ebp
call   1040 <WriteFSK@plt>
mov    %ebp,%edi
call   1040 <WriteFSK@plt>
mov    %ebx,%edi
and    $0x10,%edi
shr    $0x4,%edi
mov    %edi,%ebp
xor    $0x1,%ebp
call   1040 <WriteFSK@plt>
mov    %ebp,%edi
call   1040 <WriteFSK@plt>
mov    %ebx,%edi
and    $0x8,%edi
shr    $0x3,%edi
mov    %edi,%ebp
xor    $0x1,%ebp
call   1040 <WriteFSK@plt>
mov    %ebp,%edi
call   1040 <WriteFSK@plt>
mov    %ebx,%edi
and    $0x4,%edi
shr    $0x2,%edi
mov    %edi,%ebp
xor    $0x1,%ebp
call   1040 <WriteFSK@plt>
mov    %ebp,%edi
call   1040 <WriteFSK@plt>
mov    %ebx,%edi
and    $0x2,%edi
shr    %edi
mov    %edi,%ebp
xor    $0x1,%ebp
call   1040 <WriteFSK@plt>
mov    %ebp,%edi
call   1040 <WriteFSK@plt>
and    $0x1,%ebx
mov    %ebx,%ebp
xor    $0x1,%ebp
mov    %ebx,%edi
call   1040 <WriteFSK@plt>
mov    %ebp,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <WriteFSK@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"%x\00"
define void @WriteByteManchester(i8 zeroext %0, i8 signext %1) {
%3 = alloca i8
%4 = alloca i8
%5 = alloca i8
%6 = alloca i32
store i8 %0, i8* %3
store i8 %1, i8* %4
%7 = load i8, i8* %4
%8 = sext i8 %7 to i32
%9 = icmp eq i32 %8, 1
br i1 %9, label %10, label %15
10: ; preds = %2
%11 = load i8, i8* %3
%12 = zext i8 %11 to i32
%13 = xor i32 %12, 255
%14 = trunc i32 %13 to i8
store i8 %14, i8* %5
br label %17
15: ; preds = %2
%16 = load i8, i8* %3
store i8 %16, i8* %5
br label %17
17: ; preds = %15, %10
%18 = load i8, i8* %5
%19 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 zeroext %18)
store i32 7, i32* %6
br label %20
20: ; preds = %37, %17
%21 = load i32, i32* %6
%22 = icmp sge i32 %21, 0
br i1 %22, label %23, label %40
23: ; preds = %20
%24 = load i8, i8* %5
%25 = zext i8 %24 to i32
%26 = load i32, i32* %6
%27 = ashr i32 %25, %26
%28 = and i32 %27, 1
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %33
30: ; preds = %23
%31 = call i32 @WriteFSK(i32 0)
%32 = call i32 @WriteFSK(i32 1)
br label %36
33: ; preds = %23
%34 = call i32 @WriteFSK(i32 1)
%35 = call i32 @WriteFSK(i32 0)
br label %36
36: ; preds = %33, %30
br label %37
37: ; preds = %36
%38 = load i32, i32* %6
%39 = add nsw i32 %38, -1
store i32 %39, i32* %6
br label %20
40: ; preds = %20
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%x\00"
define void @WriteByteManchester(i8 zeroext %0, i8 signext %1) {
%3 = icmp eq i8 %1, 1
%4 = sext i1 %3 to i8
%5 = xor i8 %4, %0
%6 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 zeroext %5)
%7 = zext i8 %5 to i32
%8 = lshr i32 %7, 7
%9 = lshr i32 %7, 7
%10 = xor i32 %9, 1
%11 = tail call i32 @WriteFSK(i32 %8)
%12 = tail call i32 @WriteFSK(i32 %10)
%13 = and i32 %7, 64
%14 = lshr exact i32 %13, 6
%15 = lshr exact i32 %13, 6
%16 = xor i32 %15, 1
%17 = tail call i32 @WriteFSK(i32 %14)
%18 = tail call i32 @WriteFSK(i32 %16)
%19 = and i32 %7, 32
%20 = lshr exact i32 %19, 5
%21 = lshr exact i32 %19, 5
%22 = xor i32 %21, 1
%23 = tail call i32 @WriteFSK(i32 %20)
%24 = tail call i32 @WriteFSK(i32 %22)
%25 = and i32 %7, 16
%26 = lshr exact i32 %25, 4
%27 = lshr exact i32 %25, 4
%28 = xor i32 %27, 1
%29 = tail call i32 @WriteFSK(i32 %26)
%30 = tail call i32 @WriteFSK(i32 %28)
%31 = and i32 %7, 8
%32 = lshr exact i32 %31, 3
%33 = lshr exact i32 %31, 3
%34 = xor i32 %33, 1
%35 = tail call i32 @WriteFSK(i32 %32)
%36 = tail call i32 @WriteFSK(i32 %34)
%37 = and i32 %7, 4
%38 = lshr exact i32 %37, 2
%39 = lshr exact i32 %37, 2
%40 = xor i32 %39, 1
%41 = tail call i32 @WriteFSK(i32 %38)
%42 = tail call i32 @WriteFSK(i32 %40)
%43 = and i32 %7, 2
%44 = lshr exact i32 %43, 1
%45 = lshr exact i32 %43, 1
%46 = xor i32 %45, 1
%47 = tail call i32 @WriteFSK(i32 %44)
%48 = tail call i32 @WriteFSK(i32 %46)
%49 = and i32 %7, 1
%50 = xor i32 %49, 1
%51 = tail call i32 @WriteFSK(i32 %49)
%52 = tail call i32 @WriteFSK(i32 %50)
ret void
}