#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 */
typedef int /*<<< orphan*/ table;

/* Variables and functions */
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ show_table(float *, int);
int /*<<< orphan*/ tri_insertion_croissant(float *, int);
int /*<<< orphan*/ tri_insertion_decroissant(float *, int);
int main() {
  int choix = 0;
  float table[10] = {5, 4, 8, 3, 9, 6, 2, 7, 4, 3};
  int table_size = sizeof(table) / sizeof(table[0]);
  while (choix < 1 || choix > 2) {
    printf("Quelle sorte de tri voulez-vous?\n");
    printf("1) Croissant\n2) Décroissant\nChoix: ");
    scanf("%d", &choix);
  }
  switch (choix) {
  case 1:
    show_table(table, table_size);
    tri_insertion_croissant(table, table_size);
    break;
  case 2:
    show_table(table, table_size);
    tri_insertion_decroissant(table, table_size);
    break;
  }
  show_table(table, table_size);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
lea    -0x30(%rbp),%rdi
lea    0xe7f(%rip),%rsi
mov    $0x28,%edx
call   1040 <memcpy@plt>
movl   $0xa,-0x34(%rbp)
mov    $0x1,%al
cmpl   $0x1,-0x8(%rbp)
mov    %al,-0x35(%rbp)
jl     11ab <main+0x4b>
cmpl   $0x2,-0x8(%rbp)
setg   %al
mov    %al,-0x35(%rbp)
mov    -0x35(%rbp),%al
test   $0x1,%al
jne    11bb <main+0x5b>
jmp    11e8 <main+0x88>
lea    0xe66(%rip),%rdi
call   1030 <printf@plt>
lea    0xe7c(%rip),%rdi
call   1030 <printf@plt>
lea    0xe95(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
jmp    1192 <main+0x32>
mov    -0x8(%rbp),%eax
mov    %eax,-0x3c(%rbp)
sub    $0x1,%eax
je     120d <main+0xad>
jmp    11fc <main+0x9c>
mov    -0x3c(%rbp),%eax
sub    $0x2,%eax
je     122a <main+0xca>
jmp    1242 <main+0xe2>
lea    -0x30(%rbp),%rdi
mov    -0x34(%rbp),%esi
call   1080 <show_table@plt>
lea    -0x30(%rbp),%rdi
mov    -0x34(%rbp),%esi
call   1060 <tri_insertion_croissant@plt>
jmp    1242 <main+0xe2>
lea    -0x30(%rbp),%rdi
mov    -0x34(%rbp),%esi
call   1080 <show_table@plt>
lea    -0x30(%rbp),%rdi
mov    -0x34(%rbp),%esi
call   1070 <tri_insertion_decroissant@plt>
lea    -0x30(%rbp),%rdi
mov    -0x34(%rbp),%esi
call   1080 <show_table@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x38,%rsp
movl   $0x0,0xc(%rsp)
mov    0xea6(%rip),%rax
mov    %rax,0x30(%rsp)
movaps 0xe8a(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xe6e(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
lea    0xeb2(%rip),%r14
lea    0xe83(%rip),%r15
lea    0xea1(%rip),%r12
lea    0xc(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%eax
lea    -0x3(%rax),%ecx
cmp    $0xfffffffe,%ecx
jb     11c0 <main+0x60>
cmp    $0x2,%eax
je     1212 <main+0xb2>
cmp    $0x1,%eax
jne    1231 <main+0xd1>
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0xa,%esi
call   1080 <show_table@plt>
mov    %rbx,%rdi
mov    $0xa,%esi
call   1060 <tri_insertion_croissant@plt>
jmp    1231 <main+0xd1>
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0xa,%esi
call   1080 <show_table@plt>
mov    %rbx,%rdi
mov    $0xa,%esi
call   1070 <tri_insertion_decroissant@plt>
lea    0x10(%rsp),%rdi
mov    $0xa,%esi
call   1080 <show_table@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.table = [10 x float] [float 5.000000e+00, float 4.000000e+00, float 8.000000e+00, float 3.000000e+00, float 9.000000e+00, float 6.000000e+00, float 2.000000e+00, float 7.000000e+00, float 4.000000e+00, float 3.000000e+00]
@.str = [34 x i8] c"Quelle sorte de tri voulez-vous?\0A\00"
@.str.1 = [37 x i8] c"1) Croissant\0A2) D\C3\A9croissant\0AChoix: \00"
@.str.2 = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [10 x float]
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
%5 = bitcast [10 x float]* %3 to i8*
store i32 10, i32* %4
br label %6
6: ; preds = %14, %0
%7 = load i32, i32* %2
%8 = icmp slt i32 %7, 1
br i1 %8, label %12, label %9
9: ; preds = %6
%10 = load i32, i32* %2
%11 = icmp sgt i32 %10, 2
br label %12
12: ; preds = %9, %6
%13 = phi i1 [ true, %6 ], [ %11, %9 ]
br i1 %13, label %14, label %18
14: ; preds = %12
%15 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%16 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0))
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
br label %6
18: ; preds = %12
%19 = load i32, i32* %2
switch i32 %19, label %34 [
i32 1, label %20
i32 2, label %27
]
20: ; preds = %18
%21 = getelementptr inbounds [10 x float], [10 x float]* %3, i64 0, i64 0
%22 = load i32, i32* %4
%23 = call i32 @show_table(float* %21, i32 %22)
%24 = getelementptr inbounds [10 x float], [10 x float]* %3, i64 0, i64 0
%25 = load i32, i32* %4
%26 = call i32 @tri_insertion_croissant(float* %24, i32 %25)
br label %34
27: ; preds = %18
%28 = getelementptr inbounds [10 x float], [10 x float]* %3, i64 0, i64 0
%29 = load i32, i32* %4
%30 = call i32 @show_table(float* %28, i32 %29)
%31 = getelementptr inbounds [10 x float], [10 x float]* %3, i64 0, i64 0
%32 = load i32, i32* %4
%33 = call i32 @tri_insertion_decroissant(float* %31, i32 %32)
br label %34
34: ; preds = %18, %27, %20
%35 = getelementptr inbounds [10 x float], [10 x float]* %3, i64 0, i64 0
%36 = load i32, i32* %4
%37 = call i32 @show_table(float* %35, i32 %36)
ret i32 0
}

LLVM IR (-O2):
@__const.main.table = [10 x float] [float 5.000000e+00, float 4.000000e+00, float 8.000000e+00, float 3.000000e+00, float 9.000000e+00, float 6.000000e+00, float 2.000000e+00, float 7.000000e+00, float 4.000000e+00, float 3.000000e+00]
@.str.1 = [37 x i8] c"1) Croissant\0A2) D\C3\A9croissant\0AChoix: \00"
@.str.2 = [3 x i8] c"%d\00"
@str = [33 x i8] c"Quelle sorte de tri voulez-vous?\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [10 x float]
%3 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%4 = bitcast [10 x float]* %2 to i8*
br label %5
5: ; preds = %0, %5
%6 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str, i64 0, i64 0))
%7 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%9 = load i32, i32* %1
%10 = add i32 %9, -3
%11 = icmp ult i32 %10, -2
br i1 %11, label %5, label %12
12: ; preds = %5
switch i32 %9, label %21 [
i32 1, label %13
i32 2, label %17
]
13: ; preds = %12
%14 = getelementptr inbounds [10 x float], [10 x float]* %2, i64 0, i64 0
%15 = call i32 @show_table(float* %14, i32 10)
%16 = call i32 @tri_insertion_croissant(float* %14, i32 10)
br label %21
17: ; preds = %12
%18 = getelementptr inbounds [10 x float], [10 x float]* %2, i64 0, i64 0
%19 = call i32 @show_table(float* %18, i32 10)
%20 = call i32 @tri_insertion_decroissant(float* %18, i32 10)
br label %21
21: ; preds = %12, %17, %13
%22 = getelementptr inbounds [10 x float], [10 x float]* %2, i64 0, i64 0
%23 = call i32 @show_table(float* %22, i32 10)
ret i32 0
}