#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 decryptage_image_pgm(char *, char const *, char *);
int decryptage_image_ppm(char *, char const *, char *);
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_decrypt(const char *str) {
  int choix = 0;
  char nom_image[255];
  char nom_cle[255];
  char *nom_image_default = "default.ppm";
  int detection = 3;
  int checkpoint = -1;
  int fichier_correct = -1;
  while (choix < 1 || choix > 3) {
    printf("Avez vous choisi une image lors du cryptage ?\n");
    printf("1 - Oui\n");
    printf("2 - Non, j'ai 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");
    }
  }
  switch (choix) {
  case 1:
    system("cls");
    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);
      fichier_correct = detection_fichier(nom_image);
    }
    fichier_correct = -1;
    while (fichier_correct != 0) {
      printf(
          "Entrer le nom de votre fichier cle au format nom_fichier.txt :\n");
      scanf("%s", nom_cle);
      fichier_correct = detection_fichier(nom_cle);
    }
    detection = detection_ppm_pgm(nom_image);
    switch (detection) {
    case 1:
      checkpoint = decryptage_image_ppm(nom_image, str, nom_cle);
      if (checkpoint != 0) {
        printf("Erreur : le decryptage n'a pas abouti\n");
        system("pause");
        return -1;
      } else {
        printf("Succes : le decryptage est termine.\nVotre fichier decrypte "
               "est 'fichier_decrypt_image_ppm.txt'\n");
        system("pause");
        return 0;
      }
      break;
    case 2:
      checkpoint = decryptage_image_pgm(nom_image, str, nom_cle);
      if (checkpoint != 0) {
        printf("Erreur : le decryptage n'a pas abouti\n");
        system("pause");
        return 0;
      } else {
        printf("Succes : le decryptage est termine.\nVotre fichier decrypte "
               "est 'fichier_decrypt_image_pgm.txt'\n");
        system("pause");
        return 0;
      }
      break;
    default:
      printf("Erreur default / break");
      system("pause");
      return -1;
      break;
    }
    break;
  case 2:
    system("cls");
    while (fichier_correct != 0) {
      printf(
          "Entrer le nom de votre fichier cle au format nom_fichier.txt :\n");
      scanf("%s", nom_cle);
      fichier_correct = detection_fichier(nom_cle);
    };
    checkpoint = decryptage_image_ppm(nom_image_default, str, nom_cle);
    if (checkpoint != 0) {
      printf("Erreur : le decryptage n'a pas abouti\n");
      system("pause");
      return -1;
    } else {
      printf("Succes : le decryptage est termine.\nVotre fichier decrypte est "
             "'fichier_decrypt_image_ppm.txt'\n");
      system("pause");
      return 0;
    }
    break;
  case 3:
    return 0;
    break;
  default:
    printf("Erreur default / break");
    system("pause");
    return -1;
    break;
  }
}


