#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*/ fputc(unsigned char, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
void printbits(unsigned char v) {
  int i;
  for (i = 7; i >= 0; i--)
    fputc(('0' + ((v >> i) & 1)), stderr);
}


x86 assembly (clang, -O0):
<printbits>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
movl   $0x7,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jl     115d <printbits+0x4d>
movzbl -0x1(%rbp),%eax
mov    -0x8(%rbp),%ecx
sar    %cl,%eax
and    $0x1,%eax
add    $0x30,%eax
mov    0x2e9b(%rip),%rcx
mov    (%rcx),%esi
movzbl %al,%edi
call   1030 <fputc@plt>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
jmp    1125 <printbits+0x15>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printbits>:
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebx
mov    %ebx,%eax
shr    $0x7,%al
or     $0x30,%al
mov    0x2ebc(%rip),%r14
mov    (%r14),%esi
movzbl %al,%edi
call   1030 <fputc@plt>
mov    %ebx,%eax
shr    $0x6,%al
and    $0x1,%al
or     $0x30,%al
mov    (%r14),%esi
movzbl %al,%edi
call   1030 <fputc@plt>
mov    %ebx,%eax
shr    $0x5,%al
and    $0x1,%al
or     $0x30,%al
mov    (%r14),%esi
movzbl %al,%edi
call   1030 <fputc@plt>
mov    %ebx,%eax
shr    $0x4,%al
and    $0x1,%al
or     $0x30,%al
mov    (%r14),%esi
movzbl %al,%edi
call   1030 <fputc@plt>
mov    %ebx,%eax
shr    $0x3,%al
and    $0x1,%al
or     $0x30,%al
mov    (%r14),%esi
movzbl %al,%edi
call   1030 <fputc@plt>
mov    %ebx,%eax
shr    $0x2,%al
and    $0x1,%al
or     $0x30,%al
mov    (%r14),%esi
movzbl %al,%edi
call   1030 <fputc@plt>
mov    %ebx,%eax
shr    %al
and    $0x1,%al
or     $0x30,%al
mov    (%r14),%esi
movzbl %al,%edi
call   1030 <fputc@plt>
and    $0x1,%bl
or     $0x30,%bl
mov    (%r14),%esi
movzbl %bl,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <fputc@plt>

LLVM IR (-O0):
@stderr = global i32 0
define void @printbits(i8 zeroext %0) {
%2 = alloca i8
%3 = alloca i32
store i8 %0, i8* %2
store i32 7, i32* %3
br label %4
4: ; preds = %17, %1
%5 = load i32, i32* %3
%6 = icmp sge i32 %5, 0
br i1 %6, label %7, label %20
7: ; preds = %4
%8 = load i8, i8* %2
%9 = zext i8 %8 to i32
%10 = load i32, i32* %3
%11 = ashr i32 %9, %10
%12 = and i32 %11, 1
%13 = add nsw i32 48, %12
%14 = trunc i32 %13 to i8
%15 = load i32, i32* @stderr
%16 = call i32 @fputc(i8 zeroext %14, i32 %15)
br label %17
17: ; preds = %7
%18 = load i32, i32* %3
%19 = add nsw i32 %18, -1
store i32 %19, i32* %3
br label %4
20: ; preds = %4
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
define void @printbits(i8 zeroext %0) {
%2 = lshr i8 %0, 7
%3 = or i8 %2, 48
%4 = load i32, i32* @stderr
%5 = tail call i32 @fputc(i8 zeroext %3, i32 %4)
%6 = lshr i8 %0, 6
%7 = and i8 %6, 1
%8 = or i8 %7, 48
%9 = load i32, i32* @stderr
%10 = tail call i32 @fputc(i8 zeroext %8, i32 %9)
%11 = lshr i8 %0, 5
%12 = and i8 %11, 1
%13 = or i8 %12, 48
%14 = load i32, i32* @stderr
%15 = tail call i32 @fputc(i8 zeroext %13, i32 %14)
%16 = lshr i8 %0, 4
%17 = and i8 %16, 1
%18 = or i8 %17, 48
%19 = load i32, i32* @stderr
%20 = tail call i32 @fputc(i8 zeroext %18, i32 %19)
%21 = lshr i8 %0, 3
%22 = and i8 %21, 1
%23 = or i8 %22, 48
%24 = load i32, i32* @stderr
%25 = tail call i32 @fputc(i8 zeroext %23, i32 %24)
%26 = lshr i8 %0, 2
%27 = and i8 %26, 1
%28 = or i8 %27, 48
%29 = load i32, i32* @stderr
%30 = tail call i32 @fputc(i8 zeroext %28, i32 %29)
%31 = lshr i8 %0, 1
%32 = and i8 %31, 1
%33 = or i8 %32, 48
%34 = load i32, i32* @stderr
%35 = tail call i32 @fputc(i8 zeroext %33, i32 %34)
%36 = and i8 %0, 1
%37 = or i8 %36, 48
%38 = load i32, i32* @stderr
%39 = tail call i32 @fputc(i8 zeroext %37, i32 %38)
ret void
}