#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*/ write(int, ...);
void ft_bit_rev_print(void *addr, size_t size) {
  int i;
  size_t j;
  unsigned char *c;
  unsigned char a;
  unsigned char b;
  c = addr;
  j = 0;
  while (j++ < size) {
    a = c[j - 1];
    i = -1;
    while (++i < 8) {
      b = a % 2 + '0';
      write(1, &b, 1);
      a = a / 2;
    }
    write(1, "|", 1);
    if (j % 2 == 0)
      write(1, "\n", 1);
  }
}


x86 assembly (clang, -O0):
<ft_bit_rev_print>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20(%rbp)
cmp    -0x10(%rbp),%rax
jae    11ef <ft_bit_rev_print+0xdf>
mov    -0x28(%rbp),%rax
mov    -0x20(%rbp),%rcx
sub    $0x1,%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x29(%rbp)
movl   $0xffffffff,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
cmp    $0x8,%eax
jge    11ae <ft_bit_rev_print+0x9e>
movzbl -0x29(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
add    $0x30,%edx
mov    %dl,%al
mov    %al,-0x2a(%rbp)
mov    $0x1,%edx
lea    -0x2a(%rbp),%rsi
mov    %edx,%edi
mov    $0x0,%al
call   1030 <write@plt>
movzbl -0x29(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %al,-0x29(%rbp)
jmp    1162 <ft_bit_rev_print+0x52>
mov    $0x1,%edx
lea    0xe46(%rip),%rsi
mov    %edx,%edi
mov    $0x0,%al
call   1030 <write@plt>
mov    -0x20(%rbp),%rax
and    $0x1,%rax
cmp    $0x0,%rax
jne    11ea <ft_bit_rev_print+0xda>
mov    $0x1,%edx
lea    0xe21(%rip),%rsi
mov    %edx,%edi
mov    $0x0,%al
call   1030 <write@plt>
jmp    1130 <ft_bit_rev_print+0x20>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_bit_rev_print>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %rsi,%rsi
je     12a2 <ft_bit_rev_print+0x192>
mov    %rsi,%r15
mov    %rdi,%r14
neg    %r15
mov    $0x1,%ebp
lea    0x7(%rsp),%rbx
lea    0xec2(%rip),%r12
jmp    1156 <ft_bit_rev_print+0x46>
lea    (%r15,%rbp,1),%rax
add    $0x1,%rax
add    $0x1,%rbp
cmp    $0x1,%rax
je     12a2 <ft_bit_rev_print+0x192>
movzbl -0x1(%r14,%rbp,1),%r13d
mov    %r13d,%eax
and    $0x1,%al
or     $0x30,%al
mov    %al,0x7(%rsp)
mov    $0x1,%edi
mov    %rbx,%rsi
mov    $0x1,%edx
xor    %eax,%eax
call   1030 <write@plt>
mov    %r13d,%eax
shr    %al
and    $0x1,%al
or     $0x30,%al
mov    %al,0x7(%rsp)
mov    $0x1,%edi
mov    %rbx,%rsi
mov    $0x1,%edx
xor    %eax,%eax
call   1030 <write@plt>
mov    %r13d,%eax
shr    $0x2,%al
and    $0x1,%al
or     $0x30,%al
mov    %al,0x7(%rsp)
mov    $0x1,%edi
mov    %rbx,%rsi
mov    $0x1,%edx
xor    %eax,%eax
call   1030 <write@plt>
mov    %r13d,%eax
shr    $0x3,%al
and    $0x1,%al
or     $0x30,%al
mov    %al,0x7(%rsp)
mov    $0x1,%edi
mov    %rbx,%rsi
mov    $0x1,%edx
xor    %eax,%eax
call   1030 <write@plt>
mov    %r13d,%eax
shr    $0x4,%al
and    $0x1,%al
or     $0x30,%al
mov    %al,0x7(%rsp)
mov    $0x1,%edi
mov    %rbx,%rsi
mov    $0x1,%edx
xor    %eax,%eax
call   1030 <write@plt>
mov    %r13d,%eax
shr    $0x5,%al
and    $0x1,%al
or     $0x30,%al
mov    %al,0x7(%rsp)
mov    $0x1,%edi
mov    %rbx,%rsi
mov    $0x1,%edx
xor    %eax,%eax
call   1030 <write@plt>
mov    %r13d,%eax
shr    $0x6,%al
and    $0x1,%al
or     $0x30,%al
mov    %al,0x7(%rsp)
mov    $0x1,%edi
mov    %rbx,%rsi
mov    $0x1,%edx
xor    %eax,%eax
call   1030 <write@plt>
shr    $0x7,%r13b
or     $0x30,%r13b
mov    %r13b,0x7(%rsp)
mov    $0x1,%edi
mov    %rbx,%rsi
mov    $0x1,%edx
xor    %eax,%eax
call   1030 <write@plt>
mov    $0x1,%edi
mov    %r12,%rsi
mov    $0x1,%edx
xor    %eax,%eax
call   1030 <write@plt>
test   $0x1,%bpl
jne    1140 <ft_bit_rev_print+0x30>
mov    $0x1,%edi
lea    0xd71(%rip),%rsi
mov    $0x1,%edx
xor    %eax,%eax
call   1030 <write@plt>
jmp    1140 <ft_bit_rev_print+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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