#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*/ fputc(char, int /*<<< orphan*/);
int /*<<< orphan*/ print_bit_char(unsigned char);
int /*<<< orphan*/ stdout;
extern void print_bit(unsigned char *ptr, unsigned int size) {
  unsigned char *first_character;
  int ch;
  first_character = (ptr + size - 1);
  for (ch = 1; ch <= size; ++ch) {
    print_bit_char(*first_character);
    fputc(' ', stdout);
    --(first_character);
  }
  fputc('\n', stdout);
}


x86 assembly (clang, -O0):
<print_bit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
add    %rcx,%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
ja     118d <print_bit+0x6d>
mov    -0x18(%rbp),%rax
movzbl (%rax),%edi
call   1040 <print_bit_char@plt>
mov    0x2e79(%rip),%rax
mov    (%rax),%esi
mov    $0x20,%edi
call   1030 <fputc@plt>
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1148 <print_bit+0x28>
mov    0x2e4c(%rip),%rax
mov    (%rax),%esi
mov    $0xa,%edi
call   1030 <fputc@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_bit>:
push   %r15
push   %r14
push   %rbx
test   %esi,%esi
je     1160 <print_bit+0x40>
mov    %rdi,%r14
mov    %esi,%ebx
mov    0x2eab(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nop
movzbl -0x1(%r14,%rbx,1),%edi
call   1040 <print_bit_char@plt>
mov    (%r15),%esi
mov    $0x20,%edi
call   1030 <fputc@plt>
add    $0xffffffffffffffff,%rbx
test   %ebx,%ebx
jne    1140 <print_bit+0x20>
mov    0x2e79(%rip),%rax
mov    (%rax),%esi
mov    $0xa,%edi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <fputc@plt>

LLVM IR (-O0):
@stdout = global i32 0
define void @print_bit(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%7 = load i8*, i8** %3
%8 = load i32, i32* %4
%9 = zext i32 %8 to i64
%10 = getelementptr inbounds i8, i8* %7, i64 %9
%11 = getelementptr inbounds i8, i8* %10, i64 -1
store i8* %11, i8** %5
store i32 1, i32* %6
br label %12
12: ; preds = %24, %2
%13 = load i32, i32* %6
%14 = load i32, i32* %4
%15 = icmp ule i32 %13, %14
br i1 %15, label %16, label %27
16: ; preds = %12
%17 = load i8*, i8** %5
%18 = load i8, i8* %17
%19 = call i32 @print_bit_char(i8 zeroext %18)
%20 = load i32, i32* @stdout
%21 = call i32 @fputc(i8 signext 32, i32 %20)
%22 = load i8*, i8** %5
%23 = getelementptr inbounds i8, i8* %22, i32 -1
store i8* %23, i8** %5
br label %24
24: ; preds = %16
%25 = load i32, i32* %6
%26 = add nsw i32 %25, 1
store i32 %26, i32* %6
br label %12
27: ; preds = %12
%28 = load i32, i32* @stdout
%29 = call i32 @fputc(i8 signext 10, i32 %28)
ret void
}

LLVM IR (-O2):
@stdout = global i32 0
define void @print_bit(i8* nocapture %0, i32 %1) {
%3 = icmp eq i32 %1, 0
br i1 %3, label %17, label %4
4: ; preds = %2
%5 = zext i32 %1 to i64
%6 = getelementptr inbounds i8, i8* %0, i64 %5
br label %7
7: ; preds = %4, %7
%8 = phi i8* [ %10, %7 ], [ %6, %4 ]
%9 = phi i32 [ %15, %7 ], [ 1, %4 ]
%10 = getelementptr inbounds i8, i8* %8, i64 -1
%11 = load i8, i8* %10
%12 = tail call i32 @print_bit_char(i8 zeroext %11)
%13 = load i32, i32* @stdout
%14 = tail call i32 @fputc(i8 signext 32, i32 %13)
%15 = add nuw i32 %9, 1
%16 = icmp eq i32 %9, %1
br i1 %16, label %17, label %7
17: ; preds = %7, %2
%18 = load i32, i32* @stdout
%19 = tail call i32 @fputc(i8 signext 10, i32 %18)
ret void
}