#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*/ printf(char *);
print_board_rect(unsigned char grid[10000 / 4 + 1][10000 / 2 + 2],
                 unsigned int startx, unsigned int starty, unsigned int width,
                 unsigned int height) {
  unsigned int i, j, k, l, block;
  for (i = 0; i < height; i++) {
    for (l = 0; l < 2; l++) {
      for (j = 0; j < width; j++) {
        block = grid[startx + j][starty + i];
        for (k = 0; k < 4; k++) {
          if ((block >> (l * 4 + k)) & 0x1) {
            printf("O");
          } else {
            printf(".");
          }
        }
      }
      printf("\n");
    }
  }
}


x86 assembly (clang, -O0):
<print_board_rect>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x20(%rbp),%eax
jae    1220 <print_board_rect+0x110>
movl   $0x0,-0x30(%rbp)
cmpl   $0x2,-0x30(%rbp)
jae    120d <print_board_rect+0xfd>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jae    11f3 <print_board_rect+0xe3>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    -0x28(%rbp),%ecx
mov    %ecx,%ecx
imul   $0x138a,%rcx,%rcx
add    %rcx,%rax
mov    -0x18(%rbp),%ecx
add    -0x24(%rbp),%ecx
mov    %ecx,%ecx
movzbl (%rax,%rcx,1),%eax
mov    %eax,-0x34(%rbp)
movl   $0x0,-0x2c(%rbp)
cmpl   $0x4,-0x2c(%rbp)
jae    11e0 <print_board_rect+0xd0>
mov    -0x34(%rbp),%eax
mov    -0x30(%rbp),%ecx
shl    $0x2,%ecx
add    -0x2c(%rbp),%ecx
shr    %cl,%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     11c1 <print_board_rect+0xb1>
lea    0xe49(%rip),%rdi
call   1030 <printf@plt>
jmp    11cd <print_board_rect+0xbd>
lea    0xe3a(%rip),%rdi
call   1030 <printf@plt>
jmp    11d2 <print_board_rect+0xc2>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    118c <print_board_rect+0x7c>
jmp    11e5 <print_board_rect+0xd5>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1154 <print_board_rect+0x44>
lea    0xe0a(%rip),%rdi
call   1030 <printf@plt>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1143 <print_board_rect+0x33>
jmp    1212 <print_board_rect+0x102>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1130 <print_board_rect+0x20>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_board_rect>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %ecx,(%rsp)
mov    %rdx,0x10(%rsp)
mov    %esi,0x4(%rsp)
test   %r8d,%r8d
je     12b5 <print_board_rect+0x1a5>
mov    %rdi,%r13
mov    %r8d,%eax
mov    %rax,0x18(%rsp)
mov    (%rsp),%eax
mov    %rax,0x8(%rsp)
xor    %ecx,%ecx
jmp    1178 <print_board_rect+0x68>
nopw   0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x20(%rsp),%rcx
add    $0x1,%rcx
cmp    0x18(%rsp),%rcx
je     12b5 <print_board_rect+0x1a5>
cmpl   $0x0,(%rsp)
mov    %rcx,0x20(%rsp)
je     1150 <print_board_rect+0x40>
mov    0x10(%rsp),%rax
lea    (%rcx,%rax,1),%r15d
mov    0x8(%rsp),%r14
mov    0x4(%rsp),%r12d
jmp    11b1 <print_board_rect+0xa1>
nopl   0x0(%rax,%rax,1)
mov    %ebx,%edi
call   1030 <putchar@plt>
add    $0x1,%r12d
add    $0xffffffffffffffff,%r14
je     1220 <print_board_rect+0x110>
mov    %r12d,%eax
imul   $0x138a,%rax,%rax
add    %r13,%rax
movzbl (%r15,%rax,1),%ebp
mov    $0x2e,%ebx
mov    $0x2e,%edi
test   $0x1,%bpl
je     11d8 <print_board_rect+0xc8>
mov    $0x4f,%edi
call   1030 <putchar@plt>
mov    $0x2e,%edi
test   $0x2,%bpl
je     11ed <print_board_rect+0xdd>
mov    $0x4f,%edi
call   1030 <putchar@plt>
mov    $0x2e,%edi
test   $0x4,%bpl
je     1202 <print_board_rect+0xf2>
mov    $0x4f,%edi
call   1030 <putchar@plt>
test   $0x8,%bpl
je     11a0 <print_board_rect+0x90>
mov    $0x4f,%ebx
jmp    11a0 <print_board_rect+0x90>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0xa,%edi
call   1030 <putchar@plt>
cmpl   $0x0,(%rsp)
je     115a <print_board_rect+0x4a>
mov    0x4(%rsp),%ebp
mov    0x8(%rsp),%r12
jmp    1255 <print_board_rect+0x145>
nop
mov    %r14d,%edi
call   1030 <putchar@plt>
add    $0x1,%ebp
add    $0xffffffffffffffff,%r12
je     115a <print_board_rect+0x4a>
mov    %ebp,%eax
imul   $0x138a,%rax,%rax
add    %r13,%rax
movzbl (%r15,%rax,1),%ebx
mov    $0x2e,%r14d
mov    $0x2e,%edi
test   $0x10,%bl
je     127b <print_board_rect+0x16b>
mov    $0x4f,%edi
call   1030 <putchar@plt>
mov    $0x2e,%edi
test   $0x20,%bl
je     128f <print_board_rect+0x17f>
mov    $0x4f,%edi
call   1030 <putchar@plt>
mov    $0x2e,%edi
test   $0x40,%bl
je     12a3 <print_board_rect+0x193>
mov    $0x4f,%edi
call   1030 <putchar@plt>
test   $0x80,%bl
je     1240 <print_board_rect+0x130>
mov    $0x4f,%r14d
jmp    1240 <print_board_rect+0x130>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"O\00"
@.str.1 = [2 x i8] c".\00"
@.str.2 = [2 x i8] c"\0A\00"
define i32 @print_board_rect([5002 x i8]* %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca i32
%7 = alloca [5002 x i8]*
%8 = alloca i32
%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 [5002 x i8]* %0, [5002 x i8]** %7
store i32 %1, i32* %8
store i32 %2, i32* %9
store i32 %3, i32* %10
store i32 %4, i32* %11
store i32 0, i32* %12
br label %17
17: ; preds = %74, %5
%18 = load i32, i32* %12
%19 = load i32, i32* %11
%20 = icmp ult i32 %18, %19
br i1 %20, label %21, label %77
21: ; preds = %17
store i32 0, i32* %15
br label %22
22: ; preds = %70, %21
%23 = load i32, i32* %15
%24 = icmp ult i32 %23, 2
br i1 %24, label %25, label %73
25: ; preds = %22
store i32 0, i32* %13
br label %26
26: ; preds = %65, %25
%27 = load i32, i32* %13
%28 = load i32, i32* %10
%29 = icmp ult i32 %27, %28
br i1 %29, label %30, label %68
30: ; preds = %26
%31 = load [5002 x i8]*, [5002 x i8]** %7
%32 = load i32, i32* %8
%33 = load i32, i32* %13
%34 = add i32 %32, %33
%35 = zext i32 %34 to i64
%36 = getelementptr inbounds [5002 x i8], [5002 x i8]* %31, i64 %35
%37 = load i32, i32* %9
%38 = load i32, i32* %12
%39 = add i32 %37, %38
%40 = zext i32 %39 to i64
%41 = getelementptr inbounds [5002 x i8], [5002 x i8]* %36, i64 0, i64 %40
%42 = load i8, i8* %41
%43 = zext i8 %42 to i32
store i32 %43, i32* %16
store i32 0, i32* %14
br label %44
44: ; preds = %61, %30
%45 = load i32, i32* %14
%46 = icmp ult i32 %45, 4
br i1 %46, label %47, label %64
47: ; preds = %44
%48 = load i32, i32* %16
%49 = load i32, i32* %15
%50 = mul i32 %49, 4
%51 = load i32, i32* %14
%52 = add i32 %50, %51
%53 = lshr i32 %48, %52
%54 = and i32 %53, 1
%55 = icmp ne i32 %54, 0
br i1 %55, label %56, label %58
56: ; preds = %47
%57 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %60
58: ; preds = %47
%59 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %60
60: ; preds = %58, %56
br label %61
61: ; preds = %60
%62 = load i32, i32* %14
%63 = add i32 %62, 1
store i32 %63, i32* %14
br label %44
64: ; preds = %44
br label %65
65: ; preds = %64
%66 = load i32, i32* %13
%67 = add i32 %66, 1
store i32 %67, i32* %13
br label %26
68: ; preds = %26
%69 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %70
70: ; preds = %68
%71 = load i32, i32* %15
%72 = add i32 %71, 1
store i32 %72, i32* %15
br label %22
73: ; preds = %22
br label %74
74: ; preds = %73
%75 = load i32, i32* %12
%76 = add i32 %75, 1
store i32 %76, i32* %12
br label %17
77: ; preds = %17
%78 = load i32, i32* %6
ret i32 %78
}

