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


x86 assembly (clang, -O0):
<tb_dump_binary_big>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %dl,%al
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %al,-0x11(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x4(%rbp),%eax
jae    11c4 <tb_dump_binary_big+0xb4>
movl   $0x7,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jl     1197 <tb_dump_binary_big+0x87>
mov    -0x20(%rbp),%rax
movslq -0x28(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
mov    -0x2c(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
and    %ecx,%eax
mov    %al,-0x21(%rbp)
mov    -0x2c(%rbp),%ecx
movzbl -0x21(%rbp),%eax
sar    %cl,%eax
mov    %al,-0x21(%rbp)
lea    0xe80(%rip),%rdi
movsbl -0x21(%rbp),%esi
call   1030 <printf@plt>
mov    -0x2c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x2c(%rbp)
jmp    1146 <tb_dump_binary_big+0x36>
cmpb   $0x0,-0x11(%rbp)
je     11b1 <tb_dump_binary_big+0xa1>
lea    0xe5b(%rip),%rdi
movsbl -0x11(%rbp),%esi
call   1030 <printf@plt>
jmp    11b6 <tb_dump_binary_big+0xa6>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1133 <tb_dump_binary_big+0x23>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tb_dump_binary_big>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %edi,%edi
je     11fe <tb_dump_binary_big+0xee>
mov    %edx,%r14d
mov    %rsi,%rbx
mov    %edi,%r13d
xor    %r12d,%r12d
lea    0xeca(%rip),%rbp
movsbl %r14b,%r15d
jmp    114d <tb_dump_binary_big+0x3d>
nopl   0x0(%rax)
add    $0x1,%r12
cmp    %r12,%r13
je     11fe <tb_dump_binary_big+0xee>
movzbl (%rbx,%r12,1),%eax
shr    $0x7,%al
movzbl %al,%esi
mov    %rbp,%rdi
call   1030 <printf@plt>
movzbl (%rbx,%r12,1),%esi
shr    $0x6,%esi
and    $0x1,%esi
mov    %rbp,%rdi
call   1030 <printf@plt>
movzbl (%rbx,%r12,1),%esi
shr    $0x5,%esi
and    $0x1,%esi
mov    %rbp,%rdi
call   1030 <printf@plt>
movzbl (%rbx,%r12,1),%esi
shr    $0x4,%esi
and    $0x1,%esi
mov    %rbp,%rdi
call   1030 <printf@plt>
movzbl (%rbx,%r12,1),%esi
shr    $0x3,%esi
and    $0x1,%esi
mov    %rbp,%rdi
call   1030 <printf@plt>
movzbl (%rbx,%r12,1),%esi
shr    $0x2,%esi
and    $0x1,%esi
mov    %rbp,%rdi
call   1030 <printf@plt>
movzbl (%rbx,%r12,1),%esi
shr    %esi
and    $0x1,%esi
mov    %rbp,%rdi
call   1030 <printf@plt>
movzbl (%rbx,%r12,1),%esi
and    $0x1,%esi
mov    %rbp,%rdi
call   1030 <printf@plt>
test   %r14b,%r14b
je     1140 <tb_dump_binary_big+0x30>
lea    0xe12(%rip),%rdi
mov    %r15d,%esi
call   1030 <printf@plt>
jmp    1140 <tb_dump_binary_big+0x30>
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_big(i32 %0, i8* %1, i8 signext %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8
%7 = alloca i8*
%8 = alloca i8
%9 = alloca i32
%10 = alloca i32
store i32 %0, i32* %4
store i8* %1, i8** %5
store i8 %2, i8* %6
%11 = load i8*, i8** %5
store i8* %11, i8** %7
store i32 0, i32* %9
br label %12
12: ; preds = %48, %3
%13 = load i32, i32* %9
%14 = load i32, i32* %4
%15 = icmp ult i32 %13, %14
br i1 %15, label %16, label %51
16: ; preds = %12
store i32 7, i32* %10
br label %17
17: ; preds = %38, %16
%18 = load i32, i32* %10
%19 = icmp sge i32 %18, 0
br i1 %19, label %20, label %41
20: ; preds = %17
%21 = load i8*, i8** %7
%22 = load i32, i32* %9
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %21, i64 %23
%25 = load i8, i8* %24
%26 = zext i8 %25 to i32
%27 = load i32, i32* %10
%28 = shl i32 1, %27
%29 = and i32 %26, %28
%30 = trunc i32 %29 to i8
store i8 %30, i8* %8
%31 = load i32, i32* %10
%32 = load i8, i8* %8
%33 = zext i8 %32 to i32
%34 = ashr i32 %33, %31
%35 = trunc i32 %34 to i8
store i8 %35, i8* %8
%36 = load i8, i8* %8
%37 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %36)
br label %38
38: ; preds = %20
%39 = load i32, i32* %10
%40 = add nsw i32 %39, -1
store i32 %40, i32* %10
br label %17
41: ; preds = %17
%42 = load i8, i8* %6
%43 = icmp ne i8 %42, 0
br i1 %43, label %44, label %47
44: ; preds = %41
%45 = load i8, i8* %6
%46 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8 signext %45)
br label %47
47: ; preds = %44, %41
br label %48
48: ; preds = %47
%49 = load i32, i32* %9
%50 = add nsw i32 %49, 1
store i32 %50, i32* %9
br label %12
51: ; preds = %12
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_big(i32 %0, i8* nocapture %1, i8 signext %2) {
%4 = icmp eq i32 %0, 0
br i1 %4, label %46, label %5
5: ; preds = %3
%6 = icmp eq i8 %2, 0
%7 = zext i32 %0 to i64
br label %8
8: ; preds = %5, %43
%9 = phi i64 [ 0, %5 ], [ %44, %43 ]
%10 = getelementptr inbounds i8, i8* %1, i64 %9
%11 = load i8, i8* %10
%12 = lshr i8 %11, 7
%13 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %12)
%14 = load i8, i8* %10
%15 = lshr i8 %14, 6
%16 = and i8 %15, 1
%17 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %16)
%18 = load i8, i8* %10
%19 = lshr i8 %18, 5
%20 = and i8 %19, 1
%21 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %20)
%22 = load i8, i8* %10
%23 = lshr i8 %22, 4
%24 = and i8 %23, 1
%25 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %24)
%26 = load i8, i8* %10
%27 = lshr i8 %26, 3
%28 = and i8 %27, 1
%29 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %28)
%30 = load i8, i8* %10
%31 = lshr i8 %30, 2
%32 = and i8 %31, 1
%33 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %32)
%34 = load i8, i8* %10
%35 = lshr i8 %34, 1
%36 = and i8 %35, 1
%37 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %36)
%38 = load i8, i8* %10
%39 = and i8 %38, 1
%40 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %39)
br i1 %6, label %43, label %41
41: ; preds = %8
%42 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8 signext %2)
br label %43
43: ; preds = %8, %41
%44 = add nuw nsw i64 %9, 1
%45 = icmp eq i64 %44, %7
br i1 %45, label %46, label %8
46: ; preds = %43, %3
ret void
}