#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ printf(char *);
void affiche_fichier(int **tab, int n, int m, char *nom) {
  int i, j;
  FILE *fichier = NULL;
  fichier = fopen("tableau.txt", "w");
  if (fichier != NULL) {
    for (i = 0; i < n; i++) {
      for (j = 0; j < m; j++) {
        if (tab[i][j] == 1) {
          fprintf(fichier, "o ");
        } else {
          fprintf(fichier, ". ");
        }
      }
      fprintf(fichier, "\n");
    }
  } else {
    printf("\n****** Erreur : impossible d'ouvrir le fichier ******");
  }
  fclose(fichier);
}


x86 assembly (clang, -O0):
<affiche_fichier>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
movq   $0x0,-0x28(%rbp)
lea    0xe9b(%rip),%rdi
lea    0xea0(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     121b <affiche_fichier+0xdb>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1216 <affiche_fichier+0xd6>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11f8 <affiche_fichier+0xb8>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x20(%rbp),%rcx
cmpl   $0x1,(%rax,%rcx,4)
jne    11d5 <affiche_fichier+0x95>
mov    -0x28(%rbp),%rdi
lea    0xe43(%rip),%rsi
call   1050 <fprintf@plt>
jmp    11e5 <affiche_fichier+0xa5>
mov    -0x28(%rbp),%rdi
lea    0xe31(%rip),%rsi
call   1050 <fprintf@plt>
jmp    11ea <affiche_fichier+0xaa>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    119a <affiche_fichier+0x5a>
mov    -0x28(%rbp),%rdi
lea    0xe11(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1187 <affiche_fichier+0x47>
jmp    1227 <affiche_fichier+0xe7>
lea    0xdf4(%rip),%rdi
call   1040 <printf@plt>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<affiche_fichier>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %edx,0xc(%rsp)
mov    %esi,%r15d
mov    %rdi,%r12
lea    0xe91(%rip),%rdi
lea    0xe96(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%r13
test   %rax,%rax
je     1212 <affiche_fichier+0xc2>
test   %r15d,%r15d
jle    121e <affiche_fichier+0xce>
mov    %r15d,%eax
mov    %rax,0x10(%rsp)
mov    0xc(%rsp),%ebx
xor    %ebp,%ebp
lea    0xe69(%rip),%r14
jmp    11c8 <affiche_fichier+0x78>
nopw   0x0(%rax,%rax,1)
mov    $0xa,%edi
mov    %r13,%rsi
call   1050 <fputc@plt>
add    $0x1,%rbp
cmp    0x10(%rsp),%rbp
je     121e <affiche_fichier+0xce>
cmpl   $0x0,0xc(%rsp)
jle    11b0 <affiche_fichier+0x60>
xor    %r15d,%r15d
jmp    11fb <affiche_fichier+0xab>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0x2,%esi
mov    $0x1,%edx
mov    %r13,%rcx
call   1070 <fwrite@plt>
add    $0x1,%r15
cmp    %r15,%rbx
je     11b0 <affiche_fichier+0x60>
mov    (%r12,%rbp,8),%rax
cmpl   $0x1,(%rax,%r15,4)
mov    %r14,%rdi
je     11e0 <affiche_fichier+0x90>
lea    0xe01(%rip),%rdi
jmp    11e0 <affiche_fichier+0x90>
lea    0xdfb(%rip),%rdi
call   1040 <printf@plt>
mov    %r13,%rdi
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fclose@plt>

LLVM IR (-O0):
@.str = [12 x i8] c"tableau.txt\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [3 x i8] c"o \00"
@.str.3 = [3 x i8] c". \00"
@.str.4 = [2 x i8] c"\0A\00"
@.str.5 = [55 x i8] c"\0A****** Erreur : impossible d'ouvrir le fichier ******\00"
define void @affiche_fichier(i32** %0, i32 %1, i32 %2, i8* %3) {
%5 = alloca i32**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32*
store i32** %0, i32*** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i8* %3, i8** %8
store i32* null, i32** %11
%12 = call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %12, i32** %11
%13 = load i32*, i32** %11
%14 = icmp ne i32* %13, null
br i1 %14, label %15, label %53
15: ; preds = %4
store i32 0, i32* %9
br label %16
16: ; preds = %49, %15
%17 = load i32, i32* %9
%18 = load i32, i32* %6
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %52
20: ; preds = %16
store i32 0, i32* %10
br label %21
21: ; preds = %43, %20
%22 = load i32, i32* %10
%23 = load i32, i32* %7
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %46
25: ; preds = %21
%26 = load i32**, i32*** %5
%27 = load i32, i32* %9
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i32*, i32** %26, i64 %28
%30 = load i32*, i32** %29
%31 = load i32, i32* %10
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i32, i32* %30, i64 %32
%34 = load i32, i32* %33
%35 = icmp eq i32 %34, 1
br i1 %35, label %36, label %39
36: ; preds = %25
%37 = load i32*, i32** %11
%38 = call i32 @fprintf(i32* %37, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %42
39: ; preds = %25
%40 = load i32*, i32** %11
%41 = call i32 @fprintf(i32* %40, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %42
42: ; preds = %39, %36
br label %43
43: ; preds = %42
%44 = load i32, i32* %10
%45 = add nsw i32 %44, 1
store i32 %45, i32* %10
br label %21
46: ; preds = %21
%47 = load i32*, i32** %11
%48 = call i32 @fprintf(i32* %47, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %49
49: ; preds = %46
%50 = load i32, i32* %9
%51 = add nsw i32 %50, 1
store i32 %51, i32* %9
br label %16
52: ; preds = %16
br label %55
53: ; preds = %4
%54 = call i32 @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.5, i64 0, i64 0))
br label %55
55: ; preds = %53, %52
%56 = load i32*, i32** %11
%57 = call i32 @fclose(i32* %56)
ret void
}

LLVM IR (-O2):
@.str = [12 x i8] c"tableau.txt\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [3 x i8] c"o \00"
@.str.3 = [3 x i8] c". \00"
@.str.5 = [55 x i8] c"\0A****** Erreur : impossible d'ouvrir le fichier ******\00"
define void @affiche_fichier(i32** nocapture %0, i32 %1, i32 %2, i8* nocapture readnone %3) {
%5 = tail call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %31, label %7
7: ; preds = %4
%8 = icmp sgt i32 %1, 0
br i1 %8, label %9, label %33
9: ; preds = %7
%10 = icmp sgt i32 %2, 0
%11 = zext i32 %1 to i64
%12 = zext i32 %2 to i64
br label %13
13: ; preds = %9, %27
%14 = phi i64 [ 0, %9 ], [ %29, %27 ]
br i1 %10, label %15, label %27
15: ; preds = %13
%16 = getelementptr inbounds i32*, i32** %0, i64 %14
br label %17
17: ; preds = %15, %17
%18 = phi i64 [ 0, %15 ], [ %25, %17 ]
%19 = load i32*, i32** %16
%20 = getelementptr inbounds i32, i32* %19, i64 %18
%21 = load i32, i32* %20
%22 = icmp eq i32 %21, 1
%23 = select i1 %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0)
%24 = tail call i64 @fwrite(i8* %23, i64 2, i64 1, i32* %5)
%25 = add nuw nsw i64 %18, 1
%26 = icmp eq i64 %25, %12
br i1 %26, label %27, label %17
27: ; preds = %17, %13
%28 = tail call i32 @fputc(i32 10, i32* %5)
%29 = add nuw nsw i64 %14, 1
%30 = icmp eq i64 %29, %11
br i1 %30, label %33, label %13
31: ; preds = %4
%32 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @.str.5, i64 0, i64 0))
br label %33
33: ; preds = %27, %7, %31
%34 = tail call i32 @fclose(i32* %5)
ret void
}