#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*/ draw_rectangle(unsigned char *, int, int, int, int, int, int,
                                  unsigned char);
void grid(unsigned char *sl, int w, int h, unsigned char *a) {
  int i, j;
  unsigned char black, white, tr;
  black = 0;
  white = 255;
  tr = 200;
  for (i = 0; i < (w * h); i++)
    sl[i] = black;
  for (i = 0; i < (w * h); i++)
    a[i] = 0;
  for (i = 0; i < h; i = i + 2)
    for (j = 0; j < w; j = j + 10) {
      sl[i * w + j] = white;
      a[i * w + j] = tr;
    }
  for (i = 0; i < h; i = i + 10)
    for (j = 0; j < w; j = j + 2) {
      sl[i * w + j] = white;
      a[i * w + j] = tr;
    }
  for (i = 0; i < h; i = i + 50)
    for (j = 0; j < w; j = j + 50) {
      draw_rectangle(sl, w, h, i, j - 1, 1, 3, white);
      draw_rectangle(sl, w, h, i - 1, j, 3, 1, white);
      draw_rectangle(a, w, h, i, j - 1, 1, 3, tr);
      draw_rectangle(a, w, h, i - 1, j, 3, 1, tr);
    }
  for (i = 0; i < h; i = i + 100)
    for (j = 0; j < w; j = j + 100) {
      draw_rectangle(sl, w, h, i, j - 4, 1, 9, white);
      draw_rectangle(sl, w, h, i - 4, j, 9, 1, white);
      draw_rectangle(sl, w, h, i - 1, j - 1, 3, 3, white);
      draw_rectangle(a, w, h, i, j - 4, 1, 9, tr);
      draw_rectangle(a, w, h, i - 4, j, 9, 1, tr);
      draw_rectangle(a, w, h, i - 1, j - 1, 3, 3, tr);
    }
}


