#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*/ printf(char *, unsigned int);
int /*<<< orphan*/ write_0();
int /*<<< orphan*/ write_1();
void writeByte(unsigned int value) {
  value &= 0xff;
  printf("%02x ", value);
  for (int i = 0; i < 8; i++) {
    if ((value & 0x80)) {
      write_1();
    } else {
      write_0();
    }
    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)
mov    -0x4(%rbp),%esi
lea    0xeb0(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x8,-0x8(%rbp)
jge    11a1 <writeByte+0x71>
mov    -0x4(%rbp),%eax
and    $0x80,%eax
cmp    $0x0,%eax
je     1183 <writeByte+0x53>
mov    $0x0,%al
call   1030 <write_1@plt>
jmp    118a <writeByte+0x5a>
mov    $0x0,%al
call   1050 <write_0@plt>
mov    -0x4(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x4(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    115c <writeByte+0x2c>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<writeByte>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebx
movzbl %bl,%ebp
lea    0xec1(%rip),%rdi
mov    %ebp,%esi
call   1040 <printf@plt>
xor    %eax,%eax
test   $0x80,%bpl
jne    1155 <writeByte+0x25>
call   1050 <write_0@plt>
jmp    115a <writeByte+0x2a>
call   1030 <write_1@plt>
xor    %eax,%eax
test   $0x40,%bl
jne    1168 <writeByte+0x38>
call   1050 <write_0@plt>
jmp    116d <writeByte+0x3d>
call   1030 <write_1@plt>
xor    %eax,%eax
test   $0x20,%bl
jne    117b <writeByte+0x4b>
call   1050 <write_0@plt>
jmp    1180 <writeByte+0x50>
call   1030 <write_1@plt>
xor    %eax,%eax
test   $0x10,%bl
jne    118e <writeByte+0x5e>
call   1050 <write_0@plt>
jmp    1193 <writeByte+0x63>
call   1030 <write_1@plt>
xor    %eax,%eax
test   $0x8,%bl
jne    11a1 <writeByte+0x71>
call   1050 <write_0@plt>
jmp    11a6 <writeByte+0x76>
call   1030 <write_1@plt>
xor    %eax,%eax
test   $0x4,%bl
jne    11b4 <writeByte+0x84>
call   1050 <write_0@plt>
jmp    11b9 <writeByte+0x89>
call   1030 <write_1@plt>
xor    %eax,%eax
test   $0x2,%bl
jne    11c7 <writeByte+0x97>
call   1050 <write_0@plt>
jmp    11cc <writeByte+0x9c>
call   1030 <write_1@plt>
xor    %eax,%eax
add    $0x8,%rsp
test   $0x1,%bl
jne    11de <writeByte+0xae>
pop    %rbx
pop    %rbp
jmp    1050 <write_0@plt>
pop    %rbx
pop    %rbp
jmp    1030 <write_1@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"%02x \00"
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
%6 = load i32, i32* %2
%7 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %6)
store i32 0, i32* %3
br label %8
8: ; preds = %22, %1
%9 = load i32, i32* %3
%10 = icmp slt i32 %9, 8
br i1 %10, label %11, label %25
11: ; preds = %8
%12 = load i32, i32* %2
%13 = and i32 %12, 128
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %11
%16 = call i32 (...) @write_1()
br label %19
17: ; preds = %11
%18 = call i32 (...) @write_0()
br label %19
19: ; preds = %17, %15
%20 = load i32, i32* %2
%21 = mul i32 %20, 2
store i32 %21, i32* %2
br label %22
22: ; preds = %19
%23 = load i32, i32* %3
%24 = add nsw i32 %23, 1
store i32 %24, i32* %3
br label %8
25: ; preds = %8
ret void
}

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