LLVM IR (-O2):
define i32 @print_board_rect([5002 x i8]* nocapture %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = icmp eq i32 %4, 0
br i1 %6, label %77, label %7
7: ; preds = %5
%8 = icmp eq i32 %3, 0
%9 = zext i32 %4 to i64
%10 = zext i32 %3 to i64
%11 = zext i32 %3 to i64
br label %12
12: ; preds = %7, %73
%13 = phi i64 [ 0, %7 ], [ %75, %73 ]
%14 = trunc i64 %13 to i32
%15 = add i32 %14, %2
%16 = zext i32 %15 to i64
br i1 %8, label %17, label %19
17: ; preds = %12
%18 = tail call i32 @putchar(i32 10)
br label %73
19: ; preds = %12, %19
%20 = phi i64 [ %43, %19 ], [ 0, %12 ]
%21 = trunc i64 %20 to i32
%22 = add i32 %21, %1
%23 = zext i32 %22 to i64
%24 = getelementptr inbounds [5002 x i8], [5002 x i8]* %0, i64 %23, i64 %16
%25 = load i8, i8* %24
%26 = zext i8 %25 to i32
%27 = and i32 %26, 1
%28 = icmp eq i32 %27, 0
%29 = select i1 %28, i32 46, i32 79
%30 = tail call i32 @putchar(i32 %29)
%31 = and i32 %26, 2
%32 = icmp eq i32 %31, 0
%33 = select i1 %32, i32 46, i32 79
%34 = tail call i32 @putchar(i32 %33)
%35 = and i32 %26, 4
%36 = icmp eq i32 %35, 0
%37 = select i1 %36, i32 46, i32 79
%38 = tail call i32 @putchar(i32 %37)
%39 = and i32 %26, 8
%40 = icmp eq i32 %39, 0
%41 = select i1 %40, i32 46, i32 79
%42 = tail call i32 @putchar(i32 %41)
%43 = add nuw nsw i64 %20, 1
%44 = icmp eq i64 %43, %10
br i1 %44, label %45, label %19
45: ; preds = %19
%46 = tail call i32 @putchar(i32 10)
br i1 %8, label %73, label %47
47: ; preds = %45, %47
%48 = phi i64 [ %71, %47 ], [ 0, %45 ]
%49 = trunc i64 %48 to i32
%50 = add i32 %49, %1
%51 = zext i32 %50 to i64
%52 = getelementptr inbounds [5002 x i8], [5002 x i8]* %0, i64 %51, i64 %16
%53 = load i8, i8* %52
%54 = zext i8 %53 to i32
%55 = and i32 %54, 16
%56 = icmp eq i32 %55, 0
%57 = select i1 %56, i32 46, i32 79
%58 = tail call i32 @putchar(i32 %57)
%59 = and i32 %54, 32
%60 = icmp eq i32 %59, 0
%61 = select i1 %60, i32 46, i32 79
%62 = tail call i32 @putchar(i32 %61)
%63 = and i32 %54, 64
%64 = icmp eq i32 %63, 0
%65 = select i1 %64, i32 46, i32 79
%66 = tail call i32 @putchar(i32 %65)
%67 = and i32 %54, 128
%68 = icmp eq i32 %67, 0
%69 = select i1 %68, i32 46, i32 79
%70 = tail call i32 @putchar(i32 %69)
%71 = add nuw nsw i64 %48, 1
%72 = icmp eq i64 %71, %11
br i1 %72, label %73, label %47
73: ; preds = %47, %17, %45
%74 = tail call i32 @putchar(i32 10)
%75 = add nuw nsw i64 %13, 1
%76 = icmp eq i64 %75, %9
br i1 %76, label %77, label %12
77: ; preds = %73, %5
ret i32 undef
}