#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*/ print_char(char);
void print_bin(unsigned char h, unsigned char count) {
  unsigned char i;
  h <<= 8 - count;
  for (i = 0; i < count; i++) {
    print_char(h & 0x80 ? '1' : '0');
    h <<= 1;
  }
}


x86 assembly (clang, -O0):
<print_bin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %sil,%al
mov    %dil,%cl
mov    %cl,-0x1(%rbp)
mov    %al,-0x2(%rbp)
movzbl -0x2(%rbp),%eax
mov    $0x8,%ecx
sub    %eax,%ecx
movzbl -0x1(%rbp),%eax
shl    %cl,%eax
mov    %al,-0x1(%rbp)
movb   $0x0,-0x3(%rbp)
movzbl -0x3(%rbp),%eax
movzbl -0x2(%rbp),%ecx
cmp    %ecx,%eax
jge    1185 <print_bin+0x75>
movzbl -0x1(%rbp),%edx
and    $0x80,%edx
mov    $0x30,%eax
mov    $0x31,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
movsbl %al,%edi
call   1030 <print_char@plt>
movzbl -0x1(%rbp),%eax
shl    $0x1,%eax
mov    %al,-0x1(%rbp)
mov    -0x3(%rbp),%al
add    $0x1,%al
mov    %al,-0x3(%rbp)
jmp    113c <print_bin+0x2c>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_bin>:
push   %rbp
push   %rbx
push   %rax
test   %esi,%esi
je     1152 <print_bin+0x42>
mov    %esi,%ebx
movzbl %dil,%ebp
mov    $0x8,%cl
sub    %bl,%cl
shl    %cl,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %ebp,%eax
and    $0x80,%eax
cmp    $0x1,%eax
mov    $0x31,%edi
sbb    $0x0,%edi
call   1030 <print_char@plt>
movzbl %bpl,%ebp
add    %ebp,%ebp
add    $0xff,%bl
jne    1130 <print_bin+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
define void @print_bin(i8 zeroext %0, i8 zeroext %1) {
%3 = icmp eq i8 %1, 0
br i1 %3, label %20, label %4
4: ; preds = %2
%5 = zext i8 %0 to i32
%6 = zext i8 %1 to i32
%7 = sub nsw i32 8, %6
%8 = shl nuw nsw i32 %5, %7
br label %9
9: ; preds = %4, %9
%10 = phi i8 [ %18, %9 ], [ 0, %4 ]
%11 = phi i32 [ %17, %9 ], [ %8, %4 ]
%12 = and i32 %11, 128
%13 = icmp eq i32 %12, 0
%14 = select i1 %13, i8 48, i8 49
%15 = tail call i32 @print_char(i8 signext %14)
%16 = shl i32 %11, 1
%17 = and i32 %16, 510
%18 = add nuw i8 %10, 1
%19 = icmp eq i8 %18, %1
br i1 %19, label %20, label %9
20: ; preds = %9, %2
ret void
}