#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*/ strcmp(char *, char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
int boardcount(char *bn) {
  int i;
  static char bname[1024][20];
  static int count[1024];
  static int nboard = 0;
  for (i = 0; i < nboard; i++) {
    if (!strcmp(bname[i], bn)) {
      return count[i]++;
    }
  }
  if (nboard >= 1024)
    return 0;
  strncpy(bname[nboard], bn, 19);
  bname[nboard][19] = 0;
  count[nboard] = 1;
  nboard++;
  return 0;
}


x86 assembly (clang, -O0):
<boardcount>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    0x8f04(%rip),%eax
jge    119e <boardcount+0x7e>
movslq -0x14(%rbp),%rax
lea    0x2ef3(%rip),%rdi
imul   $0x14,%rax,%rax
add    %rax,%rdi
mov    -0x10(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    118b <boardcount+0x6b>
movslq -0x14(%rbp),%rdx
lea    0x7ecf(%rip),%rax
mov    (%rax,%rdx,4),%eax
mov    %eax,%esi
add    $0x1,%esi
lea    0x7ec0(%rip),%rcx
mov    %esi,(%rcx,%rdx,4)
mov    %eax,-0x4(%rbp)
jmp    1221 <boardcount+0x101>
jmp    1190 <boardcount+0x70>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1133 <boardcount+0x13>
cmpl   $0x400,0x8e98(%rip)
jl     11ba <boardcount+0x9a>
movl   $0x0,-0x4(%rbp)
jmp    1221 <boardcount+0x101>
movslq 0x8e7f(%rip),%rax
lea    0x2e78(%rip),%rdi
imul   $0x14,%rax,%rax
add    %rax,%rdi
mov    -0x10(%rbp),%rsi
mov    $0x13,%edx
call   1030 <strncpy@plt>
movslq 0x8e5c(%rip),%rcx
lea    0x2e55(%rip),%rax
imul   $0x14,%rcx,%rcx
add    %rcx,%rax
movb   $0x0,0x13(%rax)
movslq 0x8e43(%rip),%rcx
lea    0x7e3c(%rip),%rax
movl   $0x1,(%rax,%rcx,4)
mov    0x8e2f(%rip),%eax
add    $0x1,%eax
mov    %eax,0x8e26(%rip)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<boardcount>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
movslq 0x8f0b(%rip),%r12
test   %r12,%r12
jle    1178 <boardcount+0x58>
mov    %r12d,%r13d
lea    0x7efc(%rip),%r15
lea    0x2ef5(%rip),%rbx
mov    %r13,%rbp
xchg   %ax,%ax
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <strcmp@plt>
test   %eax,%eax
je     11bd <boardcount+0x9d>
add    $0x4,%r15
add    $0x14,%rbx
add    $0xffffffffffffffff,%rbp
jne    1150 <boardcount+0x30>
xor    %eax,%eax
cmp    $0x3ff,%r13d
jg     11c8 <boardcount+0xa8>
lea    (%r12,%r12,4),%rax
lea    0x2ebd(%rip),%rbx
lea    (%rbx,%rax,4),%rdi
mov    %r14,%rsi
mov    $0x13,%edx
call   1030 <strncpy@plt>
movslq 0x8ea5(%rip),%rcx
lea    0x8e9e(%rip),%r15
lea    (%rcx,%rcx,4),%rax
movb   $0x0,0x13(%rbx,%rax,4)
lea    0x7e8e(%rip),%rax
movl   $0x1,(%rax,%rcx,4)
xor    %eax,%eax
jmp    11c2 <boardcount+0xa2>
mov    (%r15),%ecx
mov    %ecx,%eax
add    $0x1,%ecx
mov    %ecx,(%r15)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@boardcount.bname = internal global [1024 x [20 x i8]] zeroinitializer
@boardcount.count = internal global [1024 x i32] zeroinitializer
@boardcount.nboard = internal global i32 0
define i32 @boardcount(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
store i32 0, i32* %4
br label %5
5: ; preds = %24, %1
%6 = load i32, i32* %4
%7 = load i32, i32* @boardcount.nboard
%8 = icmp slt i32 %6, %7
br i1 %8, label %9, label %27
9: ; preds = %5
%10 = load i32, i32* %4
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [1024 x [20 x i8]], [1024 x [20 x i8]]* @boardcount.bname, i64 0, i64 %11
%13 = getelementptr inbounds [20 x i8], [20 x i8]* %12, i64 0, i64 0
%14 = load i8*, i8** %3
%15 = call i32 @strcmp(i8* %13, i8* %14)
%16 = icmp ne i32 %15, 0
br i1 %16, label %23, label %17
17: ; preds = %9
%18 = load i32, i32* %4
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [1024 x i32], [1024 x i32]* @boardcount.count, i64 0, i64 %19
%21 = load i32, i32* %20
%22 = add nsw i32 %21, 1
store i32 %22, i32* %20
store i32 %21, i32* %2
br label %47
23: ; preds = %9
br label %24
24: ; preds = %23
%25 = load i32, i32* %4
%26 = add nsw i32 %25, 1
store i32 %26, i32* %4
br label %5
27: ; preds = %5
%28 = load i32, i32* @boardcount.nboard
%29 = icmp sge i32 %28, 1024
br i1 %29, label %30, label %31
30: ; preds = %27
store i32 0, i32* %2
br label %47
31: ; preds = %27
%32 = load i32, i32* @boardcount.nboard
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [1024 x [20 x i8]], [1024 x [20 x i8]]* @boardcount.bname, i64 0, i64 %33
%35 = getelementptr inbounds [20 x i8], [20 x i8]* %34, i64 0, i64 0
%36 = load i8*, i8** %3
%37 = call i32 @strncpy(i8* %35, i8* %36, i32 19)
%38 = load i32, i32* @boardcount.nboard
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds [1024 x [20 x i8]], [1024 x [20 x i8]]* @boardcount.bname, i64 0, i64 %39
%41 = getelementptr inbounds [20 x i8], [20 x i8]* %40, i64 0, i64 19
store i8 0, i8* %41
%42 = load i32, i32* @boardcount.nboard
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [1024 x i32], [1024 x i32]* @boardcount.count, i64 0, i64 %43
store i32 1, i32* %44
%45 = load i32, i32* @boardcount.nboard
%46 = add nsw i32 %45, 1
store i32 %46, i32* @boardcount.nboard
store i32 0, i32* %2
br label %47
47: ; preds = %31, %30, %17
%48 = load i32, i32* %2
ret i32 %48
}

LLVM IR (-O2):
@boardcount.bname = internal global [1024 x [20 x i8]] zeroinitializer
@boardcount.count = internal unnamed_addr global [1024 x i32] zeroinitializer
@boardcount.nboard = internal unnamed_addr global i32 0
define i32 @boardcount(i8* %0) {
%2 = load i32, i32* @boardcount.nboard
%3 = icmp sgt i32 %2, 0
br i1 %3, label %4, label %20
4: ; preds = %1
%5 = zext i32 %2 to i64
br label %6
6: ; preds = %4, %15
%7 = phi i64 [ 0, %4 ], [ %16, %15 ]
%8 = getelementptr inbounds [1024 x [20 x i8]], [1024 x [20 x i8]]* @boardcount.bname, i64 0, i64 %7, i64 0
%9 = tail call i32 @strcmp(i8* %8, i8* dereferenceable(1) %0)
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %15
11: ; preds = %6
%12 = and i64 %7, 4294967295
%13 = getelementptr inbounds [1024 x i32], [1024 x i32]* @boardcount.count, i64 0, i64 %12
%14 = load i32, i32* %13
br label %28
15: ; preds = %6
%16 = add nuw nsw i64 %7, 1
%17 = icmp eq i64 %16, %5
br i1 %17, label %18, label %6
18: ; preds = %15
%19 = icmp sgt i32 %2, 1023
br i1 %19, label %33, label %20
20: ; preds = %1, %18
%21 = sext i32 %2 to i64
%22 = getelementptr inbounds [1024 x [20 x i8]], [1024 x [20 x i8]]* @boardcount.bname, i64 0, i64 %21, i64 0
%23 = tail call i32 @strncpy(i8* %22, i8* %0, i32 19)
%24 = load i32, i32* @boardcount.nboard
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [1024 x [20 x i8]], [1024 x [20 x i8]]* @boardcount.bname, i64 0, i64 %25, i64 19
store i8 0, i8* %26
%27 = getelementptr inbounds [1024 x i32], [1024 x i32]* @boardcount.count, i64 0, i64 %25
store i32 1, i32* %27
br label %28
28: ; preds = %11, %20
%29 = phi i32 [ %24, %20 ], [ %14, %11 ]
%30 = phi i32* [ @boardcount.nboard, %20 ], [ %13, %11 ]
%31 = phi i32 [ 0, %20 ], [ %14, %11 ]
%32 = add nsw i32 %29, 1
store i32 %32, i32* %30
br label %33
33: ; preds = %28, %18
%34 = phi i32 [ 0, %18 ], [ %31, %28 ]
ret i32 %34
}