#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*/ copyMatriz(int **, int **);
int getColumnaConflictoEnFila(int **, int, int);
int getFilaConflictoEnColumna(int **, int, int);
scalar_t__ sePuedeSwapAbajo(int);
scalar_t__ sePuedeSwapArriba(int);
scalar_t__ swapAbajo(int **, int **, int, int, int /*<<< orphan*/);
scalar_t__ swapArriba(int **, int **, int, int, int /*<<< orphan*/);
int forzarFilasCuadros(int sudoku[9][9], int candidato, int iPosicionAtratar,
                       int jPosicionAtratar) {
  int iPosicionConflicto =
      getFilaConflictoEnColumna(sudoku, jPosicionAtratar, candidato);
  iPosicionConflicto =
      iPosicionConflicto == -1 ? iPosicionAtratar : iPosicionConflicto;
  int jPosicionConflicto =
      getColumnaConflictoEnFila(sudoku, iPosicionAtratar, candidato);
  jPosicionConflicto =
      jPosicionConflicto == -1 ? jPosicionAtratar : jPosicionConflicto;
  int sudokuSimulacion[9][9];
  copyMatriz(sudoku, sudokuSimulacion);
  if (sePuedeSwapArriba(iPosicionConflicto)) {
    if (swapArriba(sudoku, sudokuSimulacion, iPosicionConflicto,
                   jPosicionConflicto, 0)) {
      copyMatriz(sudokuSimulacion, sudoku);
      return 1;
    }
  }
  copyMatriz(sudoku, sudokuSimulacion);
  if (sePuedeSwapAbajo(iPosicionConflicto)) {
    if (swapAbajo(sudoku, sudokuSimulacion, iPosicionConflicto,
                  jPosicionConflicto, 0)) {
      copyMatriz(sudokuSimulacion, sudoku);
      return 1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<forzarFilasCuadros>:
push   %rbp
mov    %rsp,%rbp
sub    $0x180,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1070 <getFilaConflictoEnColumna@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0xffffffff,-0x20(%rbp)
jne    11b2 <forzarFilasCuadros+0x42>
mov    -0x18(%rbp),%eax
mov    %eax,-0x174(%rbp)
jmp    11bb <forzarFilasCuadros+0x4b>
mov    -0x20(%rbp),%eax
mov    %eax,-0x174(%rbp)
mov    -0x174(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1050 <getColumnaConflictoEnFila@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0xffffffff,-0x24(%rbp)
jne    11ee <forzarFilasCuadros+0x7e>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x178(%rbp)
jmp    11f7 <forzarFilasCuadros+0x87>
mov    -0x24(%rbp),%eax
mov    %eax,-0x178(%rbp)
mov    -0x178(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x170(%rbp),%rsi
call   1080 <copyMatriz@plt>
mov    -0x20(%rbp),%edi
call   1040 <sePuedeSwapArriba@plt>
cmp    $0x0,%rax
je     1266 <forzarFilasCuadros+0xf6>
mov    -0x10(%rbp),%rdi
lea    -0x170(%rbp),%rsi
mov    -0x20(%rbp),%edx
mov    -0x24(%rbp),%ecx
xor    %r8d,%r8d
call   1030 <swapArriba@plt>
cmp    $0x0,%rax
je     1261 <forzarFilasCuadros+0xf1>
lea    -0x170(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1080 <copyMatriz@plt>
movl   $0x1,-0x4(%rbp)
jmp    12d3 <forzarFilasCuadros+0x163>
jmp    1266 <forzarFilasCuadros+0xf6>
mov    -0x10(%rbp),%rdi
lea    -0x170(%rbp),%rsi
call   1080 <copyMatriz@plt>
mov    -0x20(%rbp),%edi
call   1060 <sePuedeSwapAbajo@plt>
cmp    $0x0,%rax
je     12cc <forzarFilasCuadros+0x15c>
mov    -0x10(%rbp),%rdi
lea    -0x170(%rbp),%rsi
mov    -0x20(%rbp),%edx
mov    -0x24(%rbp),%ecx
xor    %r8d,%r8d
call   1090 <swapAbajo@plt>
cmp    $0x0,%rax
je     12c7 <forzarFilasCuadros+0x157>
lea    -0x170(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1080 <copyMatriz@plt>
movl   $0x1,-0x4(%rbp)
jmp    12d3 <forzarFilasCuadros+0x163>
jmp    12cc <forzarFilasCuadros+0x15c>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x180,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<forzarFilasCuadros>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x150,%rsp
mov    %ecx,%r15d
mov    %edx,%ebx
mov    %esi,%ebp
mov    %rdi,%r14
mov    %ecx,%esi
mov    %ebp,%edx
call   1070 <getFilaConflictoEnColumna@plt>
mov    %eax,%r12d
cmp    $0xffffffff,%eax
cmove  %ebx,%r12d
mov    %r14,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
call   1050 <getColumnaConflictoEnFila@plt>
mov    %eax,%ebx
cmp    $0xffffffff,%eax
cmove  %r15d,%ebx
mov    %rsp,%rsi
mov    %r14,%rdi
call   1080 <copyMatriz@plt>
mov    %r12d,%edi
call   1040 <sePuedeSwapArriba@plt>
test   %rax,%rax
je     11e1 <forzarFilasCuadros+0x71>
mov    %rsp,%rsi
mov    %r14,%rdi
mov    %r12d,%edx
mov    %ebx,%ecx
xor    %r8d,%r8d
call   1030 <swapArriba@plt>
test   %rax,%rax
jne    1214 <forzarFilasCuadros+0xa4>
mov    %rsp,%rsi
mov    %r14,%rdi
call   1080 <copyMatriz@plt>
mov    %r12d,%edi
call   1060 <sePuedeSwapAbajo@plt>
test   %rax,%rax
je     1227 <forzarFilasCuadros+0xb7>
mov    %rsp,%rsi
xor    %r15d,%r15d
mov    %r14,%rdi
mov    %r12d,%edx
mov    %ebx,%ecx
xor    %r8d,%r8d
call   1090 <swapAbajo@plt>
test   %rax,%rax
je     122a <forzarFilasCuadros+0xba>
mov    %rsp,%rdi
mov    %r14,%rsi
call   1080 <copyMatriz@plt>
mov    $0x1,%r15d
jmp    122a <forzarFilasCuadros+0xba>
xor    %r15d,%r15d
mov    %r15d,%eax
add    $0x150,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @forzarFilasCuadros([9 x i32]* %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca [9 x i32]*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca [9 x [9 x 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
%13 = load [9 x i32]*, [9 x i32]** %6
%14 = bitcast [9 x i32]* %13 to i32**
%15 = load i32, i32* %9
%16 = load i32, i32* %7
%17 = call i32 @getFilaConflictoEnColumna(i32** %14, i32 %15, i32 %16)
store i32 %17, i32* %10
%18 = load i32, i32* %10
%19 = icmp eq i32 %18, -1
br i1 %19, label %20, label %22
20: ; preds = %4
%21 = load i32, i32* %8
br label %24
22: ; preds = %4
%23 = load i32, i32* %10
br label %24
24: ; preds = %22, %20
%25 = phi i32 [ %21, %20 ], [ %23, %22 ]
store i32 %25, i32* %10
%26 = load [9 x i32]*, [9 x i32]** %6
%27 = bitcast [9 x i32]* %26 to i32**
%28 = load i32, i32* %8
%29 = load i32, i32* %7
%30 = call i32 @getColumnaConflictoEnFila(i32** %27, i32 %28, i32 %29)
store i32 %30, i32* %11
%31 = load i32, i32* %11
%32 = icmp eq i32 %31, -1
br i1 %32, label %33, label %35
33: ; preds = %24
%34 = load i32, i32* %9
br label %37
35: ; preds = %24
%36 = load i32, i32* %11
br label %37
37: ; preds = %35, %33
%38 = phi i32 [ %34, %33 ], [ %36, %35 ]
store i32 %38, i32* %11
%39 = load [9 x i32]*, [9 x i32]** %6
%40 = bitcast [9 x i32]* %39 to i32**
%41 = getelementptr inbounds [9 x [9 x i32]], [9 x [9 x i32]]* %12, i64 0, i64 0
%42 = bitcast [9 x i32]* %41 to i32**
%43 = call i32 @copyMatriz(i32** %40, i32** %42)
%44 = load i32, i32* %10
%45 = call i64 @sePuedeSwapArriba(i32 %44)
%46 = icmp ne i64 %45, 0
br i1 %46, label %47, label %63
47: ; preds = %37
%48 = load [9 x i32]*, [9 x i32]** %6
%49 = bitcast [9 x i32]* %48 to i32**
%50 = getelementptr inbounds [9 x [9 x i32]], [9 x [9 x i32]]* %12, i64 0, i64 0
%51 = bitcast [9 x i32]* %50 to i32**
%52 = load i32, i32* %10
%53 = load i32, i32* %11
%54 = call i64 @swapArriba(i32** %49, i32** %51, i32 %52, i32 %53, i32 0)
%55 = icmp ne i64 %54, 0
br i1 %55, label %56, label %62
56: ; preds = %47
%57 = getelementptr inbounds [9 x [9 x i32]], [9 x [9 x i32]]* %12, i64 0, i64 0
%58 = bitcast [9 x i32]* %57 to i32**
%59 = load [9 x i32]*, [9 x i32]** %6
%60 = bitcast [9 x i32]* %59 to i32**
%61 = call i32 @copyMatriz(i32** %58, i32** %60)
store i32 1, i32* %5
br label %89
62: ; preds = %47
br label %63
63: ; preds = %62, %37
%64 = load [9 x i32]*, [9 x i32]** %6
%65 = bitcast [9 x i32]* %64 to i32**
%66 = getelementptr inbounds [9 x [9 x i32]], [9 x [9 x i32]]* %12, i64 0, i64 0
%67 = bitcast [9 x i32]* %66 to i32**
%68 = call i32 @copyMatriz(i32** %65, i32** %67)
%69 = load i32, i32* %10
%70 = call i64 @sePuedeSwapAbajo(i32 %69)
%71 = icmp ne i64 %70, 0
br i1 %71, label %72, label %88
72: ; preds = %63
%73 = load [9 x i32]*, [9 x i32]** %6
%74 = bitcast [9 x i32]* %73 to i32**
%75 = getelementptr inbounds [9 x [9 x i32]], [9 x [9 x i32]]* %12, i64 0, i64 0
%76 = bitcast [9 x i32]* %75 to i32**
%77 = load i32, i32* %10
%78 = load i32, i32* %11
%79 = call i64 @swapAbajo(i32** %74, i32** %76, i32 %77, i32 %78, i32 0)
%80 = icmp ne i64 %79, 0
br i1 %80, label %81, label %87
81: ; preds = %72
%82 = getelementptr inbounds [9 x [9 x i32]], [9 x [9 x i32]]* %12, i64 0, i64 0
%83 = bitcast [9 x i32]* %82 to i32**
%84 = load [9 x i32]*, [9 x i32]** %6
%85 = bitcast [9 x i32]* %84 to i32**
%86 = call i32 @copyMatriz(i32** %83, i32** %85)
store i32 1, i32* %5
br label %89
87: ; preds = %72
br label %88
88: ; preds = %87, %63
store i32 0, i32* %5
br label %89
89: ; preds = %88, %81, %56
%90 = load i32, i32* %5
ret i32 %90
}

LLVM IR (-O2):
define i32 @forzarFilasCuadros([9 x i32]* %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca [9 x [9 x i32]]
%6 = bitcast [9 x i32]* %0 to i32**
%7 = tail call i32 @getFilaConflictoEnColumna(i32** %6, i32 %3, i32 %1)
%8 = icmp eq i32 %7, -1
%9 = select i1 %8, i32 %2, i32 %7
%10 = tail call i32 @getColumnaConflictoEnFila(i32** %6, i32 %2, i32 %1)
%11 = icmp eq i32 %10, -1
%12 = select i1 %11, i32 %3, i32 %10
%13 = bitcast [9 x [9 x i32]]* %5 to i8*
%14 = bitcast [9 x [9 x i32]]* %5 to i32**
%15 = call i32 @copyMatriz(i32** %6, i32** %14)
%16 = call i64 @sePuedeSwapArriba(i32 %9)
%17 = icmp eq i64 %16, 0
br i1 %17, label %21, label %18
18: ; preds = %4
%19 = call i64 @swapArriba(i32** %6, i32** %14, i32 %9, i32 %12, i32 0)
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %28
21: ; preds = %18, %4
%22 = call i32 @copyMatriz(i32** %6, i32** %14)
%23 = call i64 @sePuedeSwapAbajo(i32 %9)
%24 = icmp eq i64 %23, 0
br i1 %24, label %30, label %25
25: ; preds = %21
%26 = call i64 @swapAbajo(i32** %6, i32** %14, i32 %9, i32 %12, i32 0)
%27 = icmp eq i64 %26, 0
br i1 %27, label %30, label %28
28: ; preds = %25, %18
%29 = call i32 @copyMatriz(i32** %14, i32** %6)
br label %30
30: ; preds = %28, %21, %25
%31 = phi i32 [ 0, %25 ], [ 0, %21 ], [ 1, %28 ]
ret i32 %31
}