#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 */

/* Variables and functions */
int /*<<< orphan*/ getchar();
int menu_annexe();
int menu_cryptage();
int menu_decryptage();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf_s(char *, unsigned int *);
int /*<<< orphan*/ system(char *);
int main(void) {
  int retour_menu = 0;
  int watchdog = 0;
  unsigned int choix = 0;
  while (watchdog != 1) {
    system("cls");
    while (choix < 1 || choix > 4) {
      printf("===== Projet C FISA 1 : Cryptage / Decryptage =====\n");
      printf("1 - Cryptage\n");
      printf("2 - Decryptage\n");
      printf("3 - Annexe / aide\n");
      printf("4 - Quitter le programme\n\n");
      scanf_s("%d", &choix);
      getchar();
      if (choix < 1 || choix > 4) {
        system("cls");
        printf("Erreur : vous n'avez pas entre un choix correct\n\n");
        choix = 0;
      }
    }
    switch (choix) {
    case 1:
      system("cls");
      retour_menu = menu_cryptage();
      if (retour_menu != 0) {
        printf("Erreur dans l'execution du programme\n");
      }
      choix = 0;
      break;
    case 2:
      system("cls");
      retour_menu = menu_decryptage();
      if (retour_menu != 0) {
        printf("Erreur dans l'execution du programme\n");
      }
      choix = 0;
      break;
    case 3:
      system("cls");
      retour_menu = menu_annexe();
      if (retour_menu != 0) {
        printf("Erreur dans l'execution du programme\n");
      }
      choix = 0;
      break;
    case 4:
      watchdog = 1;
      break;
    default:
      return -1;
      break;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x1,-0xc(%rbp)
je     134c <main+0x1dc>
lea    0xe6b(%rip),%rdi
call   1040 <system@plt>
mov    $0x1,%al
cmpl   $0x1,-0x10(%rbp)
mov    %al,-0x11(%rbp)
jb     11c3 <main+0x53>
cmpl   $0x4,-0x10(%rbp)
seta   %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    11d3 <main+0x63>
jmp    125e <main+0xee>
lea    0xe3a(%rip),%rdi
call   1050 <printf@plt>
lea    0xe63(%rip),%rdi
call   1050 <printf@plt>
lea    0xe65(%rip),%rdi
call   1050 <printf@plt>
lea    0xe69(%rip),%rdi
call   1050 <printf@plt>
lea    0xe70(%rip),%rdi
call   1050 <printf@plt>
lea    0xe7f(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1080 <scanf_s@plt>
mov    $0x0,%al
call   1070 <getchar@plt>
cmpl   $0x1,-0x10(%rbp)
jb     123a <main+0xca>
cmpl   $0x4,-0x10(%rbp)
jbe    1259 <main+0xe9>
lea    0xdcf(%rip),%rdi
call   1040 <system@plt>
lea    0xe4b(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x10(%rbp)
jmp    11aa <main+0x3a>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x3,%eax
ja     133b <main+0x1cb>
mov    -0x20(%rbp),%rax
lea    0xd82(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xd82(%rip),%rdi
call   1040 <system@plt>
mov    $0x0,%al
call   1030 <menu_cryptage@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     12b3 <main+0x143>
lea    0xe1c(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x10(%rbp)
jmp    1347 <main+0x1d7>
lea    0xd4a(%rip),%rdi
call   1040 <system@plt>
mov    $0x0,%al
call   1090 <menu_decryptage@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     12eb <main+0x17b>
lea    0xde4(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x10(%rbp)
jmp    1347 <main+0x1d7>
lea    0xd12(%rip),%rdi
call   1040 <system@plt>
mov    $0x0,%al
call   1060 <menu_annexe@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     1323 <main+0x1b3>
lea    0xdac(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x10(%rbp)
jmp    1347 <main+0x1d7>
movl   $0x1,-0xc(%rbp)
jmp    1347 <main+0x1d7>
movl   $0xffffffff,-0x4(%rbp)
jmp    1353 <main+0x1e3>
jmp    1194 <main+0x24>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
movl   $0x0,0x4(%rsp)
lea    0xee6(%rip),%r12
lea    0xeec(%rip),%r13
lea    0xef4(%rip),%rbx
lea    0xeff(%rip),%rbp
lea    0xe6e(%rip),%r14
lea    0x4(%rsp),%r15
jmp    11b8 <main+0x48>
nopl   (%rax)
movl   $0x0,0x4(%rsp)
lea    0xe51(%rip),%rdi
call   1050 <system@plt>
mov    0x4(%rsp),%eax
lea    -0x5(%rax),%ecx
cmp    $0xfffffffb,%ecx
jbe    1224 <main+0xb4>
add    $0xffffffff,%eax
cmp    $0x3,%eax
ja     12fc <main+0x18c>
lea    0xe1d(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe1d(%rip),%rdi
call   1050 <system@plt>
xor    %eax,%eax
call   1040 <menu_cryptage@plt>
test   %eax,%eax
je     120f <main+0x9f>
lea    0xe0d(%rip),%rdi
call   1030 <puts@plt>
movl   $0x0,0x4(%rsp)
jmp    11b8 <main+0x48>
nopl   0x0(%rax)
test   %eax,%eax
jne    11d0 <main+0x60>
lea    0xe11(%rip),%rdi
call   1030 <puts@plt>
mov    %r12,%rdi
call   1030 <puts@plt>
mov    %r13,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    %rbp,%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1080 <scanf_s@plt>
xor    %eax,%eax
call   1070 <getchar@plt>
mov    0x4(%rsp),%eax
lea    -0x5(%rax),%ecx
cmp    $0xfffffffb,%ecx
ja     1220 <main+0xb0>
lea    0xd9b(%rip),%rdi
call   1050 <system@plt>
lea    0xe37(%rip),%rdi
call   1030 <puts@plt>
movl   $0x0,0x4(%rsp)
xor    %eax,%eax
jmp    1220 <main+0xb0>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    0xd69(%rip),%rdi
call   1050 <system@plt>
xor    %eax,%eax
call   1090 <menu_decryptage@plt>
test   %eax,%eax
je     12c3 <main+0x153>
lea    0xd59(%rip),%rdi
call   1030 <puts@plt>
movl   $0x0,0x4(%rsp)
jmp    11b8 <main+0x48>
lea    0xd39(%rip),%rdi
call   1050 <system@plt>
xor    %eax,%eax
call   1060 <menu_annexe@plt>
test   %eax,%eax
je     11b0 <main+0x40>
lea    0xd25(%rip),%rdi
call   1030 <puts@plt>
jmp    11b0 <main+0x40>
mov    $0xffffffff,%eax
jmp    1305 <main+0x195>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"cls\00"
@.str.1 = [53 x i8] c"===== Projet C FISA 1 : Cryptage / Decryptage =====\0A\00"
@.str.2 = [14 x i8] c"1 - Cryptage\0A\00"
@.str.3 = [16 x i8] c"2 - Decryptage\0A\00"
@.str.4 = [19 x i8] c"3 - Annexe / aide\0A\00"
@.str.5 = [27 x i8] c"4 - Quitter le programme\0A\0A\00"
@.str.6 = [3 x i8] c"%d\00"
@.str.7 = [50 x i8] c"Erreur : vous n'avez pas entre un choix correct\0A\0A\00"
@.str.8 = [38 x i8] c"Erreur dans l'execution du programme\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
store i32 0, i32* %4
br label %5
5: ; preds = %63, %0
%6 = load i32, i32* %3
%7 = icmp ne i32 %6, 1
br i1 %7, label %8, label %64
8: ; preds = %5
%9 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
br label %10
10: ; preds = %34, %8
%11 = load i32, i32* %4
%12 = icmp ult i32 %11, 1
br i1 %12, label %16, label %13
13: ; preds = %10
%14 = load i32, i32* %4
%15 = icmp ugt i32 %14, 4
br label %16
16: ; preds = %13, %10
%17 = phi i1 [ true, %10 ], [ %15, %13 ]
br i1 %17, label %18, label %35
18: ; preds = %16
%19 = call i32 @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.1, i64 0, i64 0))
%20 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%21 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
%22 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0))
%23 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0))
%24 = call i32 @scanf_s(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %4)
%25 = call i32 (...) @getchar()
%26 = load i32, i32* %4
%27 = icmp ult i32 %26, 1
br i1 %27, label %31, label %28
28: ; preds = %18
%29 = load i32, i32* %4
%30 = icmp ugt i32 %29, 4
br i1 %30, label %31, label %34
31: ; preds = %28, %18
%32 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%33 = call i32 @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.7, i64 0, i64 0))
store i32 0, i32* %4
br label %34
34: ; preds = %31, %28
br label %10
35: ; preds = %16
%36 = load i32, i32* %4
switch i32 %36, label %62 [
i32 1, label %37
i32 2, label %45
i32 3, label %53
i32 4, label %61
]
37: ; preds = %35
%38 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%39 = call i32 (...) @menu_cryptage()
store i32 %39, i32* %2
%40 = load i32, i32* %2
%41 = icmp ne i32 %40, 0
br i1 %41, label %42, label %44
42: ; preds = %37
%43 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.8, i64 0, i64 0))
br label %44
44: ; preds = %42, %37
store i32 0, i32* %4
br label %63
45: ; preds = %35
%46 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%47 = call i32 (...) @menu_decryptage()
store i32 %47, i32* %2
%48 = load i32, i32* %2
%49 = icmp ne i32 %48, 0
br i1 %49, label %50, label %52
50: ; preds = %45
%51 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.8, i64 0, i64 0))
br label %52
52: ; preds = %50, %45
store i32 0, i32* %4
br label %63
53: ; preds = %35
%54 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%55 = call i32 (...) @menu_annexe()
store i32 %55, i32* %2
%56 = load i32, i32* %2
%57 = icmp ne i32 %56, 0
br i1 %57, label %58, label %60
58: ; preds = %53
%59 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.8, i64 0, i64 0))
br label %60
60: ; preds = %58, %53
store i32 0, i32* %4
br label %63
61: ; preds = %35
store i32 1, i32* %3
br label %63
62: ; preds = %35
store i32 -1, i32* %1
br label %65
63: ; preds = %61, %60, %52, %44
br label %5
64: ; preds = %5
store i32 0, i32* %1
br label %65
65: ; preds = %64, %62
%66 = load i32, i32* %1
ret i32 %66
}

