#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 */
struct timeval {
  double tv_sec;
  double tv_usec;
};

/* Variables and functions */
int atoi(char *);
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/);
int /*<<< orphan*/ initMatrix(long **, int);
scalar_t__ malloc(int);
int /*<<< orphan*/ printMatrix(long **);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ problemeNumero1(int, long **, long **);
int /*<<< orphan*/ problemeNumero2(int, long **, long **);
int main(int argc, char *argv[]) {
  struct timeval start, end;
  int problemeExecuter;
  int valeurInitiale;
  int nombreIteration;
  if (argc != 4) {
    printf("Veuillez entrer le nombre d'arguments comme suivant: #1 Choix du "
           "probleme a executer, #2 La valeur initiale des elements de la "
           "matrice, #3 le nombre d'iterations\n");
    return 1;
  }
  problemeExecuter = atoi(argv[1]);
  valeurInitiale = atoi(argv[2]);
  nombreIteration = atoi(argv[3]);
  gettimeofday(&start, 0);
  long **mat;
  mat = (long **)malloc(8 * sizeof(long *));
  for (int i = 0; i < 8; i++) {
    mat[i] = (long *)malloc(8 * sizeof(long));
  }
  initMatrix(mat, valeurInitiale);
  long **matkmoins1 = mat;
  if (problemeExecuter == 1) {
    problemeNumero1(nombreIteration, matkmoins1, mat);
  } else if (problemeExecuter == 2) {
    problemeNumero2(nombreIteration, matkmoins1, mat);
  } else {
    return 2;
  }
  gettimeofday(&end, 0);
  printf("Problème %d : impression de la matrice 'mat' :\n", problemeExecuter);
  printMatrix(mat);
  printf("Temps que l'application a pris pour terminer (en secondes): %f \n",
         (end.tv_sec + (end.tv_usec / 1000000.0) - start.tv_sec +
          (start.tv_usec / 1000000.0)));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x4,-0x8(%rbp)
je     11ba <main+0x3a>
lea    0xe61(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    130c <main+0x18c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x34(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x3c(%rbp)
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
call   1050 <gettimeofday@plt>
mov    $0x40,%edi
call   1070 <malloc@plt>
mov    %rax,-0x48(%rbp)
movl   $0x0,-0x4c(%rbp)
cmpl   $0x8,-0x4c(%rbp)
jge    123b <main+0xbb>
mov    $0x40,%edi
call   1070 <malloc@plt>
mov    %rax,%rdx
mov    -0x48(%rbp),%rax
movslq -0x4c(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    120a <main+0x8a>
mov    -0x48(%rbp),%rdi
mov    -0x38(%rbp),%esi
call   10a0 <initMatrix@plt>
mov    -0x48(%rbp),%rax
mov    %rax,-0x58(%rbp)
cmpl   $0x1,-0x34(%rbp)
jne    126e <main+0xee>
mov    -0x3c(%rbp),%edi
mov    -0x58(%rbp),%rsi
mov    -0x48(%rbp),%rdx
call   1030 <problemeNumero1@plt>
jmp    129e <main+0x11e>
cmpl   $0x2,-0x34(%rbp)
jne    128d <main+0x10d>
mov    -0x3c(%rbp),%edi
mov    -0x58(%rbp),%rsi
mov    -0x48(%rbp),%rdx
call   1080 <problemeNumero2@plt>
jmp    1299 <main+0x119>
movl   $0x2,-0x4(%rbp)
jmp    130c <main+0x18c>
jmp    129e <main+0x11e>
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
call   1050 <gettimeofday@plt>
mov    -0x34(%rbp),%esi
lea    0xdf8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x48(%rbp),%rdi
call   1060 <printMatrix@plt>
movsd  -0x30(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
movsd  0xd2b(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
subsd  -0x20(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  0xd11(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
lea    0xdde(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x20,%rsp
cmp    $0x4,%edi
jne    1284 <main+0xf4>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
call   10a0 <atoi@plt>
mov    %eax,%r12d
mov    0x10(%rbx),%rdi
call   10a0 <atoi@plt>
mov    %eax,%r15d
mov    0x18(%rbx),%rdi
call   10a0 <atoi@plt>
mov    %eax,%r14d
lea    0x10(%rsp),%rdi
xor    %esi,%esi
call   1060 <gettimeofday@plt>
mov    $0x40,%edi
call   1080 <malloc@plt>
mov    %rax,%rbx
mov    $0x40,%edi
call   1080 <malloc@plt>
mov    %rax,(%rbx)
mov    $0x40,%edi
call   1080 <malloc@plt>
mov    %rax,0x8(%rbx)
mov    $0x40,%edi
call   1080 <malloc@plt>
mov    %rax,0x10(%rbx)
mov    $0x40,%edi
call   1080 <malloc@plt>
mov    %rax,0x18(%rbx)
mov    $0x40,%edi
call   1080 <malloc@plt>
mov    %rax,0x20(%rbx)
mov    $0x40,%edi
call   1080 <malloc@plt>
mov    %rax,0x28(%rbx)
mov    $0x40,%edi
call   1080 <malloc@plt>
mov    %rax,0x30(%rbx)
mov    $0x40,%edi
call   1080 <malloc@plt>
mov    %rax,0x38(%rbx)
mov    %rbx,%rdi
mov    %r15d,%esi
call   10b0 <initMatrix@plt>
cmp    $0x2,%r12d
je     1297 <main+0x107>
mov    $0x2,%ebp
cmp    $0x1,%r12d
jne    1303 <main+0x173>
mov    %r14d,%edi
mov    %rbx,%rsi
mov    %rbx,%rdx
call   1040 <problemeNumero1@plt>
jmp    12a5 <main+0x115>
lea    0xdef(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebp
jmp    1303 <main+0x173>
mov    %r14d,%edi
mov    %rbx,%rsi
mov    %rbx,%rdx
call   1090 <problemeNumero2@plt>
mov    %rsp,%rdi
xor    %ebp,%ebp
xor    %esi,%esi
call   1060 <gettimeofday@plt>
lea    0xd50(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1070 <printMatrix@plt>
movsd  0x8(%rsp),%xmm1
movsd  0xd28(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  (%rsp),%xmm1
subsd  0x10(%rsp),%xmm1
movsd  0x18(%rsp),%xmm0
divsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
lea    0xd3d(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    %ebp,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.timeval = type { double, double }
@.str = [163 x i8] c"Veuillez entrer le nombre d'arguments comme suivant: Choix du probleme a executer, La valeur initiale des elements de la matrice, le nombre d'iterations\0A\00"
@.str.1 = [49 x i8] c"Probl\C3\A8me %d : impression de la matrice 'mat' :\0A\00"
@.str.2 = [65 x i8] c"Temps que l'application a pris pour terminer (en secondes): %f \0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.timeval
%7 = alloca %struct.timeval
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i64**
%12 = alloca i32
%13 = alloca i64**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = load i32, i32* %4
%15 = icmp ne i32 %14, 4
br i1 %15, label %16, label %18
16: ; preds = %2
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([163 x i8], [163 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %89
18: ; preds = %2
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i32 @atoi(i8* %21)
store i32 %22, i32* %8
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 2
%25 = load i8*, i8** %24
%26 = call i32 @atoi(i8* %25)
store i32 %26, i32* %9
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 3
%29 = load i8*, i8** %28
%30 = call i32 @atoi(i8* %29)
store i32 %30, i32* %10
%31 = call i32 @gettimeofday(%struct.timeval* %6, i32 0)
%32 = call i64 @malloc(i32 64)
%33 = inttoptr i64 %32 to i64**
store i64** %33, i64*** %11
store i32 0, i32* %12
br label %34
34: ; preds = %44, %18
%35 = load i32, i32* %12
%36 = icmp slt i32 %35, 8
br i1 %36, label %37, label %47
37: ; preds = %34
%38 = call i64 @malloc(i32 64)
%39 = inttoptr i64 %38 to i64*
%40 = load i64**, i64*** %11
%41 = load i32, i32* %12
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i64*, i64** %40, i64 %42
store i64* %39, i64** %43
br label %44
44: ; preds = %37
%45 = load i32, i32* %12
%46 = add nsw i32 %45, 1
store i32 %46, i32* %12
br label %34
47: ; preds = %34
%48 = load i64**, i64*** %11
%49 = load i32, i32* %9
%50 = call i32 @initMatrix(i64** %48, i32 %49)
%51 = load i64**, i64*** %11
store i64** %51, i64*** %13
%52 = load i32, i32* %8
%53 = icmp eq i32 %52, 1
br i1 %53, label %54, label %59
54: ; preds = %47
%55 = load i32, i32* %10
%56 = load i64**, i64*** %13
%57 = load i64**, i64*** %11
%58 = call i32 @problemeNumero1(i32 %55, i64** %56, i64** %57)
br label %69
59: ; preds = %47
%60 = load i32, i32* %8
%61 = icmp eq i32 %60, 2
br i1 %61, label %62, label %67
62: ; preds = %59
%63 = load i32, i32* %10
%64 = load i64**, i64*** %13
%65 = load i64**, i64*** %11
%66 = call i32 @problemeNumero2(i32 %63, i64** %64, i64** %65)
br label %68
67: ; preds = %59
store i32 2, i32* %3
br label %89
68: ; preds = %62
br label %69
69: ; preds = %68, %54
%70 = call i32 @gettimeofday(%struct.timeval* %7, i32 0)
%71 = load i32, i32* %8
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0), i32 %71)
%73 = load i64**, i64*** %11
%74 = call i32 @printMatrix(i64** %73)
%75 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 0
%76 = load double, double* %75
%77 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 1
%78 = load double, double* %77
%79 = fdiv double %78, 1.000000e+06
%80 = fadd double %76, %79
%81 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 0
%82 = load double, double* %81
%83 = fsub double %80, %82
%84 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 1
%85 = load double, double* %84
%86 = fdiv double %85, 1.000000e+06
%87 = fadd double %83, %86
%88 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.2, i64 0, i64 0), double %87)
store i32 0, i32* %3
br label %89
89: ; preds = %69, %67, %16
%90 = load i32, i32* %3
ret i32 %90
}

LLVM IR (-O2):
%struct.timeval = type { double, double }
@.str.1 = [49 x i8] c"Probl\C3\A8me %d : impression de la matrice 'mat' :\0A\00"
@.str.2 = [65 x i8] c"Temps que l'application a pris pour terminer (en secondes): %f \0A\00"
@str = [162 x i8] c"Veuillez entrer le nombre d'arguments comme suivant: Choix du probleme a executer, La valeur initiale des elements de la matrice, le nombre d'iterations\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.timeval
%4 = alloca %struct.timeval
%5 = bitcast %struct.timeval* %3 to i8*
%6 = bitcast %struct.timeval* %4 to i8*
%7 = icmp eq i32 %0, 4
br i1 %7, label %10, label %8
8: ; preds = %2
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([162 x i8], [162 x i8]* @str, i64 0, i64 0))
br label %69
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = tail call i32 @atoi(i8* %12)
%14 = getelementptr inbounds i8*, i8** %1, i64 2
%15 = load i8*, i8** %14
%16 = tail call i32 @atoi(i8* %15)
%17 = getelementptr inbounds i8*, i8** %1, i64 3
%18 = load i8*, i8** %17
%19 = tail call i32 @atoi(i8* %18)
%20 = call i32 @gettimeofday(%struct.timeval* %3, i32 0)
%21 = call i64 @malloc(i32 64)
%22 = inttoptr i64 %21 to i64**
%23 = call i64 @malloc(i32 64)
%24 = inttoptr i64 %23 to i64*
store i64* %24, i64** %22
%25 = call i64 @malloc(i32 64)
%26 = inttoptr i64 %25 to i64*
%27 = getelementptr inbounds i64*, i64** %22, i64 1
store i64* %26, i64** %27
%28 = call i64 @malloc(i32 64)
%29 = inttoptr i64 %28 to i64*
%30 = getelementptr inbounds i64*, i64** %22, i64 2
store i64* %29, i64** %30
%31 = call i64 @malloc(i32 64)
%32 = inttoptr i64 %31 to i64*
%33 = getelementptr inbounds i64*, i64** %22, i64 3
store i64* %32, i64** %33
%34 = call i64 @malloc(i32 64)
%35 = inttoptr i64 %34 to i64*
%36 = getelementptr inbounds i64*, i64** %22, i64 4
store i64* %35, i64** %36
%37 = call i64 @malloc(i32 64)
%38 = inttoptr i64 %37 to i64*
%39 = getelementptr inbounds i64*, i64** %22, i64 5
store i64* %38, i64** %39
%40 = call i64 @malloc(i32 64)
%41 = inttoptr i64 %40 to i64*
%42 = getelementptr inbounds i64*, i64** %22, i64 6
store i64* %41, i64** %42
%43 = call i64 @malloc(i32 64)
%44 = inttoptr i64 %43 to i64*
%45 = getelementptr inbounds i64*, i64** %22, i64 7
store i64* %44, i64** %45
%46 = call i32 @initMatrix(i64** %22, i32 %16)
switch i32 %13, label %69 [
i32 1, label %47
i32 2, label %49
]
47: ; preds = %10
%48 = call i32 @problemeNumero1(i32 %19, i64** %22, i64** %22)
br label %51
49: ; preds = %10
%50 = call i32 @problemeNumero2(i32 %19, i64** %22, i64** %22)
br label %51
51: ; preds = %49, %47
%52 = call i32 @gettimeofday(%struct.timeval* %4, i32 0)
%53 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0), i32 %13)
%54 = call i32 @printMatrix(i64** %22)
%55 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 0
%56 = load double, double* %55
%57 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 1
%58 = load double, double* %57
%59 = fdiv double %58, 1.000000e+06
%60 = fadd double %56, %59
%61 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 0
%62 = load double, double* %61
%63 = fsub double %60, %62
%64 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 1
%65 = load double, double* %64
%66 = fdiv double %65, 1.000000e+06
%67 = fadd double %63, %66
%68 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([65 x i8], [65 x i8]* @.str.2, i64 0, i64 0), double %67)
br label %69
69: ; preds = %51, %10, %8
%70 = phi i32 [ 1, %8 ], [ 0, %51 ], [ 2, %10 ]
ret i32 %70
}