#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*/ write_0();
int /*<<< orphan*/ write_1();
void writeByte(unsigned int value) {
  value &= 0xff;
  for (int i = 0; i < 8; i++) {
    if ((value & 0x80)) {
      write_0();
    } else {
      write_1();
    }
    value *= 2;
  }
}


x86 assembly (clang, -O0):
<writeByte>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
and    $0xff,%eax
mov    %eax,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x8,-0x8(%rbp)
jge    1182 <writeByte+0x62>
mov    -0x4(%rbp),%eax
and    $0x80,%eax
cmp    $0x0,%eax
je     1164 <writeByte+0x44>
mov    $0x0,%al
call   1040 <write_0@plt>
jmp    116b <writeByte+0x4b>
mov    $0x0,%al
call   1030 <write_1@plt>
mov    -0x4(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x4(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    113d <writeByte+0x1d>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<writeByte>:
push   %rbx
mov    %edi,%ebx
xor    %eax,%eax
test   $0x80,%bl
jne    1131 <writeByte+0x11>
call   1030 <write_1@plt>
jmp    1136 <writeByte+0x16>
call   1040 <write_0@plt>
xor    %eax,%eax
test   $0x40,%bl
jne    1144 <writeByte+0x24>
call   1030 <write_1@plt>
jmp    1149 <writeByte+0x29>
call   1040 <write_0@plt>
xor    %eax,%eax
test   $0x20,%bl
jne    1157 <writeByte+0x37>
call   1030 <write_1@plt>
jmp    115c <writeByte+0x3c>
call   1040 <write_0@plt>
xor    %eax,%eax
test   $0x10,%bl
jne    116a <writeByte+0x4a>
call   1030 <write_1@plt>
jmp    116f <writeByte+0x4f>
call   1040 <write_0@plt>
xor    %eax,%eax
test   $0x8,%bl
jne    117d <writeByte+0x5d>
call   1030 <write_1@plt>
jmp    1182 <writeByte+0x62>
call   1040 <write_0@plt>
xor    %eax,%eax
test   $0x4,%bl
jne    1190 <writeByte+0x70>
call   1030 <write_1@plt>
jmp    1195 <writeByte+0x75>
call   1040 <write_0@plt>
xor    %eax,%eax
test   $0x2,%bl
jne    11a3 <writeByte+0x83>
call   1030 <write_1@plt>
jmp    11a8 <writeByte+0x88>
call   1040 <write_0@plt>
xor    %eax,%eax
test   $0x1,%bl
jne    11b5 <writeByte+0x95>
pop    %rbx
jmp    1030 <write_1@plt>
pop    %rbx
jmp    1040 <write_0@plt>

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

LLVM IR (-O2):
define void @writeByte(i32 %0) {
%2 = and i32 %0, 128
%3 = icmp eq i32 %2, 0
br i1 %3, label %6, label %4
4: ; preds = %1
%5 = tail call i32 (...) @write_0()
br label %8
6: ; preds = %1
%7 = tail call i32 (...) @write_1()
br label %8
8: ; preds = %6, %4
%9 = and i32 %0, 64
%10 = icmp eq i32 %9, 0
br i1 %10, label %13, label %11
11: ; preds = %8
%12 = tail call i32 (...) @write_0()
br label %15
13: ; preds = %8
%14 = tail call i32 (...) @write_1()
br label %15
15: ; preds = %13, %11
%16 = and i32 %0, 32
%17 = icmp eq i32 %16, 0
br i1 %17, label %20, label %18
18: ; preds = %15
%19 = tail call i32 (...) @write_0()
br label %22
20: ; preds = %15
%21 = tail call i32 (...) @write_1()
br label %22
22: ; preds = %20, %18
%23 = and i32 %0, 16
%24 = icmp eq i32 %23, 0
br i1 %24, label %27, label %25
25: ; preds = %22
%26 = tail call i32 (...) @write_0()
br label %29
27: ; preds = %22
%28 = tail call i32 (...) @write_1()
br label %29
29: ; preds = %27, %25
%30 = and i32 %0, 8
%31 = icmp eq i32 %30, 0
br i1 %31, label %34, label %32
32: ; preds = %29
%33 = tail call i32 (...) @write_0()
br label %36
34: ; preds = %29
%35 = tail call i32 (...) @write_1()
br label %36
36: ; preds = %34, %32
%37 = and i32 %0, 4
%38 = icmp eq i32 %37, 0
br i1 %38, label %41, label %39
39: ; preds = %36
%40 = tail call i32 (...) @write_0()
br label %43
41: ; preds = %36
%42 = tail call i32 (...) @write_1()
br label %43
43: ; preds = %41, %39
%44 = and i32 %0, 2
%45 = icmp eq i32 %44, 0
br i1 %45, label %48, label %46
46: ; preds = %43
%47 = tail call i32 (...) @write_0()
br label %50
48: ; preds = %43
%49 = tail call i32 (...) @write_1()
br label %50
50: ; preds = %48, %46
%51 = and i32 %0, 1
%52 = icmp eq i32 %51, 0
br i1 %52, label %55, label %53
53: ; preds = %50
%54 = tail call i32 (...) @write_0()
br label %57
55: ; preds = %50
%56 = tail call i32 (...) @write_1()
br label %57
57: ; preds = %55, %53
ret void
}