#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*/ NullCheck(unsigned char const *);
int /*<<< orphan*/ clock_extern_setPixel(int, int, unsigned char const);
int clock_drawPattern(const unsigned char pattern[(8)]) {
  NullCheck(pattern);
  for (int y = 0; y < 8; ++y) {
    const unsigned char ch = pattern[y];
    for (int x = 0; x < 8; ++x)
      clock_extern_setPixel(x, y, ch & 1 << (8 - x - 1));
  }
  return 0;
}


x86 assembly (clang, -O0):
<clock_drawPattern>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <NullCheck@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0x8,-0xc(%rbp)
jge    11ae <clock_drawPattern+0x8e>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0xd(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x8,-0x14(%rbp)
jge    119b <clock_drawPattern+0x7b>
mov    -0x14(%rbp),%edi
mov    -0xc(%rbp),%esi
movzbl -0xd(%rbp),%eax
mov    $0x8,%ecx
sub    -0x14(%rbp),%ecx
sub    $0x1,%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
and    %ecx,%eax
movzbl %al,%edx
call   1030 <clock_extern_setPixel@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    115b <clock_drawPattern+0x3b>
jmp    11a0 <clock_drawPattern+0x80>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    113c <clock_drawPattern+0x1c>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<clock_drawPattern>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%r14
call   1040 <NullCheck@plt>
xor    %ebx,%ebx
xchg   %ax,%ax
movzbl (%r14,%rbx,1),%ebp
mov    %ebp,%edx
and    $0xffffff80,%edx
xor    %edi,%edi
mov    %ebx,%esi
call   1030 <clock_extern_setPixel@plt>
mov    %ebp,%edx
and    $0x40,%edx
mov    $0x1,%edi
mov    %ebx,%esi
call   1030 <clock_extern_setPixel@plt>
mov    %ebp,%edx
and    $0x20,%edx
mov    $0x2,%edi
mov    %ebx,%esi
call   1030 <clock_extern_setPixel@plt>
mov    %ebp,%edx
and    $0x10,%edx
mov    $0x3,%edi
mov    %ebx,%esi
call   1030 <clock_extern_setPixel@plt>
mov    %ebp,%edx
and    $0x8,%edx
mov    $0x4,%edi
mov    %ebx,%esi
call   1030 <clock_extern_setPixel@plt>
mov    %ebp,%edx
and    $0x4,%edx
mov    $0x5,%edi
mov    %ebx,%esi
call   1030 <clock_extern_setPixel@plt>
mov    %ebp,%edx
and    $0x2,%edx
mov    $0x6,%edi
mov    %ebx,%esi
call   1030 <clock_extern_setPixel@plt>
and    $0x1,%ebp
mov    $0x7,%edi
mov    %ebx,%esi
mov    %ebp,%edx
call   1030 <clock_extern_setPixel@plt>
add    $0x1,%rbx
cmp    $0x8,%rbx
jne    1130 <clock_drawPattern+0x10>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @clock_drawPattern(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8
%5 = alloca i32
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = call i32 @NullCheck(i8* %6)
store i32 0, i32* %3
br label %8
8: ; preds = %36, %1
%9 = load i32, i32* %3
%10 = icmp slt i32 %9, 8
br i1 %10, label %11, label %39
11: ; preds = %8
%12 = load i8*, i8** %2
%13 = load i32, i32* %3
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %12, i64 %14
%16 = load i8, i8* %15
store i8 %16, i8* %4
store i32 0, i32* %5
br label %17
17: ; preds = %32, %11
%18 = load i32, i32* %5
%19 = icmp slt i32 %18, 8
br i1 %19, label %20, label %35
20: ; preds = %17
%21 = load i32, i32* %5
%22 = load i32, i32* %3
%23 = load i8, i8* %4
%24 = zext i8 %23 to i32
%25 = load i32, i32* %5
%26 = sub nsw i32 8, %25
%27 = sub nsw i32 %26, 1
%28 = shl i32 1, %27
%29 = and i32 %24, %28
%30 = trunc i32 %29 to i8
%31 = call i32 @clock_extern_setPixel(i32 %21, i32 %22, i8 zeroext %30)
br label %32
32: ; preds = %20
%33 = load i32, i32* %5
%34 = add nsw i32 %33, 1
store i32 %34, i32* %5
br label %17
35: ; preds = %17
br label %36
36: ; preds = %35
%37 = load i32, i32* %3
%38 = add nsw i32 %37, 1
store i32 %38, i32* %3
br label %8
39: ; preds = %8
ret i32 0
}

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