#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*/ writeBit(int /*<<< orphan*/ *, int, unsigned char *,
                            unsigned char *);
void char2bits(FILE *outfptr, int ch, unsigned char *whichbit,
               unsigned char *curbyte) {
  unsigned char mask = 0x40;
  while (mask > 0) {
    writeBit(outfptr, (ch & mask) == mask, whichbit, curbyte);
    mask >>= 1;
  }
}


x86 assembly (clang, -O0):
<char2bits>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movb   $0x40,-0x21(%rbp)
movzbl -0x21(%rbp),%eax
cmp    $0x0,%eax
jle    116f <char2bits+0x5f>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%eax
movzbl -0x21(%rbp),%ecx
and    %ecx,%eax
movzbl -0x21(%rbp),%ecx
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%esi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
call   1030 <writeBit@plt>
movzbl -0x21(%rbp),%eax
sar    $0x1,%eax
mov    %al,-0x21(%rbp)
jmp    112b <char2bits+0x1b>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<char2bits>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %rdx,%r15
mov    %esi,%ebp
mov    %rdi,%rbx
shr    $0x6,%esi
and    $0x1,%esi
call   1030 <writeBit@plt>
mov    %ebp,%esi
shr    $0x5,%esi
and    $0x1,%esi
mov    %rbx,%rdi
mov    %r15,%rdx
mov    %r14,%rcx
call   1030 <writeBit@plt>
mov    %ebp,%esi
shr    $0x4,%esi
and    $0x1,%esi
mov    %rbx,%rdi
mov    %r15,%rdx
mov    %r14,%rcx
call   1030 <writeBit@plt>
mov    %ebp,%esi
shr    $0x3,%esi
and    $0x1,%esi
mov    %rbx,%rdi
mov    %r15,%rdx
mov    %r14,%rcx
call   1030 <writeBit@plt>
mov    %ebp,%esi
shr    $0x2,%esi
and    $0x1,%esi
mov    %rbx,%rdi
mov    %r15,%rdx
mov    %r14,%rcx
call   1030 <writeBit@plt>
mov    %ebp,%esi
shr    %esi
and    $0x1,%esi
mov    %rbx,%rdi
mov    %r15,%rdx
mov    %r14,%rcx
call   1030 <writeBit@plt>
and    $0x1,%ebp
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %r15,%rdx
mov    %r14,%rcx
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <writeBit@plt>

LLVM IR (-O0):
define void @char2bits(i32* %0, i32 %1, i8* %2, i8* %3) {
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8
store i32* %0, i32** %5
store i32 %1, i32* %6
store i8* %2, i8** %7
store i8* %3, i8** %8
store i8 64, i8* %9
br label %10
10: ; preds = %14, %4
%11 = load i8, i8* %9
%12 = zext i8 %11 to i32
%13 = icmp sgt i32 %12, 0
br i1 %13, label %14, label %31
14: ; preds = %10
%15 = load i32*, i32** %5
%16 = load i32, i32* %6
%17 = load i8, i8* %9
%18 = zext i8 %17 to i32
%19 = and i32 %16, %18
%20 = load i8, i8* %9
%21 = zext i8 %20 to i32
%22 = icmp eq i32 %19, %21
%23 = zext i1 %22 to i32
%24 = load i8*, i8** %7
%25 = load i8*, i8** %8
%26 = call i32 @writeBit(i32* %15, i32 %23, i8* %24, i8* %25)
%27 = load i8, i8* %9
%28 = zext i8 %27 to i32
%29 = ashr i32 %28, 1
%30 = trunc i32 %29 to i8
store i8 %30, i8* %9
br label %10
31: ; preds = %10
ret void
}

LLVM IR (-O2):
define void @char2bits(i32* %0, i32 %1, i8* %2, i8* %3) {
%5 = lshr i32 %1, 6
%6 = and i32 %5, 1
%7 = tail call i32 @writeBit(i32* %0, i32 %6, i8* %2, i8* %3)
%8 = lshr i32 %1, 5
%9 = and i32 %8, 1
%10 = tail call i32 @writeBit(i32* %0, i32 %9, i8* %2, i8* %3)
%11 = lshr i32 %1, 4
%12 = and i32 %11, 1
%13 = tail call i32 @writeBit(i32* %0, i32 %12, i8* %2, i8* %3)
%14 = lshr i32 %1, 3
%15 = and i32 %14, 1
%16 = tail call i32 @writeBit(i32* %0, i32 %15, i8* %2, i8* %3)
%17 = lshr i32 %1, 2
%18 = and i32 %17, 1
%19 = tail call i32 @writeBit(i32* %0, i32 %18, i8* %2, i8* %3)
%20 = lshr i32 %1, 1
%21 = and i32 %20, 1
%22 = tail call i32 @writeBit(i32* %0, i32 %21, i8* %2, i8* %3)
%23 = and i32 %1, 1
%24 = tail call i32 @writeBit(i32* %0, i32 %23, i8* %2, i8* %3)
ret void
}