#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 /*<<< orphan*/ matrix_print(int **);
int /*<<< orphan*/ matrix_traspone(int **);
int /*<<< orphan*/ printf(char *);
void matrix(void) {
  int matrix[3][3];
  int x, y;
  for (x = 0; x < 3; x++) {
    for (y = 0; y < 3; y++)
      matrix[x][y] = (x + 1) * (y + 1);
  }
  printf("Matrice\n");
  matrix_print(matrix);
  printf("\n");
  matrix_traspone(matrix);
  matrix_print(matrix);
  printf("\n");
}


x86 assembly (clang, -O0):
<matrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x34(%rbp)
cmpl   $0x3,-0x34(%rbp)
jge    11a0 <matrix+0x70>
movl   $0x0,-0x38(%rbp)
cmpl   $0x3,-0x38(%rbp)
jge    118d <matrix+0x5d>
mov    -0x34(%rbp),%edx
add    $0x1,%edx
mov    -0x38(%rbp),%eax
add    $0x1,%eax
imul   %eax,%edx
movslq -0x34(%rbp),%rcx
lea    -0x30(%rbp),%rax
imul   $0xc,%rcx,%rcx
add    %rcx,%rax
movslq -0x38(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1150 <matrix+0x20>
jmp    1192 <matrix+0x62>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    113f <matrix+0xf>
lea    0xe59(%rip),%rdi
call   1040 <printf@plt>
lea    -0x30(%rbp),%rdi
call   1030 <matrix_print@plt>
lea    0xe4b(%rip),%rdi
call   1040 <printf@plt>
lea    -0x30(%rbp),%rdi
call   1050 <matrix_traspone@plt>
lea    -0x30(%rbp),%rdi
call   1030 <matrix_print@plt>
lea    0xe2d(%rip),%rdi
call   1040 <printf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<matrix>:
push   %rbx
sub    $0x30,%rsp
movaps 0xeb4(%rip),%xmm0
movaps %xmm0,(%rsp)
movaps 0xeb9(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movl   $0x9,0x20(%rsp)
lea    0xeb5(%rip),%rdi
call   1050 <puts@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1030 <matrix_print@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    %rbx,%rdi
call   1060 <matrix_traspone@plt>
mov    %rbx,%rdi
call   1030 <matrix_print@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [9 x i8] c"Matrice\0A\00"
@.str.1 = [2 x i8] c"\0A\00"
define void @matrix() {
%1 = alloca [3 x [3 x i32]]
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %2
br label %4
4: ; preds = %27, %0
%5 = load i32, i32* %2
%6 = icmp slt i32 %5, 3
br i1 %6, label %7, label %30
7: ; preds = %4
store i32 0, i32* %3
br label %8
8: ; preds = %23, %7
%9 = load i32, i32* %3
%10 = icmp slt i32 %9, 3
br i1 %10, label %11, label %26
11: ; preds = %8
%12 = load i32, i32* %2
%13 = add nsw i32 %12, 1
%14 = load i32, i32* %3
%15 = add nsw i32 %14, 1
%16 = mul nsw i32 %13, %15
%17 = load i32, i32* %2
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %1, i64 0, i64 %18
%20 = load i32, i32* %3
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [3 x i32], [3 x i32]* %19, i64 0, i64 %21
store i32 %16, i32* %22
br label %23
23: ; preds = %11
%24 = load i32, i32* %3
%25 = add nsw i32 %24, 1
store i32 %25, i32* %3
br label %8
26: ; preds = %8
br label %27
27: ; preds = %26
%28 = load i32, i32* %2
%29 = add nsw i32 %28, 1
store i32 %29, i32* %2
br label %4
30: ; preds = %4
%31 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%32 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %1, i64 0, i64 0
%33 = bitcast [3 x i32]* %32 to i32**
%34 = call i32 @matrix_print(i32** %33)
%35 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%36 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %1, i64 0, i64 0
%37 = bitcast [3 x i32]* %36 to i32**
%38 = call i32 @matrix_traspone(i32** %37)
%39 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %1, i64 0, i64 0
%40 = bitcast [3 x i32]* %39 to i32**
%41 = call i32 @matrix_print(i32** %40)
%42 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@str = [8 x i8] c"Matrice\00"
define void @matrix() {
%1 = alloca [3 x [3 x i32]]
%2 = bitcast [3 x [3 x i32]]* %1 to i8*
%3 = bitcast [3 x [3 x i32]]* %1 to <4 x i32>*
store <4 x i32> <i32 1, i32 2, i32 3, i32 2>, <4 x i32>* %3
%4 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %1, i64 0, i64 1, i64 1
%5 = bitcast i32* %4 to <4 x i32>*
store <4 x i32> <i32 4, i32 6, i32 3, i32 6>, <4 x i32>* %5
%6 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %1, i64 0, i64 2, i64 2
store i32 9, i32* %6
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str, i64 0, i64 0))
%8 = bitcast [3 x [3 x i32]]* %1 to i32**
%9 = call i32 @matrix_print(i32** %8)
%10 = call i32 @putchar(i32 10)
%11 = call i32 @matrix_traspone(i32** %8)
%12 = call i32 @matrix_print(i32** %8)
%13 = call i32 @putchar(i32 10)
ret void
}