#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 calcularCntPistas(int);
int /*<<< orphan*/ copyMatriz(int **, int **);
int /*<<< orphan*/ decodePosicionAborrar(int *, int, int);
int /*<<< orphan*/ printSudokuSolaLinea(int **);
int /*<<< orphan*/ shuffle(int *, int);
scalar_t__ solucionUnica(int, int, int **);
void agujerearSudoku(int dificultad, int sudokuSolucion[9][9],
                     int sudokuAresolver[9][9]) {
  copyMatriz(sudokuSolucion, sudokuAresolver);
  int listaBorrar[81];
  int i;
  for (i = 0; i < 81; i++) {
    listaBorrar[i] = i;
  }
  int *pListaBorrar = listaBorrar;
  shuffle(pListaBorrar, 81);
  int posicionAborrar,
      coordenadasPosicionAborrar[2] = {0, 0},
      *pCoordenadasPosicionAborrar = coordenadasPosicionAborrar;
  int pistas = 81 - calcularCntPistas(dificultad);
  for (i = 0; i < 81; i++) {
    if (pistas == 0) {
      break;
    }
    posicionAborrar = listaBorrar[i];
    decodePosicionAborrar(pCoordenadasPosicionAborrar, 81, posicionAborrar);
    if (solucionUnica(coordenadasPosicionAborrar[0],
                      coordenadasPosicionAborrar[1], sudokuAresolver)) {
      sudokuAresolver[coordenadasPosicionAborrar[0]]
                     [coordenadasPosicionAborrar[1]] = 0;
      pistas--;
    }
  }
  printSudokuSolaLinea(sudokuAresolver);
}


