#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*/ v_printf(int, char *, ...);
void NESCompositeRowToChannels(char *tile_row, char *buf) {
  v_printf(3, "NESCompositeRowToChannels()");
  if (!tile_row || !buf)
    return;
  v_printf(4, "Passed errorchecking.");
  buf[0] = 0;
  buf[1] = 0;
  int i = 0;
  for (i = 0; i < 8; i++) {
    v_printf(4, "Checking %d", tile_row[i]);
    buf[0] <<= 1;
    buf[1] <<= 1;
    if (tile_row[i] & 1)
      buf[0]++;
    if (tile_row[i] & 2)
      buf[1]++;
  }
  v_printf(4, "Done.");
}


x86 assembly (clang, -O0):
<NESCompositeRowToChannels>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x3,%edi
lea    0xed4(%rip),%rsi
mov    $0x0,%al
call   1030 <v_printf@plt>
cmpq   $0x0,-0x8(%rbp)
je     1149 <NESCompositeRowToChannels+0x39>
cmpq   $0x0,-0x10(%rbp)
jne    114e <NESCompositeRowToChannels+0x3e>
jmp    122f <NESCompositeRowToChannels+0x11f>
mov    $0x4,%edi
lea    0xec2(%rip),%rsi
mov    $0x0,%al
call   1030 <v_printf@plt>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rax
movb   $0x0,0x1(%rax)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x8,-0x14(%rbp)
jge    121c <NESCompositeRowToChannels+0x10c>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%edx
mov    $0x4,%edi
lea    0xe92(%rip),%rsi
mov    $0x0,%al
call   1030 <v_printf@plt>
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
shl    $0x1,%ecx
mov    %cl,(%rax)
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%ecx
shl    $0x1,%ecx
mov    %cl,0x1(%rax)
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     11e4 <NESCompositeRowToChannels+0xd4>
mov    -0x10(%rbp),%rax
mov    (%rax),%cl
add    $0x1,%cl
mov    %cl,(%rax)
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
and    $0x2,%eax
cmp    $0x0,%eax
je     1209 <NESCompositeRowToChannels+0xf9>
mov    -0x10(%rbp),%rax
mov    0x1(%rax),%cl
add    $0x1,%cl
mov    %cl,0x1(%rax)
jmp    120e <NESCompositeRowToChannels+0xfe>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    117e <NESCompositeRowToChannels+0x6e>
mov    $0x4,%edi
lea    0xe16(%rip),%rsi
mov    $0x0,%al
call   1030 <v_printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<NESCompositeRowToChannels>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r12
mov    %rdi,%r14
lea    0xedb(%rip),%rsi
mov    $0x3,%edi
xor    %eax,%eax
call   1030 <v_printf@plt>
test   %r14,%r14
je     11ca <NESCompositeRowToChannels+0xba>
test   %r12,%r12
je     11ca <NESCompositeRowToChannels+0xba>
lea    0xed2(%rip),%rsi
mov    $0x4,%edi
xor    %eax,%eax
call   1030 <v_printf@plt>
movw   $0x0,(%r12)
lea    0xece(%rip),%r15
xor    %ebx,%ebx
jmp    117a <NESCompositeRowToChannels+0x6a>
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbx
cmp    $0x8,%rbx
je     11d6 <NESCompositeRowToChannels+0xc6>
movsbl (%r14,%rbx,1),%edx
mov    $0x4,%edi
mov    %r15,%rsi
xor    %eax,%eax
call   1030 <v_printf@plt>
movzbl (%r12),%ecx
movzbl 0x1(%r12),%eax
add    %cl,%cl
mov    %cl,(%r12)
add    %al,%al
mov    %al,0x1(%r12)
movzbl (%r14,%rbx,1),%edx
test   $0x1,%dl
je     11bc <NESCompositeRowToChannels+0xac>
or     $0x1,%cl
mov    %cl,(%r12)
movzbl (%r14,%rbx,1),%edx
test   $0x2,%dl
je     1170 <NESCompositeRowToChannels+0x60>
or     $0x1,%al
mov    %al,0x1(%r12)
jmp    1170 <NESCompositeRowToChannels+0x60>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
lea    0xe61(%rip),%rsi
mov    $0x4,%edi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <v_printf@plt>

