#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ ecrireSudoku(int /*<<< orphan*/, int **);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ lireSudoku(int /*<<< orphan*/ *, int **);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ solveSudoku(int **);
int /*<<< orphan*/ stdout;
scalar_t__ sudokuValide(int **);
int main(int argc, char *argv[]) {
  FILE *fich;
  int sudoku[9][9];
  if (argc != 2) {
    printf(" usage: %s nomFich.txt \n", argv[0]);
    exit(-1);
  }
  fich = fopen(argv[1], "r");
  if (!fich) {
    perror("Erreur d'ouverture du fichier\n");
    exit(1);
  }
  lireSudoku(fich, sudoku);
  printf(" sudoku lu: \n");
  ecrireSudoku(stdout, sudoku);
  if (sudokuValide(sudoku)) {
    printf("Et en plus il est valide !\n");
    solveSudoku(sudoku);
    printf("Résolution: \n");
    ecrireSudoku(stdout, sudoku);
    if (sudokuValide(sudoku)) {
      printf("La solution est valide !\n");
    }
  } else {
    printf("\nLe sudoku lu n'est pas valide, pas de résolution possible.\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x160,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11c2 <main+0x42>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe4f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0xffffffff,%edi
call   10a0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe48(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11fb <main+0x7b>
lea    0xe2f(%rip),%rdi
call   1090 <perror@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    -0x18(%rbp),%rdi
lea    -0x160(%rbp),%rsi
call   1050 <lireSudoku@plt>
lea    0xe28(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2dc0(%rip),%rax
mov    (%rax),%edi
lea    -0x160(%rbp),%rsi
call   1030 <ecrireSudoku@plt>
lea    -0x160(%rbp),%rdi
call   1060 <sudokuValide@plt>
cmp    $0x0,%rax
je     12aa <main+0x12a>
lea    0xdfd(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x160(%rbp),%rdi
call   1070 <solveSudoku@plt>
lea    0xdff(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2d6d(%rip),%rax
mov    (%rax),%edi
lea    -0x160(%rbp),%rsi
call   1030 <ecrireSudoku@plt>
lea    -0x160(%rbp),%rdi
call   1060 <sudokuValide@plt>
cmp    $0x0,%rax
je     12a5 <main+0x125>
lea    0xdd5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12b8 <main+0x138>
lea    0xddc(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x160,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x148,%rsp
cmp    $0x2,%edi
jne    1252 <main+0xc2>
mov    0x8(%rsi),%rdi
lea    0xe6b(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     126d <main+0xdd>
mov    %rsp,%rbx
mov    %rax,%rdi
mov    %rbx,%rsi
call   1060 <lireSudoku@plt>
lea    0xe69(%rip),%rdi
call   1040 <puts@plt>
mov    0x2e03(%rip),%r14
mov    (%r14),%edi
mov    %rbx,%rsi
call   1030 <ecrireSudoku@plt>
mov    %rbx,%rdi
call   1070 <sudokuValide@plt>
test   %rax,%rax
je     1239 <main+0xa9>
lea    0xe88(%rip),%rdi
call   1040 <puts@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1080 <solveSudoku@plt>
lea    0xe8c(%rip),%rdi
call   1040 <puts@plt>
mov    (%r14),%edi
mov    %rbx,%rsi
call   1030 <ecrireSudoku@plt>
mov    %rbx,%rdi
call   1070 <sudokuValide@plt>
test   %rax,%rax
je     1245 <main+0xb5>
lea    0xe76(%rip),%rdi
jmp    1240 <main+0xb0>
lea    0xe07(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x148,%rsp
pop    %rbx
pop    %r14
ret
mov    (%rsi),%rsi
lea    0xda4(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xffffffff,%edi
call   10b0 <exit@plt>
lea    0xda7(%rip),%rdi
call   10a0 <perror@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@.str = [25 x i8] c" usage: %s nomFich.txt \0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [31 x i8] c"Erreur d'ouverture du fichier\0A\00"
@.str.3 = [14 x i8] c" sudoku lu: \0A\00"
@stdout = global i32 0
@.str.4 = [28 x i8] c"Et en plus il est valide !\0A\00"
@.str.5 = [15 x i8] c"R\C3\A9solution: \0A\00"
@.str.6 = [26 x i8] c"La solution est valide !\0A\00"
@.str.7 = [62 x i8] c"\0ALe sudoku lu n'est pas valide, pas de r\C3\A9solution possible.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca [9 x [9 x i32]]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 2
br i1 %9, label %10, label %16
10: ; preds = %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 0
%13 = load i8*, i8** %12
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %13)
%15 = call i32 @exit(i32 -1)
unreachable
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call i32* @fopen(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %20, i32** %6
%21 = load i32*, i32** %6
%22 = icmp ne i32* %21, null
br i1 %22, label %26, label %23
23: ; preds = %16
%24 = call i32 @perror(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
%25 = call i32 @exit(i32 1)
unreachable
26: ; preds = %16
%27 = load i32*, i32** %6
%28 = getelementptr inbounds [9 x [9 x i32]], [9 x [9 x i32]]* %7, i64 0, i64 0
%29 = bitcast [9 x i32]* %28 to i32**
%30 = call i32 @lireSudoku(i32* %27, i32** %29)
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
%32 = load i32, i32* @stdout
%33 = getelementptr inbounds [9 x [9 x i32]], [9 x [9 x i32]]* %7, i64 0, i64 0
%34 = bitcast [9 x i32]* %33 to i32**
%35 = call i32 @ecrireSudoku(i32 %32, i32** %34)
%36 = getelementptr inbounds [9 x [9 x i32]], [9 x [9 x i32]]* %7, i64 0, i64 0
%37 = bitcast [9 x i32]* %36 to i32**
%38 = call i64 @sudokuValide(i32** %37)
%39 = icmp ne i64 %38, 0
br i1 %39, label %40, label %57
40: ; preds = %26
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0))
%42 = getelementptr inbounds [9 x [9 x i32]], [9 x [9 x i32]]* %7, i64 0, i64 0
%43 = bitcast [9 x i32]* %42 to i32**
%44 = call i32 @solveSudoku(i32** %43)
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
%46 = load i32, i32* @stdout
%47 = getelementptr inbounds [9 x [9 x i32]], [9 x [9 x i32]]* %7, i64 0, i64 0
%48 = bitcast [9 x i32]* %47 to i32**
%49 = call i32 @ecrireSudoku(i32 %46, i32** %48)
%50 = getelementptr inbounds [9 x [9 x i32]], [9 x [9 x i32]]* %7, i64 0, i64 0
%51 = bitcast [9 x i32]* %50 to i32**
%52 = call i64 @sudokuValide(i32** %51)
%53 = icmp ne i64 %52, 0
br i1 %53, label %54, label %56
54: ; preds = %40
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0))
br label %56
56: ; preds = %54, %40
br label %59
57: ; preds = %26
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.7, i64 0, i64 0))
br label %59
59: ; preds = %57, %56
ret i32 0
}

LLVM IR (-O2):
@.str = [25 x i8] c" usage: %s nomFich.txt \0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [31 x i8] c"Erreur d'ouverture du fichier\0A\00"
@stdout = global i32 0
@str = [13 x i8] c" sudoku lu: \00"
@str.8 = [61 x i8] c"\0ALe sudoku lu n'est pas valide, pas de r\C3\A9solution possible.\00"
@str.9 = [27 x i8] c"Et en plus il est valide !\00"
@str.10 = [14 x i8] c"R\C3\A9solution: \00"
@str.11 = [25 x i8] c"La solution est valide !\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [9 x [9 x i32]]
%4 = bitcast [9 x [9 x i32]]* %3 to i8*
%5 = icmp eq i32 %0, 2
br i1 %5, label %10, label %6
6: ; preds = %2
%7 = load i8*, i8** %1
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %7)
%9 = tail call i32 @exit(i32 -1)
unreachable
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = tail call i32* @fopen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %18
15: ; preds = %10
%16 = tail call i32 @perror(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
%17 = tail call i32 @exit(i32 1)
unreachable
18: ; preds = %10
%19 = bitcast [9 x [9 x i32]]* %3 to i32**
%20 = call i32 @lireSudoku(i32* %13, i32** %19)
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0))
%22 = load i32, i32* @stdout
%23 = call i32 @ecrireSudoku(i32 %22, i32** %19)
%24 = call i64 @sudokuValide(i32** %19)
%25 = icmp eq i64 %24, 0
br i1 %25, label %34, label %26
26: ; preds = %18
%27 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.9, i64 0, i64 0))
%28 = call i32 @solveSudoku(i32** %19)
%29 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.10, i64 0, i64 0))
%30 = load i32, i32* @stdout
%31 = call i32 @ecrireSudoku(i32 %30, i32** %19)
%32 = call i64 @sudokuValide(i32** %19)
%33 = icmp eq i64 %32, 0
br i1 %33, label %37, label %34
34: ; preds = %18, %26
%35 = phi i8* [ getelementptr inbounds ([25 x i8], [25 x i8]* @str.11, i64 0, i64 0), %26 ], [ getelementptr inbounds ([61 x i8], [61 x i8]* @str.8, i64 0, i64 0), %18 ]
%36 = call i32 @puts(i8* dereferenceable(1) %35)
br label %37
37: ; preds = %34, %26
ret i32 0
}