#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 *, int);
void bitdump(unsigned char data) {
  int c = 0;
  for (c = 0; c < 8; c++) {
    if ((data & 0x80) == 0) {
      printf("%d", 0);
    } else {
      printf("%d", 1);
    }
    data <<= 1;
  }
}


x86 assembly (clang, -O0):
<bitdump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x8,-0x8(%rbp)
jge    1184 <bitdump+0x74>
movzbl -0x1(%rbp),%eax
and    $0x80,%eax
cmp    $0x0,%eax
jne    115b <bitdump+0x4b>
lea    0xeb1(%rip),%rdi
xor    %esi,%esi
call   1030 <printf@plt>
jmp    116c <bitdump+0x5c>
lea    0xe9e(%rip),%rdi
mov    $0x1,%esi
call   1030 <printf@plt>
movzbl -0x1(%rbp),%eax
shl    $0x1,%eax
mov    %al,-0x1(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    112c <bitdump+0x1c>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bitdump>:
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebx
mov    %ebx,%eax
shr    $0x7,%al
movzbl %al,%esi
lea    0xedb(%rip),%r14
mov    %r14,%rdi
call   1030 <printf@plt>
mov    %ebx,%eax
shr    $0x6,%al
and    $0x1,%al
movzbl %al,%esi
mov    %r14,%rdi
call   1030 <printf@plt>
mov    %ebx,%eax
shr    $0x5,%al
and    $0x1,%al
movzbl %al,%esi
mov    %r14,%rdi
call   1030 <printf@plt>
mov    %ebx,%eax
shr    $0x4,%al
and    $0x1,%al
movzbl %al,%esi
mov    %r14,%rdi
call   1030 <printf@plt>
mov    %ebx,%eax
shr    $0x3,%al
and    $0x1,%al
movzbl %al,%esi
mov    %r14,%rdi
call   1030 <printf@plt>
mov    %ebx,%eax
shr    $0x2,%al
and    $0x1,%al
movzbl %al,%esi
mov    %r14,%rdi
call   1030 <printf@plt>
mov    %ebx,%eax
shr    %al
and    $0x1,%al
movzbl %al,%esi
mov    %r14,%rdi
call   1030 <printf@plt>
and    $0x1,%ebx
mov    %r14,%rdi
mov    %ebx,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
define void @bitdump(i8 zeroext %0) {
%2 = alloca i8
%3 = alloca i32
store i8 %0, i8* %2
store i32 0, i32* %3
store i32 0, i32* %3
br label %4
4: ; preds = %21, %1
%5 = load i32, i32* %3
%6 = icmp slt i32 %5, 8
br i1 %6, label %7, label %24
7: ; preds = %4
%8 = load i8, i8* %2
%9 = zext i8 %8 to i32
%10 = and i32 %9, 128
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %7
%13 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 0)
br label %16
14: ; preds = %7
%15 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 1)
br label %16
16: ; preds = %14, %12
%17 = load i8, i8* %2
%18 = zext i8 %17 to i32
%19 = shl i32 %18, 1
%20 = trunc i32 %19 to i8
store i8 %20, i8* %2
br label %21
21: ; preds = %16
%22 = load i32, i32* %3
%23 = add nsw i32 %22, 1
store i32 %23, i32* %3
br label %4
24: ; preds = %4
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define void @bitdump(i8 zeroext %0) {
%2 = lshr i8 %0, 7
%3 = zext i8 %2 to i32
%4 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = lshr i8 %0, 6
%6 = and i8 %5, 1
%7 = zext i8 %6 to i32
%8 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = lshr i8 %0, 5
%10 = and i8 %9, 1
%11 = zext i8 %10 to i32
%12 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = lshr i8 %0, 4
%14 = and i8 %13, 1
%15 = zext i8 %14 to i32
%16 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %15)
%17 = lshr i8 %0, 3
%18 = and i8 %17, 1
%19 = zext i8 %18 to i32
%20 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %19)
%21 = lshr i8 %0, 2
%22 = and i8 %21, 1
%23 = zext i8 %22 to i32
%24 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %23)
%25 = lshr i8 %0, 1
%26 = and i8 %25, 1
%27 = zext i8 %26 to i32
%28 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %27)
%29 = and i8 %0, 1
%30 = zext i8 %29 to i32
%31 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %30)
ret void
}