x86 assembly (clang, -O0):
<agujerearSudoku>:
push   %rbp
mov    %rsp,%rbp
sub    $0x190,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1090 <copyMatriz@plt>
movl   $0x0,-0x164(%rbp)
cmpl   $0x51,-0x164(%rbp)
jge    11d2 <agujerearSudoku+0x62>
mov    -0x164(%rbp),%ecx
movslq -0x164(%rbp),%rax
mov    %ecx,-0x160(%rbp,%rax,4)
mov    -0x164(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x164(%rbp)
jmp    119d <agujerearSudoku+0x2d>
lea    -0x160(%rbp),%rax
mov    %rax,-0x170(%rbp)
mov    -0x170(%rbp),%rdi
mov    $0x51,%esi
call   1030 <shuffle@plt>
lea    -0x17c(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1050 <memset@plt>
lea    -0x17c(%rbp),%rax
mov    %rax,-0x188(%rbp)
mov    -0x4(%rbp),%edi
call   1080 <calcularCntPistas@plt>
mov    %eax,%ecx
mov    $0x51,%eax
sub    %ecx,%eax
mov    %eax,-0x18c(%rbp)
movl   $0x0,-0x164(%rbp)
cmpl   $0x51,-0x164(%rbp)
jge    12e4 <agujerearSudoku+0x174>
cmpl   $0x0,-0x18c(%rbp)
jne    1252 <agujerearSudoku+0xe2>
jmp    12e4 <agujerearSudoku+0x174>
movslq -0x164(%rbp),%rax
mov    -0x160(%rbp,%rax,4),%eax
mov    %eax,-0x174(%rbp)
mov    -0x188(%rbp),%rdi
mov    -0x174(%rbp),%edx
mov    $0x51,%esi
call   1040 <decodePosicionAborrar@plt>
mov    -0x17c(%rbp),%edi
mov    -0x178(%rbp),%esi
mov    -0x18(%rbp),%rdx
call   1070 <solucionUnica@plt>
cmp    $0x0,%rax
je     12cb <agujerearSudoku+0x15b>
mov    -0x18(%rbp),%rax
movslq -0x17c(%rbp),%rcx
imul   $0x24,%rcx,%rcx
add    %rcx,%rax
movslq -0x178(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0x18c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x18c(%rbp)
jmp    12d0 <agujerearSudoku+0x160>
mov    -0x164(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x164(%rbp)
jmp    1233 <agujerearSudoku+0xc3>
mov    -0x18(%rbp),%rdi
call   1060 <printSudokuSolaLinea@plt>
add    $0x190,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<agujerearSudoku>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x158,%rsp
mov    %rdx,%r15
mov    %edi,%r14d
mov    %rsi,%rdi
mov    %rdx,%rsi
call   1080 <copyMatriz@plt>
movaps 0xe7b(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xe7f(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xe83(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xe87(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xe8b(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0xe8f(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
movaps 0xe93(%rip),%xmm0
movaps %xmm0,0x70(%rsp)
movaps 0xe97(%rip),%xmm0
movaps %xmm0,0x80(%rsp)
movaps 0xe98(%rip),%xmm0
movaps %xmm0,0x90(%rsp)
movaps 0xe99(%rip),%xmm0
movaps %xmm0,0xa0(%rsp)
movaps 0xe9a(%rip),%xmm0
movaps %xmm0,0xb0(%rsp)
movaps 0xe9b(%rip),%xmm0
movaps %xmm0,0xc0(%rsp)
movaps 0xe9c(%rip),%xmm0
movaps %xmm0,0xd0(%rsp)
movaps 0xe9d(%rip),%xmm0
movaps %xmm0,0xe0(%rsp)
movaps 0xe9e(%rip),%xmm0
movaps %xmm0,0xf0(%rsp)
movaps 0xe9f(%rip),%xmm0
movaps %xmm0,0x100(%rsp)
movaps 0xea0(%rip),%xmm0
movaps %xmm0,0x110(%rsp)
movaps 0xea1(%rip),%xmm0
movaps %xmm0,0x120(%rsp)
movaps 0xea2(%rip),%xmm0
movaps %xmm0,0x130(%rsp)
movaps 0xea3(%rip),%xmm0
movaps %xmm0,0x140(%rsp)
movl   $0x50,0x150(%rsp)
lea    0x10(%rsp),%rdi
mov    $0x51,%ebp
mov    $0x51,%esi
call   1030 <shuffle@plt>
movq   $0x0,0x8(%rsp)
mov    %r14d,%edi
call   1070 <calcularCntPistas@plt>
cmp    $0x51,%eax
je     1330 <agujerearSudoku+0x1d0>
sub    %eax,%ebp
xor    %ebx,%ebx
lea    0x8(%rsp),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x10(%rsp,%rbx,4),%edx
mov    %r14,%rdi
mov    $0x51,%esi
call   1040 <decodePosicionAborrar@plt>
mov    0x8(%rsp),%edi
mov    0xc(%rsp),%esi
mov    %r15,%rdx
call   1060 <solucionUnica@plt>
test   %rax,%rax
je     1322 <agujerearSudoku+0x1c2>
movslq 0x8(%rsp),%rax
movslq 0xc(%rsp),%rcx
lea    (%rax,%rax,8),%rax
lea    (%r15,%rax,4),%rax
movl   $0x0,(%rax,%rcx,4)
add    $0xffffffff,%ebp
cmp    $0x4f,%rbx
ja     1330 <agujerearSudoku+0x1d0>
add    $0x1,%rbx
test   %ebp,%ebp
jne    12e0 <agujerearSudoku+0x180>
mov    %r15,%rdi
call   1050 <printSudokuSolaLinea@plt>
add    $0x158,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @agujerearSudoku(i32 %0, [9 x i32]* %1, [9 x i32]* %2) {
%4 = alloca i32
%5 = alloca [9 x i32]*
%6 = alloca [9 x i32]*
%7 = alloca [81 x i32]
%8 = alloca i32
%9 = alloca i32*
%10 = alloca i32
%11 = alloca [2 x i32]
%12 = alloca i32*
%13 = alloca i32
store i32 %0, i32* %4
store [9 x i32]* %1, [9 x i32]** %5
store [9 x i32]* %2, [9 x i32]** %6
%14 = load [9 x i32]*, [9 x i32]** %5
%15 = bitcast [9 x i32]* %14 to i32**
%16 = load [9 x i32]*, [9 x i32]** %6
%17 = bitcast [9 x i32]* %16 to i32**
%18 = call i32 @copyMatriz(i32** %15, i32** %17)
store i32 0, i32* %8
br label %19
19: ; preds = %27, %3
%20 = load i32, i32* %8
%21 = icmp slt i32 %20, 81
br i1 %21, label %22, label %30
22: ; preds = %19
%23 = load i32, i32* %8
%24 = load i32, i32* %8
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [81 x i32], [81 x i32]* %7, i64 0, i64 %25
store i32 %23, i32* %26
br label %27
27: ; preds = %22
%28 = load i32, i32* %8
%29 = add nsw i32 %28, 1
store i32 %29, i32* %8
br label %19
30: ; preds = %19
%31 = getelementptr inbounds [81 x i32], [81 x i32]* %7, i64 0, i64 0
store i32* %31, i32** %9
%32 = load i32*, i32** %9
%33 = call i32 @shuffle(i32* %32, i32 81)
%34 = bitcast [2 x i32]* %11 to i8*
%35 = getelementptr inbounds [2 x i32], [2 x i32]* %11, i64 0, i64 0
store i32* %35, i32** %12
%36 = load i32, i32* %4
%37 = call i32 @calcularCntPistas(i32 %36)
%38 = sub nsw i32 81, %37
store i32 %38, i32* %13
store i32 0, i32* %8
br label %39
39: ; preds = %75, %30
%40 = load i32, i32* %8
%41 = icmp slt i32 %40, 81
br i1 %41, label %42, label %78
42: ; preds = %39
%43 = load i32, i32* %13
%44 = icmp eq i32 %43, 0
br i1 %44, label %45, label %46
45: ; preds = %42
br label %78
46: ; preds = %42
%47 = load i32, i32* %8
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [81 x i32], [81 x i32]* %7, i64 0, i64 %48
%50 = load i32, i32* %49
store i32 %50, i32* %10
%51 = load i32*, i32** %12
%52 = load i32, i32* %10
%53 = call i32 @decodePosicionAborrar(i32* %51, i32 81, i32 %52)
%54 = getelementptr inbounds [2 x i32], [2 x i32]* %11, i64 0, i64 0
%55 = load i32, i32* %54
%56 = getelementptr inbounds [2 x i32], [2 x i32]* %11, i64 0, i64 1
%57 = load i32, i32* %56
%58 = load [9 x i32]*, [9 x i32]** %6
%59 = bitcast [9 x i32]* %58 to i32**
%60 = call i64 @solucionUnica(i32 %55, i32 %57, i32** %59)
%61 = icmp ne i64 %60, 0
br i1 %61, label %62, label %74
62: ; preds = %46
%63 = load [9 x i32]*, [9 x i32]** %6
%64 = getelementptr inbounds [2 x i32], [2 x i32]* %11, i64 0, i64 0
%65 = load i32, i32* %64
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds [9 x i32], [9 x i32]* %63, i64 %66
%68 = getelementptr inbounds [2 x i32], [2 x i32]* %11, i64 0, i64 1
%69 = load i32, i32* %68
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds [9 x i32], [9 x i32]* %67, i64 0, i64 %70
store i32 0, i32* %71
%72 = load i32, i32* %13
%73 = add nsw i32 %72, -1
store i32 %73, i32* %13
br label %74
74: ; preds = %62, %46
br label %75
75: ; preds = %74
%76 = load i32, i32* %8
%77 = add nsw i32 %76, 1
store i32 %77, i32* %8
br label %39
78: ; preds = %45, %39
%79 = load [9 x i32]*, [9 x i32]** %6
%80 = bitcast [9 x i32]* %79 to i32**
%81 = call i32 @printSudokuSolaLinea(i32** %80)
ret void
}

LLVM IR (-O2):
define void @agujerearSudoku(i32 %0, [9 x i32]* %1, [9 x i32]* %2) {
%4 = alloca [81 x i32]
%5 = alloca i64
%6 = bitcast [9 x i32]* %1 to i32**
%7 = bitcast [9 x i32]* %2 to i32**
%8 = tail call i32 @copyMatriz(i32** %6, i32** %7)
%9 = bitcast [81 x i32]* %4 to i8*
%10 = bitcast [81 x i32]* %4 to <4 x i32>*
store <4 x i32> <i32 0, i32 1, i32 2, i32 3>, <4 x i32>* %10
%11 = getelementptr inbounds [81 x i32], [81 x i32]* %4, i64 0, i64 4
%12 = bitcast i32* %11 to <4 x i32>*
store <4 x i32> <i32 4, i32 5, i32 6, i32 7>, <4 x i32>* %12
%13 = getelementptr inbounds [81 x i32], [81 x i32]* %4, i64 0, i64 8
%14 = bitcast i32* %13 to <4 x i32>*
store <4 x i32> <i32 8, i32 9, i32 10, i32 11>, <4 x i32>* %14
%15 = getelementptr inbounds [81 x i32], [81 x i32]* %4, i64 0, i64 12
%16 = bitcast i32* %15 to <4 x i32>*
store <4 x i32> <i32 12, i32 13, i32 14, i32 15>, <4 x i32>* %16
%17 = getelementptr inbounds [81 x i32], [81 x i32]* %4, i64 0, i64 16
%18 = bitcast i32* %17 to <4 x i32>*
store <4 x i32> <i32 16, i32 17, i32 18, i32 19>, <4 x i32>* %18
%19 = getelementptr inbounds [81 x i32], [81 x i32]* %4, i64 0, i64 20
%20 = bitcast i32* %19 to <4 x i32>*
store <4 x i32> <i32 20, i32 21, i32 22, i32 23>, <4 x i32>* %20
%21 = getelementptr inbounds [81 x i32], [81 x i32]* %4, i64 0, i64 24
%22 = bitcast i32* %21 to <4 x i32>*
store <4 x i32> <i32 24, i32 25, i32 26, i32 27>, <4 x i32>* %22
%23 = getelementptr inbounds [81 x i32], [81 x i32]* %4, i64 0, i64 28
%24 = bitcast i32* %23 to <4 x i32>*
store <4 x i32> <i32 28, i32 29, i32 30, i32 31>, <4 x i32>* %24
%25 = getelementptr inbounds [81 x i32], [81 x i32]* %4, i64 0, i64 32
%26 = bitcast i32* %25 to <4 x i32>*
store <4 x i32> <i32 32, i32 33, i32 34, i32 35>, <4 x i32>* %26
%27 = getelementptr inbounds [81 x i32], [81 x i32]* %4, i64 0, i64 36
%28 = bitcast i32* %27 to <4 x i32>*
store <4 x i32> <i32 36, i32 37, i32 38, i32 39>, <4 x i32>* %28
%29 = getelementptr inbounds [81 x i32], [81 x i32]* %4, i64 0, i64 40
%30 = bitcast i32* %29 to <4 x i32>*
store <4 x i32> <i32 40, i32 41, i32 42, i32 43>, <4 x i32>* %30
%31 = getelementptr inbounds [81 x i32], [81 x i32]* %4, i64 0, i64 44
%32 = bitcast i32* %31 to <4 x i32>*
store <4 x i32> <i32 44, i32 45, i32 46, i32 47>, <4 x i32>* %32
%33 = getelementptr inbounds [81 x i32], [81 x i32]* %4, i64 0, i64 48
%34 = bitcast i32* %33 to <4 x i32>*
store <4 x i32> <i32 48, i32 49, i32 50, i32 51>, <4 x i32>* %34
%35 = getelementptr inbounds [81 x i32], [81 x i32]* %4, i64 0, i64 52
%36 = bitcast i32* %35 to <4 x i32>*
store <4 x i32> <i32 52, i32 53, i32 54, i32 55>, <4 x i32>* %36
%37 = getelementptr inbounds [81 x i32], [81 x i32]* %4, i64 0, i64 56
%38 = bitcast i32* %37 to <4 x i32>*
store <4 x i32> <i32 56, i32 57, i32 58, i32 59>, <4 x i32>* %38
%39 = getelementptr inbounds [81 x i32], [81 x i32]* %4, i64 0, i64 60
%40 = bitcast i32* %39 to <4 x i32>*
store <4 x i32> <i32 60, i32 61, i32 62, i32 63>, <4 x i32>* %40
%41 = getelementptr inbounds [81 x i32], [81 x i32]* %4, i64 0, i64 64
%42 = bitcast i32* %41 to <4 x i32>*
store <4 x i32> <i32 64, i32 65, i32 66, i32 67>, <4 x i32>* %42
%43 = getelementptr inbounds [81 x i32], [81 x i32]* %4, i64 0, i64 68
%44 = bitcast i32* %43 to <4 x i32>*
store <4 x i32> <i32 68, i32 69, i32 70, i32 71>, <4 x i32>* %44
%45 = getelementptr inbounds [81 x i32], [81 x i32]* %4, i64 0, i64 72
%46 = bitcast i32* %45 to <4 x i32>*
store <4 x i32> <i32 72, i32 73, i32 74, i32 75>, <4 x i32>* %46
%47 = getelementptr inbounds [81 x i32], [81 x i32]* %4, i64 0, i64 76
%48 = bitcast i32* %47 to <4 x i32>*
store <4 x i32> <i32 76, i32 77, i32 78, i32 79>, <4 x i32>* %48
%49 = getelementptr inbounds [81 x i32], [81 x i32]* %4, i64 0, i64 80
store i32 80, i32* %49
%50 = getelementptr inbounds [81 x i32], [81 x i32]* %4, i64 0, i64 0
%51 = call i32 @shuffle(i32* %50, i32 81)
%52 = bitcast i64* %5 to i8*
store i64 0, i64* %5
%53 = bitcast i64* %5 to i32*
%54 = call i32 @calcularCntPistas(i32 %0)
%55 = icmp eq i32 %54, 81
br i1 %55, label %83, label %56
56: ; preds = %3
%57 = bitcast i64* %5 to [2 x i32]*
%58 = sub nsw i32 81, %54
%59 = getelementptr inbounds [2 x i32], [2 x i32]* %57, i64 0, i64 1
br label %60
60: ; preds = %56, %77
%61 = phi i64 [ 0, %56 ], [ %79, %77 ]
%62 = phi i32 [ %58, %56 ], [ %78, %77 ]
%63 = getelementptr inbounds [81 x i32], [81 x i32]* %4, i64 0, i64 %61
%64 = load i32, i32* %63
%65 = call i32 @decodePosicionAborrar(i32* %53, i32 81, i32 %64)
%66 = load i32, i32* %53
%67 = load i32, i32* %59
%68 = call i64 @solucionUnica(i32 %66, i32 %67, i32** %7)
%69 = icmp eq i64 %68, 0
br i1 %69, label %77, label %70
70: ; preds = %60
%71 = load i32, i32* %53
%72 = sext i32 %71 to i64
%73 = load i32, i32* %59
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds [9 x i32], [9 x i32]* %2, i64 %72, i64 %74
store i32 0, i32* %75
%76 = add nsw i32 %62, -1
br label %77
77: ; preds = %60, %70
%78 = phi i32 [ %76, %70 ], [ %62, %60 ]
%79 = add nuw nsw i64 %61, 1
%80 = icmp ugt i64 %61, 79
%81 = icmp eq i32 %78, 0
%82 = select i1 %80, i1 true, i1 %81
br i1 %82, label %83, label %60
83: ; preds = %77, %3
%84 = call i32 @printSudokuSolaLinea(i32** %7)
ret void
}