#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 /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int nombreAleatoire(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
int strlen(char *);
int piocherMot(char *motPioche) {
  FILE *dico = NULL;
  int nombreMots = 0, numMotChoisi = 0;
  int caractereLu = 0;
  dico = fopen("Dico.txt", "r");
  if (dico == NULL) {
    printf("\nImpossible de charger le dictionnaire de mots");
    return 0;
  }
  do {
    caractereLu = fgetc(dico);
    if (caractereLu == '\n')
      nombreMots++;
  } while (caractereLu != EOF);
  numMotChoisi = nombreAleatoire(nombreMots);
  rewind(dico);
  while (numMotChoisi > 0) {
    caractereLu = fgetc(dico);
    if (caractereLu == '\n')
      numMotChoisi--;
  }
  fgets(motPioche, 100, dico);
  motPioche[strlen(motPioche) - 1] = '\0';
  fclose(dico);
  if (strlen(motPioche) < 4 || strlen(motPioche) > 8)
    piocherMot(motPioche);
  return 1;
}


x86 assembly (clang, -O0):
<piocherMot>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
lea    0xe40(%rip),%rdi
lea    0xe42(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11f3 <piocherMot+0x63>
lea    0xe29(%rip),%rdi
call   1060 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    12e0 <piocherMot+0x150>
jmp    11f8 <piocherMot+0x68>
mov    -0x18(%rbp),%rdi
call   1080 <fgetc@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0xa,-0x24(%rbp)
jne    1217 <piocherMot+0x87>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    121c <piocherMot+0x8c>
mov    -0x24(%rbp),%eax
mov    0x2dc2(%rip),%rcx
cmp    (%rcx),%eax
jne    11f8 <piocherMot+0x68>
mov    -0x1c(%rbp),%edi
call   1030 <nombreAleatoire@plt>
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1070 <rewind@plt>
cmpl   $0x0,-0x20(%rbp)
jle    1270 <piocherMot+0xe0>
mov    -0x18(%rbp),%rdi
call   1080 <fgetc@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0xa,-0x24(%rbp)
jne    126b <piocherMot+0xdb>
mov    -0x20(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x20(%rbp)
jmp    1242 <piocherMot+0xb2>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x64,%esi
call   1090 <fgets@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
cmp    $0x4,%eax
jl     12d0 <piocherMot+0x140>
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
cmp    $0x8,%eax
jle    12d9 <piocherMot+0x149>
mov    -0x10(%rbp),%rdi
call   10a0 <piocherMot@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<piocherMot>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r13
lea    0xe6b(%rip),%rdi
lea    0xe6d(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,(%rsp)
test   %rax,%rax
je     1285 <piocherMot+0x105>
xor    %r14d,%r14d
mov    0x2e30(%rip),%r15
lea    0xe4a(%rip),%r12
mov    (%rsp),%rbx
jmp    11ee <piocherMot+0x6e>
cs nopw 0x0(%rax,%rax,1)
nop
lea    0xe29(%rip),%rdi
mov    %r12,%rsi
call   10a0 <fopen@plt>
mov    %rax,%rbx
mov    $0x1,%r14b
test   %rax,%rax
je     1285 <piocherMot+0x105>
xor    %ebp,%ebp
mov    %rbx,%rdi
call   1080 <fgetc@plt>
xor    %ecx,%ecx
cmp    $0xa,%eax
sete   %cl
add    %ecx,%ebp
cmp    (%r15),%eax
jne    11f0 <piocherMot+0x70>
mov    %ebp,%edi
call   1030 <nombreAleatoire@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1070 <rewind@plt>
test   %ebp,%ebp
jle    1234 <piocherMot+0xb4>
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1080 <fgetc@plt>
xor    %ecx,%ecx
cmp    $0xa,%eax
sete   %cl
sub    %ecx,%ebp
jne    1220 <piocherMot+0xa0>
mov    %r13,%rdi
mov    $0x64,%esi
mov    %rbx,%rdx
call   1090 <fgets@plt>
mov    %r13,%rdi
call   1050 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%r13,1)
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    %r13,%rdi
call   1050 <strlen@plt>
cmp    $0x4,%eax
jl     11d0 <piocherMot+0x50>
mov    %r13,%rdi
call   1050 <strlen@plt>
cmp    $0x9,%eax
jge    11d0 <piocherMot+0x50>
mov    $0x1,%ecx
jmp    129c <piocherMot+0x11c>
cmpq   $0x0,(%rsp)
setne  %r14b
lea    0xd76(%rip),%rdi
call   1060 <printf@plt>
xor    %ecx,%ecx
test   $0x1,%r14b
mov    $0x1,%eax
cmove  %ecx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"Dico.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [47 x i8] c"\0AImpossible de charger le dictionnaire de mots\00"
@EOF = global i32 0
define i32 @piocherMot(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %3
store i32* null, i32** %4
store i32 0, i32* %5
store i32 0, i32* %6
store i32 0, i32* %7
%8 = call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %8, i32** %4
%9 = load i32*, i32** %4
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %13
11: ; preds = %1
%12 = call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %2
br label %67
13: ; preds = %1
br label %14
14: ; preds = %23, %13
%15 = load i32*, i32** %4
%16 = call i32 @fgetc(i32* %15)
store i32 %16, i32* %7
%17 = load i32, i32* %7
%18 = icmp eq i32 %17, 10
br i1 %18, label %19, label %22
19: ; preds = %14
%20 = load i32, i32* %5
%21 = add nsw i32 %20, 1
store i32 %21, i32* %5
br label %22
22: ; preds = %19, %14
br label %23
23: ; preds = %22
%24 = load i32, i32* %7
%25 = load i32, i32* @EOF
%26 = icmp ne i32 %24, %25
br i1 %26, label %14, label %27
27: ; preds = %23
%28 = load i32, i32* %5
%29 = call i32 @nombreAleatoire(i32 %28)
store i32 %29, i32* %6
%30 = load i32*, i32** %4
%31 = call i32 @rewind(i32* %30)
br label %32
32: ; preds = %43, %27
%33 = load i32, i32* %6
%34 = icmp sgt i32 %33, 0
br i1 %34, label %35, label %44
35: ; preds = %32
%36 = load i32*, i32** %4
%37 = call i32 @fgetc(i32* %36)
store i32 %37, i32* %7
%38 = load i32, i32* %7
%39 = icmp eq i32 %38, 10
br i1 %39, label %40, label %43
40: ; preds = %35
%41 = load i32, i32* %6
%42 = add nsw i32 %41, -1
store i32 %42, i32* %6
br label %43
43: ; preds = %40, %35
br label %32
44: ; preds = %32
%45 = load i8*, i8** %3
%46 = load i32*, i32** %4
%47 = call i32 @fgets(i8* %45, i32 100, i32* %46)
%48 = load i8*, i8** %3
%49 = load i8*, i8** %3
%50 = call i32 @strlen(i8* %49)
%51 = sub nsw i32 %50, 1
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds i8, i8* %48, i64 %52
store i8 0, i8* %53
%54 = load i32*, i32** %4
%55 = call i32 @fclose(i32* %54)
%56 = load i8*, i8** %3
%57 = call i32 @strlen(i8* %56)
%58 = icmp slt i32 %57, 4
br i1 %58, label %63, label %59
59: ; preds = %44
%60 = load i8*, i8** %3
%61 = call i32 @strlen(i8* %60)
%62 = icmp sgt i32 %61, 8
br i1 %62, label %63, label %66
63: ; preds = %59, %44
%64 = load i8*, i8** %3
%65 = call i32 @piocherMot(i8* %64)
br label %66
66: ; preds = %63, %59
store i32 1, i32* %2
br label %67
67: ; preds = %66, %11
%68 = load i32, i32* %2
ret i32 %68
}

LLVM IR (-O2):
@.str = [9 x i8] c"Dico.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [47 x i8] c"\0AImpossible de charger le dictionnaire de mots\00"
@EOF = global i32 0
define i32 @piocherMot(i8* %0) {
%2 = tail call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%3 = icmp eq i32* %2, null
br i1 %3, label %7, label %4
4: ; preds = %1, %41
%5 = phi i32* [ %42, %41 ], [ %2, %1 ]
%6 = phi i1 [ true, %41 ], [ false, %1 ]
br label %10
7: ; preds = %41, %1
%8 = xor i1 %3, true
%9 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str.2, i64 0, i64 0))
br label %44
10: ; preds = %4, %10
%11 = phi i32 [ %15, %10 ], [ 0, %4 ]
%12 = tail call i32 @fgetc(i32* %5)
%13 = icmp eq i32 %12, 10
%14 = zext i1 %13 to i32
%15 = add nuw nsw i32 %11, %14
%16 = load i32, i32* @EOF
%17 = icmp eq i32 %12, %16
br i1 %17, label %18, label %10
18: ; preds = %10
%19 = tail call i32 @nombreAleatoire(i32 %15)
%20 = tail call i32 @rewind(i32* %5)
%21 = icmp sgt i32 %19, 0
br i1 %21, label %22, label %29
22: ; preds = %18, %22
%23 = phi i32 [ %27, %22 ], [ %19, %18 ]
%24 = tail call i32 @fgetc(i32* %5)
%25 = icmp eq i32 %24, 10
%26 = sext i1 %25 to i32
%27 = add nsw i32 %23, %26
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %22
29: ; preds = %22, %18
%30 = tail call i32 @fgets(i8* %0, i32 100, i32* %5)
%31 = tail call i32 @strlen(i8* %0)
%32 = add nsw i32 %31, -1
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8, i8* %0, i64 %33
store i8 0, i8* %34
%35 = tail call i32 @fclose(i32* %5)
%36 = tail call i32 @strlen(i8* %0)
%37 = icmp slt i32 %36, 4
br i1 %37, label %41, label %38
38: ; preds = %29
%39 = tail call i32 @strlen(i8* %0)
%40 = icmp sgt i32 %39, 8
br i1 %40, label %41, label %44
41: ; preds = %38, %29
%42 = tail call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%43 = icmp eq i32* %42, null
br i1 %43, label %7, label %4
44: ; preds = %38, %7
%45 = phi i1 [ %8, %7 ], [ %6, %38 ]
%46 = phi i32 [ 0, %7 ], [ 1, %38 ]
%47 = select i1 %45, i32 1, i32 %46
ret i32 %47
}