#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 EOF;
int errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
void afficheFichier(char *nomFichierTxt) {
  int caractere;
  FILE *fichier3 = NULL;
  fichier3 = fopen(nomFichierTxt, "r+");
  if (fichier3 != NULL) {
    caractere = fgetc(fichier3);
    while (caractere != EOF) {
      printf("%c", caractere);
      caractere = fgetc(fichier3);
    }
    fclose(fichier3);
  } else {
    printf("Impossible d'ouvrir ou de créer le fichier %s ", nomFichierTxt);
    printf("errno = %d.\n", errno);
    exit(1);
  }
}


x86 assembly (clang, -O0):
<afficheFichier>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe91(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11d1 <afficheFichier+0x81>
mov    -0x18(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    0x2e4f(%rip),%rcx
cmp    (%rcx),%eax
je     11c3 <afficheFichier+0x73>
mov    -0xc(%rbp),%esi
lea    0xe58(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %eax,-0xc(%rbp)
jmp    118f <afficheFichier+0x3f>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
jmp    1204 <afficheFichier+0xb4>
mov    -0x8(%rbp),%rsi
lea    0xe2a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2dee(%rip),%rax
mov    (%rax),%esi
lea    0xe43(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<afficheFichier>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
lea    0xe92(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     11b3 <afficheFichier+0x53>
mov    %rax,%rbx
mov    %rax,%rdi
call   1060 <fgetc@plt>
mov    0x2e5e(%rip),%r14
cmp    (%r14),%eax
je     11a4 <afficheFichier+0x44>
nop
mov    %eax,%edi
call   1030 <putchar@plt>
mov    %rbx,%rdi
call   1060 <fgetc@plt>
cmp    (%r14),%eax
jne    1190 <afficheFichier+0x30>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <fclose@plt>
lea    0xe49(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2e0d(%rip),%rax
mov    (%rax),%esi
lea    0xe5f(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"r+\00"
@EOF = global i32 0
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [48 x i8] c"Impossible d'ouvrir ou de cr\C3\A9er le fichier %s \00"
@.str.3 = [13 x i8] c"errno = %d.\0A\00"
@errno = global i32 0
define void @afficheFichier(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32*
store i8* %0, i8** %2
store i32* null, i32** %4
%5 = load i8*, i8** %2
%6 = call i32* @fopen(i8* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %6, i32** %4
%7 = load i32*, i32** %4
%8 = icmp ne i32* %7, null
br i1 %8, label %9, label %24
9: ; preds = %1
%10 = load i32*, i32** %4
%11 = call i32 @fgetc(i32* %10)
store i32 %11, i32* %3
br label %12
12: ; preds = %16, %9
%13 = load i32, i32* %3
%14 = load i32, i32* @EOF
%15 = icmp ne i32 %13, %14
br i1 %15, label %16, label %21
16: ; preds = %12
%17 = load i32, i32* %3
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %17)
%19 = load i32*, i32** %4
%20 = call i32 @fgetc(i32* %19)
store i32 %20, i32* %3
br label %12
21: ; preds = %12
%22 = load i32*, i32** %4
%23 = call i32 @fclose(i32* %22)
br label %30
24: ; preds = %1
%25 = load i8*, i8** %2
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0), i8* %25)
%27 = load i32, i32* @errno
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 %27)
%29 = call i32 @exit(i32 1)
unreachable
30: ; preds = %21
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"r+\00"
@EOF = global i32 0
@.str.2 = [48 x i8] c"Impossible d'ouvrir ou de cr\C3\A9er le fichier %s \00"
@.str.3 = [13 x i8] c"errno = %d.\0A\00"
@errno = global i32 0
define void @afficheFichier(i8* %0) {
%2 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i32* %2, null
br i1 %3, label %16, label %4
4: ; preds = %1
%5 = tail call i32 @fgetc(i32* %2)
%6 = load i32, i32* @EOF
%7 = icmp eq i32 %5, %6
br i1 %7, label %14, label %8
8: ; preds = %4, %8
%9 = phi i32 [ %11, %8 ], [ %5, %4 ]
%10 = tail call i32 @putchar(i32 %9)
%11 = tail call i32 @fgetc(i32* %2)
%12 = load i32, i32* @EOF
%13 = icmp eq i32 %11, %12
br i1 %13, label %14, label %8
14: ; preds = %8, %4
%15 = tail call i32 @fclose(i32* %2)
ret void
16: ; preds = %1
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0), i8* %0)
%18 = load i32, i32* @errno
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 %18)
%20 = tail call i32 @exit(i32 1)
unreachable
}