#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 *, unsigned char);
int /*<<< orphan*/ puts(char *);
void pb(int s, void *p) {
  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);
  puts("");
}


x86 assembly (clang, -O0):
<pb>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jl     11a2 <pb+0x82>
movl   $0x7,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jl     118f <pb+0x6f>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
mov    -0x18(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
and    %ecx,%eax
mov    -0x18(%rbp),%ecx
sar    %cl,%eax
lea    0xe87(%rip),%rdi
movzbl %al,%esi
call   1040 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
jmp    1149 <pb+0x29>
jmp    1194 <pb+0x74>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    1138 <pb+0x18>
lea    0xe59(%rip),%rdi
call   1030 <puts@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pb>:
push   %r15
push   %r14
push   %rbx
test   %edi,%edi
jle    11ea <pb+0xca>
mov    %rsi,%r15
mov    %edi,%ebx
add    $0x1,%rbx
lea    0xec3(%rip),%r14
nopl   (%rax)
movzbl -0x2(%r15,%rbx,1),%eax
shr    $0x7,%al
movzbl %al,%esi
mov    %r14,%rdi
call   1040 <printf@plt>
movzbl -0x2(%r15,%rbx,1),%esi
shr    $0x6,%esi
and    $0x1,%esi
mov    %r14,%rdi
call   1040 <printf@plt>
movzbl -0x2(%r15,%rbx,1),%esi
shr    $0x5,%esi
and    $0x1,%esi
mov    %r14,%rdi
call   1040 <printf@plt>
movzbl -0x2(%r15,%rbx,1),%esi
shr    $0x4,%esi
and    $0x1,%esi
mov    %r14,%rdi
call   1040 <printf@plt>
movzbl -0x2(%r15,%rbx,1),%esi
shr    $0x3,%esi
and    $0x1,%esi
mov    %r14,%rdi
call   1040 <printf@plt>
movzbl -0x2(%r15,%rbx,1),%esi
shr    $0x2,%esi
and    $0x1,%esi
mov    %r14,%rdi
call   1040 <printf@plt>
movzbl -0x2(%r15,%rbx,1),%esi
shr    %esi
and    $0x1,%esi
mov    %r14,%rdi
call   1040 <printf@plt>
movzbl -0x2(%r15,%rbx,1),%esi
and    $0x1,%esi
mov    %r14,%rdi
call   1040 <printf@plt>
add    $0xffffffffffffffff,%rbx
cmp    $0x1,%rbx
ja     1140 <pb+0x20>
mov    $0xa,%edi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <putchar@plt>

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

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