#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 */
typedef int /*<<< orphan*/ defaultPieces;

/* Variables and functions */
int /*<<< orphan*/ convert_hex_char_to_int(char const);
int /*<<< orphan*/ set_piece(int /*<<< orphan*/, char const, char const,
                             int **);
void reset_board(int **board) {
  const char *defaultPieces[32] = {
      "A18", "828", "938", "B48", "C58", "968", "878", "A88",
      "717", "727", "737", "747", "757", "767", "777", "787",
      "112", "122", "132", "142", "152", "162", "172", "182",
      "411", "221", "331", "541", "651", "361", "271", "481"};
  for (int i = 0; i < sizeof(defaultPieces) / sizeof(int *); i++) {
    set_piece(convert_hex_char_to_int(defaultPieces[i][0]),
              defaultPieces[i][1] - '0', defaultPieces[i][2] - '0', board);
  }
}


x86 assembly (clang, -O0):
<reset_board>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x110(%rbp),%rdi
lea    0x2bd3(%rip),%rsi
mov    $0x100,%edx
call   1030 <memcpy@plt>
movl   $0x0,-0x114(%rbp)
movslq -0x114(%rbp),%rax
cmp    $0x20,%rax
jae    11dc <reset_board+0xac>
movslq -0x114(%rbp),%rax
mov    -0x110(%rbp,%rax,8),%rax
ff
movsbl (%rax),%edi
call   1040 <convert_hex_char_to_int@plt>
mov    %eax,%edi
movslq -0x114(%rbp),%rax
mov    -0x110(%rbp,%rax,8),%rax
ff
movsbl 0x1(%rax),%eax
sub    $0x30,%eax
mov    %al,%dl
movslq -0x114(%rbp),%rax
mov    -0x110(%rbp,%rax,8),%rax
ff
movsbl 0x2(%rax),%eax
sub    $0x30,%eax
mov    -0x8(%rbp),%rcx
movsbl %dl,%esi
movsbl %al,%edx
call   1050 <set_piece@plt>
mov    -0x114(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x114(%rbp)
jmp    1161 <reset_board+0x31>
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<reset_board>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
xor    %ebx,%ebx
lea    0x2bec(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    (%rbx,%r15,1),%r12
movsbl (%r12),%edi
call   1030 <convert_hex_char_to_int@plt>
movzbl 0x1(%r12),%ecx
movzbl 0x2(%r12),%edx
add    $0xd0,%cl
add    $0xd0,%dl
movsbl %cl,%esi
movsbl %dl,%edx
mov    %eax,%edi
mov    %r14,%rcx
call   1040 <set_piece@plt>
add    $0x8,%rbx
cmp    $0x100,%rbx
jne    1140 <reset_board+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [4 x i8] c"A18\00"
@.str.1 = [4 x i8] c"828\00"
@.str.2 = [4 x i8] c"938\00"
@.str.3 = [4 x i8] c"B48\00"
@.str.4 = [4 x i8] c"C58\00"
@.str.5 = [4 x i8] c"968\00"
@.str.6 = [4 x i8] c"878\00"
@.str.7 = [4 x i8] c"A88\00"
@.str.8 = [4 x i8] c"717\00"
@.str.9 = [4 x i8] c"727\00"
@.str.10 = [4 x i8] c"737\00"
@.str.11 = [4 x i8] c"747\00"
@.str.12 = [4 x i8] c"757\00"
@.str.13 = [4 x i8] c"767\00"
@.str.14 = [4 x i8] c"777\00"
@.str.15 = [4 x i8] c"787\00"
@.str.16 = [4 x i8] c"112\00"
@.str.17 = [4 x i8] c"122\00"
@.str.18 = [4 x i8] c"132\00"
@.str.19 = [4 x i8] c"142\00"
@.str.20 = [4 x i8] c"152\00"
@.str.21 = [4 x i8] c"162\00"
@.str.22 = [4 x i8] c"172\00"
@.str.23 = [4 x i8] c"182\00"
@.str.24 = [4 x i8] c"411\00"
@.str.25 = [4 x i8] c"221\00"
@.str.26 = [4 x i8] c"331\00"
@.str.27 = [4 x i8] c"541\00"
@.str.28 = [4 x i8] c"651\00"
@.str.29 = [4 x i8] c"361\00"
@.str.30 = [4 x i8] c"271\00"
@.str.31 = [4 x i8] c"481\00"
@__const.reset_board.defaultPieces = [32 x i8*] [i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.13, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.14, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.15, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.16, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.17, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.18, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.19, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.20, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.21, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.22, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.23, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.24, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.25, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.26, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.27, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.28, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.29, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.30, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.31, i32 0, i32 0)]
define void @reset_board(i32** %0) {
%2 = alloca i32**
%3 = alloca [32 x i8*]
%4 = alloca i32
store i32** %0, i32*** %2
%5 = bitcast [32 x i8*]* %3 to i8*
store i32 0, i32* %4
br label %6
6: ; preds = %38, %1
%7 = load i32, i32* %4
%8 = sext i32 %7 to i64
%9 = icmp ult i64 %8, 32
br i1 %9, label %10, label %41
10: ; preds = %6
%11 = load i32, i32* %4
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [32 x i8*], [32 x i8*]* %3, i64 0, i64 %12
%14 = load i8*, i8** %13
%15 = getelementptr inbounds i8, i8* %14, i64 0
%16 = load i8, i8* %15
%17 = call i32 @convert_hex_char_to_int(i8 signext %16)
%18 = load i32, i32* %4
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [32 x i8*], [32 x i8*]* %3, i64 0, i64 %19
%21 = load i8*, i8** %20
%22 = getelementptr inbounds i8, i8* %21, i64 1
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = sub nsw i32 %24, 48
%26 = trunc i32 %25 to i8
%27 = load i32, i32* %4
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [32 x i8*], [32 x i8*]* %3, i64 0, i64 %28
%30 = load i8*, i8** %29
%31 = getelementptr inbounds i8, i8* %30, i64 2
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = sub nsw i32 %33, 48
%35 = trunc i32 %34 to i8
%36 = load i32**, i32*** %2
%37 = call i32 @set_piece(i32 %17, i8 signext %26, i8 signext %35, i32** %36)
br label %38
38: ; preds = %10
%39 = load i32, i32* %4
%40 = add nsw i32 %39, 1
store i32 %40, i32* %4
br label %6
41: ; preds = %6
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"A18\00"
@.str.1 = [4 x i8] c"828\00"
@.str.2 = [4 x i8] c"938\00"
@.str.3 = [4 x i8] c"B48\00"
@.str.4 = [4 x i8] c"C58\00"
@.str.5 = [4 x i8] c"968\00"
@.str.6 = [4 x i8] c"878\00"
@.str.7 = [4 x i8] c"A88\00"
@.str.8 = [4 x i8] c"717\00"
@.str.9 = [4 x i8] c"727\00"
@.str.10 = [4 x i8] c"737\00"
@.str.11 = [4 x i8] c"747\00"
@.str.12 = [4 x i8] c"757\00"
@.str.13 = [4 x i8] c"767\00"
@.str.14 = [4 x i8] c"777\00"
@.str.15 = [4 x i8] c"787\00"
@.str.16 = [4 x i8] c"112\00"
@.str.17 = [4 x i8] c"122\00"
@.str.18 = [4 x i8] c"132\00"
@.str.19 = [4 x i8] c"142\00"
@.str.20 = [4 x i8] c"152\00"
@.str.21 = [4 x i8] c"162\00"
@.str.22 = [4 x i8] c"172\00"
@.str.23 = [4 x i8] c"182\00"
@.str.24 = [4 x i8] c"411\00"
@.str.25 = [4 x i8] c"221\00"
@.str.26 = [4 x i8] c"331\00"
@.str.27 = [4 x i8] c"541\00"
@.str.28 = [4 x i8] c"651\00"
@.str.29 = [4 x i8] c"361\00"
@.str.30 = [4 x i8] c"271\00"
@.str.31 = [4 x i8] c"481\00"
@__const.reset_board.defaultPieces = [32 x i8*] [i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.13, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.14, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.15, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.16, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.17, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.18, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.19, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.20, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.21, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.22, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.23, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.24, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.25, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.26, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.27, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.28, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.29, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.30, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.31, i32 0, i32 0)]
define void @reset_board(i32** %0) {
br label %3
2: ; preds = %3
ret void
3: ; preds = %1, %3
%4 = phi i64 [ 0, %1 ], [ %16, %3 ]
%5 = getelementptr inbounds [32 x i8*], [32 x i8*]* @__const.reset_board.defaultPieces, i64 0, i64 %4
%6 = load i8*, i8** %5
%7 = load i8, i8* %6
%8 = tail call i32 @convert_hex_char_to_int(i8 signext %7)
%9 = getelementptr inbounds i8, i8* %6, i64 1
%10 = load i8, i8* %9
%11 = add i8 %10, -48
%12 = getelementptr inbounds i8, i8* %6, i64 2
%13 = load i8, i8* %12
%14 = add i8 %13, -48
%15 = tail call i32 @set_piece(i32 %8, i8 signext %11, i8 signext %14, i32** %0)
%16 = add nuw nsw i64 %4, 1
%17 = icmp eq i64 %16, 32
br i1 %17, label %2, label %3
}