#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*/ putchar(char);
int libswd_bin8_print(char *data) {
  unsigned char i, bits = *data;
  for (i = 0; i < 8; i++)
    putchar(((bits << i) & 0x80) ? '1' : '0');
  return i;
}


x86 assembly (clang, -O0):
<libswd_bin8_print>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%al
mov    %al,-0xa(%rbp)
movb   $0x0,-0x9(%rbp)
movzbl -0x9(%rbp),%eax
cmp    $0x8,%eax
jge    116b <libswd_bin8_print+0x5b>
movzbl -0xa(%rbp),%edx
movzbl -0x9(%rbp),%ecx
shl    %cl,%edx
and    $0x80,%edx
mov    $0x30,%eax
mov    $0x31,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
movsbl %al,%edi
call   1030 <putchar@plt>
mov    -0x9(%rbp),%al
add    $0x1,%al
mov    %al,-0x9(%rbp)
jmp    1129 <libswd_bin8_print+0x19>
movzbl -0x9(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<libswd_bin8_print>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
movzbl (%rdi),%eax
movd   %eax,%xmm0
pshufd $0x0,%xmm0,%xmm0
movdqa 0xed1(%rip),%xmm1
pand   %xmm0,%xmm1
pand   0xed5(%rip),%xmm0
pxor   %xmm2,%xmm2
pcmpeqd %xmm2,%xmm0
pcmpeqd %xmm2,%xmm1
packssdw %xmm0,%xmm1
packsswb %xmm1,%xmm1
pmovmskb %xmm1,%ebx
mov    %ebx,%eax
and    $0x2,%al
shr    %al
mov    %al,0x7(%rsp)
mov    %ebx,%r14d
and    $0x4,%r14b
shr    $0x2,%r14b
mov    %ebx,%r15d
and    $0x8,%r15b
shr    $0x3,%r15b
mov    %ebx,%r12d
and    $0x10,%r12b
shr    $0x4,%r12b
mov    %ebx,%r13d
and    $0x20,%r13b
shr    $0x5,%r13b
mov    %ebx,%ebp
and    $0x40,%bpl
shr    $0x6,%bpl
mov    %ebx,%eax
shr    $0x7,%al
movzbl %al,%edi
xor    $0x31,%edi
call   1030 <putchar@plt>
movzbl %bpl,%edi
xor    $0x31,%edi
call   1030 <putchar@plt>
movzbl %r13b,%edi
xor    $0x31,%edi
call   1030 <putchar@plt>
movzbl %r12b,%edi
xor    $0x31,%edi
call   1030 <putchar@plt>
movzbl %r15b,%edi
xor    $0x31,%edi
call   1030 <putchar@plt>
movzbl %r14b,%edi
xor    $0x31,%edi
call   1030 <putchar@plt>
movzbl 0x7(%rsp),%edi
xor    $0x31,%edi
call   1030 <putchar@plt>
and    $0x1,%ebx
xor    $0x31,%ebx
mov    %ebx,%edi
call   1030 <putchar@plt>
mov    $0x8,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @libswd_bin8_print(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = zext i8 %2 to i32
%4 = insertelement <8 x i32> poison, i32 %3, i64 0
%5 = shufflevector <8 x i32> %4, <8 x i32> poison, <8 x i32> zeroinitializer
%6 = and <8 x i32> %5, <i32 1, i32 2, i32 4, i32 8, i32 16, i32 32, i32 64, i32 128>
%7 = icmp eq <8 x i32> %6, zeroinitializer
%8 = extractelement <8 x i1> %7, i64 7
%9 = select i1 %8, i8 48, i8 49
%10 = tail call i32 @putchar(i8 signext %9)
%11 = extractelement <8 x i1> %7, i64 6
%12 = select i1 %11, i8 48, i8 49
%13 = tail call i32 @putchar(i8 signext %12)
%14 = extractelement <8 x i1> %7, i64 5
%15 = select i1 %14, i8 48, i8 49
%16 = tail call i32 @putchar(i8 signext %15)
%17 = extractelement <8 x i1> %7, i64 4
%18 = select i1 %17, i8 48, i8 49
%19 = tail call i32 @putchar(i8 signext %18)
%20 = extractelement <8 x i1> %7, i64 3
%21 = select i1 %20, i8 48, i8 49
%22 = tail call i32 @putchar(i8 signext %21)
%23 = extractelement <8 x i1> %7, i64 2
%24 = select i1 %23, i8 48, i8 49
%25 = tail call i32 @putchar(i8 signext %24)
%26 = extractelement <8 x i1> %7, i64 1
%27 = select i1 %26, i8 48, i8 49
%28 = tail call i32 @putchar(i8 signext %27)
%29 = extractelement <8 x i1> %7, i64 0
%30 = select i1 %29, i8 48, i8 49
%31 = tail call i32 @putchar(i8 signext %30)
ret i32 8
}