#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 */
typedef int uint8_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, char *);
void p_binary(uint8_t i) {
  int j;
  for (j = 0; j <= 7; j++) {
    printf("%s", i & 0x80 ? "1" : "0");
    i <<= 1;
  }
}


x86 assembly (clang, -O0):
<p_binary>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x7,-0x8(%rbp)
jg     116d <p_binary+0x5d>
mov    -0x4(%rbp),%ecx
and    $0x80,%ecx
lea    0xec9(%rip),%rsi
lea    0xec0(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rsi
lea    0xeaf(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x4(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1122 <p_binary+0x12>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<p_binary>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
movd   %edi,%xmm0
pshufd $0x0,%xmm0,%xmm0
movdqa 0xed8(%rip),%xmm1
pand   %xmm0,%xmm1
pand   0xedc(%rip),%xmm0
pxor   %xmm2,%xmm2
pcmpeqd %xmm2,%xmm0
pcmpeqd %xmm2,%xmm1
packssdw %xmm0,%xmm1
packsswb %xmm1,%xmm1
pmovmskb %xmm1,%ebp
lea    0xed2(%rip),%r15
lea    0xec9(%rip),%rbx
test   $0x80,%bpl
mov    %rbx,%rsi
cmovne %r15,%rsi
lea    0xeb4(%rip),%r14
mov    %r14,%rdi
call   1030 <printf@plt>
test   $0x40,%bpl
mov    %rbx,%rsi
cmovne %r15,%rsi
mov    %r14,%rdi
call   1030 <printf@plt>
test   $0x20,%bpl
mov    %rbx,%rsi
cmovne %r15,%rsi
mov    %r14,%rdi
call   1030 <printf@plt>
test   $0x10,%bpl
mov    %rbx,%rsi
cmovne %r15,%rsi
mov    %r14,%rdi
call   1030 <printf@plt>
test   $0x8,%bpl
mov    %rbx,%rsi
cmovne %r15,%rsi
mov    %r14,%rdi
call   1030 <printf@plt>
test   $0x4,%bpl
mov    %rbx,%rsi
cmovne %r15,%rsi
mov    %r14,%rdi
call   1030 <printf@plt>
test   $0x2,%bpl
mov    %rbx,%rsi
cmovne %r15,%rsi
mov    %r14,%rdi
call   1030 <printf@plt>
test   $0x1,%bpl
cmovne %r15,%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [2 x i8] c"1\00"
@.str.2 = [2 x i8] c"0\00"
define void @p_binary(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %3
br label %4
4: ; preds = %16, %1
%5 = load i32, i32* %3
%6 = icmp sle i32 %5, 7
br i1 %6, label %7, label %19
7: ; preds = %4
%8 = load i32, i32* %2
%9 = and i32 %8, 128
%10 = icmp ne i32 %9, 0
%11 = zext i1 %10 to i64
%12 = select i1 %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0)
%13 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %12)
%14 = load i32, i32* %2
%15 = shl i32 %14, 1
store i32 %15, i32* %2
br label %16
16: ; preds = %7
%17 = load i32, i32* %3
%18 = add nsw i32 %17, 1
store i32 %18, i32* %3
br label %4
19: ; preds = %4
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [2 x i8] c"1\00"
@.str.2 = [2 x i8] c"0\00"
define void @p_binary(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* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0)
%8 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %7)
%9 = extractelement <8 x i1> %5, i64 6
%10 = select i1 %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0)
%11 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = extractelement <8 x i1> %5, i64 5
%13 = select i1 %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0)
%14 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %13)
%15 = extractelement <8 x i1> %5, i64 4
%16 = select i1 %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0)
%17 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %16)
%18 = extractelement <8 x i1> %5, i64 3
%19 = select i1 %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0)
%20 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %19)
%21 = extractelement <8 x i1> %5, i64 2
%22 = select i1 %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0)
%23 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %22)
%24 = extractelement <8 x i1> %5, i64 1
%25 = select i1 %24, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0)
%26 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %25)
%27 = extractelement <8 x i1> %5, i64 0
%28 = select i1 %27, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0)
%29 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %28)
ret void
}