#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 doAddition(int, int);
int doDivision(int, int);
int doMultiplication(int, int);
int doPuissance(int, int);
int doSubstraction(int, int);
int /*<<< orphan*/ puts(char *);
int doOperation(int selection, int val1, int val2) {
  int op_result;
  switch (selection) {
  case 1:
    op_result = doAddition(val1, val2);
    break;
  case 2:
    op_result = doSubstraction(val1, val2);
    break;
  case 3:
    op_result = doMultiplication(val1, val2);
    break;
  case 4:
    op_result = doDivision(val1, val2);
    break;
  case 5:
    op_result = doPuissance(val1, val2);
    break;
  case 6:
    break;
  default:
    puts("Faire un choix compris entre 1 et 6");
  }
  return op_result;
}


x86 assembly (clang, -O0):
<doOperation>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x5,%eax
ja     11fe <doOperation+0x9e>
mov    -0x18(%rbp),%rax
lea    0xe6f(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1080 <doAddition@plt>
mov    %eax,-0x10(%rbp)
jmp    120a <doOperation+0xaa>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1040 <doSubstraction@plt>
mov    %eax,-0x10(%rbp)
jmp    120a <doOperation+0xaa>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1060 <doMultiplication@plt>
mov    %eax,-0x10(%rbp)
jmp    120a <doOperation+0xaa>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1070 <doDivision@plt>
mov    %eax,-0x10(%rbp)
jmp    120a <doOperation+0xaa>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1050 <doPuissance@plt>
mov    %eax,-0x10(%rbp)
jmp    120a <doOperation+0xaa>
jmp    120a <doOperation+0xaa>
lea    0xe13(%rip),%rdi
call   1030 <puts@plt>
mov    -0x10(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<doOperation>:
push   %rax
add    $0xffffffff,%edi
cmp    $0x5,%edi
ja     1183 <doOperation+0x23>
lea    0xe90(%rip),%rax
movslq (%rax,%rdi,4),%rcx
add    %rax,%rcx
jmp    *%rcx
mov    %esi,%edi
mov    %edx,%esi
pop    %rax
jmp    1080 <doAddition@plt>
lea    0xe8e(%rip),%rdi
call   1030 <puts@plt>
pop    %rcx
ret
mov    %esi,%edi
mov    %edx,%esi
pop    %rax
jmp    1040 <doSubstraction@plt>
mov    %esi,%edi
mov    %edx,%esi
pop    %rax
jmp    1060 <doMultiplication@plt>
mov    %esi,%edi
mov    %edx,%esi
pop    %rax
jmp    1070 <doDivision@plt>
mov    %esi,%edi
mov    %edx,%esi
pop    %rax
jmp    1050 <doPuissance@plt>

LLVM IR (-O0):
@.str = [36 x i8] c"Faire un choix compris entre 1 et 6\00"
define i32 @doOperation(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%8 = load i32, i32* %4
switch i32 %8, label %30 [
i32 1, label %9
i32 2, label %13
i32 3, label %17
i32 4, label %21
i32 5, label %25
i32 6, label %29
]
9: ; preds = %3
%10 = load i32, i32* %5
%11 = load i32, i32* %6
%12 = call i32 @doAddition(i32 %10, i32 %11)
store i32 %12, i32* %7
br label %32
13: ; preds = %3
%14 = load i32, i32* %5
%15 = load i32, i32* %6
%16 = call i32 @doSubstraction(i32 %14, i32 %15)
store i32 %16, i32* %7
br label %32
17: ; preds = %3
%18 = load i32, i32* %5
%19 = load i32, i32* %6
%20 = call i32 @doMultiplication(i32 %18, i32 %19)
store i32 %20, i32* %7
br label %32
21: ; preds = %3
%22 = load i32, i32* %5
%23 = load i32, i32* %6
%24 = call i32 @doDivision(i32 %22, i32 %23)
store i32 %24, i32* %7
br label %32
25: ; preds = %3
%26 = load i32, i32* %5
%27 = load i32, i32* %6
%28 = call i32 @doPuissance(i32 %26, i32 %27)
store i32 %28, i32* %7
br label %32
29: ; preds = %3
br label %32
30: ; preds = %3
%31 = call i32 @puts(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
br label %32
32: ; preds = %30, %29, %25, %21, %17, %13, %9
%33 = load i32, i32* %7
ret i32 %33
}

LLVM IR (-O2):
@.str = [36 x i8] c"Faire un choix compris entre 1 et 6\00"
define i32 @doOperation(i32 %0, i32 %1, i32 %2) {
switch i32 %0, label %14 [
i32 1, label %4
i32 2, label %6
i32 3, label %8
i32 4, label %10
i32 5, label %12
i32 6, label %16
]
4: ; preds = %3
%5 = tail call i32 @doAddition(i32 %1, i32 %2)
br label %16
6: ; preds = %3
%7 = tail call i32 @doSubstraction(i32 %1, i32 %2)
br label %16
8: ; preds = %3
%9 = tail call i32 @doMultiplication(i32 %1, i32 %2)
br label %16
10: ; preds = %3
%11 = tail call i32 @doDivision(i32 %1, i32 %2)
br label %16
12: ; preds = %3
%13 = tail call i32 @doPuissance(i32 %1, i32 %2)
br label %16
14: ; preds = %3
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
br label %16
16: ; preds = %14, %3, %12, %10, %8, %6, %4
%17 = phi i32 [ undef, %14 ], [ undef, %3 ], [ %13, %12 ], [ %11, %10 ], [ %9, %8 ], [ %7, %6 ], [ %5, %4 ]
ret i32 %17
}