#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*/ assert(int);
int strlen(char const *);
int boardArrayToBoardString(const char *pieces[8], char boardStr[65]) {
  int boardRow;
  int piecesRow;
  int i;
  for (piecesRow = 7, boardRow = 0; piecesRow >= 0; piecesRow--, boardRow++) {
    assert(strlen(pieces[piecesRow]) == 8);
    for (i = 0; i < 8; i++) {
      boardStr[boardRow * 8 + i] = pieces[piecesRow][i];
    }
  }
  boardStr[64] = '\0';
  return 1;
}


x86 assembly (clang, -O0):
<boardArrayToBoardString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x7,-0x18(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x0,-0x18(%rbp)
jl     11ca <boardArrayToBoardString+0xaa>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <strlen@plt>
cmp    $0x8,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x8,-0x1c(%rbp)
jge    11ae <boardArrayToBoardString+0x8e>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
shl    $0x3,%ecx
add    -0x1c(%rbp),%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1170 <boardArrayToBoardString+0x50>
jmp    11b3 <boardArrayToBoardString+0x93>
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    113e <boardArrayToBoardString+0x1e>
mov    -0x10(%rbp),%rax
movb   $0x0,0x40(%rax)
mov    $0x1,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<boardArrayToBoardString>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
lea    0x7(%rsi),%r12
mov    $0x7,%ebx
nopw   0x0(%rax,%rax,1)
mov    (%r15,%rbx,8),%rdi
call   1030 <strlen@plt>
xor    %edi,%edi
cmp    $0x8,%eax
sete   %dil
call   1040 <assert@plt>
mov    (%r15,%rbx,8),%rax
movzbl (%rax),%eax
mov    %al,-0x7(%r12)
mov    (%r15,%rbx,8),%rax
movzbl 0x1(%rax),%eax
mov    %al,-0x6(%r12)
mov    (%r15,%rbx,8),%rax
movzbl 0x2(%rax),%eax
mov    %al,-0x5(%r12)
mov    (%r15,%rbx,8),%rax
movzbl 0x3(%rax),%eax
mov    %al,-0x4(%r12)
mov    (%r15,%rbx,8),%rax
movzbl 0x4(%rax),%eax
mov    %al,-0x3(%r12)
mov    (%r15,%rbx,8),%rax
movzbl 0x5(%rax),%eax
mov    %al,-0x2(%r12)
mov    (%r15,%rbx,8),%rax
movzbl 0x6(%rax),%eax
mov    %al,-0x1(%r12)
mov    (%r15,%rbx,8),%rax
movzbl 0x7(%rax),%eax
mov    %al,(%r12)
add    $0x8,%r12
add    $0xffffffffffffffff,%rbx
jb     1140 <boardArrayToBoardString+0x20>
movb   $0x0,0x40(%r14)
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @boardArrayToBoardString(i8** %0, i8* %1) {
%3 = alloca i8**
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i8** %0, i8*** %3
store i8* %1, i8** %4
store i32 7, i32* %6
store i32 0, i32* %5
br label %8
8: ; preds = %45, %2
%9 = load i32, i32* %6
%10 = icmp sge i32 %9, 0
br i1 %10, label %11, label %50
11: ; preds = %8
%12 = load i8**, i8*** %3
%13 = load i32, i32* %6
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8*, i8** %12, i64 %14
%16 = load i8*, i8** %15
%17 = call i32 @strlen(i8* %16)
%18 = icmp eq i32 %17, 8
%19 = zext i1 %18 to i32
%20 = call i32 @assert(i32 %19)
store i32 0, i32* %7
br label %21
21: ; preds = %41, %11
%22 = load i32, i32* %7
%23 = icmp slt i32 %22, 8
br i1 %23, label %24, label %44
24: ; preds = %21
%25 = load i8**, i8*** %3
%26 = load i32, i32* %6
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8*, i8** %25, i64 %27
%29 = load i8*, i8** %28
%30 = load i32, i32* %7
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %29, i64 %31
%33 = load i8, i8* %32
%34 = load i8*, i8** %4
%35 = load i32, i32* %5
%36 = mul nsw i32 %35, 8
%37 = load i32, i32* %7
%38 = add nsw i32 %36, %37
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i8, i8* %34, i64 %39
store i8 %33, i8* %40
br label %41
41: ; preds = %24
%42 = load i32, i32* %7
%43 = add nsw i32 %42, 1
store i32 %43, i32* %7
br label %21
44: ; preds = %21
br label %45
45: ; preds = %44
%46 = load i32, i32* %6
%47 = add nsw i32 %46, -1
store i32 %47, i32* %6
%48 = load i32, i32* %5
%49 = add nsw i32 %48, 1
store i32 %49, i32* %5
br label %8
50: ; preds = %8
%51 = load i8*, i8** %4
%52 = getelementptr inbounds i8, i8* %51, i64 64
store i8 0, i8* %52
ret i32 1
}

LLVM IR (-O2):
define i32 @boardArrayToBoardString(i8** nocapture %0, i8* nocapture writeonly %1) {
br label %3
3: ; preds = %2, %3
%4 = phi i64 [ 0, %2 ], [ %52, %3 ]
%5 = phi i64 [ 7, %2 ], [ %51, %3 ]
%6 = getelementptr inbounds i8*, i8** %0, i64 %5
%7 = load i8*, i8** %6
%8 = tail call i32 @strlen(i8* %7)
%9 = icmp eq i32 %8, 8
%10 = zext i1 %9 to i32
%11 = tail call i32 @assert(i32 %10)
%12 = shl nsw i64 %4, 3
%13 = load i8*, i8** %6
%14 = load i8, i8* %13
%15 = getelementptr inbounds i8, i8* %1, i64 %12
store i8 %14, i8* %15
%16 = load i8*, i8** %6
%17 = getelementptr inbounds i8, i8* %16, i64 1
%18 = load i8, i8* %17
%19 = or i64 %12, 1
%20 = getelementptr inbounds i8, i8* %1, i64 %19
store i8 %18, i8* %20
%21 = load i8*, i8** %6
%22 = getelementptr inbounds i8, i8* %21, i64 2
%23 = load i8, i8* %22
%24 = or i64 %12, 2
%25 = getelementptr inbounds i8, i8* %1, i64 %24
store i8 %23, i8* %25
%26 = load i8*, i8** %6
%27 = getelementptr inbounds i8, i8* %26, i64 3
%28 = load i8, i8* %27
%29 = or i64 %12, 3
%30 = getelementptr inbounds i8, i8* %1, i64 %29
store i8 %28, i8* %30
%31 = load i8*, i8** %6
%32 = getelementptr inbounds i8, i8* %31, i64 4
%33 = load i8, i8* %32
%34 = or i64 %12, 4
%35 = getelementptr inbounds i8, i8* %1, i64 %34
store i8 %33, i8* %35
%36 = load i8*, i8** %6
%37 = getelementptr inbounds i8, i8* %36, i64 5
%38 = load i8, i8* %37
%39 = or i64 %12, 5
%40 = getelementptr inbounds i8, i8* %1, i64 %39
store i8 %38, i8* %40
%41 = load i8*, i8** %6
%42 = getelementptr inbounds i8, i8* %41, i64 6
%43 = load i8, i8* %42
%44 = or i64 %12, 6
%45 = getelementptr inbounds i8, i8* %1, i64 %44
store i8 %43, i8* %45
%46 = load i8*, i8** %6
%47 = getelementptr inbounds i8, i8* %46, i64 7
%48 = load i8, i8* %47
%49 = or i64 %12, 7
%50 = getelementptr inbounds i8, i8* %1, i64 %49
store i8 %48, i8* %50
%51 = add nsw i64 %5, -1
%52 = add nuw nsw i64 %4, 1
%53 = icmp eq i64 %52, 8
br i1 %53, label %54, label %3
54: ; preds = %3
%55 = getelementptr inbounds i8, i8* %1, i64 64
store i8 0, i8* %55
ret i32 1
}