#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 /*<<< orphan*/ ft_putchar(char);
void ft_putbits(unsigned char c) {
  unsigned char b;
  b = (char)128;
  while (b) {
    ft_putchar(c & b ? '1' : '0');
    b = b >> 1;
  }
}


x86 assembly (clang, -O0):
<ft_putbits>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
movb   $0x80,-0x2(%rbp)
cmpb   $0x0,-0x2(%rbp)
je     115d <ft_putbits+0x4d>
movzbl -0x1(%rbp),%edx
movzbl -0x2(%rbp),%eax
and    %eax,%edx
mov    $0x30,%eax
mov    $0x31,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
movsbl %al,%edi
call   1030 <ft_putchar@plt>
movzbl -0x2(%rbp),%eax
sar    $0x1,%eax
mov    %al,-0x2(%rbp)
jmp    1122 <ft_putbits+0x12>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_putbits>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebx
xor    %edi,%edi
test   %bl,%bl
setns  %dil
xor    $0x31,%edi
call   1030 <ft_putchar@plt>
mov    %ebx,%eax
and    $0x40,%al
cmp    $0x1,%al
mov    $0x31,%ebp
mov    $0x31,%edi
sbb    $0x0,%edi
call   1030 <ft_putchar@plt>
mov    %ebx,%eax
and    $0x20,%al
cmp    $0x1,%al
mov    $0x31,%edi
sbb    $0x0,%edi
call   1030 <ft_putchar@plt>
mov    %ebx,%eax
and    $0x10,%al
cmp    $0x1,%al
mov    $0x31,%edi
sbb    $0x0,%edi
call   1030 <ft_putchar@plt>
mov    %ebx,%eax
and    $0x8,%al
cmp    $0x1,%al
mov    $0x31,%edi
sbb    $0x0,%edi
call   1030 <ft_putchar@plt>
mov    %ebx,%eax
and    $0x4,%al
cmp    $0x1,%al
mov    $0x31,%edi
sbb    $0x0,%edi
call   1030 <ft_putchar@plt>
mov    %ebx,%eax
and    $0x2,%al
cmp    $0x1,%al
sbb    $0x0,%ebp
mov    %ebp,%edi
call   1030 <ft_putchar@plt>
and    $0x1,%bl
or     $0x30,%bl
movzbl %bl,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <ft_putchar@plt>

LLVM IR (-O0):
define void @ft_putbits(i8 zeroext %0) {
%2 = alloca i8
%3 = alloca i8
store i8 %0, i8* %2
store i8 -128, i8* %3
br label %4
4: ; preds = %7, %1
%5 = load i8, i8* %3
%6 = icmp ne i8 %5, 0
br i1 %6, label %7, label %22
7: ; preds = %4
%8 = load i8, i8* %2
%9 = zext i8 %8 to i32
%10 = load i8, i8* %3
%11 = zext i8 %10 to i32
%12 = and i32 %9, %11
%13 = icmp ne i32 %12, 0
%14 = zext i1 %13 to i64
%15 = select i1 %13, i32 49, i32 48
%16 = trunc i32 %15 to i8
%17 = call i32 @ft_putchar(i8 signext %16)
%18 = load i8, i8* %3
%19 = zext i8 %18 to i32
%20 = ashr i32 %19, 1
%21 = trunc i32 %20 to i8
store i8 %21, i8* %3
br label %4
22: ; preds = %4
ret void
}

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