LLVM IR (-O2):
@.str = [4 x i8] c"cls\00"
@.str.6 = [3 x i8] c"%d\00"
@str.10 = [37 x i8] c"Erreur dans l'execution du programme\00"
@str.11 = [52 x i8] c"===== Projet C FISA 1 : Cryptage / Decryptage =====\00"
@str.12 = [13 x i8] c"1 - Cryptage\00"
@str.13 = [15 x i8] c"2 - Decryptage\00"
@str.14 = [18 x i8] c"3 - Annexe / aide\00"
@str.15 = [26 x i8] c"4 - Quitter le programme\0A\00"
@str.16 = [49 x i8] c"Erreur : vous n'avez pas entre un choix correct\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 0, i32* %1
br label %3
3: ; preds = %48, %0
%4 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%5 = load i32, i32* %1
%6 = add i32 %5, -5
%7 = icmp ult i32 %6, -4
br i1 %7, label %8, label %25
8: ; preds = %3, %22
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @str.11, i64 0, i64 0))
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.12, i64 0, i64 0))
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.13, i64 0, i64 0))
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.14, i64 0, i64 0))
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.15, i64 0, i64 0))
%14 = call i32 @scanf_s(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %1)
%15 = call i32 (...) @getchar()
%16 = load i32, i32* %1
%17 = add i32 %16, -5
%18 = icmp ult i32 %17, -4
br i1 %18, label %19, label %22
19: ; preds = %8
%20 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @str.16, i64 0, i64 0))
store i32 0, i32* %1
br label %22
22: ; preds = %8, %19
%23 = phi i32 [ %16, %8 ], [ 0, %19 ]
%24 = icmp eq i32 %23, 0
br i1 %24, label %8, label %25
25: ; preds = %22, %3
%26 = phi i32 [ %5, %3 ], [ %23, %22 ]
switch i32 %26, label %49 [
i32 1, label %27
i32 2, label %34
i32 3, label %41
i32 4, label %50
]
27: ; preds = %25
%28 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%29 = call i32 (...) @menu_cryptage()
%30 = icmp eq i32 %29, 0
br i1 %30, label %33, label %31
31: ; preds = %27
%32 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.10, i64 0, i64 0))
br label %33
33: ; preds = %31, %27
store i32 0, i32* %1
br label %48
34: ; preds = %25
%35 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%36 = call i32 (...) @menu_decryptage()
%37 = icmp eq i32 %36, 0
br i1 %37, label %40, label %38
38: ; preds = %34
%39 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.10, i64 0, i64 0))
br label %40
40: ; preds = %38, %34
store i32 0, i32* %1
br label %48
41: ; preds = %25
%42 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%43 = call i32 (...) @menu_annexe()
%44 = icmp eq i32 %43, 0
br i1 %44, label %47, label %45
45: ; preds = %41
%46 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.10, i64 0, i64 0))
br label %47
47: ; preds = %45, %41
store i32 0, i32* %1
br label %48
48: ; preds = %47, %40, %33
br label %3
49: ; preds = %25
br label %50
50: ; preds = %25, %49
%51 = phi i32 [ -1, %49 ], [ 0, %25 ]
ret i32 %51
}