#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*/ SEEK_SET;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int ChooseWordInDic(char MotSecret[]) {
  FILE *Dico = NULL;
  int carac = 0, NbMots = 0, MotChoisi = 0, i = 0;
  Dico = fopen("Dictionnaire.txt", "r");
  if (Dico == NULL) {
    printf("\n\n\n\nErreur produite lors de l'ouverture du Dictionnaire.");
    exit(0);
  }
  do {
    carac = fgetc(Dico);
    if (carac == '\n') {
      NbMots++;
    }
  } while (carac != EOF);
  fseek(Dico, 0, SEEK_SET);
  srand(time(NULL));
  MotChoisi = (rand() % NbMots);
  i = 0;
  carac = 0;
  while (i < MotChoisi) {
    carac = fgetc(Dico);
    if (carac == '\n') {
      i++;
    }
  }
  i = 0;
  carac = 0;
  while (carac != '\n') {
    carac = fgetc(Dico);
    MotSecret[i] = carac;
    i++;
  }
  MotSecret[i - 1] = '\0';
  fclose(Dico);
}


x86 assembly (clang, -O0):
<ChooseWordInDic>:
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)
movl   $0x0,-0x28(%rbp)
lea    0xe39(%rip),%rdi
lea    0xe43(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11f5 <ChooseWordInDic+0x65>
lea    0xe2a(%rip),%rdi
call   1040 <printf@plt>
xor    %edi,%edi
call   10a0 <exit@plt>
jmp    11fa <ChooseWordInDic+0x6a>
mov    -0x18(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0xa,-0x1c(%rbp)
jne    1219 <ChooseWordInDic+0x89>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    121e <ChooseWordInDic+0x8e>
mov    -0x1c(%rbp),%eax
mov    0x2dc0(%rip),%rcx
cmp    (%rcx),%eax
jne    11fa <ChooseWordInDic+0x6a>
mov    -0x18(%rbp),%rdi
mov    0x2d9d(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1080 <fseek@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
mov    $0x0,%al
call   10b0 <rand@plt>
cltd
idivl  -0x20(%rbp)
mov    %edx,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    12a0 <ChooseWordInDic+0x110>
mov    -0x18(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0xa,-0x1c(%rbp)
jne    129b <ChooseWordInDic+0x10b>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1270 <ChooseWordInDic+0xe0>
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0xa,-0x1c(%rbp)
je     12e2 <ChooseWordInDic+0x152>
mov    -0x18(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %al,%dl
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    12ae <ChooseWordInDic+0x11e>
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ChooseWordInDic>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
lea    0xe5f(%rip),%rdi
lea    0xe69(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     126f <ChooseWordInDic+0xdf>
mov    %rax,%r15
xor    %ebp,%ebp
mov    0x2e26(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r15,%rdi
call   1050 <fgetc@plt>
xor    %ecx,%ecx
cmp    $0xa,%eax
sete   %cl
add    %ecx,%ebp
cmp    (%rbx),%eax
jne    11d0 <ChooseWordInDic+0x40>
mov    0x2deb(%rip),%rax
mov    (%rax),%edx
xor    %ebx,%ebx
mov    %r15,%rdi
xor    %esi,%esi
call   1080 <fseek@plt>
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
xor    %eax,%eax
call   10b0 <rand@plt>
cltd
idiv   %ebp
test   %edx,%edx
jle    1236 <ChooseWordInDic+0xa6>
mov    %edx,%ebp
nopl   0x0(%rax)
mov    %r15,%rdi
call   1050 <fgetc@plt>
xor    %ecx,%ecx
cmp    $0xa,%eax
sete   %cl
add    %ecx,%ebx
cmp    %ebp,%ebx
jl     1220 <ChooseWordInDic+0x90>
mov    $0xffffffffffffffff,%rbx
nopl   (%rax)
mov    %r15,%rdi
call   1050 <fgetc@plt>
mov    %al,0x1(%r14,%rbx,1)
add    $0x1,%rbx
cmp    $0xa,%eax
jne    1240 <ChooseWordInDic+0xb0>
mov    %ebx,%eax
movb   $0x0,(%r14,%rax,1)
mov    %r15,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fclose@plt>
lea    0xd9d(%rip),%rdi
call   1040 <printf@plt>
xor    %edi,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [17 x i8] c"Dictionnaire.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [57 x i8] c"\0A\0A\0A\0AErreur produite lors de l'ouverture du Dictionnaire.\00"
@EOF = global i32 0
@SEEK_SET = global i32 0
define i32 @ChooseWordInDic(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = 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
store i32 0, i32* %8
%9 = call i32* @fopen(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %9, i32** %4
%10 = load i32*, i32** %4
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %15
12: ; preds = %1
%13 = call i32 @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 @exit(i32 0)
unreachable
15: ; preds = %1
br label %16
16: ; preds = %25, %15
%17 = load i32*, i32** %4
%18 = call i32 @fgetc(i32* %17)
store i32 %18, i32* %5
%19 = load i32, i32* %5
%20 = icmp eq i32 %19, 10
br i1 %20, label %21, label %24
21: ; preds = %16
%22 = load i32, i32* %6
%23 = add nsw i32 %22, 1
store i32 %23, i32* %6
br label %24
24: ; preds = %21, %16
br label %25
25: ; preds = %24
%26 = load i32, i32* %5
%27 = load i32, i32* @EOF
%28 = icmp ne i32 %26, %27
br i1 %28, label %16, label %29
29: ; preds = %25
%30 = load i32*, i32** %4
%31 = load i32, i32* @SEEK_SET
%32 = call i32 @fseek(i32* %30, i32 0, i32 %31)
%33 = call i32 @time(i32* null)
%34 = call i32 @srand(i32 %33)
%35 = call i32 (...) @rand()
%36 = load i32, i32* %6
%37 = srem i32 %35, %36
store i32 %37, i32* %7
store i32 0, i32* %8
store i32 0, i32* %5
br label %38
38: ; preds = %50, %29
%39 = load i32, i32* %8
%40 = load i32, i32* %7
%41 = icmp slt i32 %39, %40
br i1 %41, label %42, label %51
42: ; preds = %38
%43 = load i32*, i32** %4
%44 = call i32 @fgetc(i32* %43)
store i32 %44, i32* %5
%45 = load i32, i32* %5
%46 = icmp eq i32 %45, 10
br i1 %46, label %47, label %50
47: ; preds = %42
%48 = load i32, i32* %8
%49 = add nsw i32 %48, 1
store i32 %49, i32* %8
br label %50
50: ; preds = %47, %42
br label %38
51: ; preds = %38
store i32 0, i32* %8
store i32 0, i32* %5
br label %52
52: ; preds = %55, %51
%53 = load i32, i32* %5
%54 = icmp ne i32 %53, 10
br i1 %54, label %55, label %66
55: ; preds = %52
%56 = load i32*, i32** %4
%57 = call i32 @fgetc(i32* %56)
store i32 %57, i32* %5
%58 = load i32, i32* %5
%59 = trunc i32 %58 to i8
%60 = load i8*, i8** %3
%61 = load i32, i32* %8
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds i8, i8* %60, i64 %62
store i8 %59, i8* %63
%64 = load i32, i32* %8
%65 = add nsw i32 %64, 1
store i32 %65, i32* %8
br label %52
66: ; preds = %52
%67 = load i8*, i8** %3
%68 = load i32, i32* %8
%69 = sub nsw i32 %68, 1
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds i8, i8* %67, i64 %70
store i8 0, i8* %71
%72 = load i32*, i32** %4
%73 = call i32 @fclose(i32* %72)
%74 = load i32, i32* %2
ret i32 %74
}

LLVM IR (-O2):
@.str = [17 x i8] c"Dictionnaire.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [57 x i8] c"\0A\0A\0A\0AErreur produite lors de l'ouverture du Dictionnaire.\00"
@EOF = global i32 0
@SEEK_SET = global i32 0
define i32 @ChooseWordInDic(i8* nocapture writeonly %0) {
%2 = tail call i32* @fopen(i8* getelementptr inbounds ([17 x i8], [17 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 %4, label %7
4: ; preds = %1
%5 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @.str.2, i64 0, i64 0))
%6 = tail call i32 @exit(i32 0)
unreachable
7: ; preds = %1, %7
%8 = phi i32 [ %12, %7 ], [ 0, %1 ]
%9 = tail call i32 @fgetc(i32* %2)
%10 = icmp eq i32 %9, 10
%11 = zext i1 %10 to i32
%12 = add nuw nsw i32 %8, %11
%13 = load i32, i32* @EOF
%14 = icmp eq i32 %9, %13
br i1 %14, label %15, label %7
15: ; preds = %7
%16 = load i32, i32* @SEEK_SET
%17 = tail call i32 @fseek(i32* %2, i32 0, i32 %16)
%18 = tail call i32 @time(i32* null)
%19 = tail call i32 @srand(i32 %18)
%20 = tail call i32 (...) @rand()
%21 = srem i32 %20, %12
%22 = icmp sgt i32 %21, 0
br i1 %22, label %23, label %30
23: ; preds = %15, %23
%24 = phi i32 [ %28, %23 ], [ 0, %15 ]
%25 = tail call i32 @fgetc(i32* %2)
%26 = icmp eq i32 %25, 10
%27 = zext i1 %26 to i32
%28 = add nuw nsw i32 %24, %27
%29 = icmp slt i32 %28, %21
br i1 %29, label %23, label %30
30: ; preds = %23, %15
br label %31
31: ; preds = %30, %31
%32 = phi i64 [ %36, %31 ], [ 0, %30 ]
%33 = tail call i32 @fgetc(i32* %2)
%34 = trunc i32 %33 to i8
%35 = getelementptr inbounds i8, i8* %0, i64 %32
store i8 %34, i8* %35
%36 = add nuw i64 %32, 1
%37 = icmp eq i32 %33, 10
br i1 %37, label %38, label %31
38: ; preds = %31
%39 = and i64 %32, 4294967295
%40 = getelementptr inbounds i8, i8* %0, i64 %39
store i8 0, i8* %40
%41 = tail call i32 @fclose(i32* %2)
ret i32 undef
}