#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 EXIT_SUCCESS;
int choixMode();
int demandeNombre();
int /*<<< orphan*/ printf(char *, ...);
double threadsCalcul(int, int);
int main() {
  printf("Fibonacci\n");
  int choix = choixMode();
  if (choix == 1) {
    printf("mode auto\n");
    int k_max = 64;
    int n_max = 100000000;
    int n, k;
    for (n = 10; n <= n_max; n *= 10) {
      printf("---------------taille du TAB = %d---------------\n", n);
      for (k = 1024; k >= 1; k /= 2) {
        printf(" %d \t %d \t %f\n\n", n, k, threadsCalcul(n, k));
      }
    }
  } else if (choix == 0) {
    printf("mode manuel\n");
    printf("Entrez la taille du tableau n: ");
    int n = demandeNombre();
    printf("Entrez le nombre de threads k: ");
    int k = demandeNombre();
    threadsCalcul(n, k);
  } else
    printf("problème dans la fonction choixMode()\n");
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1030 <choixMode@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    1216 <main+0xd6>
lea    0xe93(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x40,-0xc(%rbp)
movl   $0x5f5e100,-0x10(%rbp)
movl   $0xa,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jg     1211 <main+0xd1>
mov    -0x14(%rbp),%esi
lea    0xe6c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x400,-0x18(%rbp)
cmpl   $0x1,-0x18(%rbp)
jl     1200 <main+0xc0>
mov    -0x14(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1040 <threadsCalcul@plt>
mov    -0x28(%rbp),%esi
mov    -0x24(%rbp),%edx
lea    0xe62(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x18(%rbp)
jmp    11b8 <main+0x78>
jmp    1205 <main+0xc5>
imul   $0xa,-0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    1194 <main+0x54>
jmp    1281 <main+0x141>
cmpl   $0x0,-0x8(%rbp)
jne    126e <main+0x12e>
lea    0xe31(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe30(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1060 <demandeNombre@plt>
mov    %eax,-0x1c(%rbp)
lea    0xe38(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1060 <demandeNombre@plt>
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%edi
mov    -0x20(%rbp),%esi
call   1040 <threadsCalcul@plt>
jmp    127c <main+0x13c>
lea    0xe30(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1281 <main+0x141>
mov    0x2d58(%rip),%rax
mov    (%rax),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
lea    0xf26(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1030 <choixMode@plt>
test   %eax,%eax
je     12fe <main+0x1ae>
cmp    $0x1,%eax
jne    1341 <main+0x1f1>
lea    0xf3f(%rip),%rdi
call   1040 <puts@plt>
mov    $0xa,%ebx
lea    0xe6f(%rip),%r14
lea    0xe9a(%rip),%r15
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %ebx,%edi
mov    $0x400,%esi
call   1050 <threadsCalcul@plt>
mov    %r15,%rdi
mov    %ebx,%esi
mov    $0x400,%edx
mov    $0x1,%al
call   1060 <printf@plt>
mov    %ebx,%edi
mov    $0x200,%esi
call   1050 <threadsCalcul@plt>
mov    %r15,%rdi
mov    %ebx,%esi
mov    $0x200,%edx
mov    $0x1,%al
call   1060 <printf@plt>
mov    %ebx,%edi
mov    $0x100,%esi
call   1050 <threadsCalcul@plt>
mov    %r15,%rdi
mov    %ebx,%esi
mov    $0x100,%edx
mov    $0x1,%al
call   1060 <printf@plt>
mov    %ebx,%edi
mov    $0x80,%esi
call   1050 <threadsCalcul@plt>
mov    %r15,%rdi
mov    %ebx,%esi
mov    $0x80,%edx
mov    $0x1,%al
call   1060 <printf@plt>
mov    %ebx,%edi
mov    $0x40,%esi
call   1050 <threadsCalcul@plt>
mov    %r15,%rdi
mov    %ebx,%esi
mov    $0x40,%edx
mov    $0x1,%al
call   1060 <printf@plt>
mov    %ebx,%edi
mov    $0x20,%esi
call   1050 <threadsCalcul@plt>
mov    %r15,%rdi
mov    %ebx,%esi
mov    $0x20,%edx
mov    $0x1,%al
call   1060 <printf@plt>
mov    %ebx,%edi
mov    $0x10,%esi
call   1050 <threadsCalcul@plt>
mov    %r15,%rdi
mov    %ebx,%esi
mov    $0x10,%edx
mov    $0x1,%al
call   1060 <printf@plt>
mov    %ebx,%edi
mov    $0x8,%esi
call   1050 <threadsCalcul@plt>
mov    %r15,%rdi
mov    %ebx,%esi
mov    $0x8,%edx
mov    $0x1,%al
call   1060 <printf@plt>
mov    %ebx,%edi
mov    $0x4,%esi
call   1050 <threadsCalcul@plt>
mov    %r15,%rdi
mov    %ebx,%esi
mov    $0x4,%edx
mov    $0x1,%al
call   1060 <printf@plt>
mov    %ebx,%edi
mov    $0x2,%esi
call   1050 <threadsCalcul@plt>
mov    %r15,%rdi
mov    %ebx,%esi
mov    $0x2,%edx
mov    $0x1,%al
call   1060 <printf@plt>
mov    %ebx,%edi
mov    $0x1,%esi
call   1050 <threadsCalcul@plt>
mov    %r15,%rdi
mov    %ebx,%esi
mov    $0x1,%edx
mov    $0x1,%al
call   1060 <printf@plt>
add    %ebx,%ebx
lea    (%rbx,%rbx,4),%ebx
cmp    $0x5f5e101,%ebx
jb     11a0 <main+0x50>
jmp    134d <main+0x1fd>
lea    0xdae(%rip),%rdi
call   1040 <puts@plt>
lea    0xd31(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
call   1070 <demandeNombre@plt>
mov    %eax,%ebx
lea    0xd3a(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
call   1070 <demandeNombre@plt>
mov    %ebx,%edi
mov    %eax,%esi
call   1050 <threadsCalcul@plt>
jmp    134d <main+0x1fd>
lea    0xd44(%rip),%rdi
call   1040 <puts@plt>
mov    0x2c8c(%rip),%rax
mov    (%rax),%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [11 x i8] c"Fibonacci\0A\00"
@.str.1 = [11 x i8] c"mode auto\0A\00"
@.str.2 = [50 x i8] c"---------------taille du TAB = %d---------------\0A\00"
@.str.3 = [16 x i8] c" %d \09 %d \09 %f\0A\0A\00"
@.str.4 = [13 x i8] c"mode manuel\0A\00"
@.str.5 = [32 x i8] c"Entrez la taille du tableau n: \00"
@.str.6 = [32 x i8] c"Entrez le nombre de threads k: \00"
@.str.7 = [40 x i8] c"probl\C3\A8me dans la fonction choixMode()\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %1
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%10 = call i32 (...) @choixMode()
store i32 %10, i32* %2
%11 = load i32, i32* %2
%12 = icmp eq i32 %11, 1
br i1 %12, label %13, label %40
13: ; preds = %0
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
store i32 64, i32* %3
store i32 100000000, i32* %4
store i32 10, i32* %5
br label %15
15: ; preds = %36, %13
%16 = load i32, i32* %5
%17 = load i32, i32* %4
%18 = icmp sle i32 %16, %17
br i1 %18, label %19, label %39
19: ; preds = %15
%20 = load i32, i32* %5
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.2, i64 0, i64 0), i32 %20)
store i32 1024, i32* %6
br label %22
22: ; preds = %32, %19
%23 = load i32, i32* %6
%24 = icmp sge i32 %23, 1
br i1 %24, label %25, label %35
25: ; preds = %22
%26 = load i32, i32* %5
%27 = load i32, i32* %6
%28 = load i32, i32* %5
%29 = load i32, i32* %6
%30 = call double @threadsCalcul(i32 %28, i32 %29)
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %26, i32 %27, double %30)
br label %32
32: ; preds = %25
%33 = load i32, i32* %6
%34 = sdiv i32 %33, 2
store i32 %34, i32* %6
br label %22
35: ; preds = %22
br label %36
36: ; preds = %35
%37 = load i32, i32* %5
%38 = mul nsw i32 %37, 10
store i32 %38, i32* %5
br label %15
39: ; preds = %15
br label %55
40: ; preds = %0
%41 = load i32, i32* %2
%42 = icmp eq i32 %41, 0
br i1 %42, label %43, label %52
43: ; preds = %40
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0))
%46 = call i32 (...) @demandeNombre()
store i32 %46, i32* %7
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0))
%48 = call i32 (...) @demandeNombre()
store i32 %48, i32* %8
%49 = load i32, i32* %7
%50 = load i32, i32* %8
%51 = call double @threadsCalcul(i32 %49, i32 %50)
br label %54
52: ; preds = %40
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.7, i64 0, i64 0))
br label %54
54: ; preds = %52, %43
br label %55
55: ; preds = %54, %39
%56 = load i32, i32* @EXIT_SUCCESS
ret i32 %56
}

LLVM IR (-O2):
@.str.2 = [50 x i8] c"---------------taille du TAB = %d---------------\0A\00"
@.str.3 = [16 x i8] c" %d \09 %d \09 %f\0A\0A\00"
@.str.5 = [32 x i8] c"Entrez la taille du tableau n: \00"
@.str.6 = [32 x i8] c"Entrez le nombre de threads k: \00"
@EXIT_SUCCESS = global i32 0
@str = [10 x i8] c"Fibonacci\00"
@str.8 = [39 x i8] c"probl\C3\A8me dans la fonction choixMode()\00"
@str.9 = [12 x i8] c"mode manuel\00"
@str.10 = [10 x i8] c"mode auto\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 (...) @choixMode()
switch i32 %2, label %39 [
i32 1, label %3
i32 0, label %32
]
3: ; preds = %0
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.10, i64 0, i64 0))
br label %5
5: ; preds = %3, %5
%6 = phi i32 [ 10, %3 ], [ %30, %5 ]
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str.2, i64 0, i64 0), i32 %6)
%8 = tail call double @threadsCalcul(i32 %6, i32 1024)
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %6, i32 1024, double %8)
%10 = tail call double @threadsCalcul(i32 %6, i32 512)
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %6, i32 512, double %10)
%12 = tail call double @threadsCalcul(i32 %6, i32 256)
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %6, i32 256, double %12)
%14 = tail call double @threadsCalcul(i32 %6, i32 128)
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %6, i32 128, double %14)
%16 = tail call double @threadsCalcul(i32 %6, i32 64)
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %6, i32 64, double %16)
%18 = tail call double @threadsCalcul(i32 %6, i32 32)
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %6, i32 32, double %18)
%20 = tail call double @threadsCalcul(i32 %6, i32 16)
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %6, i32 16, double %20)
%22 = tail call double @threadsCalcul(i32 %6, i32 8)
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %6, i32 8, double %22)
%24 = tail call double @threadsCalcul(i32 %6, i32 4)
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %6, i32 4, double %24)
%26 = tail call double @threadsCalcul(i32 %6, i32 2)
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %6, i32 2, double %26)
%28 = tail call double @threadsCalcul(i32 %6, i32 1)
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %6, i32 1, double %28)
%30 = mul nuw nsw i32 %6, 10
%31 = icmp ult i32 %30, 100000001
br i1 %31, label %5, label %41
32: ; preds = %0
%33 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.9, i64 0, i64 0))
%34 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0))
%35 = tail call i32 (...) @demandeNombre()
%36 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0))
%37 = tail call i32 (...) @demandeNombre()
%38 = tail call double @threadsCalcul(i32 %35, i32 %37)
br label %41
39: ; preds = %0
%40 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str.8, i64 0, i64 0))
br label %41
41: ; preds = %5, %32, %39
%42 = load i32, i32* @EXIT_SUCCESS
ret i32 %42
}