x86 assembly (clang, -O0):
<menu_image_decrypt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x240,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xe63(%rip),%rax
mov    %rax,-0x228(%rbp)
movl   $0x3,-0x22c(%rbp)
movl   $0xffffffff,-0x230(%rbp)
ff ff ff
movl   $0xffffffff,-0x234(%rbp)
ff ff ff
mov    $0x1,%al
cmpl   $0x1,-0x14(%rbp)
mov    %al,-0x235(%rbp)
jl     11e1 <menu_image_decrypt+0x61>
cmpl   $0x3,-0x14(%rbp)
setg   %al
mov    %al,-0x235(%rbp)
mov    -0x235(%rbp),%al
test   $0x1,%al
jne    11f4 <menu_image_decrypt+0x74>
jmp    126e <menu_image_decrypt+0xee>
lea    0xe11(%rip),%rdi
call   1050 <printf@plt>
lea    0xe34(%rip),%rdi
call   1050 <printf@plt>
lea    0xe31(%rip),%rdi
call   1050 <printf@plt>
lea    0xe50(%rip),%rdi
call   1050 <printf@plt>
lea    0xe63(%rip),%rdi
lea    -0x14(%rbp),%rsi
mov    $0x0,%al
call   10a0 <scanf@plt>
mov    $0x0,%al
call   1090 <getchar@plt>
cmpl   $0x1,-0x14(%rbp)
jl     1251 <menu_image_decrypt+0xd1>
cmpl   $0x3,-0x14(%rbp)
jle    1269 <menu_image_decrypt+0xe9>
lea    0xe39(%rip),%rdi
call   1040 <system@plt>
lea    0xe31(%rip),%rdi
call   1050 <printf@plt>
jmp    11c2 <menu_image_decrypt+0x42>
mov    -0x14(%rbp),%eax
mov    %eax,-0x23c(%rbp)
sub    $0x1,%eax
je     12ad <menu_image_decrypt+0x12d>
jmp    1285 <menu_image_decrypt+0x105>
mov    -0x23c(%rbp),%eax
sub    $0x2,%eax
je     1495 <menu_image_decrypt+0x315>
jmp    1299 <menu_image_decrypt+0x119>
mov    -0x23c(%rbp),%eax
sub    $0x3,%eax
je     1558 <menu_image_decrypt+0x3d8>
jmp    1564 <menu_image_decrypt+0x3e4>
lea    0xddd(%rip),%rdi
call   1040 <system@plt>
cmpl   $0x0,-0x234(%rbp)
je     12fe <menu_image_decrypt+0x17e>
lea    0xdf9(%rip),%rdi
call   1050 <printf@plt>
lea    -0x120(%rbp),%rsi
lea    0xeb1(%rip),%rdi
mov    $0x0,%al
call   10a0 <scanf@plt>
lea    -0x120(%rbp),%rdi
call   1080 <detection_fichier@plt>
mov    %eax,-0x234(%rbp)
jmp    12b9 <menu_image_decrypt+0x139>
movl   $0xffffffff,-0x234(%rbp)
ff ff ff
cmpl   $0x0,-0x234(%rbp)
je     134d <menu_image_decrypt+0x1cd>
lea    0xe78(%rip),%rdi
call   1050 <printf@plt>
lea    -0x220(%rbp),%rsi
lea    0xe62(%rip),%rdi
mov    $0x0,%al
call   10a0 <scanf@plt>
lea    -0x220(%rbp),%rdi
call   1080 <detection_fichier@plt>
mov    %eax,-0x234(%rbp)
jmp    1308 <menu_image_decrypt+0x188>
lea    -0x120(%rbp),%rdi
call   1070 <detection_ppm_pgm@plt>
mov    %eax,-0x22c(%rbp)
mov    -0x22c(%rbp),%eax
mov    %eax,-0x240(%rbp)
sub    $0x1,%eax
je     138d <menu_image_decrypt+0x20d>
jmp    1379 <menu_image_decrypt+0x1f9>
mov    -0x240(%rbp),%eax
sub    $0x2,%eax
je     13ff <menu_image_decrypt+0x27f>
jmp    1471 <menu_image_decrypt+0x2f1>
lea    -0x120(%rbp),%rdi
mov    -0x10(%rbp),%rsi
lea    -0x220(%rbp),%rdx
call   1030 <decryptage_image_ppm@plt>
mov    %eax,-0x230(%rbp)
cmpl   $0x0,-0x230(%rbp)
je     13db <menu_image_decrypt+0x25b>
lea    0xe16(%rip),%rdi
call   1050 <printf@plt>
lea    0xe31(%rip),%rdi
call   1040 <system@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1583 <menu_image_decrypt+0x403>
lea    0xe1f(%rip),%rdi
call   1050 <printf@plt>
lea    0xe0d(%rip),%rdi
call   1040 <system@plt>
movl   $0x0,-0x4(%rbp)
jmp    1583 <menu_image_decrypt+0x403>
lea    -0x120(%rbp),%rdi
mov    -0x10(%rbp),%rsi
lea    -0x220(%rbp),%rdx
call   1060 <decryptage_image_pgm@plt>
mov    %eax,-0x230(%rbp)
cmpl   $0x0,-0x230(%rbp)
je     144d <menu_image_decrypt+0x2cd>
lea    0xda4(%rip),%rdi
call   1050 <printf@plt>
lea    0xdbf(%rip),%rdi
call   1040 <system@plt>
movl   $0x0,-0x4(%rbp)
jmp    1583 <menu_image_decrypt+0x403>
lea    0xe0d(%rip),%rdi
call   1050 <printf@plt>
lea    0xd9b(%rip),%rdi
call   1040 <system@plt>
movl   $0x0,-0x4(%rbp)
jmp    1583 <menu_image_decrypt+0x403>
lea    0xe49(%rip),%rdi
call   1050 <printf@plt>
lea    0xd77(%rip),%rdi
call   1040 <system@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1583 <menu_image_decrypt+0x403>
lea    0xbf5(%rip),%rdi
call   1040 <system@plt>
cmpl   $0x0,-0x234(%rbp)
je     14e6 <menu_image_decrypt+0x366>
lea    0xcdf(%rip),%rdi
call   1050 <printf@plt>
lea    -0x220(%rbp),%rsi
lea    0xcc9(%rip),%rdi
mov    $0x0,%al
call   10a0 <scanf@plt>
lea    -0x220(%rbp),%rdi
call   1080 <detection_fichier@plt>
mov    %eax,-0x234(%rbp)
jmp    14a1 <menu_image_decrypt+0x321>
mov    -0x228(%rbp),%rdi
mov    -0x10(%rbp),%rsi
lea    -0x220(%rbp),%rdx
call   1030 <decryptage_image_ppm@plt>
mov    %eax,-0x230(%rbp)
cmpl   $0x0,-0x230(%rbp)
je     1534 <menu_image_decrypt+0x3b4>
lea    0xcbd(%rip),%rdi
call   1050 <printf@plt>
lea    0xcd8(%rip),%rdi
call   1040 <system@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1583 <menu_image_decrypt+0x403>
lea    0xcc6(%rip),%rdi
call   1050 <printf@plt>
lea    0xcb4(%rip),%rdi
call   1040 <system@plt>
movl   $0x0,-0x4(%rbp)
jmp    1583 <menu_image_decrypt+0x403>
movl   $0x0,-0x4(%rbp)
jmp    1583 <menu_image_decrypt+0x403>
lea    0xd56(%rip),%rdi
call   1050 <printf@plt>
lea    0xc84(%rip),%rdi
call   1040 <system@plt>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x240,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<menu_image_decrypt>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x218,%rsp
mov    %rdi,0x8(%rsp)
movl   $0x0,0x4(%rsp)
lea    0x10a1(%rip),%r13
lea    0x10c4(%rip),%rbx
lea    0xe49(%rip),%rbp
lea    0x4(%rsp),%r14
lea    0xe40(%rip),%r15
lea    0x10c8(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
lea    0x1039(%rip),%rdi
call   1030 <puts@plt>
lea    0x105b(%rip),%rdi
call   1030 <puts@plt>
mov    %r13,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    %rbp,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   10b0 <scanf@plt>
xor    %eax,%eax
call   10a0 <getchar@plt>
mov    0x4(%rsp),%eax
lea    -0x4(%rax),%ecx
cmp    $0xfffffffc,%ecx
ja     1244 <menu_image_decrypt+0xb4>
mov    %r15,%rdi
call   1050 <system@plt>
mov    %r12,%rdi
call   1030 <puts@plt>
mov    0x4(%rsp),%eax
lea    -0x4(%rax),%ecx
cmp    $0xfffffffd,%ecx
jb     11e0 <menu_image_decrypt+0x50>
cmp    $0x3,%eax
je     139e <menu_image_decrypt+0x20e>
cmp    $0x2,%eax
je     1324 <menu_image_decrypt+0x194>
cmp    $0x1,%eax
jne    1316 <menu_image_decrypt+0x186>
lea    0xda9(%rip),%rdi
call   1050 <system@plt>
lea    0xee4(%rip),%r14
lea    0xd9a(%rip),%rbp
lea    0x110(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   10b0 <scanf@plt>
mov    %rbx,%rdi
call   1090 <detection_fichier@plt>
test   %eax,%eax
jne    1290 <menu_image_decrypt+0x100>
lea    0xe5f(%rip),%r14
lea    0xd54(%rip),%rbp
lea    0x10(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   10b0 <scanf@plt>
mov    %rbx,%rdi
call   1090 <detection_fichier@plt>
test   %eax,%eax
jne    12d0 <menu_image_decrypt+0x140>
lea    0x110(%rsp),%rdi
call   1080 <detection_ppm_pgm@plt>
cmp    $0x2,%eax
je     13ab <menu_image_decrypt+0x21b>
cmp    $0x1,%eax
jne    1316 <menu_image_decrypt+0x186>
lea    0x110(%rsp),%rdi
jmp    1378 <menu_image_decrypt+0x1e8>
lea    0xcff(%rip),%rdi
call   1060 <printf@plt>
jmp    1397 <menu_image_decrypt+0x207>
lea    0xce4(%rip),%rdi
call   1050 <system@plt>
lea    0xde0(%rip),%r14
lea    0xcd5(%rip),%rbp
lea    0x10(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   10b0 <scanf@plt>
mov    %rbx,%rdi
call   1090 <detection_fichier@plt>
test   %eax,%eax
jne    1350 <menu_image_decrypt+0x1c0>
lea    0xc88(%rip),%rdi
lea    0x10(%rsp),%rdx
mov    0x8(%rsp),%rsi
call   1040 <decryptage_image_ppm@plt>
test   %eax,%eax
je     13a2 <menu_image_decrypt+0x212>
lea    0xd5f(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%ebx
jmp    13dd <menu_image_decrypt+0x24d>
xor    %ebx,%ebx
jmp    13e9 <menu_image_decrypt+0x259>
lea    0xce9(%rip),%rdi
jmp    13d6 <menu_image_decrypt+0x246>
lea    0x110(%rsp),%rdi
lea    0x10(%rsp),%rdx
mov    0x8(%rsp),%rsi
call   1070 <decryptage_image_pgm@plt>
test   %eax,%eax
je     13cf <menu_image_decrypt+0x23f>
lea    0xd24(%rip),%rdi
jmp    13d6 <menu_image_decrypt+0x246>
lea    0xc5d(%rip),%rdi
call   1030 <puts@plt>
xor    %ebx,%ebx
lea    0xc32(%rip),%rdi
call   1050 <system@plt>
mov    %ebx,%eax
add    $0x218,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"default.ppm\00"
@.str.1 = [47 x i8] c"Avez vous choisi une image lors du cryptage ?\0A\00"
@.str.2 = [9 x i8] c"1 - Oui\0A\00"
@.str.3 = [43 x i8] c"2 - Non, j'ai laisse le programme choisir\0A\00"
@.str.4 = [31 x i8] c"3 - Retour au menu principal\0A\0A\00"
@.str.5 = [3 x i8] c"%d\00"
@.str.6 = [4 x i8] c"cls\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 = [64 x i8] c"Entrer le nom de votre fichier cle au format nom_fichier.txt :\0A\00"
@.str.11 = [39 x i8] c"Erreur : le decryptage n'a pas abouti\0A\00"
@.str.12 = [6 x i8] c"pause\00"
@.str.13 = [96 x i8] c"Succes : le decryptage est termine.\0AVotre fichier decrypte est 'fichier_decrypt_image_ppm.txt'\0A\00"
@.str.14 = [96 x i8] c"Succes : le decryptage est termine.\0AVotre fichier decrypte est 'fichier_decrypt_image_pgm.txt'\0A\00"
@.str.15 = [23 x i8] c"Erreur default / break\00"
define i32 @menu_image_decrypt(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca [255 x i8]
%6 = alloca [255 x i8]
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = 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** %7
store i32 3, i32* %8
store i32 -1, i32* %9
store i32 -1, i32* %10
br label %11
11: ; preds = %34, %1
%12 = load i32, i32* %4
%13 = icmp slt i32 %12, 1
br i1 %13, label %17, label %14
14: ; preds = %11
%15 = load i32, i32* %4
%16 = icmp sgt i32 %15, 3
br label %17
17: ; preds = %14, %11
%18 = phi i1 [ true, %11 ], [ %16, %14 ]
br i1 %18, label %19, label %35
19: ; preds = %17
%20 = call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0))
%21 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%22 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.3, i64 0, i64 0))
%23 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0))
%24 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, 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 = %19
%29 = load i32, i32* %4
%30 = icmp sgt i32 %29, 3
br i1 %30, label %31, label %34
31: ; preds = %28, %19
%32 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, 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 %11
35: ; preds = %17
%36 = load i32, i32* %4
switch i32 %36, label %116 [
i32 1, label %37
i32 2, label %91
i32 3, label %115
]
37: ; preds = %35
%38 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
br label %39
39: ; preds = %42, %37
%40 = load i32, i32* %10
%41 = icmp ne i32 %40, 0
br i1 %41, label %42, label %48
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 = getelementptr inbounds [255 x i8], [255 x i8]* %5, i64 0, i64 0
%47 = call i32 @detection_fichier(i8* %46)
store i32 %47, i32* %10
br label %39
48: ; preds = %39
store i32 -1, i32* %10
br label %49
49: ; preds = %52, %48
%50 = load i32, i32* %10
%51 = icmp ne i32 %50, 0
br i1 %51, label %52, label %58
52: ; preds = %49
%53 = call i32 @printf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.10, i64 0, i64 0))
%54 = getelementptr inbounds [255 x i8], [255 x i8]* %6, i64 0, i64 0
%55 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i8* %54)
%56 = getelementptr inbounds [255 x i8], [255 x i8]* %6, i64 0, i64 0
%57 = call i32 @detection_fichier(i8* %56)
store i32 %57, i32* %10
br label %49
58: ; preds = %49
%59 = getelementptr inbounds [255 x i8], [255 x i8]* %5, i64 0, i64 0
%60 = call i32 @detection_ppm_pgm(i8* %59)
store i32 %60, i32* %8
%61 = load i32, i32* %8
switch i32 %61, label %88 [
i32 1, label %62
i32 2, label %75
]
62: ; preds = %58
%63 = getelementptr inbounds [255 x i8], [255 x i8]* %5, i64 0, i64 0
%64 = load i8*, i8** %3
%65 = getelementptr inbounds [255 x i8], [255 x i8]* %6, i64 0, i64 0
%66 = call i32 @decryptage_image_ppm(i8* %63, i8* %64, i8* %65)
store i32 %66, i32* %9
%67 = load i32, i32* %9
%68 = icmp ne i32 %67, 0
br i1 %68, label %69, label %72
69: ; preds = %62
%70 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.11, i64 0, i64 0))
%71 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.12, i64 0, i64 0))
store i32 -1, i32* %2
br label %119
72: ; preds = %62
%73 = call i32 @printf(i8* getelementptr inbounds ([96 x i8], [96 x i8]* @.str.13, i64 0, i64 0))
%74 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.12, i64 0, i64 0))
store i32 0, i32* %2
br label %119
75: ; preds = %58
%76 = getelementptr inbounds [255 x i8], [255 x i8]* %5, i64 0, i64 0
%77 = load i8*, i8** %3
%78 = getelementptr inbounds [255 x i8], [255 x i8]* %6, i64 0, i64 0
%79 = call i32 @decryptage_image_pgm(i8* %76, i8* %77, i8* %78)
store i32 %79, i32* %9
%80 = load i32, i32* %9
%81 = icmp ne i32 %80, 0
br i1 %81, label %82, label %85
82: ; preds = %75
%83 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.11, i64 0, i64 0))
%84 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.12, i64 0, i64 0))
store i32 0, i32* %2
br label %119
85: ; preds = %75
%86 = call i32 @printf(i8* getelementptr inbounds ([96 x i8], [96 x i8]* @.str.14, i64 0, i64 0))
%87 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.12, i64 0, i64 0))
store i32 0, i32* %2
br label %119
88: ; preds = %58
%89 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.15, i64 0, i64 0))
%90 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.12, i64 0, i64 0))
store i32 -1, i32* %2
br label %119
91: ; preds = %35
%92 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
br label %93
93: ; preds = %96, %91
%94 = load i32, i32* %10
%95 = icmp ne i32 %94, 0
br i1 %95, label %96, label %102
96: ; preds = %93
%97 = call i32 @printf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.10, i64 0, i64 0))
%98 = getelementptr inbounds [255 x i8], [255 x i8]* %6, i64 0, i64 0
%99 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i8* %98)
%100 = getelementptr inbounds [255 x i8], [255 x i8]* %6, i64 0, i64 0
%101 = call i32 @detection_fichier(i8* %100)
store i32 %101, i32* %10
br label %93
102: ; preds = %93
%103 = load i8*, i8** %7
%104 = load i8*, i8** %3
%105 = getelementptr inbounds [255 x i8], [255 x i8]* %6, i64 0, i64 0
%106 = call i32 @decryptage_image_ppm(i8* %103, i8* %104, i8* %105)
store i32 %106, i32* %9
%107 = load i32, i32* %9
%108 = icmp ne i32 %107, 0
br i1 %108, label %109, label %112
109: ; preds = %102
%110 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.11, i64 0, i64 0))
%111 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.12, i64 0, i64 0))
store i32 -1, i32* %2
br label %119
112: ; preds = %102
%113 = call i32 @printf(i8* getelementptr inbounds ([96 x i8], [96 x i8]* @.str.13, i64 0, i64 0))
%114 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.12, i64 0, i64 0))
store i32 0, i32* %2
br label %119
115: ; preds = %35
store i32 0, i32* %2
br label %119
116: ; preds = %35
%117 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.15, i64 0, i64 0))
%118 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.12, i64 0, i64 0))
store i32 -1, i32* %2
br label %119
119: ; preds = %116, %115, %112, %109, %88, %85, %82, %72, %69
%120 = load i32, i32* %2
ret i32 %120
}

