#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*/ print_pixel(unsigned char);
int /*<<< orphan*/ printf(char *);
void print_square(unsigned char *c) {
  int i, j;
  for (j = 7; j >= 0; j--) {
    for (i = 0; i < 8; i++)
      print_pixel(c[j] & (1 << (7 - i)));
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<print_square>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x7,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jl     119d <print_square+0x7d>
movl   $0x0,-0xc(%rbp)
cmpl   $0x8,-0xc(%rbp)
jge    1183 <print_square+0x63>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
mov    $0x7,%ecx
sub    -0xc(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
and    %ecx,%eax
movzbl %al,%edi
call   1030 <print_pixel@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1144 <print_square+0x24>
lea    0xe76(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
jmp    1133 <print_square+0x13>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_square>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    $0x7,%ebx
nopl   0x0(%rax)
movzbl (%r14,%rbx,1),%edi
and    $0xffffff80,%edi
call   1040 <print_pixel@plt>
movzbl (%r14,%rbx,1),%edi
and    $0x40,%edi
call   1040 <print_pixel@plt>
movzbl (%r14,%rbx,1),%edi
and    $0x20,%edi
call   1040 <print_pixel@plt>
movzbl (%r14,%rbx,1),%edi
and    $0x10,%edi
call   1040 <print_pixel@plt>
movzbl (%r14,%rbx,1),%edi
and    $0x8,%edi
call   1040 <print_pixel@plt>
movzbl (%r14,%rbx,1),%edi
and    $0x4,%edi
call   1040 <print_pixel@plt>
movzbl (%r14,%rbx,1),%edi
and    $0x2,%edi
call   1040 <print_pixel@plt>
movzbl (%r14,%rbx,1),%edi
and    $0x1,%edi
call   1040 <print_pixel@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0xffffffffffffffff,%rbx
jb     1130 <print_square+0x10>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define void @print_square(i8* nocapture %0) {
br label %2
2: ; preds = %1, %2
%3 = phi i64 [ 7, %1 ], [ %30, %2 ]
%4 = getelementptr inbounds i8, i8* %0, i64 %3
%5 = load i8, i8* %4
%6 = and i8 %5, -128
%7 = tail call i32 @print_pixel(i8 zeroext %6)
%8 = load i8, i8* %4
%9 = and i8 %8, 64
%10 = tail call i32 @print_pixel(i8 zeroext %9)
%11 = load i8, i8* %4
%12 = and i8 %11, 32
%13 = tail call i32 @print_pixel(i8 zeroext %12)
%14 = load i8, i8* %4
%15 = and i8 %14, 16
%16 = tail call i32 @print_pixel(i8 zeroext %15)
%17 = load i8, i8* %4
%18 = and i8 %17, 8
%19 = tail call i32 @print_pixel(i8 zeroext %18)
%20 = load i8, i8* %4
%21 = and i8 %20, 4
%22 = tail call i32 @print_pixel(i8 zeroext %21)
%23 = load i8, i8* %4
%24 = and i8 %23, 2
%25 = tail call i32 @print_pixel(i8 zeroext %24)
%26 = load i8, i8* %4
%27 = and i8 %26, 1
%28 = tail call i32 @print_pixel(i8 zeroext %27)
%29 = tail call i32 @putchar(i32 10)
%30 = add nsw i64 %3, -1
%31 = icmp eq i64 %3, 0
br i1 %31, label %32, label %2
32: ; preds = %2
ret void
}