#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ writePulse(int /*<<< orphan*/ *, int);
void writeByte(FILE *output, int byte) {
  int i;
  writePulse(output, 1200);
  for (i = 0; i < 8; i++) {
    if (byte & 1) {
      writePulse(output, 2400);
      writePulse(output, 2400);
    } else
      writePulse(output, 1200);
    byte = byte >> 1;
  }
  for (i = 0; i < 4; i++)
    writePulse(output, 2400);
}


x86 assembly (clang, -O0):
<writeByte>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x4b0,%esi
call   1030 <writePulse@plt>
movl   $0x0,-0x10(%rbp)
cmpl   $0x8,-0x10(%rbp)
jge    1193 <writeByte+0x83>
mov    -0xc(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     116e <writeByte+0x5e>
mov    -0x8(%rbp),%rdi
mov    $0x960,%esi
call   1030 <writePulse@plt>
mov    -0x8(%rbp),%rdi
mov    $0x960,%esi
call   1030 <writePulse@plt>
jmp    117c <writeByte+0x6c>
mov    -0x8(%rbp),%rdi
mov    $0x4b0,%esi
call   1030 <writePulse@plt>
mov    -0xc(%rbp),%eax
sar    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1134 <writeByte+0x24>
movl   $0x0,-0x10(%rbp)
cmpl   $0x4,-0x10(%rbp)
jge    11c0 <writeByte+0xb0>
mov    -0x8(%rbp),%rdi
mov    $0x960,%esi
call   1030 <writePulse@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    119a <writeByte+0x8a>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<writeByte>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%r15d
mov    %rdi,%rbx
mov    $0x4b0,%r14d
mov    $0x4b0,%esi
call   1030 <writePulse@plt>
mov    $0x4b0,%ebp
test   $0x1,%r15b
je     114a <writeByte+0x3a>
mov    $0x960,%ebp
mov    %rbx,%rdi
mov    $0x960,%esi
call   1030 <writePulse@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
call   1030 <writePulse@plt>
test   $0x2,%r15b
je     116d <writeByte+0x5d>
mov    $0x960,%r14d
mov    %rbx,%rdi
mov    $0x960,%esi
call   1030 <writePulse@plt>
mov    %rbx,%rdi
mov    %r14d,%esi
call   1030 <writePulse@plt>
mov    $0x4b0,%r14d
mov    $0x4b0,%ebp
test   $0x4,%r15b
je     119b <writeByte+0x8b>
mov    $0x960,%ebp
mov    %rbx,%rdi
mov    $0x960,%esi
call   1030 <writePulse@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
call   1030 <writePulse@plt>
test   $0x8,%r15b
je     11be <writeByte+0xae>
mov    $0x960,%r14d
mov    %rbx,%rdi
mov    $0x960,%esi
call   1030 <writePulse@plt>
mov    %rbx,%rdi
mov    %r14d,%esi
call   1030 <writePulse@plt>
mov    $0x4b0,%r14d
mov    $0x4b0,%ebp
test   $0x10,%r15b
je     11ec <writeByte+0xdc>
mov    $0x960,%ebp
mov    %rbx,%rdi
mov    $0x960,%esi
call   1030 <writePulse@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
call   1030 <writePulse@plt>
test   $0x20,%r15b
je     120f <writeByte+0xff>
mov    $0x960,%r14d
mov    %rbx,%rdi
mov    $0x960,%esi
call   1030 <writePulse@plt>
mov    %rbx,%rdi
mov    %r14d,%esi
call   1030 <writePulse@plt>
mov    $0x4b0,%r14d
mov    $0x4b0,%ebp
test   $0x40,%r15b
je     123d <writeByte+0x12d>
mov    $0x960,%ebp
mov    %rbx,%rdi
mov    $0x960,%esi
call   1030 <writePulse@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
call   1030 <writePulse@plt>
test   $0x80,%r15b
je     1260 <writeByte+0x150>
mov    $0x960,%r14d
mov    %rbx,%rdi
mov    $0x960,%esi
call   1030 <writePulse@plt>
mov    %rbx,%rdi
mov    %r14d,%esi
call   1030 <writePulse@plt>
mov    %rbx,%rdi
mov    $0x960,%esi
call   1030 <writePulse@plt>
mov    %rbx,%rdi
mov    $0x960,%esi
call   1030 <writePulse@plt>
mov    %rbx,%rdi
mov    $0x960,%esi
call   1030 <writePulse@plt>
mov    %rbx,%rdi
mov    $0x960,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <writePulse@plt>

LLVM IR (-O0):
define void @writeByte(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
%6 = load i32*, i32** %3
%7 = call i32 @writePulse(i32* %6, i32 1200)
store i32 0, i32* %5
br label %8
8: ; preds = %26, %2
%9 = load i32, i32* %5
%10 = icmp slt i32 %9, 8
br i1 %10, label %11, label %29
11: ; preds = %8
%12 = load i32, i32* %4
%13 = and i32 %12, 1
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %20
15: ; preds = %11
%16 = load i32*, i32** %3
%17 = call i32 @writePulse(i32* %16, i32 2400)
%18 = load i32*, i32** %3
%19 = call i32 @writePulse(i32* %18, i32 2400)
br label %23
20: ; preds = %11
%21 = load i32*, i32** %3
%22 = call i32 @writePulse(i32* %21, i32 1200)
br label %23
23: ; preds = %20, %15
%24 = load i32, i32* %4
%25 = ashr i32 %24, 1
store i32 %25, i32* %4
br label %26
26: ; preds = %23
%27 = load i32, i32* %5
%28 = add nsw i32 %27, 1
store i32 %28, i32* %5
br label %8
29: ; preds = %8
store i32 0, i32* %5
br label %30
30: ; preds = %36, %29
%31 = load i32, i32* %5
%32 = icmp slt i32 %31, 4
br i1 %32, label %33, label %39
33: ; preds = %30
%34 = load i32*, i32** %3
%35 = call i32 @writePulse(i32* %34, i32 2400)
br label %36
36: ; preds = %33
%37 = load i32, i32* %5
%38 = add nsw i32 %37, 1
store i32 %38, i32* %5
br label %30
39: ; preds = %30
ret void
}

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