LLVM IR (-O2):
@.str = [12 x i8] c"default.ppm\00"
@.str.5 = [3 x i8] c"%d\00"
@.str.6 = [4 x i8] c"cls\00"
@.str.9 = [3 x i8] c"%s\00"
@.str.12 = [6 x i8] c"pause\00"
@.str.15 = [23 x i8] c"Erreur default / break\00"
@str.18 = [95 x i8] c"Succes : le decryptage est termine.\0AVotre fichier decrypte est 'fichier_decrypt_image_pgm.txt'\00"
@str.20 = [95 x i8] c"Succes : le decryptage est termine.\0AVotre fichier decrypte est 'fichier_decrypt_image_ppm.txt'\00"
@str.21 = [38 x i8] c"Erreur : le decryptage n'a pas abouti\00"
@str.22 = [63 x i8] c"Entrer le nom de votre fichier cle au format nom_fichier.txt :\00"
@str.23 = [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.24 = [46 x i8] c"Avez vous choisi une image lors du cryptage ?\00"
@str.25 = [8 x i8] c"1 - Oui\00"
@str.26 = [42 x i8] c"2 - Non, j'ai laisse le programme choisir\00"
@str.27 = [30 x i8] c"3 - Retour au menu principal\0A\00"
@str.28 = [48 x i8] c"Erreur : vous n'avez pas entre un choix correct\00"
define i32 @menu_image_decrypt(i8* %0) {
%2 = alloca i32
%3 = alloca [255 x i8]
%4 = alloca [255 x i8]
%5 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%6 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds [255 x i8], [255 x i8]* %4, i64 0, i64 0
br label %8
8: ; preds = %1, %18
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str.24, i64 0, i64 0))
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.25, i64 0, i64 0))
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str.26, i64 0, i64 0))
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.27, i64 0, i64 0))
%13 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %2)
%14 = call i32 (...) @getchar()
%15 = load i32, i32* %2
%16 = add i32 %15, -4
%17 = icmp ult i32 %16, -3
br i1 %17, label %18, label %24
18: ; preds = %8
%19 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%20 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @str.28, i64 0, i64 0))
%21 = load i32, i32* %2
%22 = add i32 %21, -4
%23 = icmp ult i32 %22, -3
br i1 %23, label %8, label %24
24: ; preds = %8, %18
%25 = phi i32 [ %21, %18 ], [ %15, %8 ]
switch i32 %25, label %70 [
i32 1, label %26
i32 2, label %56
i32 3, label %75
]
26: ; preds = %24
%27 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
br label %28
28: ; preds = %26, %28
%29 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([202 x i8], [202 x i8]* @str.23, i64 0, i64 0))
%30 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i8* %6)
%31 = call i32 @detection_fichier(i8* %6)
%32 = icmp eq i32 %31, 0
br i1 %32, label %33, label %28
33: ; preds = %28, %33
%34 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([63 x i8], [63 x i8]* @str.22, i64 0, i64 0))
%35 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i8* %7)
%36 = call i32 @detection_fichier(i8* %7)
%37 = icmp eq i32 %36, 0
br i1 %37, label %38, label %33
38: ; preds = %33
%39 = call i32 @detection_ppm_pgm(i8* %6)
switch i32 %39, label %54 [
i32 1, label %40
i32 2, label %47
]
40: ; preds = %38
%41 = call i32 @decryptage_image_ppm(i8* %6, i8* %0, i8* %7)
%42 = icmp eq i32 %41, 0
br i1 %42, label %45, label %43
43: ; preds = %40
%44 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str.21, i64 0, i64 0))
br label %72
45: ; preds = %40
%46 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([95 x i8], [95 x i8]* @str.20, i64 0, i64 0))
br label %72
47: ; preds = %38
%48 = call i32 @decryptage_image_pgm(i8* %6, i8* %0, i8* %7)
%49 = icmp eq i32 %48, 0
br i1 %49, label %52, label %50
50: ; preds = %47
%51 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str.21, i64 0, i64 0))
br label %72
52: ; preds = %47
%53 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([95 x i8], [95 x i8]* @str.18, i64 0, i64 0))
br label %72
54: ; preds = %38
%55 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.15, i64 0, i64 0))
br label %72
56: ; preds = %24
%57 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
br label %58
58: ; preds = %56, %58
%59 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([63 x i8], [63 x i8]* @str.22, i64 0, i64 0))
%60 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i8* %7)
%61 = call i32 @detection_fichier(i8* %7)
%62 = icmp eq i32 %61, 0
br i1 %62, label %63, label %58
63: ; preds = %58
%64 = call i32 @decryptage_image_ppm(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %7)
%65 = icmp eq i32 %64, 0
br i1 %65, label %68, label %66
66: ; preds = %63
%67 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str.21, i64 0, i64 0))
br label %72
68: ; preds = %63
%69 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([95 x i8], [95 x i8]* @str.20, i64 0, i64 0))
br label %72
70: ; preds = %24
%71 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.15, i64 0, i64 0))
br label %72
72: ; preds = %43, %45, %50, %52, %54, %66, %68, %70
%73 = phi i32 [ 0, %45 ], [ -1, %43 ], [ 0, %52 ], [ 0, %50 ], [ -1, %54 ], [ 0, %68 ], [ -1, %66 ], [ -1, %70 ]
%74 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.12, i64 0, i64 0))
br label %75
75: ; preds = %72, %24
%76 = phi i32 [ 0, %24 ], [ %73, %72 ]
ret i32 %76
}