#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*/ GBA_Debug_PrintZoomedSpriteAt(int, int, unsigned char *, int,
                                                 int, int, int, int, int);
int /*<<< orphan*/ memset(unsigned char *, int /*<<< orphan*/, int);
void GBA_Debug_PrintSpritesPage(int page, int buf_has_alpha_channel,
                                unsigned char *buffer, int bufw, int bufh) {
  if (buf_has_alpha_channel) {
    memset(buffer, 0, bufw * bufh * 4);
  } else {
    for (int i = 0; i < bufw; i++) {
      for (int j = 0; j < bufh; j++) {
        int index = (j * bufw + i) * 3;
        buffer[index + 0] = ((i & 32) ^ (j & 32)) ? 0x80 : 0xB0;
        buffer[index + 1] = ((i & 32) ^ (j & 32)) ? 0x80 : 0xB0;
        buffer[index + 2] = ((i & 32) ^ (j & 32)) ? 0x80 : 0xB0;
      }
    }
  }
  for (int i = 0; i < 8; i++) {
    for (int j = 0; j < 8; j++) {
      int sprnum = (page * 64) + (j * 8) + i;
      GBA_Debug_PrintZoomedSpriteAt(sprnum, buf_has_alpha_channel, buffer, bufw,
                                    bufh, (i * (64 + 16)) + 16,
                                    (j * (64 + 16)) + 16, 64, 64);
    }
  }
}


