#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 cryptage_image_pgm(char *, char const *);
int cryptage_image_ppm(char *, char const *);
int detection_fichier(char *);
int detection_ppm_pgm(char *);
int /*<<< orphan*/ getchar();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, ...);
int /*<<< orphan*/ system(char *);
int menu_image_crypt(const char *str) {
  int choix = 0;
  char nom_image[255];
  char *nom_image_default = "default.ppm";
  int detection = 3;
  int checkpoint = -1;
  int fichier_correct = -1;
  while (choix < 1 || choix > 3) {
    system("cls");
    printf("Voulez vous choisir une image ?\n");
    printf("1 - Oui\n");
    printf("2 - Non, je laisse le programme choisir\n");
    printf("3 - Retour au menu principal\n\n");
    scanf("%d", &choix);
    getchar();
    if (choix < 1 || choix > 3) {
      system("cls");
      printf("Erreur : vous n'avez pas entre un choix correct\n");
    }
  }
  system("cls");
  switch (choix) {
  case 1:
    while (fichier_correct != 0) {
      printf("Entrer le nom de votre image au format nom_image.format "
             ":\nATTENTION : Les espaces et les carateres speciaux ne sont pas "
             "autorises dans le nom de l'image.\nSeules les images .pgm et "
             ".ppm sont autorisees.\n");
      scanf("%s", nom_image);
      system("cls");
      fichier_correct = detection_fichier(nom_image);
    }
    detection = detection_ppm_pgm(nom_image);
    switch (detection) {
    case 1:
      system("cls");
      checkpoint = cryptage_image_ppm(nom_image, str);
      if (checkpoint != 0) {
        printf("Erreur : le cryptage n'a pas abouti\n");
        system("pause");
        return -1;
      } else {
        printf("Succes : le cryptage est termine.\nVotre fichier crypte est "
               "'fichier_crypt_image_ppm.txt' et la cle 'key.txt'\n");
        system("pause");
        return 0;
      }
      break;
    case 2:
      system("cls");
      checkpoint = cryptage_image_pgm(nom_image, str);
      if (checkpoint != 0) {
        printf("Erreur : le cryptage n'a pas abouti\n");
        system("pause");
        return 0;
      } else {
        printf("Succes : le cryptage est termine.\nVotre fichier crypte est "
               "'fichier_crypt_image_pgm.txt' et la cle 'key.txt'\n");
        system("pause");
        return 0;
      }
      break;
    default:
      printf("Erreur default / break");
      return -1;
      break;
    }
    break;
  case 2:
    system("cls");
    checkpoint = cryptage_image_ppm(nom_image_default, str);
    if (checkpoint != 0) {
      printf("Erreur : le cryptage n'a pas abouti\n");
      system("pause");
      return -1;
    } else {
      printf("Succes : le cryptage est termine.\nVotre fichier crypte est "
             "'fichier_crypt_image_ppm.txt' et la cle 'key.txt'\n");
      system("pause");
      return 0;
    }
    break;
  case 3:
    return 0;
    break;
  default:
    printf("Erreur default / break");
    return -1;
    break;
  }
}


