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

/* Variables and functions */
int /*<<< orphan*/ fputc(char, int /*<<< orphan*/ *);
void print_encoding(FILE *f, uint8_t *encoding, unsigned size) {
  int i;
  for (i = size - 1; i >= 0; --i) {
    fputc((encoding[i / 8] & (1 << (i % 8))) ? '1' : '0', f);
  }
}


x86 assembly (clang, -O0):
<print_encoding>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jl     119b <print_encoding+0x8b>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %edx,%ecx
mov    -0x1c(%rbp),%edx
mov    $0x1,%eax
shl    %cl,%eax
and    %eax,%edx
mov    $0x30,%eax
mov    $0x31,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    -0x8(%rbp),%rsi
movsbl %al,%edi
call   1030 <fputc@plt>
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
jmp    112c <print_encoding+0x1c>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_encoding>:
push   %r15
push   %r14
push   %rbx
mov    %edx,%eax
add    $0xffffffff,%eax
js     115b <print_encoding+0x4b>
mov    %edx,%ebx
mov    %rsi,%r14
mov    %rdi,%r15
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0xffffffff,%ebx
mov    %ebx,%eax
shr    $0x3,%eax
mov    (%r14,%rax,4),%eax
mov    %ebx,%ecx
and    $0x7,%cl
movzbl %cl,%ecx
bt     %ecx,%eax
mov    $0x31,%edi
adc    $0xffffffff,%edi
mov    %r15,%rsi
call   1030 <fputc@plt>
test   %ebx,%ebx
jg     1130 <print_encoding+0x20>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @print_encoding(i32* %0, i32* %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
store i32* %0, i32** %4
store i32* %1, i32** %5
store i32 %2, i32* %6
%8 = load i32, i32* %6
%9 = sub i32 %8, 1
store i32 %9, i32* %7
br label %10
10: ; preds = %30, %3
%11 = load i32, i32* %7
%12 = icmp sge i32 %11, 0
br i1 %12, label %13, label %33
13: ; preds = %10
%14 = load i32*, i32** %5
%15 = load i32, i32* %7
%16 = sdiv i32 %15, 8
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i32, i32* %14, i64 %17
%19 = load i32, i32* %18
%20 = load i32, i32* %7
%21 = srem i32 %20, 8
%22 = shl i32 1, %21
%23 = and i32 %19, %22
%24 = icmp ne i32 %23, 0
%25 = zext i1 %24 to i64
%26 = select i1 %24, i32 49, i32 48
%27 = trunc i32 %26 to i8
%28 = load i32*, i32** %4
%29 = call i32 @fputc(i8 signext %27, i32* %28)
br label %30
30: ; preds = %13
%31 = load i32, i32* %7
%32 = add nsw i32 %31, -1
store i32 %32, i32* %7
br label %10
33: ; preds = %10
ret void
}

LLVM IR (-O2):
define void @print_encoding(i32* nocapture %0, i32* nocapture %1, i32 %2) {
%4 = add i32 %2, -1
%5 = icmp sgt i32 %4, -1
br i1 %5, label %6, label %20
6: ; preds = %3, %6
%7 = phi i32 [ %18, %6 ], [ %4, %3 ]
%8 = lshr i32 %7, 3
%9 = zext i32 %8 to i64
%10 = getelementptr inbounds i32, i32* %1, i64 %9
%11 = load i32, i32* %10
%12 = and i32 %7, 7
%13 = shl nuw nsw i32 1, %12
%14 = and i32 %11, %13
%15 = icmp eq i32 %14, 0
%16 = select i1 %15, i8 48, i8 49
%17 = tail call i32 @fputc(i8 signext %16, i32* %0)
%18 = add nsw i32 %7, -1
%19 = icmp sgt i32 %7, 0
br i1 %19, label %6, label %20
20: ; preds = %6, %3
ret void
}