#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 *);
void paintCells(int *row, int rowLength) {
  for (int i = 0; i < rowLength; i++) {
    printf("|");
    switch (row[i]) {
    case 0:
      printf(" ");
      break;
    case 1:
      printf("A");
      break;
    case 2:
      printf("B");
      break;
    case 3:
      printf("x");
      break;
    }
  }
  printf("|\n");
}


x86 assembly (clang, -O0):
<paintCells>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11bd <paintCells+0xad>
lea    0xed7(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %rax,-0x18(%rbp)
sub    $0x3,%rax
ja     11aa <paintCells+0x9a>
mov    -0x18(%rbp),%rax
lea    0xe9e(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xea0(%rip),%rdi
call   1030 <printf@plt>
jmp    11aa <paintCells+0x9a>
lea    0xe91(%rip),%rdi
call   1030 <printf@plt>
jmp    11aa <paintCells+0x9a>
lea    0xe82(%rip),%rdi
call   1030 <printf@plt>
jmp    11aa <paintCells+0x9a>
lea    0xe73(%rip),%rdi
call   1030 <printf@plt>
jmp    11af <paintCells+0x9f>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1126 <paintCells+0x16>
lea    0xe56(%rip),%rdi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<paintCells>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %esi,%esi
jle    1168 <paintCells+0x48>
mov    %rdi,%r14
mov    %esi,%r15d
xor    %ebx,%ebx
lea    0xec9(%rip),%r12
jmp    1149 <paintCells+0x29>
nopl   (%rax)
add    $0x1,%rbx
cmp    %rbx,%r15
je     1168 <paintCells+0x48>
mov    $0x7c,%edi
call   1030 <putchar@plt>
movslq (%r14,%rbx,4),%rax
cmp    $0x3,%rax
ja     1140 <paintCells+0x20>
mov    (%r12,%rax,4),%edi
call   1030 <putchar@plt>
jmp    1140 <paintCells+0x20>
lea    0xe91(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1040 <puts@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"|\00"
@.str.1 = [2 x i8] c" \00"
@.str.2 = [2 x i8] c"A\00"
@.str.3 = [2 x i8] c"B\00"
@.str.4 = [2 x i8] c"x\00"
@.str.5 = [3 x i8] c"|\0A\00"
define void @paintCells(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
store i32 0, i32* %5
br label %6
6: ; preds = %26, %2
%7 = load i32, i32* %5
%8 = load i32, i32* %4
%9 = icmp slt i32 %7, %8
br i1 %9, label %10, label %29
10: ; preds = %6
%11 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%12 = load i32*, i32** %3
%13 = load i32, i32* %5
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i32, i32* %12, i64 %14
%16 = load i32, i32* %15
switch i32 %16, label %25 [
i32 0, label %17
i32 1, label %19
i32 2, label %21
i32 3, label %23
]
17: ; preds = %10
%18 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %25
19: ; preds = %10
%20 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %25
21: ; preds = %10
%22 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %25
23: ; preds = %10
%24 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %25
25: ; preds = %10, %23, %21, %19, %17
br label %26
26: ; preds = %25
%27 = load i32, i32* %5
%28 = add nsw i32 %27, 1
store i32 %28, i32* %5
br label %6
29: ; preds = %6
%30 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@str = [2 x i8] c"|\00"
@switch.table.paintCells = [4 x i32] [i32 32, i32 65, i32 66, i32 120]
define void @paintCells(i32* nocapture %0, i32 %1) {
%3 = icmp sgt i32 %1, 0
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = zext i32 %1 to i64
br label %8
6: ; preds = %19, %2
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
ret void
8: ; preds = %4, %19
%9 = phi i64 [ 0, %4 ], [ %20, %19 ]
%10 = tail call i32 @putchar(i32 124)
%11 = getelementptr inbounds i32, i32* %0, i64 %9
%12 = load i32, i32* %11
%13 = icmp ult i32 %12, 4
br i1 %13, label %14, label %19
14: ; preds = %8
%15 = sext i32 %12 to i64
%16 = getelementptr inbounds [4 x i32], [4 x i32]* @switch.table.paintCells, i64 0, i64 %15
%17 = load i32, i32* %16
%18 = tail call i32 @putchar(i32 %17)
br label %19
19: ; preds = %8, %14
%20 = add nuw nsw i64 %9, 1
%21 = icmp eq i64 %20, %5
br i1 %21, label %6, label %8
}