#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*/ printf(char *, char);
void tb_dump_binary_little(unsigned s_, void *p_, char sep_) {
  int i, j;
  for (i = s_ - 1; i >= 0; i--) {
    for (j = 7; j >= 0; j--)
      printf("%u", (*((unsigned char *)p_ + i) & (1 << j)) >> j);
    if (sep_)
      printf("%c", sep_);
  }
}


x86 assembly (clang, -O0):
<tb_dump_binary_little>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dl,%al
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %al,-0x11(%rbp)
mov    -0x4(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jl     11b1 <tb_dump_binary_little+0xa1>
movl   $0x7,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jl     1184 <tb_dump_binary_little+0x74>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
mov    -0x1c(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
and    %ecx,%eax
mov    -0x1c(%rbp),%ecx
sar    %cl,%eax
lea    0xe92(%rip),%rdi
movsbl %al,%esi
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
jmp    113e <tb_dump_binary_little+0x2e>
cmpb   $0x0,-0x11(%rbp)
je     119e <tb_dump_binary_little+0x8e>
lea    0xe6e(%rip),%rdi
movsbl -0x11(%rbp),%esi
call   1030 <printf@plt>
jmp    11a3 <tb_dump_binary_little+0x93>
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
jmp    112d <tb_dump_binary_little+0x1d>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tb_dump_binary_little>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
add    $0xffffffff,%edi
js     1213 <tb_dump_binary_little+0x103>
mov    %edx,%r14d
mov    %rsi,%rbx
mov    %edi,%ebp
add    $0xffffffffffffffff,%rbp
lea    0xec9(%rip),%r13
movsbl %r14b,%r15d
lea    0xec1(%rip),%r12
jmp    1166 <tb_dump_binary_little+0x56>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbp,%rax
add    $0xffffffffffffffff,%rax
test   $0x80000000,%ebp
mov    %rax,%rbp
jne    1213 <tb_dump_binary_little+0x103>
movzbl 0x1(%rbx,%rbp,1),%eax
shr    $0x7,%al
movzbl %al,%esi
mov    %r13,%rdi
call   1030 <printf@plt>
movzbl 0x1(%rbx,%rbp,1),%esi
shr    $0x6,%esi
and    $0x1,%esi
mov    %r13,%rdi
call   1030 <printf@plt>
movzbl 0x1(%rbx,%rbp,1),%esi
shr    $0x5,%esi
and    $0x1,%esi
mov    %r13,%rdi
call   1030 <printf@plt>
movzbl 0x1(%rbx,%rbp,1),%esi
shr    $0x4,%esi
and    $0x1,%esi
mov    %r13,%rdi
call   1030 <printf@plt>
movzbl 0x1(%rbx,%rbp,1),%esi
shr    $0x3,%esi
and    $0x1,%esi
mov    %r13,%rdi
call   1030 <printf@plt>
movzbl 0x1(%rbx,%rbp,1),%esi
shr    $0x2,%esi
and    $0x1,%esi
mov    %r13,%rdi
call   1030 <printf@plt>
movzbl 0x1(%rbx,%rbp,1),%esi
shr    %esi
and    $0x1,%esi
mov    %r13,%rdi
call   1030 <printf@plt>
movzbl 0x1(%rbx,%rbp,1),%esi
and    $0x1,%esi
mov    %r13,%rdi
call   1030 <printf@plt>
test   %r14b,%r14b
je     1150 <tb_dump_binary_little+0x40>
mov    %r12,%rdi
mov    %r15d,%esi
call   1030 <printf@plt>
jmp    1150 <tb_dump_binary_little+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%u\00"
@.str.1 = [3 x i8] c"%c\00"
define void @tb_dump_binary_little(i32 %0, i8* %1, i8 signext %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %4
store i8* %1, i8** %5
store i8 %2, i8* %6
%9 = load i32, i32* %4
%10 = sub i32 %9, 1
store i32 %10, i32* %7
br label %11
11: ; preds = %42, %3
%12 = load i32, i32* %7
%13 = icmp sge i32 %12, 0
br i1 %13, label %14, label %45
14: ; preds = %11
store i32 7, i32* %8
br label %15
15: ; preds = %32, %14
%16 = load i32, i32* %8
%17 = icmp sge i32 %16, 0
br i1 %17, label %18, label %35
18: ; preds = %15
%19 = load i8*, i8** %5
%20 = load i32, i32* %7
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %19, i64 %21
%23 = load i8, i8* %22
%24 = zext i8 %23 to i32
%25 = load i32, i32* %8
%26 = shl i32 1, %25
%27 = and i32 %24, %26
%28 = load i32, i32* %8
%29 = ashr i32 %27, %28
%30 = trunc i32 %29 to i8
%31 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %30)
br label %32
32: ; preds = %18
%33 = load i32, i32* %8
%34 = add nsw i32 %33, -1
store i32 %34, i32* %8
br label %15
35: ; preds = %15
%36 = load i8, i8* %6
%37 = icmp ne i8 %36, 0
br i1 %37, label %38, label %41
38: ; preds = %35
%39 = load i8, i8* %6
%40 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8 signext %39)
br label %41
41: ; preds = %38, %35
br label %42
42: ; preds = %41
%43 = load i32, i32* %7
%44 = add nsw i32 %43, -1
store i32 %44, i32* %7
br label %11
45: ; preds = %11
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%u\00"
@.str.1 = [3 x i8] c"%c\00"
define void @tb_dump_binary_little(i32 %0, i8* nocapture %1, i8 signext %2) {
%4 = add i32 %0, -1
%5 = icmp sgt i32 %4, -1
br i1 %5, label %6, label %48
6: ; preds = %3
%7 = icmp eq i8 %2, 0
%8 = zext i32 %4 to i64
br label %9
9: ; preds = %6, %44
%10 = phi i64 [ %8, %6 ], [ %45, %44 ]
%11 = getelementptr inbounds i8, i8* %1, i64 %10
%12 = load i8, i8* %11
%13 = lshr i8 %12, 7
%14 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %13)
%15 = load i8, i8* %11
%16 = lshr i8 %15, 6
%17 = and i8 %16, 1
%18 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %17)
%19 = load i8, i8* %11
%20 = lshr i8 %19, 5
%21 = and i8 %20, 1
%22 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %21)
%23 = load i8, i8* %11
%24 = lshr i8 %23, 4
%25 = and i8 %24, 1
%26 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %25)
%27 = load i8, i8* %11
%28 = lshr i8 %27, 3
%29 = and i8 %28, 1
%30 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %29)
%31 = load i8, i8* %11
%32 = lshr i8 %31, 2
%33 = and i8 %32, 1
%34 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %33)
%35 = load i8, i8* %11
%36 = lshr i8 %35, 1
%37 = and i8 %36, 1
%38 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %37)
%39 = load i8, i8* %11
%40 = and i8 %39, 1
%41 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %40)
br i1 %7, label %44, label %42
42: ; preds = %9
%43 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8 signext %2)
br label %44
44: ; preds = %9, %42
%45 = add nsw i64 %10, -1
%46 = and i64 %45, 2147483648
%47 = icmp eq i64 %46, 0
br i1 %47, label %9, label %48
48: ; preds = %44, %3
ret void
}