x86 assembly (clang, -O0):
<grid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
movb   $0x0,-0x21(%rbp)
movb   $0xff,-0x22(%rbp)
movb   $0xc8,-0x23(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0xc(%rbp),%ecx
imul   -0x10(%rbp),%ecx
cmp    %ecx,%eax
jge    1167 <grid+0x57>
mov    -0x21(%rbp),%dl
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1139 <grid+0x29>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0xc(%rbp),%ecx
imul   -0x10(%rbp),%ecx
cmp    %ecx,%eax
jge    119a <grid+0x8a>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    116e <grid+0x5e>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    120f <grid+0xff>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11fc <grid+0xec>
mov    -0x22(%rbp),%dl
mov    -0x8(%rbp),%rax
mov    -0x1c(%rbp),%ecx
imul   -0xc(%rbp),%ecx
add    -0x20(%rbp),%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x23(%rbp),%dl
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
imul   -0xc(%rbp),%ecx
add    -0x20(%rbp),%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x20(%rbp),%eax
add    $0xa,%eax
mov    %eax,-0x20(%rbp)
jmp    11b4 <grid+0xa4>
jmp    1201 <grid+0xf1>
mov    -0x1c(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x1c(%rbp)
jmp    11a1 <grid+0x91>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1284 <grid+0x174>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1271 <grid+0x161>
mov    -0x22(%rbp),%dl
mov    -0x8(%rbp),%rax
mov    -0x1c(%rbp),%ecx
imul   -0xc(%rbp),%ecx
add    -0x20(%rbp),%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x23(%rbp),%dl
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
imul   -0xc(%rbp),%ecx
add    -0x20(%rbp),%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x20(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x20(%rbp)
jmp    1229 <grid+0x119>
jmp    1276 <grid+0x166>
mov    -0x1c(%rbp),%eax
add    $0xa,%eax
mov    %eax,-0x1c(%rbp)
jmp    1216 <grid+0x106>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1385 <grid+0x275>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1372 <grid+0x262>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x1c(%rbp),%ecx
mov    -0x20(%rbp),%r8d
sub    $0x1,%r8d
mov    $0x1,%r9d
movl   $0x3,(%rsp)
movzbl -0x22(%rbp),%eax
mov    %eax,0x8(%rsp)
call   1030 <draw_rectangle@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
mov    -0x20(%rbp),%r8d
mov    $0x3,%r9d
movl   $0x1,(%rsp)
movzbl -0x22(%rbp),%eax
mov    %eax,0x8(%rsp)
call   1030 <draw_rectangle@plt>
mov    -0x18(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x1c(%rbp),%ecx
mov    -0x20(%rbp),%r8d
sub    $0x1,%r8d
mov    $0x1,%r9d
movl   $0x3,(%rsp)
movzbl -0x23(%rbp),%eax
mov    %eax,0x8(%rsp)
call   1030 <draw_rectangle@plt>
mov    -0x18(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
mov    -0x20(%rbp),%r8d
mov    $0x3,%r9d
movl   $0x1,(%rsp)
movzbl -0x23(%rbp),%eax
mov    %eax,0x8(%rsp)
call   1030 <draw_rectangle@plt>
mov    -0x20(%rbp),%eax
add    $0x32,%eax
mov    %eax,-0x20(%rbp)
jmp    129e <grid+0x18e>
jmp    1377 <grid+0x267>
mov    -0x1c(%rbp),%eax
add    $0x32,%eax
mov    %eax,-0x1c(%rbp)
jmp    128b <grid+0x17b>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    14ea <grid+0x3da>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    14d7 <grid+0x3c7>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x1c(%rbp),%ecx
mov    -0x20(%rbp),%r8d
sub    $0x4,%r8d
mov    $0x1,%r9d
movl   $0x9,(%rsp)
movzbl -0x22(%rbp),%eax
mov    %eax,0x8(%rsp)
call   1030 <draw_rectangle@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x1c(%rbp),%ecx
sub    $0x4,%ecx
mov    -0x20(%rbp),%r8d
mov    $0x9,%r9d
movl   $0x1,(%rsp)
movzbl -0x22(%rbp),%eax
mov    %eax,0x8(%rsp)
call   1030 <draw_rectangle@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
mov    -0x20(%rbp),%r8d
sub    $0x1,%r8d
mov    $0x3,%r9d
movl   $0x3,(%rsp)
movzbl -0x22(%rbp),%eax
mov    %eax,0x8(%rsp)
call   1030 <draw_rectangle@plt>
mov    -0x18(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x1c(%rbp),%ecx
mov    -0x20(%rbp),%r8d
sub    $0x4,%r8d
mov    $0x1,%r9d
movl   $0x9,(%rsp)
movzbl -0x23(%rbp),%eax
mov    %eax,0x8(%rsp)
call   1030 <draw_rectangle@plt>
mov    -0x18(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x1c(%rbp),%ecx
sub    $0x4,%ecx
mov    -0x20(%rbp),%r8d
mov    $0x9,%r9d
movl   $0x1,(%rsp)
movzbl -0x23(%rbp),%eax
mov    %eax,0x8(%rsp)
call   1030 <draw_rectangle@plt>
mov    -0x18(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
mov    -0x20(%rbp),%r8d
sub    $0x1,%r8d
mov    $0x3,%r9d
movl   $0x3,(%rsp)
movzbl -0x23(%rbp),%eax
mov    %eax,0x8(%rsp)
call   1030 <draw_rectangle@plt>
mov    -0x20(%rbp),%eax
add    $0x64,%eax
mov    %eax,-0x20(%rbp)
jmp    139f <grid+0x28f>
jmp    14dc <grid+0x3cc>
mov    -0x1c(%rbp),%eax
add    $0x64,%eax
mov    %eax,-0x1c(%rbp)
jmp    138c <grid+0x27c>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<grid>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rcx,%rbp
mov    %edx,%r13d
mov    %esi,%r14d
mov    %rdi,%rbx
mov    %edx,%eax
imul   %esi,%eax
test   %eax,%eax
jle    1160 <grid+0x40>
mov    %eax,%r15d
mov    %rbx,%rdi
xor    %esi,%esi
mov    %r15,%rdx
call   1040 <memset@plt>
mov    %rbp,%rdi
xor    %esi,%esi
mov    %r15,%rdx
call   1040 <memset@plt>
mov    %rbx,0x20(%rsp)
mov    %rbp,0x18(%rsp)
test   %r13d,%r13d
jle    1591 <grid+0x471>
movslq %r14d,%r11
mov    %r13d,%r10d
lea    -0x1(%r11),%r9
movabs $0xcccccccccccccccd,%rcx
cc cc cc
mov    %r9,%rax
mul    %rcx
shr    $0x3,%rdx
add    $0x1,%rdx
mov    %edx,%r8d
and    $0x3,%r8d
and    $0xfffffffffffffffc,%rdx
add    %r11,%r11
lea    (%r8,%r8,1),%rax
lea    (%rax,%rax,4),%rcx
xor    %r15d,%r15d
mov    0x20(%rsp),%rbp
mov    0x18(%rsp),%rbx
jmp    11cf <grid+0xaf>
nopw   0x0(%rax,%rax,1)
add    $0x2,%r15
add    %r11,%rbx
add    %r11,%rbp
cmp    %r10,%r15
jae    1246 <grid+0x126>
test   %r14d,%r14d
jle    11c0 <grid+0xa0>
cmp    $0x1e,%r9
jae    11e0 <grid+0xc0>
xor    %eax,%eax
jmp    1221 <grid+0x101>
xchg   %ax,%ax
mov    %rdx,%rdi
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
nop
movb   $0xff,0x0(%rbp,%rax,1)
movb   $0xc8,(%rbx,%rax,1)
movb   $0xff,0xa(%rbp,%rax,1)
movb   $0xc8,0xa(%rbx,%rax,1)
movb   $0xff,0x14(%rbp,%rax,1)
movb   $0xc8,0x14(%rbx,%rax,1)
movb   $0xff,0x1e(%rbp,%rax,1)
movb   $0xc8,0x1e(%rbx,%rax,1)
add    $0x28,%rax
add    $0xfffffffffffffffc,%rdi
jne    11f0 <grid+0xd0>
test   %r8,%r8
je     11c0 <grid+0xa0>
lea    (%rbx,%rax,1),%rdi
add    %rbp,%rax
xor    %esi,%esi
nop
movb   $0xff,(%rax,%rsi,1)
movb   $0xc8,(%rdi,%rsi,1)
add    $0xa,%rsi
cmp    %rsi,%rcx
jne    1230 <grid+0x110>
jmp    11c0 <grid+0xa0>
test   %r13d,%r13d
jle    1591 <grid+0x471>
mov    %r9,%r8
shr    %r8
add    $0x1,%r8
mov    %r8d,%edx
and    $0x3,%edx
and    $0xfffffffffffffffc,%r8
mov    0x18(%rsp),%r12
lea    0x6(%r12),%rbp
lea    (%r11,%r11,4),%r11
mov    0x20(%rsp),%r15
lea    0x6(%r15),%rbx
xor    %eax,%eax
jmp    1299 <grid+0x179>
xchg   %ax,%ax
add    $0xa,%rax
add    %r11,%rbp
add    %r11,%rbx
add    %r11,%r12
add    %r11,%r15
cmp    %r10,%rax
jae    1316 <grid+0x1f6>
test   %r14d,%r14d
jle    1280 <grid+0x160>
cmp    $0x6,%r9
jae    12b0 <grid+0x190>
xor    %edi,%edi
jmp    12f1 <grid+0x1d1>
nopl   0x0(%rax,%rax,1)
mov    %r8,%rcx
xor    %edi,%edi
cs nopw 0x0(%rax,%rax,1)
nop
movb   $0xff,-0x6(%rbx,%rdi,1)
movb   $0xc8,-0x6(%rbp,%rdi,1)
movb   $0xff,-0x4(%rbx,%rdi,1)
movb   $0xc8,-0x4(%rbp,%rdi,1)
movb   $0xff,-0x2(%rbx,%rdi,1)
movb   $0xc8,-0x2(%rbp,%rdi,1)
movb   $0xff,(%rbx,%rdi,1)
movb   $0xc8,0x0(%rbp,%rdi,1)
add    $0x8,%rdi
add    $0xfffffffffffffffc,%rcx
jne    12c0 <grid+0x1a0>
test   %rdx,%rdx
je     1280 <grid+0x160>
lea    (%r12,%rdi,1),%rcx
add    %r15,%rdi
xor    %esi,%esi
nop
movb   $0xff,(%rdi,%rsi,2)
movb   $0xc8,(%rcx,%rsi,2)
add    $0x1,%rsi
cmp    %rsi,%rdx
jne    1300 <grid+0x1e0>
jmp    1280 <grid+0x160>
test   %r13d,%r13d
jle    1591 <grid+0x471>
xor    %eax,%eax
jmp    1345 <grid+0x225>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x10(%rsp),%r15
add    $0x32,%r15d
cmp    %r13d,%r15d
mov    %r15,%rax
jge    1423 <grid+0x303>
mov    %rax,0x10(%rsp)
test   %r14d,%r14d
jle    1330 <grid+0x210>
mov    0x10(%rsp),%rcx
add    $0xffffffff,%ecx
mov    %ecx,0xc(%rsp)
xor    %ebp,%ebp
nopl   (%rax)
lea    -0x1(%rbp),%ebx
mov    0x20(%rsp),%rdi
mov    %r14d,%r15d
mov    %r14d,%esi
mov    %r13d,%edx
mov    0x10(%rsp),%r12
mov    %r12d,%ecx
mov    %ebx,%r8d
mov    $0x1,%r9d
push   $0xff
push   $0x3
call   1030 <draw_rectangle@plt>
add    $0x10,%rsp
mov    0x20(%rsp),%rdi
mov    %r14d,%esi
mov    %r13d,%edx
mov    0xc(%rsp),%r14d
mov    %r14d,%ecx
mov    %ebp,%r8d
mov    $0x3,%r9d
push   $0xff
push   $0x1
call   1030 <draw_rectangle@plt>
add    $0x10,%rsp
mov    0x18(%rsp),%rdi
mov    %r15d,%esi
mov    %r13d,%edx
mov    %r12d,%ecx
mov    %ebx,%r8d
mov    0x18(%rsp),%rbx
mov    $0x1,%r9d
push   $0xc8
push   $0x3
call   1030 <draw_rectangle@plt>
add    $0x10,%rsp
mov    %rbx,%rdi
mov    %r15d,%esi
mov    %r13d,%edx
mov    %r14d,%ecx
mov    %ebp,%r8d
mov    $0x3,%r9d
push   $0xc8
push   $0x1
call   1030 <draw_rectangle@plt>
mov    %r15d,%r14d
add    $0x10,%rsp
add    $0x32,%ebp
cmp    %r15d,%ebp
jl     1360 <grid+0x240>
jmp    1330 <grid+0x210>
test   %r13d,%r13d
jle    1591 <grid+0x471>
xor    %eax,%eax
mov    0x20(%rsp),%rbx
jmp    1451 <grid+0x331>
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x28(%rsp),%rax
add    $0x64,%eax
cmp    %r13d,%eax
jge    1591 <grid+0x471>
mov    %rax,0x28(%rsp)
test   %r14d,%r14d
jle    1440 <grid+0x320>
mov    0x28(%rsp),%rax
lea    -0x4(%rax),%ecx
mov    %ecx,0x10(%rsp)
add    $0xffffffff,%eax
mov    %eax,0x30(%rsp)
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    -0x4(%r15),%r8d
mov    %r8d,0xc(%rsp)
mov    %rbx,%rdi
mov    %r14d,%esi
mov    %r13d,%edx
mov    0x28(%rsp),%rbp
mov    %ebp,%ecx
mov    $0x1,%r9d
push   $0xff
push   $0x9
call   1030 <draw_rectangle@plt>
add    $0x10,%rsp
mov    %rbx,%rdi
mov    %r14d,%esi
mov    %r13d,%edx
mov    0x10(%rsp),%ecx
mov    %r15d,%r8d
mov    $0x9,%r9d
push   $0xff
push   $0x1
call   1030 <draw_rectangle@plt>
add    $0x10,%rsp
lea    -0x1(%r15),%r8d
mov    %r8d,0x34(%rsp)
mov    %rbx,%rdi
mov    %r14d,%esi
mov    %r13d,%edx
mov    0x30(%rsp),%r12d
mov    %r12d,%ecx
mov    $0x3,%r9d
push   $0xff
push   $0x3
call   1030 <draw_rectangle@plt>
add    $0x10,%rsp
mov    0x18(%rsp),%rdi
mov    %r14d,%esi
mov    %r13d,%edx
mov    %ebp,%ecx
mov    0x18(%rsp),%rbp
mov    0xc(%rsp),%r8d
mov    $0x1,%r9d
push   $0xc8
push   $0x9
call   1030 <draw_rectangle@plt>
add    $0x10,%rsp
mov    %rbp,%rdi
mov    %r14d,%esi
mov    %r13d,%edx
mov    0x10(%rsp),%ecx
mov    %r15d,%r8d
mov    $0x9,%r9d
push   $0xc8
push   $0x1
call   1030 <draw_rectangle@plt>
add    $0x10,%rsp
mov    %rbp,%rdi
mov    %r14d,%esi
mov    %r13d,%edx
mov    %r12d,%ecx
mov    0x34(%rsp),%r8d
mov    $0x3,%r9d
push   $0xc8
push   $0x3
call   1030 <draw_rectangle@plt>
add    $0x10,%rsp
add    $0x64,%r15d
cmp    %r14d,%r15d
jl     1480 <grid+0x360>
jmp    1440 <grid+0x320>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @grid(i8* %0, i32 %1, i32 %2, i8* %3) {
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8
%12 = alloca i8
%13 = alloca i8
store i8* %0, i8** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i8* %3, i8** %8
store i8 0, i8* %11
store i8 -1, i8* %12
store i8 -56, i8* %13
store i32 0, i32* %9
br label %14
14: ; preds = %26, %4
%15 = load i32, i32* %9
%16 = load i32, i32* %6
%17 = load i32, i32* %7
%18 = mul nsw i32 %16, %17
%19 = icmp slt i32 %15, %18
br i1 %19, label %20, label %29
20: ; preds = %14
%21 = load i8, i8* %11
%22 = load i8*, i8** %5
%23 = load i32, i32* %9
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %22, i64 %24
store i8 %21, i8* %25
br label %26
26: ; preds = %20
%27 = load i32, i32* %9
%28 = add nsw i32 %27, 1
store i32 %28, i32* %9
br label %14
29: ; preds = %14
store i32 0, i32* %9
br label %30
30: ; preds = %41, %29
%31 = load i32, i32* %9
%32 = load i32, i32* %6
%33 = load i32, i32* %7
%34 = mul nsw i32 %32, %33
%35 = icmp slt i32 %31, %34
br i1 %35, label %36, label %44
36: ; preds = %30
%37 = load i8*, i8** %8
%38 = load i32, i32* %9
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i8, i8* %37, i64 %39
store i8 0, i8* %40
br label %41
41: ; preds = %36
%42 = load i32, i32* %9
%43 = add nsw i32 %42, 1
store i32 %43, i32* %9
br label %30
44: ; preds = %30
store i32 0, i32* %9
br label %45
45: ; preds = %77, %44
%46 = load i32, i32* %9
%47 = load i32, i32* %7
%48 = icmp slt i32 %46, %47
br i1 %48, label %49, label %80
49: ; preds = %45
store i32 0, i32* %10
br label %50
50: ; preds = %73, %49
%51 = load i32, i32* %10
%52 = load i32, i32* %6
%53 = icmp slt i32 %51, %52
br i1 %53, label %54, label %76
54: ; preds = %50
%55 = load i8, i8* %12
%56 = load i8*, i8** %5
%57 = load i32, i32* %9
%58 = load i32, i32* %6
%59 = mul nsw i32 %57, %58
%60 = load i32, i32* %10
%61 = add nsw i32 %59, %60
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds i8, i8* %56, i64 %62
store i8 %55, i8* %63
%64 = load i8, i8* %13
%65 = load i8*, i8** %8
%66 = load i32, i32* %9
%67 = load i32, i32* %6
%68 = mul nsw i32 %66, %67
%69 = load i32, i32* %10
%70 = add nsw i32 %68, %69
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds i8, i8* %65, i64 %71
store i8 %64, i8* %72
br label %73
73: ; preds = %54
%74 = load i32, i32* %10
%75 = add nsw i32 %74, 10
store i32 %75, i32* %10
br label %50
76: ; preds = %50
br label %77
77: ; preds = %76
%78 = load i32, i32* %9
%79 = add nsw i32 %78, 2
store i32 %79, i32* %9
br label %45
80: ; preds = %45
store i32 0, i32* %9
br label %81
81: ; preds = %113, %80
%82 = load i32, i32* %9
%83 = load i32, i32* %7
%84 = icmp slt i32 %82, %83
br i1 %84, label %85, label %116
85: ; preds = %81
store i32 0, i32* %10
br label %86
86: ; preds = %109, %85
%87 = load i32, i32* %10
%88 = load i32, i32* %6
%89 = icmp slt i32 %87, %88
br i1 %89, label %90, label %112
90: ; preds = %86
%91 = load i8, i8* %12
%92 = load i8*, i8** %5
%93 = load i32, i32* %9
%94 = load i32, i32* %6
%95 = mul nsw i32 %93, %94
%96 = load i32, i32* %10
%97 = add nsw i32 %95, %96
%98 = sext i32 %97 to i64
%99 = getelementptr inbounds i8, i8* %92, i64 %98
store i8 %91, i8* %99
%100 = load i8, i8* %13
%101 = load i8*, i8** %8
%102 = load i32, i32* %9
%103 = load i32, i32* %6
%104 = mul nsw i32 %102, %103
%105 = load i32, i32* %10
%106 = add nsw i32 %104, %105
%107 = sext i32 %106 to i64
%108 = getelementptr inbounds i8, i8* %101, i64 %107
store i8 %100, i8* %108
br label %109
109: ; preds = %90
%110 = load i32, i32* %10
%111 = add nsw i32 %110, 2
store i32 %111, i32* %10
br label %86
112: ; preds = %86
br label %113
113: ; preds = %112
%114 = load i32, i32* %9
%115 = add nsw i32 %114, 10
store i32 %115, i32* %9
br label %81
116: ; preds = %81
store i32 0, i32* %9
br label %117
117: ; preds = %163, %116
%118 = load i32, i32* %9
%119 = load i32, i32* %7
%120 = icmp slt i32 %118, %119
br i1 %120, label %121, label %166
121: ; preds = %117
store i32 0, i32* %10
br label %122
122: ; preds = %159, %121
%123 = load i32, i32* %10
%124 = load i32, i32* %6
%125 = icmp slt i32 %123, %124
br i1 %125, label %126, label %162
126: ; preds = %122
%127 = load i8*, i8** %5
%128 = load i32, i32* %6
%129 = load i32, i32* %7
%130 = load i32, i32* %9
%131 = load i32, i32* %10
%132 = sub nsw i32 %131, 1
%133 = load i8, i8* %12
%134 = call i32 @draw_rectangle(i8* %127, i32 %128, i32 %129, i32 %130, i32 %132, i32 1, i32 3, i8 zeroext %133)
%135 = load i8*, i8** %5
%136 = load i32, i32* %6
%137 = load i32, i32* %7
%138 = load i32, i32* %9
%139 = sub nsw i32 %138, 1
%140 = load i32, i32* %10
%141 = load i8, i8* %12
%142 = call i32 @draw_rectangle(i8* %135, i32 %136, i32 %137, i32 %139, i32 %140, i32 3, i32 1, i8 zeroext %141)
%143 = load i8*, i8** %8
%144 = load i32, i32* %6
%145 = load i32, i32* %7
%146 = load i32, i32* %9
%147 = load i32, i32* %10
%148 = sub nsw i32 %147, 1
%149 = load i8, i8* %13
%150 = call i32 @draw_rectangle(i8* %143, i32 %144, i32 %145, i32 %146, i32 %148, i32 1, i32 3, i8 zeroext %149)
%151 = load i8*, i8** %8
%152 = load i32, i32* %6
%153 = load i32, i32* %7
%154 = load i32, i32* %9
%155 = sub nsw i32 %154, 1
%156 = load i32, i32* %10
%157 = load i8, i8* %13
%158 = call i32 @draw_rectangle(i8* %151, i32 %152, i32 %153, i32 %155, i32 %156, i32 3, i32 1, i8 zeroext %157)
br label %159
159: ; preds = %126
%160 = load i32, i32* %10
%161 = add nsw i32 %160, 50
store i32 %161, i32* %10
br label %122
162: ; preds = %122
br label %163
163: ; preds = %162
%164 = load i32, i32* %9
%165 = add nsw i32 %164, 50
store i32 %165, i32* %9
br label %117
166: ; preds = %117
store i32 0, i32* %9
br label %167
167: ; preds = %231, %166
%168 = load i32, i32* %9
%169 = load i32, i32* %7
%170 = icmp slt i32 %168, %169
br i1 %170, label %171, label %234
171: ; preds = %167
store i32 0, i32* %10
br label %172
172: ; preds = %227, %171
%173 = load i32, i32* %10
%174 = load i32, i32* %6
%175 = icmp slt i32 %173, %174
br i1 %175, label %176, label %230
176: ; preds = %172
%177 = load i8*, i8** %5
%178 = load i32, i32* %6
%179 = load i32, i32* %7
%180 = load i32, i32* %9
%181 = load i32, i32* %10
%182 = sub nsw i32 %181, 4
%183 = load i8, i8* %12
%184 = call i32 @draw_rectangle(i8* %177, i32 %178, i32 %179, i32 %180, i32 %182, i32 1, i32 9, i8 zeroext %183)
%185 = load i8*, i8** %5
%186 = load i32, i32* %6
%187 = load i32, i32* %7
%188 = load i32, i32* %9
%189 = sub nsw i32 %188, 4
%190 = load i32, i32* %10
%191 = load i8, i8* %12
%192 = call i32 @draw_rectangle(i8* %185, i32 %186, i32 %187, i32 %189, i32 %190, i32 9, i32 1, i8 zeroext %191)
%193 = load i8*, i8** %5
%194 = load i32, i32* %6
%195 = load i32, i32* %7
%196 = load i32, i32* %9
%197 = sub nsw i32 %196, 1
%198 = load i32, i32* %10
%199 = sub nsw i32 %198, 1
%200 = load i8, i8* %12
%201 = call i32 @draw_rectangle(i8* %193, i32 %194, i32 %195, i32 %197, i32 %199, i32 3, i32 3, i8 zeroext %200)
%202 = load i8*, i8** %8
%203 = load i32, i32* %6
%204 = load i32, i32* %7
%205 = load i32, i32* %9
%206 = load i32, i32* %10
%207 = sub nsw i32 %206, 4
%208 = load i8, i8* %13
%209 = call i32 @draw_rectangle(i8* %202, i32 %203, i32 %204, i32 %205, i32 %207, i32 1, i32 9, i8 zeroext %208)
%210 = load i8*, i8** %8
%211 = load i32, i32* %6
%212 = load i32, i32* %7
%213 = load i32, i32* %9
%214 = sub nsw i32 %213, 4
%215 = load i32, i32* %10
%216 = load i8, i8* %13
%217 = call i32 @draw_rectangle(i8* %210, i32 %211, i32 %212, i32 %214, i32 %215, i32 9, i32 1, i8 zeroext %216)
%218 = load i8*, i8** %8
%219 = load i32, i32* %6
%220 = load i32, i32* %7
%221 = load i32, i32* %9
%222 = sub nsw i32 %221, 1
%223 = load i32, i32* %10
%224 = sub nsw i32 %223, 1
%225 = load i8, i8* %13
%226 = call i32 @draw_rectangle(i8* %218, i32 %219, i32 %220, i32 %222, i32 %224, i32 3, i32 3, i8 zeroext %225)
br label %227
227: ; preds = %176
%228 = load i32, i32* %10
%229 = add nsw i32 %228, 100
store i32 %229, i32* %10
br label %172
230: ; preds = %172
br label %231
231: ; preds = %230
%232 = load i32, i32* %9
%233 = add nsw i32 %232, 100
store i32 %233, i32* %9
br label %167
234: ; preds = %167
ret void
}

LLVM IR (-O2):
define void @grid(i8* %0, i32 %1, i32 %2, i8* %3) {
%5 = mul i32 %2, %1
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %10
7: ; preds = %4
%8 = zext i32 %5 to i64
%9 = zext i32 %5 to i64
br label %10
10: ; preds = %4, %7
%11 = icmp sgt i32 %2, 0
br i1 %11, label %12, label %154
12: ; preds = %10
%13 = icmp sgt i32 %1, 0
%14 = sext i32 %1 to i64
%15 = zext i32 %2 to i64
%16 = add nsw i64 %14, -1
%17 = udiv i64 %16, 10
%18 = add nuw nsw i64 %17, 1
%19 = and i64 %18, 3
%20 = icmp ult i64 %16, 30
%21 = and i64 %18, 4611686018427387900
%22 = icmp eq i64 %19, 0
br label %23
23: ; preds = %12, %70
%24 = phi i64 [ 0, %12 ], [ %71, %70 ]
br i1 %13, label %25, label %70
25: ; preds = %23
%26 = mul nsw i64 %24, %14
br i1 %20, label %59, label %38
27: ; preds = %70
br i1 %11, label %28, label %154
28: ; preds = %27
%29 = icmp sgt i32 %1, 0
%30 = sext i32 %1 to i64
%31 = zext i32 %2 to i64
%32 = lshr i64 %16, 1
%33 = add nuw i64 %32, 1
%34 = and i64 %33, 3
%35 = icmp ult i64 %16, 6
%36 = and i64 %33, -4
%37 = icmp eq i64 %34, 0
br label %73
38: ; preds = %25, %38
%39 = phi i64 [ %56, %38 ], [ 0, %25 ]
%40 = phi i64 [ %57, %38 ], [ 0, %25 ]
%41 = add nsw i64 %39, %26
%42 = getelementptr inbounds i8, i8* %0, i64 %41
store i8 -1, i8* %42
%43 = getelementptr inbounds i8, i8* %3, i64 %41
store i8 -56, i8* %43
%44 = add nuw nsw i64 %39, 10
%45 = add nsw i64 %44, %26
%46 = getelementptr inbounds i8, i8* %0, i64 %45
store i8 -1, i8* %46
%47 = getelementptr inbounds i8, i8* %3, i64 %45
store i8 -56, i8* %47
%48 = add nuw nsw i64 %39, 20
%49 = add nsw i64 %48, %26
%50 = getelementptr inbounds i8, i8* %0, i64 %49
store i8 -1, i8* %50
%51 = getelementptr inbounds i8, i8* %3, i64 %49
store i8 -56, i8* %51
%52 = add nuw nsw i64 %39, 30
%53 = add nsw i64 %52, %26
%54 = getelementptr inbounds i8, i8* %0, i64 %53
store i8 -1, i8* %54
%55 = getelementptr inbounds i8, i8* %3, i64 %53
store i8 -56, i8* %55
%56 = add nuw nsw i64 %39, 40
%57 = add i64 %40, 4
%58 = icmp eq i64 %57, %21
br i1 %58, label %59, label %38
59: ; preds = %38, %25
%60 = phi i64 [ 0, %25 ], [ %56, %38 ]
br i1 %22, label %70, label %61
61: ; preds = %59, %61
%62 = phi i64 [ %67, %61 ], [ %60, %59 ]
%63 = phi i64 [ %68, %61 ], [ 0, %59 ]
%64 = add nsw i64 %62, %26
%65 = getelementptr inbounds i8, i8* %0, i64 %64
store i8 -1, i8* %65
%66 = getelementptr inbounds i8, i8* %3, i64 %64
store i8 -56, i8* %66
%67 = add nuw nsw i64 %62, 10
%68 = add i64 %63, 1
%69 = icmp eq i64 %68, %19
br i1 %69, label %70, label %61
70: ; preds = %59, %61, %23
%71 = add nuw nsw i64 %24, 2
%72 = icmp ult i64 %71, %15
br i1 %72, label %23, label %27
73: ; preds = %28, %112
%74 = phi i64 [ 0, %28 ], [ %113, %112 ]
br i1 %29, label %75, label %112
75: ; preds = %73
%76 = mul nsw i64 %74, %30
br i1 %35, label %101, label %80
77: ; preds = %112
br i1 %11, label %78, label %154
78: ; preds = %77
%79 = icmp sgt i32 %1, 0
br label %115
80: ; preds = %75, %80
%81 = phi i64 [ %98, %80 ], [ 0, %75 ]
%82 = phi i64 [ %99, %80 ], [ 0, %75 ]
%83 = add nsw i64 %81, %76
%84 = getelementptr inbounds i8, i8* %0, i64 %83
store i8 -1, i8* %84
%85 = getelementptr inbounds i8, i8* %3, i64 %83
store i8 -56, i8* %85
%86 = or i64 %81, 2
%87 = add nsw i64 %86, %76
%88 = getelementptr inbounds i8, i8* %0, i64 %87
store i8 -1, i8* %88
%89 = getelementptr inbounds i8, i8* %3, i64 %87
store i8 -56, i8* %89
%90 = or i64 %81, 4
%91 = add nsw i64 %90, %76
%92 = getelementptr inbounds i8, i8* %0, i64 %91
store i8 -1, i8* %92
%93 = getelementptr inbounds i8, i8* %3, i64 %91
store i8 -56, i8* %93
%94 = or i64 %81, 6
%95 = add nsw i64 %94, %76
%96 = getelementptr inbounds i8, i8* %0, i64 %95
store i8 -1, i8* %96
%97 = getelementptr inbounds i8, i8* %3, i64 %95
store i8 -56, i8* %97
%98 = add nuw nsw i64 %81, 8
%99 = add i64 %82, 4
%100 = icmp eq i64 %99, %36
br i1 %100, label %101, label %80
101: ; preds = %80, %75
%102 = phi i64 [ 0, %75 ], [ %98, %80 ]
br i1 %37, label %112, label %103
103: ; preds = %101, %103
%104 = phi i64 [ %109, %103 ], [ %102, %101 ]
%105 = phi i64 [ %110, %103 ], [ 0, %101 ]
%106 = add nsw i64 %104, %76
%107 = getelementptr inbounds i8, i8* %0, i64 %106
store i8 -1, i8* %107
%108 = getelementptr inbounds i8, i8* %3, i64 %106
store i8 -56, i8* %108
%109 = add nuw nsw i64 %104, 2
%110 = add i64 %105, 1
%111 = icmp eq i64 %110, %34
br i1 %111, label %112, label %103
112: ; preds = %101, %103, %73
%113 = add nuw nsw i64 %74, 10
%114 = icmp ult i64 %113, %31
br i1 %114, label %73, label %77
115: ; preds = %78, %131
%116 = phi i32 [ 0, %78 ], [ %132, %131 ]
br i1 %79, label %117, label %131
117: ; preds = %115
%118 = add nsw i32 %116, -1
br label %122
119: ; preds = %131
br i1 %11, label %120, label %154
120: ; preds = %119
%121 = icmp sgt i32 %1, 0
br label %134
122: ; preds = %117, %122
%123 = phi i32 [ 0, %117 ], [ %129, %122 ]
%124 = add nsw i32 %123, -1
%125 = tail call i32 @draw_rectangle(i8* %0, i32 %1, i32 %2, i32 %116, i32 %124, i32 1, i32 3, i8 zeroext -1)
%126 = tail call i32 @draw_rectangle(i8* %0, i32 %1, i32 %2, i32 %118, i32 %123, i32 3, i32 1, i8 zeroext -1)
%127 = tail call i32 @draw_rectangle(i8* %3, i32 %1, i32 %2, i32 %116, i32 %124, i32 1, i32 3, i8 zeroext -56)
%128 = tail call i32 @draw_rectangle(i8* %3, i32 %1, i32 %2, i32 %118, i32 %123, i32 3, i32 1, i8 zeroext -56)
%129 = add nuw nsw i32 %123, 50
%130 = icmp slt i32 %129, %1
br i1 %130, label %122, label %131
131: ; preds = %122, %115
%132 = add nuw nsw i32 %116, 50
%133 = icmp slt i32 %132, %2
br i1 %133, label %115, label %119
134: ; preds = %120, %151
%135 = phi i32 [ 0, %120 ], [ %152, %151 ]
br i1 %121, label %136, label %151
136: ; preds = %134
%137 = add nsw i32 %135, -4
%138 = add nsw i32 %135, -1
br label %139
139: ; preds = %136, %139
%140 = phi i32 [ 0, %136 ], [ %149, %139 ]
%141 = add nsw i32 %140, -4
%142 = tail call i32 @draw_rectangle(i8* %0, i32 %1, i32 %2, i32 %135, i32 %141, i32 1, i32 9, i8 zeroext -1)
%143 = tail call i32 @draw_rectangle(i8* %0, i32 %1, i32 %2, i32 %137, i32 %140, i32 9, i32 1, i8 zeroext -1)
%144 = add nsw i32 %140, -1
%145 = tail call i32 @draw_rectangle(i8* %0, i32 %1, i32 %2, i32 %138, i32 %144, i32 3, i32 3, i8 zeroext -1)
%146 = tail call i32 @draw_rectangle(i8* %3, i32 %1, i32 %2, i32 %135, i32 %141, i32 1, i32 9, i8 zeroext -56)
%147 = tail call i32 @draw_rectangle(i8* %3, i32 %1, i32 %2, i32 %137, i32 %140, i32 9, i32 1, i8 zeroext -56)
%148 = tail call i32 @draw_rectangle(i8* %3, i32 %1, i32 %2, i32 %138, i32 %144, i32 3, i32 3, i8 zeroext -56)
%149 = add nuw nsw i32 %140, 100
%150 = icmp slt i32 %149, %1
br i1 %150, label %139, label %151
151: ; preds = %139, %134
%152 = add nuw nsw i32 %135, 100
%153 = icmp slt i32 %152, %2
br i1 %153, label %134, label %154
154: ; preds = %151, %10, %27, %77, %119
ret void
}