#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 */

/* Variables and functions */
int CHAR_BIT;
int /*<<< orphan*/ fputc(char, int /*<<< orphan*/);
int /*<<< orphan*/ stdout;
void print_bit_char(unsigned char character) {
  int bit;
  unsigned char mask = 1;
  mask <<= (CHAR_BIT - 1);
  for (bit = 1; bit <= CHAR_BIT; ++bit) {
    fputc(((character & mask) == 0) ? '0' : '1', stdout);
    mask >>= 1;
  }
}


x86 assembly (clang, -O0):
<print_bit_char>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
movb   $0x1,-0x9(%rbp)
mov    0x2eb7(%rip),%rax
mov    (%rax),%ecx
sub    $0x1,%ecx
movzbl -0x9(%rbp),%eax
shl    %cl,%eax
mov    %al,-0x9(%rbp)
movl   $0x1,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    0x2e98(%rip),%rcx
cmp    (%rcx),%eax
jg     1193 <print_bit_char+0x83>
movzbl -0x1(%rbp),%edx
movzbl -0x9(%rbp),%eax
and    %eax,%edx
mov    $0x31,%eax
mov    $0x30,%ecx
cmp    $0x0,%edx
cmove  %ecx,%eax
mov    0x2e67(%rip),%rcx
mov    (%rcx),%esi
movsbl %al,%edi
call   1030 <fputc@plt>
movzbl -0x9(%rbp),%eax
sar    $0x1,%eax
mov    %al,-0x9(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    113e <print_bit_char+0x2e>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_bit_char>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    0x2ec1(%rip),%r14
mov    (%r14),%ecx
test   %ecx,%ecx
jle    1166 <print_bit_char+0x56>
add    $0xff,%cl
mov    $0x1,%ebp
shl    %cl,%ebp
movzbl %dil,%r15d
xor    %ebx,%ebx
mov    0x2e9b(%rip),%r12
nopl   (%rax)
mov    %ebp,%eax
and    %r15d,%eax
mov    (%r12),%esi
cmp    $0x1,%eax
mov    $0x31,%edi
sbb    $0x0,%edi
call   1030 <fputc@plt>
shr    %ebp
and    $0x7f,%ebp
add    $0x1,%ebx
cmp    (%r14),%ebx
jl     1140 <print_bit_char+0x30>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@CHAR_BIT = global i32 0
@stdout = global i32 0
define void @print_bit_char(i8 zeroext %0) {
%2 = alloca i8
%3 = alloca i32
%4 = alloca i8
store i8 %0, i8* %2
store i8 1, i8* %4
%5 = load i32, i32* @CHAR_BIT
%6 = sub nsw i32 %5, 1
%7 = load i8, i8* %4
%8 = zext i8 %7 to i32
%9 = shl i32 %8, %6
%10 = trunc i32 %9 to i8
store i8 %10, i8* %4
store i32 1, i32* %3
br label %11
11: ; preds = %31, %1
%12 = load i32, i32* %3
%13 = load i32, i32* @CHAR_BIT
%14 = icmp sle i32 %12, %13
br i1 %14, label %15, label %34
15: ; preds = %11
%16 = load i8, i8* %2
%17 = zext i8 %16 to i32
%18 = load i8, i8* %4
%19 = zext i8 %18 to i32
%20 = and i32 %17, %19
%21 = icmp eq i32 %20, 0
%22 = zext i1 %21 to i64
%23 = select i1 %21, i32 48, i32 49
%24 = trunc i32 %23 to i8
%25 = load i32, i32* @stdout
%26 = call i32 @fputc(i8 signext %24, i32 %25)
%27 = load i8, i8* %4
%28 = zext i8 %27 to i32
%29 = ashr i32 %28, 1
%30 = trunc i32 %29 to i8
store i8 %30, i8* %4
br label %31
31: ; preds = %15
%32 = load i32, i32* %3
%33 = add nsw i32 %32, 1
store i32 %33, i32* %3
br label %11
34: ; preds = %11
ret void
}

LLVM IR (-O2):
@CHAR_BIT = global i32 0
@stdout = global i32 0
define void @print_bit_char(i8 zeroext %0) {
%2 = load i32, i32* @CHAR_BIT
%3 = icmp slt i32 %2, 1
br i1 %3, label %21, label %4
4: ; preds = %1
%5 = add nsw i32 %2, -1
%6 = shl nuw i32 1, %5
%7 = zext i8 %0 to i32
br label %8
8: ; preds = %4, %8
%9 = phi i32 [ %6, %4 ], [ %17, %8 ]
%10 = phi i32 [ 1, %4 ], [ %18, %8 ]
%11 = and i32 %9, %7
%12 = icmp eq i32 %11, 0
%13 = select i1 %12, i8 48, i8 49
%14 = load i32, i32* @stdout
%15 = tail call i32 @fputc(i8 signext %13, i32 %14)
%16 = lshr i32 %9, 1
%17 = and i32 %16, 127
%18 = add nuw nsw i32 %10, 1
%19 = load i32, i32* @CHAR_BIT
%20 = icmp slt i32 %10, %19
br i1 %20, label %8, label %21
21: ; preds = %8, %1
ret void
}