x86 assembly (clang, -O0):
<menu_image_crypt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xe63(%rip),%rax
mov    %rax,-0x128(%rbp)
movl   $0x3,-0x12c(%rbp)
movl   $0xffffffff,-0x130(%rbp)
ff ff ff
movl   $0xffffffff,-0x134(%rbp)
ff ff ff
mov    $0x1,%al
cmpl   $0x1,-0x14(%rbp)
mov    %al,-0x135(%rbp)
jl     11e1 <menu_image_crypt+0x61>
cmpl   $0x3,-0x14(%rbp)
setg   %al
mov    %al,-0x135(%rbp)
mov    -0x135(%rbp),%al
test   $0x1,%al
jne    11f4 <menu_image_crypt+0x74>
jmp    127a <menu_image_crypt+0xfa>
lea    0xe11(%rip),%rdi
call   1040 <system@plt>
lea    0xe09(%rip),%rdi
call   1050 <printf@plt>
lea    0xe1e(%rip),%rdi
call   1050 <printf@plt>
lea    0xe1b(%rip),%rdi
call   1050 <printf@plt>
lea    0xe38(%rip),%rdi
call   1050 <printf@plt>
lea    0xe4b(%rip),%rdi
lea    -0x14(%rbp),%rsi
mov    $0x0,%al
call   1090 <scanf@plt>
mov    $0x0,%al
call   1080 <getchar@plt>
cmpl   $0x1,-0x14(%rbp)
jl     125d <menu_image_crypt+0xdd>
cmpl   $0x3,-0x14(%rbp)
jle    1275 <menu_image_crypt+0xf5>
lea    0xda8(%rip),%rdi
call   1040 <system@plt>
lea    0xe15(%rip),%rdi
call   1050 <printf@plt>
jmp    11c2 <menu_image_crypt+0x42>
lea    0xd8b(%rip),%rdi
call   1040 <system@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x13c(%rbp)
sub    $0x1,%eax
je     12c5 <menu_image_crypt+0x145>
jmp    129d <menu_image_crypt+0x11d>
mov    -0x13c(%rbp),%eax
sub    $0x2,%eax
je     1461 <menu_image_crypt+0x2e1>
jmp    12b1 <menu_image_crypt+0x131>
mov    -0x13c(%rbp),%eax
sub    $0x3,%eax
je     14d8 <menu_image_crypt+0x358>
jmp    14e4 <menu_image_crypt+0x364>
jmp    12ca <menu_image_crypt+0x14a>
cmpl   $0x0,-0x134(%rbp)
je     131b <menu_image_crypt+0x19b>
lea    0xdd8(%rip),%rdi
call   1050 <printf@plt>
lea    -0x120(%rbp),%rsi
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1090 <scanf@plt>
lea    0xd0d(%rip),%rdi
call   1040 <system@plt>
lea    -0x120(%rbp),%rdi
call   1070 <detection_fichier@plt>
mov    %eax,-0x134(%rbp)
jmp    12ca <menu_image_crypt+0x14a>
lea    -0x120(%rbp),%rdi
call   1060 <detection_ppm_pgm@plt>
mov    %eax,-0x12c(%rbp)
mov    -0x12c(%rbp),%eax
mov    %eax,-0x140(%rbp)
sub    $0x1,%eax
je     135b <menu_image_crypt+0x1db>
jmp    1347 <menu_image_crypt+0x1c7>
mov    -0x140(%rbp),%eax
sub    $0x2,%eax
je     13d2 <menu_image_crypt+0x252>
jmp    1449 <menu_image_crypt+0x2c9>
lea    0xcaa(%rip),%rdi
call   1040 <system@plt>
lea    -0x120(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   10a0 <cryptage_image_ppm@plt>
mov    %eax,-0x130(%rbp)
cmpl   $0x0,-0x130(%rbp)
je     13ae <menu_image_crypt+0x22e>
lea    0xdf3(%rip),%rdi
call   1050 <printf@plt>
lea    0xe0c(%rip),%rdi
call   1040 <system@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    14f7 <menu_image_crypt+0x377>
lea    0xdfa(%rip),%rdi
call   1050 <printf@plt>
lea    0xde8(%rip),%rdi
call   1040 <system@plt>
movl   $0x0,-0x4(%rbp)
jmp    14f7 <menu_image_crypt+0x377>
lea    0xc33(%rip),%rdi
call   1040 <system@plt>
lea    -0x120(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <cryptage_image_pgm@plt>
mov    %eax,-0x130(%rbp)
cmpl   $0x0,-0x130(%rbp)
je     1425 <menu_image_crypt+0x2a5>
lea    0xd7c(%rip),%rdi
call   1050 <printf@plt>
lea    0xd95(%rip),%rdi
call   1040 <system@plt>
movl   $0x0,-0x4(%rbp)
jmp    14f7 <menu_image_crypt+0x377>
lea    0xdf1(%rip),%rdi
call   1050 <printf@plt>
lea    0xd71(%rip),%rdi
call   1040 <system@plt>
movl   $0x0,-0x4(%rbp)
jmp    14f7 <menu_image_crypt+0x377>
lea    0xe3b(%rip),%rdi
call   1050 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    14f7 <menu_image_crypt+0x377>
lea    0xba4(%rip),%rdi
call   1040 <system@plt>
mov    -0x128(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   10a0 <cryptage_image_ppm@plt>
mov    %eax,-0x130(%rbp)
cmpl   $0x0,-0x130(%rbp)
je     14b4 <menu_image_crypt+0x334>
lea    0xced(%rip),%rdi
call   1050 <printf@plt>
lea    0xd06(%rip),%rdi
call   1040 <system@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    14f7 <menu_image_crypt+0x377>
lea    0xcf4(%rip),%rdi
call   1050 <printf@plt>
lea    0xce2(%rip),%rdi
call   1040 <system@plt>
movl   $0x0,-0x4(%rbp)
jmp    14f7 <menu_image_crypt+0x377>
movl   $0x0,-0x4(%rbp)
jmp    14f7 <menu_image_crypt+0x377>
lea    0xda0(%rip),%rdi
call   1050 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<menu_image_crypt>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x118,%rsp
mov    %rdi,0x8(%rsp)
movl   $0x0,0x4(%rsp)
lea    0xe57(%rip),%rbx
lea    0x1067(%rip),%r13
lea    0x1088(%rip),%rbp
lea    0xe46(%rip),%r14
lea    0x4(%rsp),%r15
lea    0x1093(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1050 <system@plt>
lea    0x100c(%rip),%rdi
call   1030 <puts@plt>
lea    0x1020(%rip),%rdi
call   1030 <puts@plt>
mov    %r13,%rdi
call   1030 <puts@plt>
mov    %rbp,%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   10a0 <scanf@plt>
xor    %eax,%eax
call   1090 <getchar@plt>
mov    0x4(%rsp),%eax
add    $0xfffffffc,%eax
cmp    $0xfffffffc,%eax
ja     124c <menu_image_crypt+0xbc>
mov    %rbx,%rdi
call   1050 <system@plt>
mov    %r12,%rdi
call   1030 <puts@plt>
mov    0x4(%rsp),%eax
add    $0xfffffffc,%eax
cmp    $0xfffffffd,%eax
jb     11e0 <menu_image_crypt+0x50>
lea    0xdb9(%rip),%rdi
call   1050 <system@plt>
xor    %ebx,%ebx
mov    0x4(%rsp),%eax
cmp    $0x3,%eax
je     1358 <menu_image_crypt+0x1c8>
cmp    $0x2,%eax
je     131a <menu_image_crypt+0x18a>
cmp    $0x1,%eax
jne    130c <menu_image_crypt+0x17c>
lea    0xeb1(%rip),%r14
lea    0xd8c(%rip),%r15
lea    0x10(%rsp),%rbx
lea    0xd79(%rip),%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   10a0 <scanf@plt>
mov    %rbp,%rdi
call   1050 <system@plt>
mov    %rbx,%rdi
call   1080 <detection_fichier@plt>
test   %eax,%eax
jne    12a0 <menu_image_crypt+0x110>
lea    0x10(%rsp),%rdi
call   1070 <detection_ppm_pgm@plt>
cmp    $0x2,%eax
je     1386 <menu_image_crypt+0x1f6>
cmp    $0x1,%eax
jne    130c <menu_image_crypt+0x17c>
lea    0xd24(%rip),%rdi
call   1050 <system@plt>
lea    0x10(%rsp),%rdi
mov    0x8(%rsp),%rsi
call   10b0 <cryptage_image_ppm@plt>
test   %eax,%eax
jne    133b <menu_image_crypt+0x1ab>
lea    0xd99(%rip),%rdi
jmp    13b5 <menu_image_crypt+0x225>
lea    0xd09(%rip),%rdi
call   1060 <printf@plt>
jmp    1353 <menu_image_crypt+0x1c3>
lea    0xceb(%rip),%rdi
call   1050 <system@plt>
lea    0xcd3(%rip),%rdi
mov    0x8(%rsp),%rsi
call   10b0 <cryptage_image_ppm@plt>
test   %eax,%eax
je     136c <menu_image_crypt+0x1dc>
lea    0xdcb(%rip),%rdi
call   1030 <puts@plt>
lea    0xcc8(%rip),%rdi
call   1050 <system@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x118,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd2d(%rip),%rdi
call   1030 <puts@plt>
lea    0xc97(%rip),%rdi
call   1050 <system@plt>
jmp    1358 <menu_image_crypt+0x1c8>
lea    0xc7f(%rip),%rdi
call   1050 <system@plt>
lea    0x10(%rsp),%rdi
mov    0x8(%rsp),%rsi
call   1040 <cryptage_image_pgm@plt>
test   %eax,%eax
je     13ae <menu_image_crypt+0x21e>
lea    0xd61(%rip),%rdi
jmp    13b5 <menu_image_crypt+0x225>
lea    0xc7e(%rip),%rdi
call   1030 <puts@plt>
lea    0xc55(%rip),%rdi
call   1050 <system@plt>
xor    %ebx,%ebx
jmp    1358 <menu_image_crypt+0x1c8>

LLVM IR (-O0):
@.str = [12 x i8] c"default.ppm\00"
@.str.1 = [4 x i8] c"cls\00"
@.str.2 = [33 x i8] c"Voulez vous choisir une image ?\0A\00"
@.str.3 = [9 x i8] c"1 - Oui\0A\00"
@.str.4 = [41 x i8] c"2 - Non, je laisse le programme choisir\0A\00"
@.str.5 = [31 x i8] c"3 - Retour au menu principal\0A\0A\00"
@.str.6 = [3 x i8] c"%d\00"
@.str.7 = [49 x i8] c"Erreur : vous n'avez pas entre un choix correct\0A\00"
@.str.8 = [203 x i8] c"Entrer le nom de votre image au format nom_image.format :\0AATTENTION : Les espaces et les carateres speciaux ne sont pas autorises dans le nom de l'image.\0ASeules les images .pgm et .ppm sont autorisees.\0A\00"
@.str.9 = [3 x i8] c"%s\00"
@.str.10 = [37 x i8] c"Erreur : le cryptage n'a pas abouti\0A\00"
@.str.11 = [6 x i8] c"pause\00"
@.str.12 = [110 x i8] c"Succes : le cryptage est termine.\0AVotre fichier crypte est 'fichier_crypt_image_ppm.txt' et la cle 'key.txt'\0A\00"
@.str.13 = [110 x i8] c"Succes : le cryptage est termine.\0AVotre fichier crypte est 'fichier_crypt_image_pgm.txt' et la cle 'key.txt'\0A\00"
@.str.14 = [23 x i8] c"Erreur default / break\00"
define i32 @menu_image_crypt(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca [255 x i8]
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %3
store i32 0, i32* %4
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8** %6
store i32 3, i32* %7
store i32 -1, i32* %8
store i32 -1, i32* %9
br label %10
10: ; preds = %34, %1
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 1
br i1 %12, label %16, label %13
13: ; preds = %10
%14 = load i32, i32* %4
%15 = icmp sgt i32 %14, 3
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 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%20 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
%21 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%22 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.4, i64 0, i64 0))
%23 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0))
%24 = call i32 (i8*, ...) @scanf(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 slt i32 %26, 1
br i1 %27, label %31, label %28
28: ; preds = %18
%29 = load i32, i32* %4
%30 = icmp sgt i32 %29, 3
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.1, i64 0, i64 0))
%33 = call i32 @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.7, i64 0, i64 0))
br label %34
34: ; preds = %31, %28
br label %10
35: ; preds = %16
%36 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%37 = load i32, i32* %4
switch i32 %37, label %95 [
i32 1, label %38
i32 2, label %81
i32 3, label %94
]
38: ; preds = %35
br label %39
39: ; preds = %42, %38
%40 = load i32, i32* %9
%41 = icmp ne i32 %40, 0
br i1 %41, label %42, label %49
42: ; preds = %39
%43 = call i32 @printf(i8* getelementptr inbounds ([203 x i8], [203 x i8]* @.str.8, i64 0, i64 0))
%44 = getelementptr inbounds [255 x i8], [255 x i8]* %5, i64 0, i64 0
%45 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i8* %44)
%46 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%47 = getelementptr inbounds [255 x i8], [255 x i8]* %5, i64 0, i64 0
%48 = call i32 @detection_fichier(i8* %47)
store i32 %48, i32* %9
br label %39
49: ; preds = %39
%50 = getelementptr inbounds [255 x i8], [255 x i8]* %5, i64 0, i64 0
%51 = call i32 @detection_ppm_pgm(i8* %50)
store i32 %51, i32* %7
%52 = load i32, i32* %7
switch i32 %52, label %79 [
i32 1, label %53
i32 2, label %66
]
53: ; preds = %49
%54 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%55 = getelementptr inbounds [255 x i8], [255 x i8]* %5, i64 0, i64 0
%56 = load i8*, i8** %3
%57 = call i32 @cryptage_image_ppm(i8* %55, i8* %56)
store i32 %57, i32* %8
%58 = load i32, i32* %8
%59 = icmp ne i32 %58, 0
br i1 %59, label %60, label %63
60: ; preds = %53
%61 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.10, i64 0, i64 0))
%62 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0))
store i32 -1, i32* %2
br label %97
63: ; preds = %53
%64 = call i32 @printf(i8* getelementptr inbounds ([110 x i8], [110 x i8]* @.str.12, i64 0, i64 0))
%65 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0))
store i32 0, i32* %2
br label %97
66: ; preds = %49
%67 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%68 = getelementptr inbounds [255 x i8], [255 x i8]* %5, i64 0, i64 0
%69 = load i8*, i8** %3
%70 = call i32 @cryptage_image_pgm(i8* %68, i8* %69)
store i32 %70, i32* %8
%71 = load i32, i32* %8
%72 = icmp ne i32 %71, 0
br i1 %72, label %73, label %76
73: ; preds = %66
%74 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.10, i64 0, i64 0))
%75 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0))
store i32 0, i32* %2
br label %97
76: ; preds = %66
%77 = call i32 @printf(i8* getelementptr inbounds ([110 x i8], [110 x i8]* @.str.13, i64 0, i64 0))
%78 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0))
store i32 0, i32* %2
br label %97
79: ; preds = %49
%80 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.14, i64 0, i64 0))
store i32 -1, i32* %2
br label %97
81: ; preds = %35
%82 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%83 = load i8*, i8** %6
%84 = load i8*, i8** %3
%85 = call i32 @cryptage_image_ppm(i8* %83, i8* %84)
store i32 %85, i32* %8
%86 = load i32, i32* %8
%87 = icmp ne i32 %86, 0
br i1 %87, label %88, label %91
88: ; preds = %81
%89 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.10, i64 0, i64 0))
%90 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0))
store i32 -1, i32* %2
br label %97
91: ; preds = %81
%92 = call i32 @printf(i8* getelementptr inbounds ([110 x i8], [110 x i8]* @.str.12, i64 0, i64 0))
%93 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0))
store i32 0, i32* %2
br label %97
94: ; preds = %35
store i32 0, i32* %2
br label %97
95: ; preds = %35
%96 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.14, i64 0, i64 0))
store i32 -1, i32* %2
br label %97
97: ; preds = %95, %94, %91, %88, %79, %76, %73, %63, %60
%98 = load i32, i32* %2
ret i32 %98
}

