#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*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ affiche(int **, int, int);
int /*<<< orphan*/ affiche_fichier(int **, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ duplication(int **, int **, int, int);
int /*<<< orphan*/ generation_suivante_M(int **, int **, int, int, int *,
                                         int *);
int /*<<< orphan*/ printf(char *, int);
void jeu_fredkin(int **tab1, int n, int m, int ng) {
  int i;
  int **tab2 = NULL;
  int tableau_naissance_fredkin[9] = {0, 1, 0, 1, 0, 1, 0, 1, 0};
  int tableau_survie_fredkin[9] = {0, 1, 0, 1, 0, 1, 0, 1, 0};
  FILE *fichier = NULL;
  for (i = 0; i < ng; i++) {
    duplication(tab1, tab2, n, m);
    generation_suivante_M(tab1, tab2, n, m, tableau_naissance_fredkin,
                          tableau_survie_fredkin);
    printf("\n\nAffichage pour la generation %d\n", i + 1);
    affiche(tab2, n, m);
    affiche_fichier(tab2, n, m, fichier);
  }
}


x86 assembly (clang, -O0):
<jeu_fredkin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
movq   $0x0,-0x20(%rbp)
lea    -0x50(%rbp),%rdi
xor    %esi,%esi
mov    $0x24,%edx
call   1040 <memset@plt>
movl   $0x1,-0x4c(%rbp)
movl   $0x1,-0x44(%rbp)
movl   $0x1,-0x3c(%rbp)
movl   $0x1,-0x34(%rbp)
lea    -0x80(%rbp),%rdi
xor    %esi,%esi
mov    $0x24,%edx
call   1040 <memset@plt>
movl   $0x1,-0x7c(%rbp)
movl   $0x1,-0x74(%rbp)
movl   $0x1,-0x6c(%rbp)
movl   $0x1,-0x64(%rbp)
movq   $0x0,-0x88(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1269 <jeu_fredkin+0x109>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
call   1070 <duplication@plt>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
lea    -0x50(%rbp),%r8
lea    -0x80(%rbp),%r9
call   1080 <generation_suivante_M@plt>
mov    -0x18(%rbp),%esi
add    $0x1,%esi
lea    0xdcf(%rip),%rdi
call   1030 <printf@plt>
mov    -0x20(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1060 <affiche@plt>
mov    -0x20(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x88(%rbp),%rcx
call   1050 <affiche_fichier@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11ea <jeu_fredkin+0x8a>
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<jeu_fredkin>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x40(%rsp)
movl   $0x0,0x50(%rsp)
movl   $0x1,0x34(%rsp)
movl   $0x1,0x3c(%rsp)
movl   $0x1,0x44(%rsp)
movl   $0x1,0x4c(%rsp)
movaps %xmm0,(%rsp)
movaps %xmm0,0x10(%rsp)
movl   $0x0,0x20(%rsp)
movl   $0x1,0x4(%rsp)
movl   $0x1,0xc(%rsp)
movl   $0x1,0x14(%rsp)
movl   $0x1,0x1c(%rsp)
test   %ecx,%ecx
jle    124d <jeu_fredkin+0xfd>
mov    %ecx,%r14d
mov    %edx,%r12d
mov    %esi,%ebx
mov    %rdi,%r15
neg    %r14d
mov    $0x1,%ebp
lea    0xe1a(%rip),%r13
cs nopw 0x0(%rax,%rax,1)
mov    %r15,%rdi
xor    %esi,%esi
mov    %ebx,%edx
mov    %r12d,%ecx
call   1060 <duplication@plt>
mov    %r15,%rdi
xor    %esi,%esi
mov    %ebx,%edx
mov    %r12d,%ecx
lea    0x30(%rsp),%r8
mov    %rsp,%r9
call   1070 <generation_suivante_M@plt>
mov    %r13,%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
xor    %edi,%edi
mov    %ebx,%esi
mov    %r12d,%edx
call   1050 <affiche@plt>
xor    %edi,%edi
mov    %ebx,%esi
mov    %r12d,%edx
xor    %ecx,%ecx
call   1040 <affiche_fichier@plt>
lea    (%r14,%rbp,1),%eax
add    $0x1,%eax
mov    %ebp,%ecx
add    $0x1,%ecx
mov    %ecx,%ebp
cmp    $0x1,%eax
jne    11f0 <jeu_fredkin+0xa0>
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [35 x i8] c"\0A\0AAffichage pour la generation %d\0A\00"
define void @jeu_fredkin(i32** %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32**
%11 = alloca [9 x i32]
%12 = alloca [9 x i32]
%13 = alloca i32*
store i32** %0, i32*** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
store i32** null, i32*** %10
%14 = bitcast [9 x i32]* %11 to i8*
%15 = bitcast i8* %14 to [9 x i32]*
%16 = getelementptr inbounds [9 x i32], [9 x i32]* %15, i32 0, i32 1
store i32 1, i32* %16
%17 = getelementptr inbounds [9 x i32], [9 x i32]* %15, i32 0, i32 3
store i32 1, i32* %17
%18 = getelementptr inbounds [9 x i32], [9 x i32]* %15, i32 0, i32 5
store i32 1, i32* %18
%19 = getelementptr inbounds [9 x i32], [9 x i32]* %15, i32 0, i32 7
store i32 1, i32* %19
%20 = bitcast [9 x i32]* %12 to i8*
%21 = bitcast i8* %20 to [9 x i32]*
%22 = getelementptr inbounds [9 x i32], [9 x i32]* %21, i32 0, i32 1
store i32 1, i32* %22
%23 = getelementptr inbounds [9 x i32], [9 x i32]* %21, i32 0, i32 3
store i32 1, i32* %23
%24 = getelementptr inbounds [9 x i32], [9 x i32]* %21, i32 0, i32 5
store i32 1, i32* %24
%25 = getelementptr inbounds [9 x i32], [9 x i32]* %21, i32 0, i32 7
store i32 1, i32* %25
store i32* null, i32** %13
store i32 0, i32* %9
br label %26
26: ; preds = %55, %4
%27 = load i32, i32* %9
%28 = load i32, i32* %8
%29 = icmp slt i32 %27, %28
br i1 %29, label %30, label %58
30: ; preds = %26
%31 = load i32**, i32*** %5
%32 = load i32**, i32*** %10
%33 = load i32, i32* %6
%34 = load i32, i32* %7
%35 = call i32 @duplication(i32** %31, i32** %32, i32 %33, i32 %34)
%36 = load i32**, i32*** %5
%37 = load i32**, i32*** %10
%38 = load i32, i32* %6
%39 = load i32, i32* %7
%40 = getelementptr inbounds [9 x i32], [9 x i32]* %11, i64 0, i64 0
%41 = getelementptr inbounds [9 x i32], [9 x i32]* %12, i64 0, i64 0
%42 = call i32 @generation_suivante_M(i32** %36, i32** %37, i32 %38, i32 %39, i32* %40, i32* %41)
%43 = load i32, i32* %9
%44 = add nsw i32 %43, 1
%45 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 %44)
%46 = load i32**, i32*** %10
%47 = load i32, i32* %6
%48 = load i32, i32* %7
%49 = call i32 @affiche(i32** %46, i32 %47, i32 %48)
%50 = load i32**, i32*** %10
%51 = load i32, i32* %6
%52 = load i32, i32* %7
%53 = load i32*, i32** %13
%54 = call i32 @affiche_fichier(i32** %50, i32 %51, i32 %52, i32* %53)
br label %55
55: ; preds = %30
%56 = load i32, i32* %9
%57 = add nsw i32 %56, 1
store i32 %57, i32* %9
br label %26
58: ; preds = %26
ret void
}

LLVM IR (-O2):
@.str = [35 x i8] c"\0A\0AAffichage pour la generation %d\0A\00"
define void @jeu_fredkin(i32** %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca [9 x i32]
%6 = alloca [9 x i32]
%7 = bitcast [9 x i32]* %5 to i8*
%8 = getelementptr inbounds [9 x i32], [9 x i32]* %5, i64 0, i64 1
store i32 1, i32* %8
%9 = getelementptr inbounds [9 x i32], [9 x i32]* %5, i64 0, i64 3
store i32 1, i32* %9
%10 = getelementptr inbounds [9 x i32], [9 x i32]* %5, i64 0, i64 5
store i32 1, i32* %10
%11 = getelementptr inbounds [9 x i32], [9 x i32]* %5, i64 0, i64 7
store i32 1, i32* %11
%12 = bitcast [9 x i32]* %6 to i8*
%13 = getelementptr inbounds [9 x i32], [9 x i32]* %6, i64 0, i64 1
store i32 1, i32* %13
%14 = getelementptr inbounds [9 x i32], [9 x i32]* %6, i64 0, i64 3
store i32 1, i32* %14
%15 = getelementptr inbounds [9 x i32], [9 x i32]* %6, i64 0, i64 5
store i32 1, i32* %15
%16 = getelementptr inbounds [9 x i32], [9 x i32]* %6, i64 0, i64 7
store i32 1, i32* %16
%17 = icmp sgt i32 %3, 0
br i1 %17, label %18, label %30
18: ; preds = %4
%19 = getelementptr inbounds [9 x i32], [9 x i32]* %5, i64 0, i64 0
%20 = getelementptr inbounds [9 x i32], [9 x i32]* %6, i64 0, i64 0
br label %21
21: ; preds = %18, %21
%22 = phi i32 [ 0, %18 ], [ %25, %21 ]
%23 = call i32 @duplication(i32** %0, i32** null, i32 %1, i32 %2)
%24 = call i32 @generation_suivante_M(i32** %0, i32** null, i32 %1, i32 %2, i32* %19, i32* %20)
%25 = add nuw nsw i32 %22, 1
%26 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 %25)
%27 = call i32 @affiche(i32** null, i32 %1, i32 %2)
%28 = call i32 @affiche_fichier(i32** null, i32 %1, i32 %2, i32* null)
%29 = icmp eq i32 %25, %3
br i1 %29, label %30, label %21
30: ; preds = %21, %4
ret void
}