#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*/ wav_write_one(int /*<<< orphan*/ *);
int /*<<< orphan*/ wav_write_zero(int /*<<< orphan*/ *);
void wav_write_byte(const unsigned char b, FILE *f) {
  int l;
  unsigned char m;
  m = b;
  wav_write_zero(f);
  for (l = 0; l < 8; l++) {
    if (m & 1)
      wav_write_one(f);
    else
      wav_write_zero(f);
    m = (unsigned char)(m >> 1);
  }
  wav_write_one(f);
  wav_write_one(f);
}


x86 assembly (clang, -O0):
<wav_write_byte>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x1(%rbp),%al
mov    %al,-0x15(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <wav_write_zero@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x8,-0x14(%rbp)
jge    1191 <wav_write_byte+0x71>
movzbl -0x15(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     1170 <wav_write_byte+0x50>
mov    -0x10(%rbp),%rdi
call   1040 <wav_write_one@plt>
jmp    1179 <wav_write_byte+0x59>
mov    -0x10(%rbp),%rdi
call   1030 <wav_write_zero@plt>
movzbl -0x15(%rbp),%eax
sar    $0x1,%eax
mov    %al,-0x15(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1148 <wav_write_byte+0x28>
mov    -0x10(%rbp),%rdi
call   1040 <wav_write_one@plt>
mov    -0x10(%rbp),%rdi
call   1040 <wav_write_one@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wav_write_byte>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
mov    %rsi,%rdi
call   1030 <wav_write_zero@plt>
mov    %rbx,%rdi
test   $0x1,%bpl
jne    1140 <wav_write_byte+0x20>
call   1030 <wav_write_zero@plt>
jmp    1145 <wav_write_byte+0x25>
call   1040 <wav_write_one@plt>
mov    %rbx,%rdi
test   $0x2,%bpl
jne    1155 <wav_write_byte+0x35>
call   1030 <wav_write_zero@plt>
jmp    115a <wav_write_byte+0x3a>
call   1040 <wav_write_one@plt>
mov    %rbx,%rdi
test   $0x4,%bpl
jne    116a <wav_write_byte+0x4a>
call   1030 <wav_write_zero@plt>
jmp    116f <wav_write_byte+0x4f>
call   1040 <wav_write_one@plt>
mov    %rbx,%rdi
test   $0x8,%bpl
jne    117f <wav_write_byte+0x5f>
call   1030 <wav_write_zero@plt>
jmp    1184 <wav_write_byte+0x64>
call   1040 <wav_write_one@plt>
mov    %rbx,%rdi
test   $0x10,%bpl
jne    1194 <wav_write_byte+0x74>
call   1030 <wav_write_zero@plt>
jmp    1199 <wav_write_byte+0x79>
call   1040 <wav_write_one@plt>
mov    %rbx,%rdi
test   $0x20,%bpl
jne    11a9 <wav_write_byte+0x89>
call   1030 <wav_write_zero@plt>
jmp    11ae <wav_write_byte+0x8e>
call   1040 <wav_write_one@plt>
mov    %rbx,%rdi
test   $0x40,%bpl
jne    11be <wav_write_byte+0x9e>
call   1030 <wav_write_zero@plt>
jmp    11c3 <wav_write_byte+0xa3>
call   1040 <wav_write_one@plt>
mov    %rbx,%rdi
test   %bpl,%bpl
js     11d2 <wav_write_byte+0xb2>
call   1030 <wav_write_zero@plt>
jmp    11d7 <wav_write_byte+0xb7>
call   1040 <wav_write_one@plt>
mov    %rbx,%rdi
call   1040 <wav_write_one@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <wav_write_one@plt>

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

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