#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*/ writePeriod(int);
void writeByte(unsigned int value) {
  for (int i = 0; i < 8; i++) {
    if ((value & 1) == 1) {
      writePeriod(1000);
    } else {
      writePeriod(1846);
    }
    value >>= 1;
  }
  writePeriod(545);
}


x86 assembly (clang, -O0):
<writeByte>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x8,-0x8(%rbp)
jge    116b <writeByte+0x5b>
mov    -0x4(%rbp),%eax
and    $0x1,%eax
cmp    $0x1,%eax
jne    114a <writeByte+0x3a>
mov    $0x3e8,%edi
call   1030 <writePeriod@plt>
jmp    1154 <writeByte+0x44>
mov    $0x736,%edi
call   1030 <writePeriod@plt>
mov    -0x4(%rbp),%eax
shr    $0x1,%eax
mov    %eax,-0x4(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1122 <writeByte+0x12>
mov    $0x221,%edi
call   1030 <writePeriod@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<writeByte>:
push   %rbp
push   %r14
push   %rbx
movd   %edi,%xmm0
pshufd $0x0,%xmm0,%xmm0
movdqa 0xedb(%rip),%xmm1
pand   %xmm0,%xmm1
pand   0xedf(%rip),%xmm0
pxor   %xmm2,%xmm2
pcmpeqd %xmm2,%xmm0
pcmpeqd %xmm2,%xmm1
packssdw %xmm0,%xmm1
packsswb %xmm1,%xmm1
pmovmskb %xmm1,%ebp
test   $0x80,%bpl
mov    $0x736,%ebx
mov    $0x3e8,%r14d
mov    $0x3e8,%edi
cmovne %ebx,%edi
call   1030 <writePeriod@plt>
test   $0x40,%bpl
mov    $0x3e8,%edi
cmovne %ebx,%edi
call   1030 <writePeriod@plt>
test   $0x20,%bpl
mov    $0x3e8,%edi
cmovne %ebx,%edi
call   1030 <writePeriod@plt>
test   $0x10,%bpl
mov    $0x3e8,%edi
cmovne %ebx,%edi
call   1030 <writePeriod@plt>
test   $0x8,%bpl
mov    $0x3e8,%edi
cmovne %ebx,%edi
call   1030 <writePeriod@plt>
test   $0x4,%bpl
mov    $0x3e8,%edi
cmovne %ebx,%edi
call   1030 <writePeriod@plt>
test   $0x2,%bpl
mov    $0x3e8,%edi
cmovne %ebx,%edi
call   1030 <writePeriod@plt>
test   $0x1,%bpl
cmovne %ebx,%r14d
mov    %r14d,%edi
call   1030 <writePeriod@plt>
mov    $0x221,%edi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <writePeriod@plt>

LLVM IR (-O0):
define void @writeByte(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %3
br label %4
4: ; preds = %18, %1
%5 = load i32, i32* %3
%6 = icmp slt i32 %5, 8
br i1 %6, label %7, label %21
7: ; preds = %4
%8 = load i32, i32* %2
%9 = and i32 %8, 1
%10 = icmp eq i32 %9, 1
br i1 %10, label %11, label %13
11: ; preds = %7
%12 = call i32 @writePeriod(i32 1000)
br label %15
13: ; preds = %7
%14 = call i32 @writePeriod(i32 1846)
br label %15
15: ; preds = %13, %11
%16 = load i32, i32* %2
%17 = lshr i32 %16, 1
store i32 %17, i32* %2
br label %18
18: ; preds = %15
%19 = load i32, i32* %3
%20 = add nsw i32 %19, 1
store i32 %20, i32* %3
br label %4
21: ; preds = %4
%22 = call i32 @writePeriod(i32 545)
ret void
}

LLVM IR (-O2):
define void @writeByte(i32 %0) {
%2 = insertelement <8 x i32> poison, i32 %0, i64 0
%3 = shufflevector <8 x i32> %2, <8 x i32> poison, <8 x i32> zeroinitializer
%4 = and <8 x i32> %3, <i32 128, i32 64, i32 32, i32 16, i32 8, i32 4, i32 2, i32 1>
%5 = icmp eq <8 x i32> %4, zeroinitializer
%6 = extractelement <8 x i1> %5, i64 7
%7 = select i1 %6, i32 1846, i32 1000
%8 = tail call i32 @writePeriod(i32 %7)
%9 = extractelement <8 x i1> %5, i64 6
%10 = select i1 %9, i32 1846, i32 1000
%11 = tail call i32 @writePeriod(i32 %10)
%12 = extractelement <8 x i1> %5, i64 5
%13 = select i1 %12, i32 1846, i32 1000
%14 = tail call i32 @writePeriod(i32 %13)
%15 = extractelement <8 x i1> %5, i64 4
%16 = select i1 %15, i32 1846, i32 1000
%17 = tail call i32 @writePeriod(i32 %16)
%18 = extractelement <8 x i1> %5, i64 3
%19 = select i1 %18, i32 1846, i32 1000
%20 = tail call i32 @writePeriod(i32 %19)
%21 = extractelement <8 x i1> %5, i64 2
%22 = select i1 %21, i32 1846, i32 1000
%23 = tail call i32 @writePeriod(i32 %22)
%24 = extractelement <8 x i1> %5, i64 1
%25 = select i1 %24, i32 1846, i32 1000
%26 = tail call i32 @writePeriod(i32 %25)
%27 = extractelement <8 x i1> %5, i64 0
%28 = select i1 %27, i32 1846, i32 1000
%29 = tail call i32 @writePeriod(i32 %28)
%30 = tail call i32 @writePeriod(i32 545)
ret void
}