#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*/ acheterBoutique();
int /*<<< orphan*/ ajouterPotionInventaire(unsigned int, int /*<<< orphan*/,
                                           unsigned int);
int /*<<< orphan*/ attendre(double);
int /*<<< orphan*/ boutique();
unsigned int calculerPrixPotionAcheterBoutique(unsigned int, char *,
                                               unsigned int);
unsigned int demanderConfirmation(char *, int);
int /*<<< orphan*/ enleverTekInventaire(unsigned int);
int /*<<< orphan*/ formaterNomPotion(char *);
scalar_t__ peutAcheterCommande(unsigned int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ recupererTypePotion(char *);
int sscanf(char const *, char *, unsigned int *, char *, unsigned int *);
scalar_t__ strcmp(char const *, char *);
void executerCommandeAcheterBoutique(const char *commande) {
  char typePotion[200];
  unsigned int quantitePotion, niveauPotion;
  unsigned int prixCommande;
  unsigned int choixJoueur;
  if (strcmp(commande, "-1") == 0)
    boutique();
  else if (sscanf(commande, "%d %s %d", &quantitePotion, typePotion,
                  &niveauPotion) == 3) {
    formaterNomPotion(typePotion);
    printf("Vous souhaitez donc acheter %d potion(s) de %s de niveau %d.\n",
           quantitePotion, typePotion, niveauPotion);
    prixCommande = calculerPrixPotionAcheterBoutique(quantitePotion, typePotion,
                                                     niveauPotion);
    printf("Ca vous fera %d tek.\n", prixCommande);
    choixJoueur = demanderConfirmation(
        "Etes vous sur de vouloir faire cet achat ? (0/1)", 1);
    if (choixJoueur == 1) {
      if (peutAcheterCommande(prixCommande)) {
        enleverTekInventaire(prixCommande);
        ajouterPotionInventaire(quantitePotion, recupererTypePotion(typePotion),
                                niveauPotion);
      }
    }
    acheterBoutique();
  } else {
    printf("Veuillez entrer une commande correcte !\n");
    attendre(1.2);
    acheterBoutique();
  }
}


x86 assembly (clang, -O0):
<executerCommandeAcheterBoutique>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe1e(%rip),%rsi
call   10b0 <strcmp@plt>
cmp    $0x0,%rax
jne    1205 <executerCommandeAcheterBoutique+0x35>
mov    $0x0,%al
call   1030 <boutique@plt>
jmp    1339 <executerCommandeAcheterBoutique+0x169>
mov    -0x8(%rbp),%rdi
lea    -0xd0(%rbp),%rcx
lea    0xdf4(%rip),%rsi
lea    -0xd4(%rbp),%rdx
lea    -0xd8(%rbp),%r8
call   10e0 <sscanf@plt>
cmp    $0x3,%eax
jne    1312 <executerCommandeAcheterBoutique+0x142>
lea    -0xd0(%rbp),%rdi
call   10c0 <formaterNomPotion@plt>
mov    -0xd4(%rbp),%esi
lea    -0xd0(%rbp),%rdx
mov    -0xd8(%rbp),%ecx
lea    0xdbb(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0xd4(%rbp),%edi
lea    -0xd0(%rbp),%rsi
mov    -0xd8(%rbp),%edx
call   1090 <calculerPrixPotionAcheterBoutique@plt>
mov    %eax,-0xdc(%rbp)
mov    -0xdc(%rbp),%esi
lea    0xdc7(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xdcf(%rip),%rdi
mov    $0x1,%esi
call   1040 <demanderConfirmation@plt>
mov    %eax,-0xe0(%rbp)
cmpl   $0x1,-0xe0(%rbp)
jne    1306 <executerCommandeAcheterBoutique+0x136>
mov    -0xdc(%rbp),%edi
call   1060 <peutAcheterCommande@plt>
cmp    $0x0,%rax
je     1301 <executerCommandeAcheterBoutique+0x131>
mov    -0xdc(%rbp),%edi
call   1080 <enleverTekInventaire@plt>
mov    -0xd4(%rbp),%eax
mov    %eax,-0xe4(%rbp)
lea    -0xd0(%rbp),%rdi
call   10d0 <recupererTypePotion@plt>
mov    -0xe4(%rbp),%edi
mov    %eax,%esi
mov    -0xd8(%rbp),%edx
call   1050 <ajouterPotionInventaire@plt>
jmp    1306 <executerCommandeAcheterBoutique+0x136>
mov    $0x0,%al
call   10f0 <acheterBoutique@plt>
jmp    1334 <executerCommandeAcheterBoutique+0x164>
lea    0xd80(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movsd  0xcd8(%rip),%xmm0
call   10a0 <attendre@plt>
mov    $0x0,%al
call   10f0 <acheterBoutique@plt>
jmp    1339 <executerCommandeAcheterBoutique+0x169>
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<executerCommandeAcheterBoutique>:
push   %rbx
sub    $0xe0,%rsp
mov    %rdi,%rbx
lea    0xe16(%rip),%rsi
call   10c0 <strcmp@plt>
test   %rax,%rax
je     12b5 <executerCommandeAcheterBoutique+0xd5>
lea    0xe04(%rip),%rsi
lea    0xc(%rsp),%rdx
lea    0x10(%rsp),%rcx
lea    0x8(%rsp),%r8
mov    %rbx,%rdi
call   10f0 <sscanf@plt>
cmp    $0x3,%eax
jne    12c4 <executerCommandeAcheterBoutique+0xe4>
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   10d0 <formaterNomPotion@plt>
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%ecx
lea    0xdd1(%rip),%rdi
mov    %rbx,%rdx
xor    %eax,%eax
call   1080 <printf@plt>
mov    0xc(%rsp),%edi
mov    0x8(%rsp),%edx
mov    %rbx,%rsi
call   10a0 <calculerPrixPotionAcheterBoutique@plt>
mov    %eax,%ebx
lea    0xdec(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xdf2(%rip),%rdi
mov    $0x1,%esi
call   1050 <demanderConfirmation@plt>
cmp    $0x1,%eax
jne    12dd <executerCommandeAcheterBoutique+0xfd>
mov    %ebx,%edi
call   1070 <peutAcheterCommande@plt>
test   %rax,%rax
je     12dd <executerCommandeAcheterBoutique+0xfd>
mov    %ebx,%edi
call   1090 <enleverTekInventaire@plt>
mov    0xc(%rsp),%ebx
lea    0x10(%rsp),%rdi
call   10e0 <recupererTypePotion@plt>
mov    0x8(%rsp),%edx
mov    %ebx,%edi
mov    %eax,%esi
call   1060 <ajouterPotionInventaire@plt>
jmp    12dd <executerCommandeAcheterBoutique+0xfd>
xor    %eax,%eax
add    $0xe0,%rsp
pop    %rbx
jmp    1030 <boutique@plt>
lea    0xdce(%rip),%rdi
call   1040 <puts@plt>
movsd  0xd28(%rip),%xmm0
call   10b0 <attendre@plt>
xor    %eax,%eax
call   1100 <acheterBoutique@plt>
add    $0xe0,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"-1\00"
@.str.1 = [9 x i8] c"%d %s %d\00"
@.str.2 = [62 x i8] c"Vous souhaitez donc acheter %d potion(s) de %s de niveau %d.\0A\00"
@.str.3 = [22 x i8] c"Ca vous fera %d tek.\0A\00"
@.str.4 = [49 x i8] c"Etes vous sur de vouloir faire cet achat ? (0/1)\00"
@.str.5 = [41 x i8] c"Veuillez entrer une commande correcte !\0A\00"
define void @executerCommandeAcheterBoutique(i8* %0) {
%2 = alloca i8*
%3 = alloca [200 x i8]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %2
%8 = load i8*, i8** %2
%9 = call i64 @strcmp(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %1
%12 = call i32 (...) @boutique()
br label %54
13: ; preds = %1
%14 = load i8*, i8** %2
%15 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 0
%16 = call i32 @sscanf(i8* %14, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32* %4, i8* %15, i32* %5)
%17 = icmp eq i32 %16, 3
br i1 %17, label %18, label %49
18: ; preds = %13
%19 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 0
%20 = call i32 @formaterNomPotion(i8* %19)
%21 = load i32, i32* %4
%22 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 0
%23 = load i32, i32* %5
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.2, i64 0, i64 0), i32 %21, i8* %22, i32 %23)
%25 = load i32, i32* %4
%26 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 0
%27 = load i32, i32* %5
%28 = call i32 @calculerPrixPotionAcheterBoutique(i32 %25, i8* %26, i32 %27)
store i32 %28, i32* %6
%29 = load i32, i32* %6
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 %29)
%31 = call i32 @demanderConfirmation(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.4, i64 0, i64 0), i32 1)
store i32 %31, i32* %7
%32 = load i32, i32* %7
%33 = icmp eq i32 %32, 1
br i1 %33, label %34, label %47
34: ; preds = %18
%35 = load i32, i32* %6
%36 = call i64 @peutAcheterCommande(i32 %35)
%37 = icmp ne i64 %36, 0
br i1 %37, label %38, label %46
38: ; preds = %34
%39 = load i32, i32* %6
%40 = call i32 @enleverTekInventaire(i32 %39)
%41 = load i32, i32* %4
%42 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 0
%43 = call i32 @recupererTypePotion(i8* %42)
%44 = load i32, i32* %5
%45 = call i32 @ajouterPotionInventaire(i32 %41, i32 %43, i32 %44)
br label %46
46: ; preds = %38, %34
br label %47
47: ; preds = %46, %18
%48 = call i32 (...) @acheterBoutique()
br label %53
49: ; preds = %13
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.5, i64 0, i64 0))
%51 = call i32 @attendre(double 1.200000e+00)
%52 = call i32 (...) @acheterBoutique()
br label %53
53: ; preds = %49, %47
br label %54
54: ; preds = %53, %11
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"-1\00"
@.str.1 = [9 x i8] c"%d %s %d\00"
@.str.2 = [62 x i8] c"Vous souhaitez donc acheter %d potion(s) de %s de niveau %d.\0A\00"
@.str.3 = [22 x i8] c"Ca vous fera %d tek.\0A\00"
@.str.4 = [49 x i8] c"Etes vous sur de vouloir faire cet achat ? (0/1)\00"
@str = [40 x i8] c"Veuillez entrer une commande correcte !\00"
define void @executerCommandeAcheterBoutique(i8* %0) {
%2 = alloca [200 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 0
%6 = bitcast i32* %3 to i8*
%7 = bitcast i32* %4 to i8*
%8 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %1
%11 = tail call i32 (...) @boutique()
br label %41
12: ; preds = %1
%13 = call i32 @sscanf(i8* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32* %3, i8* %5, i32* %4)
%14 = icmp eq i32 %13, 3
br i1 %14, label %15, label %37
15: ; preds = %12
%16 = call i32 @formaterNomPotion(i8* %5)
%17 = load i32, i32* %3
%18 = load i32, i32* %4
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([62 x i8], [62 x i8]* @.str.2, i64 0, i64 0), i32 %17, i8* %5, i32 %18)
%20 = load i32, i32* %3
%21 = load i32, i32* %4
%22 = call i32 @calculerPrixPotionAcheterBoutique(i32 %20, i8* %5, i32 %21)
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 %22)
%24 = call i32 @demanderConfirmation(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.4, i64 0, i64 0), i32 1)
%25 = icmp eq i32 %24, 1
br i1 %25, label %26, label %35
26: ; preds = %15
%27 = call i64 @peutAcheterCommande(i32 %22)
%28 = icmp eq i64 %27, 0
br i1 %28, label %35, label %29
29: ; preds = %26
%30 = call i32 @enleverTekInventaire(i32 %22)
%31 = load i32, i32* %3
%32 = call i32 @recupererTypePotion(i8* %5)
%33 = load i32, i32* %4
%34 = call i32 @ajouterPotionInventaire(i32 %31, i32 %32, i32 %33)
br label %35
35: ; preds = %26, %29, %15
%36 = call i32 (...) @acheterBoutique()
br label %41
37: ; preds = %12
%38 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str, i64 0, i64 0))
%39 = call i32 @attendre(double 1.200000e+00)
%40 = call i32 (...) @acheterBoutique()
br label %41
41: ; preds = %35, %37, %10
ret void
}