#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 */
scalar_t__ EOF;
scalar_t__ fputc(unsigned char, int /*<<< orphan*/ *);
int wlWriteBit(char bit, FILE *file, unsigned char *dataByte,
               unsigned char *dataMask) {
  *dataByte <<= 1;
  *dataByte |= bit & 1;
  *dataMask = *dataMask == 0 ? 1 : (*dataMask << 1);
  if (*dataMask == 0x80) {
    if (fputc(*dataByte, file) == EOF)
      return 0;
    *dataByte = 0;
    *dataMask = 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<wlWriteBit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %dil,%al
mov    %al,-0x5(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x18(%rbp),%rax
movzbl (%rax),%ecx
shl    $0x1,%ecx
mov    %cl,(%rax)
movsbl -0x5(%rbp),%edx
and    $0x1,%edx
mov    -0x18(%rbp),%rax
movzbl (%rax),%ecx
or     %edx,%ecx
mov    %cl,(%rax)
mov    -0x20(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x0,%eax
jne    1165 <wlWriteBit+0x55>
mov    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1172 <wlWriteBit+0x62>
mov    -0x20(%rbp),%rax
movzbl (%rax),%eax
shl    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %al,%cl
mov    -0x20(%rbp),%rax
mov    %cl,(%rax)
mov    -0x20(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x80,%eax
jne    11cb <wlWriteBit+0xbb>
mov    -0x18(%rbp),%rax
mov    (%rax),%al
mov    -0x10(%rbp),%rsi
movzbl %al,%edi
call   1030 <fputc@plt>
mov    0x2e40(%rip),%rcx
cmp    (%rcx),%rax
jne    11bd <wlWriteBit+0xad>
movl   $0x0,-0x4(%rbp)
jmp    11d2 <wlWriteBit+0xc2>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wlWriteBit>:
push   %r14
push   %rbx
push   %rax
mov    %rcx,%r14
mov    (%rdx),%al
add    %al,%al
and    $0x1,%dil
or     %al,%dil
mov    %dil,(%rdx)
mov    (%rcx),%al
lea    (%rax,%rax,1),%ecx
test   %al,%al
movzbl %cl,%ecx
mov    $0x1,%eax
cmove  %eax,%ecx
mov    %cl,(%r14)
cmp    $0x80,%cl
jne    1167 <wlWriteBit+0x57>
mov    %rdx,%rbx
movzbl (%rdx),%edi
call   1030 <fputc@plt>
mov    %rax,%rcx
mov    0x2e94(%rip),%rdx
xor    %eax,%eax
cmp    (%rdx),%rcx
je     1167 <wlWriteBit+0x57>
movb   $0x0,(%rbx)
movb   $0x0,(%r14)
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@EOF = global i64 0
define i32 @wlWriteBit(i8 signext %0, i32* %1, i8* %2, i8* %3) {
%5 = alloca i32
%6 = alloca i8
%7 = alloca i32*
%8 = alloca i8*
%9 = alloca i8*
store i8 %0, i8* %6
store i32* %1, i32** %7
store i8* %2, i8** %8
store i8* %3, i8** %9
%10 = load i8*, i8** %8
%11 = load i8, i8* %10
%12 = zext i8 %11 to i32
%13 = shl i32 %12, 1
%14 = trunc i32 %13 to i8
store i8 %14, i8* %10
%15 = load i8, i8* %6
%16 = sext i8 %15 to i32
%17 = and i32 %16, 1
%18 = load i8*, i8** %8
%19 = load i8, i8* %18
%20 = zext i8 %19 to i32
%21 = or i32 %20, %17
%22 = trunc i32 %21 to i8
store i8 %22, i8* %18
%23 = load i8*, i8** %9
%24 = load i8, i8* %23
%25 = zext i8 %24 to i32
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %4
br label %33
28: ; preds = %4
%29 = load i8*, i8** %9
%30 = load i8, i8* %29
%31 = zext i8 %30 to i32
%32 = shl i32 %31, 1
br label %33
33: ; preds = %28, %27
%34 = phi i32 [ 1, %27 ], [ %32, %28 ]
%35 = trunc i32 %34 to i8
%36 = load i8*, i8** %9
store i8 %35, i8* %36
%37 = load i8*, i8** %9
%38 = load i8, i8* %37
%39 = zext i8 %38 to i32
%40 = icmp eq i32 %39, 128
br i1 %40, label %41, label %52
41: ; preds = %33
%42 = load i8*, i8** %8
%43 = load i8, i8* %42
%44 = load i32*, i32** %7
%45 = call i64 @fputc(i8 zeroext %43, i32* %44)
%46 = load i64, i64* @EOF
%47 = icmp eq i64 %45, %46
br i1 %47, label %48, label %49
48: ; preds = %41
store i32 0, i32* %5
br label %53
49: ; preds = %41
%50 = load i8*, i8** %8
store i8 0, i8* %50
%51 = load i8*, i8** %9
store i8 0, i8* %51
br label %52
52: ; preds = %49, %33
store i32 1, i32* %5
br label %53
53: ; preds = %52, %48
%54 = load i32, i32* %5
ret i32 %54
}

LLVM IR (-O2):
@EOF = global i64 0
define i32 @wlWriteBit(i8 signext %0, i32* nocapture %1, i8* nocapture %2, i8* nocapture %3) {
%5 = load i8, i8* %2
%6 = shl i8 %5, 1
%7 = and i8 %0, 1
%8 = or i8 %6, %7
store i8 %8, i8* %2
%9 = load i8, i8* %3
%10 = icmp eq i8 %9, 0
%11 = shl i8 %9, 1
%12 = select i1 %10, i8 1, i8 %11
store i8 %12, i8* %3
%13 = icmp eq i8 %12, -128
br i1 %13, label %14, label %20
14: ; preds = %4
%15 = load i8, i8* %2
%16 = tail call i64 @fputc(i8 zeroext %15, i32* %1)
%17 = load i64, i64* @EOF
%18 = icmp eq i64 %16, %17
br i1 %18, label %20, label %19
19: ; preds = %14
store i8 0, i8* %2
store i8 0, i8* %3
br label %20
20: ; preds = %4, %19, %14
%21 = phi i32 [ 0, %14 ], [ 1, %19 ], [ 1, %4 ]
ret i32 %21
}