x86 assembly (clang, -O0):
<GBA_Debug_PrintSpritesPage>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8d,-0x18(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     115d <GBA_Debug_PrintSpritesPage+0x3d>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%edx
imul   -0x18(%rbp),%edx
shl    $0x2,%edx
xor    %esi,%esi
call   1030 <memset@plt>
jmp    1249 <GBA_Debug_PrintSpritesPage+0x129>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1244 <GBA_Debug_PrintSpritesPage+0x124>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1231 <GBA_Debug_PrintSpritesPage+0x111>
mov    -0x20(%rbp),%eax
imul   -0x14(%rbp),%eax
add    -0x1c(%rbp),%eax
imul   $0x3,%eax,%eax
mov    %eax,-0x24(%rbp)
mov    -0x1c(%rbp),%edx
and    $0x20,%edx
mov    -0x20(%rbp),%eax
and    $0x20,%eax
xor    %eax,%edx
mov    $0xb0,%eax
mov    $0x80,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %al,%dl
mov    -0x10(%rbp),%rax
mov    -0x24(%rbp),%ecx
add    $0x0,%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x1c(%rbp),%edx
and    $0x20,%edx
mov    -0x20(%rbp),%eax
and    $0x20,%eax
xor    %eax,%edx
mov    $0xb0,%eax
mov    $0x80,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %al,%dl
mov    -0x10(%rbp),%rax
mov    -0x24(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x1c(%rbp),%edx
and    $0x20,%edx
mov    -0x20(%rbp),%eax
and    $0x20,%eax
xor    %eax,%edx
mov    $0xb0,%eax
mov    $0x80,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %al,%dl
mov    -0x10(%rbp),%rax
mov    -0x24(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1177 <GBA_Debug_PrintSpritesPage+0x57>
jmp    1236 <GBA_Debug_PrintSpritesPage+0x116>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1164 <GBA_Debug_PrintSpritesPage+0x44>
jmp    1249 <GBA_Debug_PrintSpritesPage+0x129>
movl   $0x0,-0x28(%rbp)
cmpl   $0x8,-0x28(%rbp)
jge    12d9 <GBA_Debug_PrintSpritesPage+0x1b9>
movl   $0x0,-0x2c(%rbp)
cmpl   $0x8,-0x2c(%rbp)
jge    12c6 <GBA_Debug_PrintSpritesPage+0x1a6>
mov    -0x4(%rbp),%eax
shl    $0x6,%eax
mov    -0x2c(%rbp),%ecx
shl    $0x3,%ecx
add    %ecx,%eax
add    -0x28(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%rdx
mov    -0x14(%rbp),%ecx
mov    -0x18(%rbp),%r8d
imul   $0x50,-0x28(%rbp),%r9d
add    $0x10,%r9d
imul   $0x50,-0x2c(%rbp),%eax
add    $0x10,%eax
mov    %eax,(%rsp)
movl   $0x40,0x8(%rsp)
movl   $0x40,0x10(%rsp)
call   1040 <GBA_Debug_PrintZoomedSpriteAt@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1261 <GBA_Debug_PrintSpritesPage+0x141>
jmp    12cb <GBA_Debug_PrintSpritesPage+0x1ab>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1250 <GBA_Debug_PrintSpritesPage+0x130>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GBA_Debug_PrintSpritesPage>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r8d,%ebx
mov    %ecx,%r15d
mov    %rdx,%r12
mov    %edi,%r14d
mov    %esi,%r13d
test   %esi,%esi
je     1351 <GBA_Debug_PrintSpritesPage+0x231>
mov    %r15d,%edx
imul   %ebx,%edx
shl    $0x2,%edx
mov    %r12,%rdi
xor    %esi,%esi
call   1030 <memset@plt>
mov    %r13d,0x8(%rsp)
shl    $0x6,%r14d
mov    %r14,0x10(%rsp)
mov    %r15d,0x1c(%rsp)
mov    %r12,0x20(%rsp)
mov    %ebx,0xc(%rsp)
xor    %r14d,%r14d
mov    $0x10,%eax
nopl   0x0(%rax)
mov    %eax,0x4(%rsp)
mov    0x10(%rsp),%r12
lea    (%r12,%r14,1),%edi
sub    $0x8,%rsp
mov    0x10(%rsp),%esi
mov    %esi,%ebp
mov    0x28(%rsp),%r15
mov    %r15,%rdx
mov    0x24(%rsp),%r13d
mov    %r13d,%ecx
mov    0x14(%rsp),%r8d
mov    0xc(%rsp),%r9d
push   $0x40
push   $0x40
push   $0x10
call   1040 <GBA_Debug_PrintZoomedSpriteAt@plt>
add    $0x20,%rsp
lea    (%r12,%r14,1),%edi
add    $0x8,%edi
sub    $0x8,%rsp
mov    %ebp,%ebx
mov    %ebp,%esi
mov    %r15,%rdx
mov    %r15,%rbp
mov    %r13d,%ecx
mov    0x14(%rsp),%r15d
mov    %r15d,%r8d
mov    0xc(%rsp),%r9d
push   $0x40
push   $0x40
push   $0x60
call   1040 <GBA_Debug_PrintZoomedSpriteAt@plt>
add    $0x20,%rsp
lea    (%r12,%r14,1),%edi
add    $0x10,%edi
sub    $0x8,%rsp
mov    %ebx,%esi
mov    %rbp,%rdx
mov    %r13d,%ecx
mov    %r15d,%r8d
mov    %r15d,%ebp
mov    0xc(%rsp),%r9d
push   $0x40
push   $0x40
push   $0xb0
call   1040 <GBA_Debug_PrintZoomedSpriteAt@plt>
add    $0x20,%rsp
lea    (%r12,%r14,1),%edi
add    $0x18,%edi
sub    $0x8,%rsp
mov    %ebx,%esi
mov    0x28(%rsp),%r15
mov    %r15,%rdx
mov    %r13d,%ecx
mov    %ebp,%ebx
mov    %ebp,%r8d
mov    0xc(%rsp),%r9d
push   $0x40
push   $0x40
push   $0x100
call   1040 <GBA_Debug_PrintZoomedSpriteAt@plt>
add    $0x20,%rsp
mov    %r12,%rbp
lea    (%r12,%r14,1),%edi
add    $0x20,%edi
sub    $0x8,%rsp
mov    0x10(%rsp),%esi
mov    %r15,%rdx
mov    %r13d,%r12d
mov    %r13d,%ecx
mov    %ebx,%r8d
mov    0xc(%rsp),%r9d
push   $0x40
push   $0x40
push   $0x150
call   1040 <GBA_Debug_PrintZoomedSpriteAt@plt>
add    $0x20,%rsp
lea    (%r14,%rbp,1),%edi
add    $0x28,%edi
sub    $0x8,%rsp
mov    0x10(%rsp),%ebp
mov    %ebp,%esi
mov    %r15,%rdx
mov    %r15,%r13
mov    %r12d,%ecx
mov    %r12d,%r15d
mov    0x14(%rsp),%r12d
mov    %r12d,%r8d
mov    0xc(%rsp),%r9d
push   $0x40
push   $0x40
push   $0x1a0
call   1040 <GBA_Debug_PrintZoomedSpriteAt@plt>
add    $0x20,%rsp
mov    0x10(%rsp),%rax
lea    (%rax,%r14,1),%edi
add    $0x30,%edi
sub    $0x8,%rsp
mov    %ebp,%esi
mov    %r13,%rdx
mov    %r15d,%ecx
mov    %r12d,%r8d
mov    0xc(%rsp),%r9d
push   $0x40
push   $0x40
push   $0x1f0
call   1040 <GBA_Debug_PrintZoomedSpriteAt@plt>
add    $0x20,%rsp
mov    0x10(%rsp),%rax
lea    (%rax,%r14,1),%edi
add    $0x38,%edi
sub    $0x8,%rsp
mov    %ebp,%esi
mov    %r13,%rdx
mov    %r15d,%ecx
mov    %r12d,%r8d
mov    0xc(%rsp),%r9d
push   $0x40
push   $0x40
push   $0x240
call   1040 <GBA_Debug_PrintZoomedSpriteAt@plt>
mov    0x24(%rsp),%eax
add    $0x20,%rsp
add    $0x1,%r14d
add    $0x50,%eax
cmp    $0x8,%r14d
jne    1180 <GBA_Debug_PrintSpritesPage+0x60>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
test   %r15d,%r15d
jle    1158 <GBA_Debug_PrintSpritesPage+0x38>
mov    %r15d,%r8d
mov    %ebx,%ecx
lea    0x2(%r12),%r9
lea    (%r8,%r8,2),%rsi
xor    %edi,%edi
mov    $0xb0,%r10d
jmp    1391 <GBA_Debug_PrintSpritesPage+0x271>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%rdi
add    $0x3,%r9
cmp    %r8,%rdi
je     1158 <GBA_Debug_PrintSpritesPage+0x38>
test   %ebx,%ebx
jle    1380 <GBA_Debug_PrintSpritesPage+0x260>
mov    %r9,%rdx
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
mov    %ebp,%eax
xor    %edi,%eax
test   $0x20,%al
mov    $0x80,%eax
cmove  %r10d,%eax
mov    %al,-0x2(%rdx)
mov    %al,-0x1(%rdx)
mov    %al,(%rdx)
add    $0x1,%rbp
add    %rsi,%rdx
cmp    %rbp,%rcx
jne    13a0 <GBA_Debug_PrintSpritesPage+0x280>
jmp    1380 <GBA_Debug_PrintSpritesPage+0x260>

LLVM IR (-O0):
define void @GBA_Debug_PrintSpritesPage(i32 %0, i32 %1, i8* %2, i32 %3, i32 %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
store i32 %0, i32* %6
store i32 %1, i32* %7
store i8* %2, i8** %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%17 = load i32, i32* %7
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %26
19: ; preds = %5
%20 = load i8*, i8** %8
%21 = load i32, i32* %9
%22 = load i32, i32* %10
%23 = mul nsw i32 %21, %22
%24 = mul nsw i32 %23, 4
%25 = call i32 @memset(i8* %20, i32 0, i32 %24)
br label %93
26: ; preds = %5
store i32 0, i32* %11
br label %27
27: ; preds = %89, %26
%28 = load i32, i32* %11
%29 = load i32, i32* %9
%30 = icmp slt i32 %28, %29
br i1 %30, label %31, label %92
31: ; preds = %27
store i32 0, i32* %12
br label %32
32: ; preds = %85, %31
%33 = load i32, i32* %12
%34 = load i32, i32* %10
%35 = icmp slt i32 %33, %34
br i1 %35, label %36, label %88
36: ; preds = %32
%37 = load i32, i32* %12
%38 = load i32, i32* %9
%39 = mul nsw i32 %37, %38
%40 = load i32, i32* %11
%41 = add nsw i32 %39, %40
%42 = mul nsw i32 %41, 3
store i32 %42, i32* %13
%43 = load i32, i32* %11
%44 = and i32 %43, 32
%45 = load i32, i32* %12
%46 = and i32 %45, 32
%47 = xor i32 %44, %46
%48 = icmp ne i32 %47, 0
%49 = zext i1 %48 to i64
%50 = select i1 %48, i32 128, i32 176
%51 = trunc i32 %50 to i8
%52 = load i8*, i8** %8
%53 = load i32, i32* %13
%54 = add nsw i32 %53, 0
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds i8, i8* %52, i64 %55
store i8 %51, i8* %56
%57 = load i32, i32* %11
%58 = and i32 %57, 32
%59 = load i32, i32* %12
%60 = and i32 %59, 32
%61 = xor i32 %58, %60
%62 = icmp ne i32 %61, 0
%63 = zext i1 %62 to i64
%64 = select i1 %62, i32 128, i32 176
%65 = trunc i32 %64 to i8
%66 = load i8*, i8** %8
%67 = load i32, i32* %13
%68 = add nsw i32 %67, 1
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds i8, i8* %66, i64 %69
store i8 %65, i8* %70
%71 = load i32, i32* %11
%72 = and i32 %71, 32
%73 = load i32, i32* %12
%74 = and i32 %73, 32
%75 = xor i32 %72, %74
%76 = icmp ne i32 %75, 0
%77 = zext i1 %76 to i64
%78 = select i1 %76, i32 128, i32 176
%79 = trunc i32 %78 to i8
%80 = load i8*, i8** %8
%81 = load i32, i32* %13
%82 = add nsw i32 %81, 2
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds i8, i8* %80, i64 %83
store i8 %79, i8* %84
br label %85
85: ; preds = %36
%86 = load i32, i32* %12
%87 = add nsw i32 %86, 1
store i32 %87, i32* %12
br label %32
88: ; preds = %32
br label %89
89: ; preds = %88
%90 = load i32, i32* %11
%91 = add nsw i32 %90, 1
store i32 %91, i32* %11
br label %27
92: ; preds = %27
br label %93
93: ; preds = %92, %19
store i32 0, i32* %14
br label %94
94: ; preds = %125, %93
%95 = load i32, i32* %14
%96 = icmp slt i32 %95, 8
br i1 %96, label %97, label %128
97: ; preds = %94
store i32 0, i32* %15
br label %98
98: ; preds = %121, %97
%99 = load i32, i32* %15
%100 = icmp slt i32 %99, 8
br i1 %100, label %101, label %124
101: ; preds = %98
%102 = load i32, i32* %6
%103 = mul nsw i32 %102, 64
%104 = load i32, i32* %15
%105 = mul nsw i32 %104, 8
%106 = add nsw i32 %103, %105
%107 = load i32, i32* %14
%108 = add nsw i32 %106, %107
store i32 %108, i32* %16
%109 = load i32, i32* %16
%110 = load i32, i32* %7
%111 = load i8*, i8** %8
%112 = load i32, i32* %9
%113 = load i32, i32* %10
%114 = load i32, i32* %14
%115 = mul nsw i32 %114, 80
%116 = add nsw i32 %115, 16
%117 = load i32, i32* %15
%118 = mul nsw i32 %117, 80
%119 = add nsw i32 %118, 16
%120 = call i32 @GBA_Debug_PrintZoomedSpriteAt(i32 %109, i32 %110, i8* %111, i32 %112, i32 %113, i32 %116, i32 %119, i32 64, i32 64)
br label %121
121: ; preds = %101
%122 = load i32, i32* %15
%123 = add nsw i32 %122, 1
store i32 %123, i32* %15
br label %98
124: ; preds = %98
br label %125
125: ; preds = %124
%126 = load i32, i32* %14
%127 = add nsw i32 %126, 1
store i32 %127, i32* %14
br label %94
128: ; preds = %94
ret void
}

LLVM IR (-O2):
define void @GBA_Debug_PrintSpritesPage(i32 %0, i32 %1, i8* %2, i32 %3, i32 %4) {
%6 = icmp eq i32 %1, 0
br i1 %6, label %7, label %14
7: ; preds = %5
%8 = icmp sgt i32 %3, 0
br i1 %8, label %9, label %39
9: ; preds = %7
%10 = icmp sgt i32 %4, 0
%11 = zext i32 %3 to i64
%12 = zext i32 %3 to i64
%13 = zext i32 %4 to i64
br label %18
14: ; preds = %5
%15 = shl i32 %3, 2
%16 = mul i32 %15, %4
%17 = tail call i32 @memset(i8* %2, i32 0, i32 %16)
br label %39
18: ; preds = %9, %20
%19 = phi i64 [ 0, %9 ], [ %21, %20 ]
br i1 %10, label %23, label %20
20: ; preds = %23, %18
%21 = add nuw nsw i64 %19, 1
%22 = icmp eq i64 %21, %12
br i1 %22, label %39, label %18
23: ; preds = %18, %23
%24 = phi i64 [ %37, %23 ], [ 0, %18 ]
%25 = mul nsw i64 %24, %11
%26 = add nuw nsw i64 %25, %19
%27 = mul nsw i64 %26, 3
%28 = xor i64 %24, %19
%29 = and i64 %28, 32
%30 = icmp eq i64 %29, 0
%31 = select i1 %30, i8 -80, i8 -128
%32 = getelementptr inbounds i8, i8* %2, i64 %27
store i8 %31, i8* %32
%33 = add nuw nsw i64 %27, 1
%34 = getelementptr inbounds i8, i8* %2, i64 %33
store i8 %31, i8* %34
%35 = add nuw nsw i64 %27, 2
%36 = getelementptr inbounds i8, i8* %2, i64 %35
store i8 %31, i8* %36
%37 = add nuw nsw i64 %24, 1
%38 = icmp eq i64 %37, %13
br i1 %38, label %20, label %23
39: ; preds = %20, %7, %14
%40 = shl nsw i32 %0, 6
br label %41
41: ; preds = %39, %41
%42 = phi i32 [ 0, %39 ], [ %61, %41 ]
%43 = add nuw nsw i32 %42, %40
%44 = mul nuw nsw i32 %42, 80
%45 = add nuw nsw i32 %44, 16
%46 = tail call i32 @GBA_Debug_PrintZoomedSpriteAt(i32 %43, i32 %1, i8* %2, i32 %3, i32 %4, i32 %45, i32 16, i32 64, i32 64)
%47 = add nuw nsw i32 %43, 8
%48 = tail call i32 @GBA_Debug_PrintZoomedSpriteAt(i32 %47, i32 %1, i8* %2, i32 %3, i32 %4, i32 %45, i32 96, i32 64, i32 64)
%49 = add nuw nsw i32 %43, 16
%50 = tail call i32 @GBA_Debug_PrintZoomedSpriteAt(i32 %49, i32 %1, i8* %2, i32 %3, i32 %4, i32 %45, i32 176, i32 64, i32 64)
%51 = add nuw nsw i32 %43, 24
%52 = tail call i32 @GBA_Debug_PrintZoomedSpriteAt(i32 %51, i32 %1, i8* %2, i32 %3, i32 %4, i32 %45, i32 256, i32 64, i32 64)
%53 = add nuw nsw i32 %43, 32
%54 = tail call i32 @GBA_Debug_PrintZoomedSpriteAt(i32 %53, i32 %1, i8* %2, i32 %3, i32 %4, i32 %45, i32 336, i32 64, i32 64)
%55 = add nuw nsw i32 %43, 40
%56 = tail call i32 @GBA_Debug_PrintZoomedSpriteAt(i32 %55, i32 %1, i8* %2, i32 %3, i32 %4, i32 %45, i32 416, i32 64, i32 64)
%57 = add nuw nsw i32 %43, 48
%58 = tail call i32 @GBA_Debug_PrintZoomedSpriteAt(i32 %57, i32 %1, i8* %2, i32 %3, i32 %4, i32 %45, i32 496, i32 64, i32 64)
%59 = add nuw nsw i32 %43, 56
%60 = tail call i32 @GBA_Debug_PrintZoomedSpriteAt(i32 %59, i32 %1, i8* %2, i32 %3, i32 %4, i32 %45, i32 576, i32 64, i32 64)
%61 = add nuw nsw i32 %42, 1
%62 = icmp eq i32 %61, 8
br i1 %62, label %63, label %41
63: ; preds = %41
ret void
}