#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 c2n(char);
char *readrow(char *desc, int n, int *array, int off, const char **prob) {
  int i, num;
  char c;
  for (i = 0; i < n; i++) {
    c = *desc++;
    if (c == 0)
      goto badchar;
    if (c == '.')
      num = -1;
    else {
      num = c2n(c);
      if (num < 0)
        goto badchar;
    }
    array[i * 3 + off] = num;
  }
  c = *desc++;
  if (c != ',')
    goto badchar;
  return desc;
badchar:
  *prob = (c == 0) ? "Game description too short"
                   : "Game description contained unexpected characters";
  return NULL;
}


x86 assembly (clang, -O0):
<readrow>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    %r8,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11be <readrow+0xae>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%al
mov    %al,-0x39(%rbp)
movsbl -0x39(%rbp),%eax
cmp    $0x0,%eax
jne    1163 <readrow+0x53>
jmp    11f1 <readrow+0xe1>
movsbl -0x39(%rbp),%eax
cmp    $0x2e,%eax
jne    117c <readrow+0x6c>
movl   $0xffffffff,-0x38(%rbp)
jmp    119c <readrow+0x8c>
movsbl -0x39(%rbp),%edi
call   1030 <c2n@plt>
mov    %eax,-0x38(%rbp)
cmpl   $0x0,-0x38(%rbp)
jge    1197 <readrow+0x87>
jmp    11f1 <readrow+0xe1>
jmp    119c <readrow+0x8c>
mov    -0x38(%rbp),%edx
mov    -0x20(%rbp),%rax
imul   $0x3,-0x34(%rbp),%ecx
add    -0x24(%rbp),%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1131 <readrow+0x21>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%al
mov    %al,-0x39(%rbp)
movsbl -0x39(%rbp),%eax
cmp    $0x2c,%eax
je     11e4 <readrow+0xd4>
jmp    11f1 <readrow+0xe1>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1219 <readrow+0x109>
movsbl -0x39(%rbp),%edx
lea    0xe1f(%rip),%rcx
lea    0xdfd(%rip),%rax
cmp    $0x0,%edx
cmove  %rax,%rcx
mov    -0x30(%rbp),%rax
mov    %rcx,(%rax)
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readrow>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8,%r14
mov    %rdi,%rbx
test   %esi,%esi
jle    1180 <readrow+0x70>
movslq %ecx,%rax
mov    %esi,%ecx
lea    (%rdx,%rax,4),%r12
shl    $0x2,%rcx
lea    (%rcx,%rcx,2),%r13
xor    %ebp,%ebp
lea    0xedc(%rip),%r15
jmp    1161 <readrow+0x51>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbx
mov    %eax,(%r12,%rbp,1)
add    $0xc,%rbp
cmp    %rbp,%r13
je     1180 <readrow+0x70>
movzbl (%rbx),%ecx
mov    $0xffffffff,%eax
cmp    $0x2e,%cl
je     1150 <readrow+0x40>
test   %cl,%cl
je     1190 <readrow+0x80>
movsbl %cl,%edi
call   1030 <c2n@plt>
test   %eax,%eax
jns    1150 <readrow+0x40>
jmp    11a0 <readrow+0x90>
mov    (%rbx),%al
test   %al,%al
je     1190 <readrow+0x80>
cmp    $0x2c,%al
jne    1199 <readrow+0x89>
add    $0x1,%rbx
jmp    11a5 <readrow+0x95>
lea    0xe69(%rip),%r15
jmp    11a0 <readrow+0x90>
lea    0xe7b(%rip),%r15
mov    %r15,(%r14)
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [27 x i8] c"Game description too short\00"
@.str.1 = [49 x i8] c"Game description contained unexpected characters\00"
define i8* @readrow(i8* %0, i32 %1, i32* %2, i32 %3, i8** %4) {
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32*
%10 = alloca i32
%11 = alloca i8**
%12 = alloca i32
%13 = alloca i32
%14 = alloca i8
store i8* %0, i8** %7
store i32 %1, i32* %8
store i32* %2, i32** %9
store i32 %3, i32* %10
store i8** %4, i8*** %11
store i32 0, i32* %12
br label %15
15: ; preds = %48, %5
%16 = load i32, i32* %12
%17 = load i32, i32* %8
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %51
19: ; preds = %15
%20 = load i8*, i8** %7
%21 = getelementptr inbounds i8, i8* %20, i32 1
store i8* %21, i8** %7
%22 = load i8, i8* %20
store i8 %22, i8* %14
%23 = load i8, i8* %14
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %27
26: ; preds = %19
br label %61
27: ; preds = %19
%28 = load i8, i8* %14
%29 = sext i8 %28 to i32
%30 = icmp eq i32 %29, 46
br i1 %30, label %31, label %32
31: ; preds = %27
store i32 -1, i32* %13
br label %39
32: ; preds = %27
%33 = load i8, i8* %14
%34 = call i32 @c2n(i8 signext %33)
store i32 %34, i32* %13
%35 = load i32, i32* %13
%36 = icmp slt i32 %35, 0
br i1 %36, label %37, label %38
37: ; preds = %32
br label %61
38: ; preds = %32
br label %39
39: ; preds = %38, %31
%40 = load i32, i32* %13
%41 = load i32*, i32** %9
%42 = load i32, i32* %12
%43 = mul nsw i32 %42, 3
%44 = load i32, i32* %10
%45 = add nsw i32 %43, %44
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i32, i32* %41, i64 %46
store i32 %40, i32* %47
br label %48
48: ; preds = %39
%49 = load i32, i32* %12
%50 = add nsw i32 %49, 1
store i32 %50, i32* %12
br label %15
51: ; preds = %15
%52 = load i8*, i8** %7
%53 = getelementptr inbounds i8, i8* %52, i32 1
store i8* %53, i8** %7
%54 = load i8, i8* %52
store i8 %54, i8* %14
%55 = load i8, i8* %14
%56 = sext i8 %55 to i32
%57 = icmp ne i32 %56, 44
br i1 %57, label %58, label %59
58: ; preds = %51
br label %61
59: ; preds = %51
%60 = load i8*, i8** %7
store i8* %60, i8** %6
br label %68
61: ; preds = %58, %37, %26
%62 = load i8, i8* %14
%63 = sext i8 %62 to i32
%64 = icmp eq i32 %63, 0
%65 = zext i1 %64 to i64
%66 = select i1 %64, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0)
%67 = load i8**, i8*** %11
store i8* %66, i8** %67
store i8* null, i8** %6
br label %68
68: ; preds = %61, %59
%69 = load i8*, i8** %6
ret i8* %69
}