LLVM IR (-O0):
@.str = [28 x i8] c"NESCompositeRowToChannels()\00"
@.str.1 = [22 x i8] c"Passed errorchecking.\00"
@.str.2 = [12 x i8] c"Checking %d\00"
@.str.3 = [6 x i8] c"Done.\00"
define void @NESCompositeRowToChannels(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%6 = call i32 (i32, i8*, ...) @v_printf(i32 3, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%7 = load i8*, i8** %3
%8 = icmp ne i8* %7, null
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = load i8*, i8** %4
%11 = icmp ne i8* %10, null
br i1 %11, label %13, label %12
12: ; preds = %9, %2
br label %75
13: ; preds = %9
%14 = call i32 (i32, i8*, ...) @v_printf(i32 4, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%15 = load i8*, i8** %4
%16 = getelementptr inbounds i8, i8* %15, i64 0
store i8 0, i8* %16
%17 = load i8*, i8** %4
%18 = getelementptr inbounds i8, i8* %17, i64 1
store i8 0, i8* %18
store i32 0, i32* %5
store i32 0, i32* %5
br label %19
19: ; preds = %70, %13
%20 = load i32, i32* %5
%21 = icmp slt i32 %20, 8
br i1 %21, label %22, label %73
22: ; preds = %19
%23 = load i8*, i8** %3
%24 = load i32, i32* %5
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %23, i64 %25
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = call i32 (i32, i8*, ...) @v_printf(i32 4, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %28)
%30 = load i8*, i8** %4
%31 = getelementptr inbounds i8, i8* %30, i64 0
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = shl i32 %33, 1
%35 = trunc i32 %34 to i8
store i8 %35, i8* %31
%36 = load i8*, i8** %4
%37 = getelementptr inbounds i8, i8* %36, i64 1
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = shl i32 %39, 1
%41 = trunc i32 %40 to i8
store i8 %41, i8* %37
%42 = load i8*, i8** %3
%43 = load i32, i32* %5
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i8, i8* %42, i64 %44
%46 = load i8, i8* %45
%47 = sext i8 %46 to i32
%48 = and i32 %47, 1
%49 = icmp ne i32 %48, 0
br i1 %49, label %50, label %55
50: ; preds = %22
%51 = load i8*, i8** %4
%52 = getelementptr inbounds i8, i8* %51, i64 0
%53 = load i8, i8* %52
%54 = add i8 %53, 1
store i8 %54, i8* %52
br label %55
55: ; preds = %50, %22
%56 = load i8*, i8** %3
%57 = load i32, i32* %5
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds i8, i8* %56, i64 %58
%60 = load i8, i8* %59
%61 = sext i8 %60 to i32
%62 = and i32 %61, 2
%63 = icmp ne i32 %62, 0
br i1 %63, label %64, label %69
64: ; preds = %55
%65 = load i8*, i8** %4
%66 = getelementptr inbounds i8, i8* %65, i64 1
%67 = load i8, i8* %66
%68 = add i8 %67, 1
store i8 %68, i8* %66
br label %69
69: ; preds = %64, %55
br label %70
70: ; preds = %69
%71 = load i32, i32* %5
%72 = add nsw i32 %71, 1
store i32 %72, i32* %5
br label %19
73: ; preds = %19
%74 = call i32 (i32, i8*, ...) @v_printf(i32 4, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %75
75: ; preds = %73, %12
ret void
}

LLVM IR (-O2):
@.str = [28 x i8] c"NESCompositeRowToChannels()\00"
@.str.1 = [22 x i8] c"Passed errorchecking.\00"
@.str.2 = [12 x i8] c"Checking %d\00"
@.str.3 = [6 x i8] c"Done.\00"
define void @NESCompositeRowToChannels(i8* %0, i8* %1) {
%3 = tail call i32 (i32, i8*, ...) @v_printf(i32 3, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%4 = icmp ne i8* %0, null
%5 = icmp ne i8* %1, null
%6 = and i1 %4, %5
br i1 %6, label %7, label %37
7: ; preds = %2
%8 = tail call i32 (i32, i8*, ...) @v_printf(i32 4, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
store i8 0, i8* %1
%9 = getelementptr inbounds i8, i8* %1, i64 1
store i8 0, i8* %9
br label %10
10: ; preds = %7, %32
%11 = phi i64 [ 0, %7 ], [ %33, %32 ]
%12 = getelementptr inbounds i8, i8* %0, i64 %11
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = tail call i32 (i32, i8*, ...) @v_printf(i32 4, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %14)
%16 = load i8, i8* %1
%17 = shl i8 %16, 1
store i8 %17, i8* %1
%18 = load i8, i8* %9
%19 = shl i8 %18, 1
store i8 %19, i8* %9
%20 = load i8, i8* %12
%21 = and i8 %20, 1
%22 = icmp eq i8 %21, 0
br i1 %22, label %26, label %23
23: ; preds = %10
%24 = or i8 %17, 1
store i8 %24, i8* %1
%25 = load i8, i8* %12
br label %26
26: ; preds = %23, %10
%27 = phi i8 [ %25, %23 ], [ %20, %10 ]
%28 = and i8 %27, 2
%29 = icmp eq i8 %28, 0
br i1 %29, label %32, label %30
30: ; preds = %26
%31 = or i8 %19, 1
store i8 %31, i8* %9
br label %32
32: ; preds = %26, %30
%33 = add nuw nsw i64 %11, 1
%34 = icmp eq i64 %33, 8
br i1 %34, label %35, label %10
35: ; preds = %32
%36 = tail call i32 (i32, i8*, ...) @v_printf(i32 4, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %37
37: ; preds = %2, %35
ret void
}