#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*/ fputs(char *, int /*<<< orphan*/ *);
void chartobinf(unsigned char c, FILE *out) {
  size_t n = 8 * sizeof(unsigned char);
  while (n-- > 0)
    fputs(((c >> n) & 1) ? "1" : "0", out);
}


x86 assembly (clang, -O0):
<chartobinf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x8,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x18(%rbp)
cmp    $0x0,%rax
jbe    1175 <chartobinf+0x65>
movzbl -0x1(%rbp),%eax
mov    -0x18(%rbp),%rcx
sar    %cl,%eax
mov    %eax,%ecx
and    $0x1,%ecx
lea    0xea9(%rip),%rdi
lea    0xea0(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rdi
mov    -0x10(%rbp),%rsi
call   1030 <fputs@plt>
jmp    112a <chartobinf+0x1a>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<chartobinf>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %edi,%ebp
mov    %edi,%eax
and    $0xffffff80,%eax
cmp    $0x1,%eax
mov    $0x31,%r14d
mov    $0x31,%edi
sbb    $0x0,%edi
call   1030 <fputc@plt>
mov    %ebp,%eax
and    $0x40,%eax
cmp    $0x1,%eax
mov    $0x31,%edi
sbb    $0x0,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
mov    %ebp,%eax
and    $0x20,%eax
cmp    $0x1,%eax
mov    $0x31,%edi
sbb    $0x0,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
mov    %ebp,%eax
and    $0x10,%eax
cmp    $0x1,%eax
mov    $0x31,%edi
sbb    $0x0,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
mov    %ebp,%eax
and    $0x8,%eax
cmp    $0x1,%eax
mov    $0x31,%edi
sbb    $0x0,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
mov    %ebp,%eax
and    $0x4,%eax
cmp    $0x1,%eax
mov    $0x31,%edi
sbb    $0x0,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
mov    %ebp,%eax
and    $0x2,%eax
cmp    $0x1,%eax
sbb    $0x0,%r14d
mov    %r14d,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
and    $0x1,%ebp
or     $0x30,%ebp
mov    %ebp,%edi
mov    %rbx,%rsi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <fputc@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"1\00"
@.str.1 = [2 x i8] c"0\00"
define void @chartobinf(i8 zeroext %0, i32* %1) {
%3 = alloca i8
%4 = alloca i32*
%5 = alloca i64
store i8 %0, i8* %3
store i32* %1, i32** %4
store i64 8, i64* %5
br label %6
6: ; preds = %10, %2
%7 = load i64, i64* %5
%8 = add i64 %7, -1
store i64 %8, i64* %5
%9 = icmp ugt i64 %7, 0
br i1 %9, label %10, label %22
10: ; preds = %6
%11 = load i8, i8* %3
%12 = zext i8 %11 to i32
%13 = load i64, i64* %5
%14 = trunc i64 %13 to i32
%15 = ashr i32 %12, %14
%16 = and i32 %15, 1
%17 = icmp ne i32 %16, 0
%18 = zext i1 %17 to i64
%19 = select i1 %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0)
%20 = load i32*, i32** %4
%21 = call i32 @fputs(i8* %19, i32* %20)
br label %6
22: ; preds = %6
ret void
}

LLVM IR (-O2):
define void @chartobinf(i8 zeroext %0, i32* nocapture %1) {
%3 = zext i8 %0 to i32
%4 = and i32 %3, 128
%5 = icmp eq i32 %4, 0
%6 = select i1 %5, i32 48, i32 49
%7 = tail call i32 @fputc(i32 %6, i32* %1)
%8 = and i32 %3, 64
%9 = icmp eq i32 %8, 0
%10 = select i1 %9, i32 48, i32 49
%11 = tail call i32 @fputc(i32 %10, i32* %1)
%12 = and i32 %3, 32
%13 = icmp eq i32 %12, 0
%14 = select i1 %13, i32 48, i32 49
%15 = tail call i32 @fputc(i32 %14, i32* %1)
%16 = and i32 %3, 16
%17 = icmp eq i32 %16, 0
%18 = select i1 %17, i32 48, i32 49
%19 = tail call i32 @fputc(i32 %18, i32* %1)
%20 = and i32 %3, 8
%21 = icmp eq i32 %20, 0
%22 = select i1 %21, i32 48, i32 49
%23 = tail call i32 @fputc(i32 %22, i32* %1)
%24 = and i32 %3, 4
%25 = icmp eq i32 %24, 0
%26 = select i1 %25, i32 48, i32 49
%27 = tail call i32 @fputc(i32 %26, i32* %1)
%28 = and i32 %3, 2
%29 = icmp eq i32 %28, 0
%30 = select i1 %29, i32 48, i32 49
%31 = tail call i32 @fputc(i32 %30, i32* %1)
%32 = and i32 %3, 1
%33 = or i32 %32, 48
%34 = tail call i32 @fputc(i32 %33, i32* %1)
ret void
}