#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 fread(unsigned char *, int, int, int /*<<< orphan*/ *);
int wlReadBit(FILE *file, unsigned char *dataByte, unsigned char *dataMask) {
  int tmp;
  if (*dataMask == 0) {
    if (fread(dataByte, 1, 1, file) != 1)
      return -1;
    *dataMask = 0x80;
  }
  tmp = *dataByte & *dataMask;
  *dataMask = *dataMask >> 1;
  return tmp ? 1 : 0;
}


x86 assembly (clang, -O0):
<wlReadBit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x0,%eax
jne    1164 <wlReadBit+0x54>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x1,%edx
mov    %edx,%esi
call   1030 <fread@plt>
cmp    $0x1,%eax
je     115d <wlReadBit+0x4d>
movl   $0xffffffff,-0x4(%rbp)
jmp    119c <wlReadBit+0x8c>
mov    -0x20(%rbp),%rax
movb   $0x80,(%rax)
mov    -0x18(%rbp),%rax
movzbl (%rax),%eax
mov    -0x20(%rbp),%rcx
movzbl (%rcx),%ecx
and    %ecx,%eax
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%rax
movzbl (%rax),%eax
sar    $0x1,%eax
mov    %al,%cl
mov    -0x20(%rbp),%rax
mov    %cl,(%rax)
mov    -0x24(%rbp),%edx
xor    %eax,%eax
mov    $0x1,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wlReadBit>:
push   %r14
push   %rbx
push   %rax
mov    %rdx,%rbx
mov    %rsi,%r14
mov    (%rdx),%al
test   %al,%al
jne    1146 <wlReadBit+0x36>
mov    %rdi,%rcx
mov    %r14,%rdi
mov    $0x1,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
cmp    $0x1,%ecx
jne    1156 <wlReadBit+0x46>
movb   $0x80,(%rbx)
mov    $0x80,%al
mov    (%r14),%cl
and    %al,%cl
shr    %al
mov    %al,(%rbx)
xor    %eax,%eax
test   %cl,%cl
setne  %al
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @wlReadBit(i32* %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
store i32* %0, i32** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
%9 = load i8*, i8** %7
%10 = load i8, i8* %9
%11 = zext i8 %10 to i32
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %21
13: ; preds = %3
%14 = load i8*, i8** %6
%15 = load i32*, i32** %5
%16 = call i32 @fread(i8* %14, i32 1, i32 1, i32* %15)
%17 = icmp ne i32 %16, 1
br i1 %17, label %18, label %19
18: ; preds = %13
store i32 -1, i32* %4
br label %39
19: ; preds = %13
%20 = load i8*, i8** %7
store i8 -128, i8* %20
br label %21
21: ; preds = %19, %3
%22 = load i8*, i8** %6
%23 = load i8, i8* %22
%24 = zext i8 %23 to i32
%25 = load i8*, i8** %7
%26 = load i8, i8* %25
%27 = zext i8 %26 to i32
%28 = and i32 %24, %27
store i32 %28, i32* %8
%29 = load i8*, i8** %7
%30 = load i8, i8* %29
%31 = zext i8 %30 to i32
%32 = ashr i32 %31, 1
%33 = trunc i32 %32 to i8
%34 = load i8*, i8** %7
store i8 %33, i8* %34
%35 = load i32, i32* %8
%36 = icmp ne i32 %35, 0
%37 = zext i1 %36 to i64
%38 = select i1 %36, i32 1, i32 0
store i32 %38, i32* %4
br label %39
39: ; preds = %21, %18
%40 = load i32, i32* %4
ret i32 %40
}

LLVM IR (-O2):
define i32 @wlReadBit(i32* nocapture %0, i8* nocapture %1, i8* nocapture %2) {
%4 = load i8, i8* %2
%5 = icmp eq i8 %4, 0
br i1 %5, label %6, label %10
6: ; preds = %3
%7 = tail call i32 @fread(i8* %1, i32 1, i32 1, i32* %0)
%8 = icmp eq i32 %7, 1
br i1 %8, label %9, label %17
9: ; preds = %6
store i8 -128, i8* %2
br label %10
10: ; preds = %9, %3
%11 = phi i8 [ -128, %9 ], [ %4, %3 ]
%12 = load i8, i8* %1
%13 = and i8 %11, %12
%14 = lshr i8 %11, 1
store i8 %14, i8* %2
%15 = icmp ne i8 %13, 0
%16 = zext i1 %15 to i32
br label %17
17: ; preds = %6, %10
%18 = phi i32 [ %16, %10 ], [ -1, %6 ]
ret i32 %18
}