#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_fd(char, int);
void ft_putbits_fd(unsigned char c, int fd) {
  unsigned char b;
  b = (char)128;
  while (b) {
    ft_putchar_fd(c & b ? '1' : '0', fd);
    b = b >> 1;
  }
}


x86 assembly (clang, -O0):
<ft_putbits_fd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    %esi,-0x8(%rbp)
movb   $0x80,-0x9(%rbp)
cmpb   $0x0,-0x9(%rbp)
je     1163 <ft_putbits_fd+0x53>
movzbl -0x1(%rbp),%edx
movzbl -0x9(%rbp),%eax
and    %eax,%edx
mov    $0x30,%eax
mov    $0x31,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    -0x8(%rbp),%esi
movsbl %al,%edi
call   1030 <ft_putchar_fd@plt>
movzbl -0x9(%rbp),%eax
sar    $0x1,%eax
mov    %al,-0x9(%rbp)
jmp    1125 <ft_putbits_fd+0x15>
add    $0x10,%rsp
pop    %rbp
ret

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

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

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