#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*/ tty_putc(char);
void cput_binary_byte(int n) {
  int i;
  for (i = 7; i >= 0; i--)
    tty_putc((n & (1 << i)) ? '1' : '0');
}


x86 assembly (clang, -O0):
<cput_binary_byte>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x7,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jl     1161 <cput_binary_byte+0x51>
mov    -0x4(%rbp),%edx
mov    -0x8(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
and    %eax,%edx
mov    $0x30,%eax
mov    $0x31,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
movsbl %al,%edi
call   1030 <tty_putc@plt>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
jmp    1122 <cput_binary_byte+0x12>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cput_binary_byte>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
movd   %edi,%xmm0
pshufd $0x0,%xmm0,%xmm0
movdqa 0xed4(%rip),%xmm1
pand   %xmm0,%xmm1
pand   0xed8(%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 <tty_putc@plt>
movzbl %bpl,%edi
xor    $0x31,%edi
call   1030 <tty_putc@plt>
movzbl %r13b,%edi
xor    $0x31,%edi
call   1030 <tty_putc@plt>
movzbl %r12b,%edi
xor    $0x31,%edi
call   1030 <tty_putc@plt>
movzbl %r15b,%edi
xor    $0x31,%edi
call   1030 <tty_putc@plt>
movzbl %r14b,%edi
xor    $0x31,%edi
call   1030 <tty_putc@plt>
movzbl 0x7(%rsp),%edi
xor    $0x31,%edi
call   1030 <tty_putc@plt>
and    $0x1,%ebx
xor    $0x31,%ebx
mov    %ebx,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <tty_putc@plt>

LLVM IR (-O0):
define void @cput_binary_byte(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %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 i32, i32* %2
%9 = load i32, i32* %3
%10 = shl i32 1, %9
%11 = and i32 %8, %10
%12 = icmp ne i32 %11, 0
%13 = zext i1 %12 to i64
%14 = select i1 %12, i32 49, i32 48
%15 = trunc i32 %14 to i8
%16 = call i32 @tty_putc(i8 signext %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):
define void @cput_binary_byte(i32 %0) {
%2 = insertelement <8 x i32> poison, i32 %0, i64 0
%3 = shufflevector <8 x i32> %2, <8 x i32> poison, <8 x i32> zeroinitializer
%4 = and <8 x i32> %3, <i32 1, i32 2, i32 4, i32 8, i32 16, i32 32, i32 64, i32 128>
%5 = icmp eq <8 x i32> %4, zeroinitializer
%6 = extractelement <8 x i1> %5, i64 7
%7 = select i1 %6, i8 48, i8 49
%8 = tail call i32 @tty_putc(i8 signext %7)
%9 = extractelement <8 x i1> %5, i64 6
%10 = select i1 %9, i8 48, i8 49
%11 = tail call i32 @tty_putc(i8 signext %10)
%12 = extractelement <8 x i1> %5, i64 5
%13 = select i1 %12, i8 48, i8 49
%14 = tail call i32 @tty_putc(i8 signext %13)
%15 = extractelement <8 x i1> %5, i64 4
%16 = select i1 %15, i8 48, i8 49
%17 = tail call i32 @tty_putc(i8 signext %16)
%18 = extractelement <8 x i1> %5, i64 3
%19 = select i1 %18, i8 48, i8 49
%20 = tail call i32 @tty_putc(i8 signext %19)
%21 = extractelement <8 x i1> %5, i64 2
%22 = select i1 %21, i8 48, i8 49
%23 = tail call i32 @tty_putc(i8 signext %22)
%24 = extractelement <8 x i1> %5, i64 1
%25 = select i1 %24, i8 48, i8 49
%26 = tail call i32 @tty_putc(i8 signext %25)
%27 = extractelement <8 x i1> %5, i64 0
%28 = select i1 %27, i8 48, i8 49
%29 = tail call i32 @tty_putc(i8 signext %28)
ret void
}