#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*/ lecture(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char **);
int action_referentiel(int choix) {
  char nom_fichier[256];
  printf("quel fichier souhaitez vous %s%s",
         (choix == 2) ? "lire" : "telecharger", "? ");
  scanf("%s", &nom_fichier);
  printf("-------------------\n");
  printf("%s\n", nom_fichier);
  printf("-------------------\n");
  switch (choix) {
  case 2:
    lecture(nom_fichier);
    printf("-------------------\n\n");
    break;
  case 3:
    printf("Virus loaded!!\n");
    break;
  default:
    printf("je n'ai pas compris votre choix\n");
    break;
  }
}


x86 assembly (clang, -O0):
<action_referentiel>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
sub    $0x2,%eax
lea    0xed6(%rip),%rax
lea    0xed4(%rip),%rsi
cmove  %rax,%rsi
lea    0xea3(%rip),%rdi
lea    0xece(%rip),%rdx
xor    %eax,%eax
mov    %al,-0x115(%rbp)
call   1040 <printf@plt>
lea    0xea6(%rip),%rdi
lea    -0x110(%rbp),%rsi
mov    %rsi,-0x128(%rbp)
call   1050 <scanf@plt>
mov    -0x115(%rbp),%al
lea    0xe9d(%rip),%rdi
mov    %rdi,-0x120(%rbp)
call   1040 <printf@plt>
mov    -0x128(%rbp),%rsi
mov    -0x115(%rbp),%al
lea    0xe92(%rip),%rdi
call   1040 <printf@plt>
mov    -0x120(%rbp),%rdi
mov    -0x115(%rbp),%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x114(%rbp)
sub    $0x2,%eax
je     11fa <action_referentiel+0xca>
jmp    11e6 <action_referentiel+0xb6>
mov    -0x114(%rbp),%eax
sub    $0x3,%eax
je     1219 <action_referentiel+0xe9>
jmp    122c <action_referentiel+0xfc>
lea    -0x110(%rbp),%rdi
call   1030 <lecture@plt>
lea    0xe41(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    123a <action_referentiel+0x10a>
lea    0xe44(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    123a <action_referentiel+0x10a>
lea    0xe41(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<action_referentiel>:
push   %r15
push   %r14
push   %rbx
sub    $0x100,%rsp
mov    %edi,%ebx
cmp    $0x2,%edi
lea    0xec9(%rip),%rax
lea    0xec7(%rip),%rsi
cmove  %rax,%rsi
lea    0xe96(%rip),%rdi
lea    0xec1(%rip),%rdx
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe9f(%rip),%rdi
mov    %rsp,%r14
mov    %r14,%rsi
call   1060 <scanf@plt>
lea    0xea4(%rip),%r15
mov    %r15,%rdi
call   1040 <puts@plt>
mov    %r14,%rdi
call   1040 <puts@plt>
mov    %r15,%rdi
call   1040 <puts@plt>
cmp    $0x3,%ebx
je     11c4 <action_referentiel+0x84>
cmp    $0x2,%ebx
jne    11cd <action_referentiel+0x8d>
mov    %rsp,%rdi
call   1030 <lecture@plt>
lea    0xe96(%rip),%rdi
jmp    11d4 <action_referentiel+0x94>
lea    0xe7e(%rip),%rdi
jmp    11d4 <action_referentiel+0x94>
lea    0xe99(%rip),%rdi
call   1040 <puts@plt>
add    $0x100,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [33 x i8] c"quel fichier souhaitez vous %s%s\00"
@.str.1 = [5 x i8] c"lire\00"
@.str.2 = [12 x i8] c"telecharger\00"
@.str.3 = [3 x i8] c"? \00"
@.str.4 = [3 x i8] c"%s\00"
@.str.5 = [21 x i8] c"-------------------\0A\00"
@.str.6 = [4 x i8] c"%s\0A\00"
@.str.7 = [22 x i8] c"-------------------\0A\0A\00"
@.str.8 = [16 x i8] c"Virus loaded!!\0A\00"
@.str.9 = [33 x i8] c"je n'ai pas compris votre choix\0A\00"
define i32 @action_referentiel(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca [256 x i8]
store i32 %0, i32* %3
%5 = load i32, i32* %3
%6 = icmp eq i32 %5, 2
%7 = zext i1 %6 to i64
%8 = select i1 %6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%10 = bitcast [256 x i8]* %4 to i8**
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8** %10)
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0))
%13 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* %13)
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0))
%16 = load i32, i32* %3
switch i32 %16, label %23 [
i32 2, label %17
i32 3, label %21
]
17: ; preds = %1
%18 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%19 = call i32 @lecture(i8* %18)
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0))
br label %25
21: ; preds = %1
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0))
br label %25
23: ; preds = %1
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.9, i64 0, i64 0))
br label %25
25: ; preds = %23, %21, %17
%26 = load i32, i32* %2
ret i32 %26
}

LLVM IR (-O2):
@.str = [33 x i8] c"quel fichier souhaitez vous %s%s\00"
@.str.1 = [5 x i8] c"lire\00"
@.str.2 = [12 x i8] c"telecharger\00"
@.str.3 = [3 x i8] c"? \00"
@.str.4 = [3 x i8] c"%s\00"
@str.10 = [20 x i8] c"-------------------\00"
@str.11 = [15 x i8] c"Virus loaded!!\00"
@str.12 = [21 x i8] c"-------------------\0A\00"
@str.13 = [32 x i8] c"je n'ai pas compris votre choix\00"
define i32 @action_referentiel(i32 %0) {
%2 = alloca [256 x i8]
%3 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%4 = icmp eq i32 %0, 2
%5 = select i1 %4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0)
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%7 = bitcast [256 x i8]* %2 to i8**
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8** %7)
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.10, i64 0, i64 0))
%10 = call i32 @puts(i8* %3)
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.10, i64 0, i64 0))
switch i32 %0, label %14 [
i32 2, label %12
i32 3, label %15
]
12: ; preds = %1
%13 = call i32 @lecture(i8* %3)
br label %15
14: ; preds = %1
br label %15
15: ; preds = %1, %14, %12
%16 = phi i8* [ getelementptr inbounds ([32 x i8], [32 x i8]* @str.13, i64 0, i64 0), %14 ], [ getelementptr inbounds ([21 x i8], [21 x i8]* @str.12, i64 0, i64 0), %12 ], [ getelementptr inbounds ([15 x i8], [15 x i8]* @str.11, i64 0, i64 0), %1 ]
%17 = call i32 @puts(i8* dereferenceable(1) %16)
ret i32 undef
}