LLVM IR (-O2):
@.str = [12 x i8] c"default.ppm\00"
@.str.1 = [4 x i8] c"cls\00"
@.str.6 = [3 x i8] c"%d\00"
@.str.9 = [3 x i8] c"%s\00"
@.str.11 = [6 x i8] c"pause\00"
@.str.14 = [23 x i8] c"Erreur default / break\00"
@str.16 = [109 x i8] c"Succes : le cryptage est termine.\0AVotre fichier crypte est 'fichier_crypt_image_pgm.txt' et la cle 'key.txt'\00"
@str.18 = [109 x i8] c"Succes : le cryptage est termine.\0AVotre fichier crypte est 'fichier_crypt_image_ppm.txt' et la cle 'key.txt'\00"
@str.19 = [36 x i8] c"Erreur : le cryptage n'a pas abouti\00"
@str.20 = [202 x i8] c"Entrer le nom de votre image au format nom_image.format :\0AATTENTION : Les espaces et les carateres speciaux ne sont pas autorises dans le nom de l'image.\0ASeules les images .pgm et .ppm sont autorisees.\00"
@str.21 = [32 x i8] c"Voulez vous choisir une image ?\00"
@str.22 = [8 x i8] c"1 - Oui\00"
@str.23 = [40 x i8] c"2 - Non, je laisse le programme choisir\00"
@str.24 = [30 x i8] c"3 - Retour au menu principal\0A\00"
@str.25 = [48 x i8] c"Erreur : vous n'avez pas entre un choix correct\00"
define i32 @menu_image_crypt(i8* %0) {
%2 = alloca i32
%3 = alloca [255 x i8]
%4 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%5 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
br label %6
6: ; preds = %1, %17
%7 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.21, i64 0, i64 0))
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.22, i64 0, i64 0))
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.23, i64 0, i64 0))
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.24, i64 0, i64 0))
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %2)
%13 = call i32 (...) @getchar()
%14 = load i32, i32* %2
%15 = add i32 %14, -4
%16 = icmp ult i32 %15, -3
br i1 %16, label %17, label %23
17: ; preds = %6
%18 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @str.25, i64 0, i64 0))
%20 = load i32, i32* %2
%21 = add i32 %20, -4
%22 = icmp ult i32 %21, -3
br i1 %22, label %6, label %23
23: ; preds = %6, %17
%24 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%25 = load i32, i32* %2
switch i32 %25, label %66 [
i32 1, label %26
i32 2, label %56
i32 3, label %68
]
26: ; preds = %23, %26
%27 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([202 x i8], [202 x i8]* @str.20, i64 0, i64 0))
%28 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i8* %5)
%29 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%30 = call i32 @detection_fichier(i8* %5)
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %26
32: ; preds = %26
%33 = call i32 @detection_ppm_pgm(i8* %5)
switch i32 %33, label %54 [
i32 1, label %34
i32 2, label %44
]
34: ; preds = %32
%35 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%36 = call i32 @cryptage_image_ppm(i8* %5, i8* %0)
%37 = icmp eq i32 %36, 0
br i1 %37, label %41, label %38
38: ; preds = %34
%39 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.19, i64 0, i64 0))
%40 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0))
br label %68
41: ; preds = %34
%42 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([109 x i8], [109 x i8]* @str.18, i64 0, i64 0))
%43 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0))
br label %68
44: ; preds = %32
%45 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%46 = call i32 @cryptage_image_pgm(i8* %5, i8* %0)
%47 = icmp eq i32 %46, 0
br i1 %47, label %51, label %48
48: ; preds = %44
%49 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.19, i64 0, i64 0))
%50 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0))
br label %68
51: ; preds = %44
%52 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([109 x i8], [109 x i8]* @str.16, i64 0, i64 0))
%53 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0))
br label %68
54: ; preds = %32
%55 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.14, i64 0, i64 0))
br label %68
56: ; preds = %23
%57 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%58 = call i32 @cryptage_image_ppm(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %0)
%59 = icmp eq i32 %58, 0
br i1 %59, label %63, label %60
60: ; preds = %56
%61 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.19, i64 0, i64 0))
%62 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0))
br label %68
63: ; preds = %56
%64 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([109 x i8], [109 x i8]* @str.18, i64 0, i64 0))
%65 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0))
br label %68
66: ; preds = %23
%67 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.14, i64 0, i64 0))
br label %68
68: ; preds = %23, %66, %63, %60, %54, %51, %48, %41, %38
%69 = phi i32 [ -1, %66 ], [ -1, %60 ], [ 0, %63 ], [ -1, %54 ], [ 0, %48 ], [ 0, %51 ], [ -1, %38 ], [ 0, %41 ], [ 0, %23 ]
ret i32 %69
}