#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*/ addInt(int *, int, int);
scalar_t__ containsInt(int *, int, int);
scalar_t__ getCantidadConflictosEnReglaCuadrado(int **, int, int, int,
                                                int /*<<< orphan*/);
scalar_t__ getCantidadConflictosEnReglaHorizontal(int **, int,
                                                  int /*<<< orphan*/, int,
                                                  int /*<<< orphan*/);
scalar_t__ getCantidadConflictosEnReglaVertical(int **, int /*<<< orphan*/, int,
                                                int, int /*<<< orphan*/);
int getCandidatoMenorCantidadConflictos(
    int sudoku[9][9], int iPosicionAtratar, int jPosicionAtratar,
    int *blackList, int *blackListCandidatosMenorCantidadConflictos) {
  int count, min = 81, candidato = 0, nuevoCandidato;
  for (nuevoCandidato = 1; nuevoCandidato <= 9; nuevoCandidato++) {
    count = 0;
    if (containsInt(blackList, 9, nuevoCandidato) ||
        containsInt(blackListCandidatosMenorCantidadConflictos, 9,
                    nuevoCandidato)) {
      continue;
    }
    count += getCantidadConflictosEnReglaCuadrado(
        sudoku, iPosicionAtratar, jPosicionAtratar, nuevoCandidato, 0);
    count += getCantidadConflictosEnReglaHorizontal(sudoku, iPosicionAtratar, 0,
                                                    nuevoCandidato, 0);
    count += getCantidadConflictosEnReglaVertical(sudoku, 0, jPosicionAtratar,
                                                  nuevoCandidato, 0);
    if (count < min) {
      min = count;
      candidato = nuevoCandidato;
    }
  }
  addInt(blackListCandidatosMenorCantidadConflictos, 9, candidato);
  return candidato;
}