LLVM IR (-O2):
@.str = [27 x i8] c"Game description too short\00"
@.str.1 = [49 x i8] c"Game description contained unexpected characters\00"
define i8* @readrow(i8* %0, i32 %1, i32* nocapture writeonly %2, i32 %3, i8** nocapture writeonly %4) {
%6 = icmp sgt i32 %1, 0
br i1 %6, label %7, label %25
7: ; preds = %5
%8 = sext i32 %3 to i64
%9 = zext i32 %1 to i64
br label %10
10: ; preds = %7, %18
%11 = phi i64 [ 0, %7 ], [ %23, %18 ]
%12 = phi i8* [ %0, %7 ], [ %13, %18 ]
%13 = getelementptr inbounds i8, i8* %12, i64 1
%14 = load i8, i8* %12
switch i8 %14, label %15 [
i8 0, label %30
i8 46, label %18
]
15: ; preds = %10
%16 = tail call i32 @c2n(i8 signext %14)
%17 = icmp slt i32 %16, 0
br i1 %17, label %31, label %18
18: ; preds = %10, %15
%19 = phi i32 [ %16, %15 ], [ -1, %10 ]
%20 = mul nuw nsw i64 %11, 3
%21 = add nsw i64 %20, %8
%22 = getelementptr inbounds i32, i32* %2, i64 %21
store i32 %19, i32* %22
%23 = add nuw nsw i64 %11, 1
%24 = icmp eq i64 %23, %9
br i1 %24, label %25, label %10
25: ; preds = %18, %5
%26 = phi i8* [ %0, %5 ], [ %13, %18 ]
%27 = load i8, i8* %26
switch i8 %27, label %31 [
i8 44, label %28
i8 0, label %30
]
28: ; preds = %25
%29 = getelementptr inbounds i8, i8* %26, i64 1
br label %33
30: ; preds = %10, %25
br label %31
31: ; preds = %15, %25, %30
%32 = phi i8* [ getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), %30 ], [ getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0), %25 ], [ getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0), %15 ]
store i8* %32, i8** %4
br label %33
33: ; preds = %31, %28
%34 = phi i8* [ null, %31 ], [ %29, %28 ]
ret i8* %34
}