#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 checkspot(int **, int, int, int *);
int pickNextGuess_most(int x[9][9], char *ignore_guess_mask) {
  int i, j;
  int possible_mask[9];
  int max_num = 0;
  int max_id = -1;
  int tmp_num;
  for (i = 0; i < 9; i++)
    for (j = 0; j < 9; j++) {
      if ((x[i][j] == 0) && (ignore_guess_mask[i * 9 + j] == 0)) {
        tmp_num = checkspot(x, i, j, possible_mask);
        if (tmp_num > max_num) {
          max_num = tmp_num;
          max_id = (i * 9) + j;
        }
      }
    }
  return max_id;
}


x86 assembly (clang, -O0):
<pickNextGuess_most>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x44(%rbp)
movl   $0xffffffff,-0x48(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x9,-0x14(%rbp)
jge    11e5 <pickNextGuess_most+0xd5>
movl   $0x0,-0x18(%rbp)
cmpl   $0x9,-0x18(%rbp)
jge    11d2 <pickNextGuess_most+0xc2>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
imul   $0x24,%rcx,%rcx
add    %rcx,%rax
movslq -0x18(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
jne    11bf <pickNextGuess_most+0xaf>
mov    -0x10(%rbp),%rax
imul   $0x9,-0x14(%rbp),%ecx
add    -0x18(%rbp),%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
jne    11bf <pickNextGuess_most+0xaf>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    -0x40(%rbp),%rcx
call   1030 <checkspot@plt>
mov    %eax,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
cmp    -0x44(%rbp),%eax
jle    11ba <pickNextGuess_most+0xaa>
mov    -0x4c(%rbp),%eax
mov    %eax,-0x44(%rbp)
imul   $0x9,-0x14(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x48(%rbp)
jmp    11bf <pickNextGuess_most+0xaf>
jmp    11c4 <pickNextGuess_most+0xb4>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1146 <pickNextGuess_most+0x36>
jmp    11d7 <pickNextGuess_most+0xc7>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1135 <pickNextGuess_most+0x25>
mov    -0x48(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pickNextGuess_most>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %rsi,0x10(%rsp)
mov    %rdi,%r12
xor    %ebx,%ebx
mov    $0xffffffff,%r14d
mov    %rdi,0x18(%rsp)
xor    %eax,%eax
mov    %rax,0x8(%rsp)
xor    %r15d,%r15d
jmp    115f <pickNextGuess_most+0x4f>
nop
mov    0x8(%rsp),%rsi
add    $0x1,%rsi
add    $0x9,%rbx
add    $0x24,%r12
mov    %rsi,%rax
mov    %rsi,0x8(%rsp)
cmp    $0x9,%rsi
je     11af <pickNextGuess_most+0x9f>
mov    0x10(%rsp),%rax
lea    (%rax,%rbx,1),%r13
xor    %ebp,%ebp
jmp    117a <pickNextGuess_most+0x6a>
nopl   0x0(%rax)
add    $0x1,%rbp
cmp    $0x9,%rbp
je     1140 <pickNextGuess_most+0x30>
cmpl   $0x0,(%r12,%rbp,4)
jne    1170 <pickNextGuess_most+0x60>
cmpb   $0x0,0x0(%r13,%rbp,1)
jne    1170 <pickNextGuess_most+0x60>
mov    0x18(%rsp),%rdi
mov    0x8(%rsp),%rsi
mov    %ebp,%edx
lea    0x20(%rsp),%rcx
call   1030 <checkspot@plt>
lea    (%rbx,%rbp,1),%ecx
cmp    %r15d,%eax
cmovg  %eax,%r15d
cmovg  %ecx,%r14d
jmp    1170 <pickNextGuess_most+0x60>
mov    %r14d,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @pickNextGuess_most([9 x i32]* %0, i8* %1) {
%3 = alloca [9 x i32]*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca [9 x i32]
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store [9 x i32]* %0, [9 x i32]** %3
store i8* %1, i8** %4
store i32 0, i32* %8
store i32 -1, i32* %9
store i32 0, i32* %5
br label %11
11: ; preds = %61, %2
%12 = load i32, i32* %5
%13 = icmp slt i32 %12, 9
br i1 %13, label %14, label %64
14: ; preds = %11
store i32 0, i32* %6
br label %15
15: ; preds = %57, %14
%16 = load i32, i32* %6
%17 = icmp slt i32 %16, 9
br i1 %17, label %18, label %60
18: ; preds = %15
%19 = load [9 x i32]*, [9 x i32]** %3
%20 = load i32, i32* %5
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [9 x i32], [9 x i32]* %19, i64 %21
%23 = load i32, i32* %6
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [9 x i32], [9 x i32]* %22, i64 0, i64 %24
%26 = load i32, i32* %25
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %56
28: ; preds = %18
%29 = load i8*, i8** %4
%30 = load i32, i32* %5
%31 = mul nsw i32 %30, 9
%32 = load i32, i32* %6
%33 = add nsw i32 %31, %32
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %29, i64 %34
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = icmp eq i32 %37, 0
br i1 %38, label %39, label %56
39: ; preds = %28
%40 = load [9 x i32]*, [9 x i32]** %3
%41 = bitcast [9 x i32]* %40 to i32**
%42 = load i32, i32* %5
%43 = load i32, i32* %6
%44 = getelementptr inbounds [9 x i32], [9 x i32]* %7, i64 0, i64 0
%45 = call i32 @checkspot(i32** %41, i32 %42, i32 %43, i32* %44)
store i32 %45, i32* %10
%46 = load i32, i32* %10
%47 = load i32, i32* %8
%48 = icmp sgt i32 %46, %47
br i1 %48, label %49, label %55
49: ; preds = %39
%50 = load i32, i32* %10
store i32 %50, i32* %8
%51 = load i32, i32* %5
%52 = mul nsw i32 %51, 9
%53 = load i32, i32* %6
%54 = add nsw i32 %52, %53
store i32 %54, i32* %9
br label %55
55: ; preds = %49, %39
br label %56
56: ; preds = %55, %28, %18
br label %57
57: ; preds = %56
%58 = load i32, i32* %6
%59 = add nsw i32 %58, 1
store i32 %59, i32* %6
br label %15
60: ; preds = %15
br label %61
61: ; preds = %60
%62 = load i32, i32* %5
%63 = add nsw i32 %62, 1
store i32 %63, i32* %5
br label %11
64: ; preds = %11
%65 = load i32, i32* %9
ret i32 %65
}

LLVM IR (-O2):
define i32 @pickNextGuess_most([9 x i32]* %0, i8* nocapture %1) {
%3 = alloca [9 x i32]
%4 = bitcast [9 x i32]* %3 to i8*
%5 = bitcast [9 x i32]* %0 to i32**
%6 = getelementptr inbounds [9 x i32], [9 x i32]* %3, i64 0, i64 0
br label %7
7: ; preds = %2, %37
%8 = phi i64 [ 0, %2 ], [ %38, %37 ]
%9 = phi i32 [ -1, %2 ], [ %34, %37 ]
%10 = phi i32 [ 0, %2 ], [ %33, %37 ]
%11 = mul nuw nsw i64 %8, 9
%12 = trunc i64 %8 to i32
br label %13
13: ; preds = %7, %32
%14 = phi i64 [ 0, %7 ], [ %35, %32 ]
%15 = phi i32 [ %9, %7 ], [ %34, %32 ]
%16 = phi i32 [ %10, %7 ], [ %33, %32 ]
%17 = getelementptr inbounds [9 x i32], [9 x i32]* %0, i64 %8, i64 %14
%18 = load i32, i32* %17
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %32
20: ; preds = %13
%21 = add nuw nsw i64 %14, %11
%22 = getelementptr inbounds i8, i8* %1, i64 %21
%23 = load i8, i8* %22
%24 = icmp eq i8 %23, 0
br i1 %24, label %25, label %32
25: ; preds = %20
%26 = trunc i64 %14 to i32
%27 = call i32 @checkspot(i32** %5, i32 %12, i32 %26, i32* %6)
%28 = icmp sgt i32 %27, %16
%29 = select i1 %28, i32 %27, i32 %16
%30 = trunc i64 %21 to i32
%31 = select i1 %28, i32 %30, i32 %15
br label %32
32: ; preds = %25, %13, %20
%33 = phi i32 [ %16, %20 ], [ %16, %13 ], [ %29, %25 ]
%34 = phi i32 [ %15, %20 ], [ %15, %13 ], [ %31, %25 ]
%35 = add nuw nsw i64 %14, 1
%36 = icmp eq i64 %35, 9
br i1 %36, label %37, label %13
37: ; preds = %32
%38 = add nuw nsw i64 %8, 1
%39 = icmp eq i64 %38, 9
br i1 %39, label %40, label %7
40: ; preds = %37
ret i32 %34
}