x86 assembly (clang, -O0):
<getCandidatoMenorCantidadConflictos>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
movl   $0x51,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x1,-0x30(%rbp)
cmpl   $0x9,-0x30(%rbp)
jg     125c <getCandidatoMenorCantidadConflictos+0x10c>
movl   $0x0,-0x24(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x30(%rbp),%edx
mov    $0x9,%esi
call   1060 <containsInt@plt>
cmp    $0x0,%rax
jne    11c6 <getCandidatoMenorCantidadConflictos+0x76>
mov    -0x20(%rbp),%rdi
mov    -0x30(%rbp),%edx
mov    $0x9,%esi
call   1060 <containsInt@plt>
cmp    $0x0,%rax
je     11cb <getCandidatoMenorCantidadConflictos+0x7b>
jmp    124e <getCandidatoMenorCantidadConflictos+0xfe>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x30(%rbp),%ecx
xor    %r8d,%r8d
call   1070 <getCantidadConflictosEnReglaCuadrado@plt>
mov    %rax,%rcx
movslq -0x24(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x30(%rbp),%ecx
xor    %r8d,%r8d
mov    %r8d,%edx
call   1040 <getCantidadConflictosEnReglaHorizontal@plt>
mov    %rax,%rcx
movslq -0x24(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%edx
mov    -0x30(%rbp),%ecx
xor    %r8d,%r8d
mov    %r8d,%esi
call   1030 <getCantidadConflictosEnReglaVertical@plt>
mov    %rax,%rcx
movslq -0x24(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x28(%rbp),%eax
jge    1249 <getCandidatoMenorCantidadConflictos+0xf9>
mov    -0x24(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x30(%rbp),%eax
mov    %eax,-0x2c(%rbp)
jmp    124e <getCandidatoMenorCantidadConflictos+0xfe>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    117f <getCandidatoMenorCantidadConflictos+0x2f>
mov    -0x20(%rbp),%rdi
mov    -0x2c(%rbp),%edx
mov    $0x9,%esi
call   1050 <addInt@plt>
mov    -0x2c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getCandidatoMenorCantidadConflictos>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r8,0x18(%rsp)
mov    %rcx,%rbp
mov    %edx,0x10(%rsp)
mov    %esi,0xc(%rsp)
mov    %rdi,0x20(%rsp)
mov    $0x51,%ebx
movl   $0x0,0x8(%rsp)
mov    $0x1,%r15d
mov    0x10(%rsp),%r13d
jmp    119e <getCandidatoMenorCantidadConflictos+0x4e>
nopl   (%rax)
add    $0x1,%r15d
cmp    $0xa,%r15d
je     123a <getCandidatoMenorCantidadConflictos+0xea>
mov    %rbp,%rdi
mov    $0x9,%esi
mov    %r15d,%edx
call   1060 <containsInt@plt>
test   %rax,%rax
jne    1190 <getCandidatoMenorCantidadConflictos+0x40>
mov    0x18(%rsp),%rdi
mov    $0x9,%esi
mov    %r15d,%edx
call   1060 <containsInt@plt>
test   %rax,%rax
jne    1190 <getCandidatoMenorCantidadConflictos+0x40>
mov    %ebx,0x14(%rsp)
mov    0x20(%rsp),%rbx
mov    %rbx,%rdi
mov    0xc(%rsp),%r14d
mov    %r14d,%esi
mov    %r13d,%edx
mov    %r15d,%ecx
xor    %r8d,%r8d
call   1070 <getCantidadConflictosEnReglaCuadrado@plt>
mov    %rax,%r12
mov    %rbx,%rdi
mov    %r14d,%esi
xor    %edx,%edx
mov    %r15d,%ecx
xor    %r8d,%r8d
call   1040 <getCantidadConflictosEnReglaHorizontal@plt>
mov    %rax,%r14
add    %r12d,%r14d
mov    %rbx,%rdi
xor    %esi,%esi
mov    %r13d,%edx
mov    %r15d,%ecx
xor    %r8d,%r8d
call   1030 <getCantidadConflictosEnReglaVertical@plt>
add    %r14d,%eax
mov    0x8(%rsp),%ecx
mov    0x14(%rsp),%edx
cmp    %eax,%edx
cmovle %edx,%eax
cmovg  %r15d,%ecx
mov    %ecx,0x8(%rsp)
mov    %eax,%ebx
jmp    1190 <getCandidatoMenorCantidadConflictos+0x40>
mov    0x18(%rsp),%rdi
mov    $0x9,%esi
mov    0x8(%rsp),%ebx
mov    %ebx,%edx
call   1050 <addInt@plt>
mov    %ebx,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @getCandidatoMenorCantidadConflictos([9 x i32]* %0, i32 %1, i32 %2, i32* %3, i32* %4) {
%6 = bitcast [9 x i32]* %0 to i32**
br label %7
7: ; preds = %5, %26
%8 = phi i32 [ 1, %5 ], [ %29, %26 ]
%9 = phi i32 [ 0, %5 ], [ %28, %26 ]
%10 = phi i32 [ 81, %5 ], [ %27, %26 ]
%11 = tail call i64 @containsInt(i32* %3, i32 9, i32 %8)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %26
13: ; preds = %7
%14 = tail call i64 @containsInt(i32* %4, i32 9, i32 %8)
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %26
16: ; preds = %13
%17 = tail call i64 @getCantidadConflictosEnReglaCuadrado(i32** %6, i32 %1, i32 %2, i32 %8, i32 0)
%18 = tail call i64 @getCantidadConflictosEnReglaHorizontal(i32** %6, i32 %1, i32 0, i32 %8, i32 0)
%19 = add i64 %18, %17
%20 = tail call i64 @getCantidadConflictosEnReglaVertical(i32** %6, i32 0, i32 %2, i32 %8, i32 0)
%21 = add i64 %19, %20
%22 = trunc i64 %21 to i32
%23 = icmp sgt i32 %10, %22
%24 = select i1 %23, i32 %22, i32 %10
%25 = select i1 %23, i32 %8, i32 %9
br label %26
26: ; preds = %16, %7, %13
%27 = phi i32 [ %10, %7 ], [ %10, %13 ], [ %24, %16 ]
%28 = phi i32 [ %9, %7 ], [ %9, %13 ], [ %25, %16 ]
%29 = add nuw nsw i32 %8, 1
%30 = icmp eq i32 %29, 10
br i1 %30, label %31, label %7
31: ; preds = %26
%32 = tail call i32 @addInt(i32* %4, i32 9, i32 %28)
ret i32 %28
}