#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*/ printf(char *, ...);
int main() {
  int *a, i;
  int *matrix1();
  int(*b)[2];
  int *r;
  int(*matrix2())[2];
  int(*c)[5][2];
  int(*matrix3())[5][2];
  a = matrix1();
  printf("matrix1\n");
  for (i = 0; i < 5; i++) {
    printf("%d %d\n", *(a + i * 2), *(a + i * 2 + 1));
  }
  b = matrix2();
  printf("matrix2\n");
  r = (int *)b;
  for (i = 0; i < 5; i++) {
    printf("%d %d\n", *r, *(r + 1));
    b++;
  }
  c = matrix3();
  printf("matrix3\n");
  for (i = 0; i < 5; i++) {
    printf("%d %d\n", (*c)[i][0], (*c)[i][1]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1050 <matrix1@plt>
mov    %rax,-0x10(%rbp)
lea    0xe9f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x5,-0x14(%rbp)
jge    11b6 <main+0x76>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
shl    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%esi
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
shl    $0x1,%ecx
movslq %ecx,%rcx
mov    0x4(%rax,%rcx,4),%edx
lea    0xe68(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    116f <main+0x2f>
mov    $0x0,%al
call   1040 <matrix2@plt>
mov    %rax,-0x20(%rbp)
lea    0xe48(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x5,-0x14(%rbp)
jge    121d <main+0xdd>
mov    -0x28(%rbp),%rax
mov    (%rax),%esi
mov    -0x28(%rbp),%rax
mov    0x4(%rax),%edx
lea    0xe0d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x20(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11de <main+0x9e>
mov    $0x0,%al
call   1060 <matrix3@plt>
mov    %rax,-0x30(%rbp)
lea    0xdea(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x5,-0x14(%rbp)
jge    127a <main+0x13a>
mov    -0x30(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%esi
mov    -0x30(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    0x4(%rax,%rcx,8),%edx
lea    0xda4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    123d <main+0xfd>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1060 <matrix1@plt>
mov    %rax,%rbx
lea    0xea2(%rip),%rdi
call   1030 <puts@plt>
mov    (%rbx),%esi
mov    0x4(%rbx),%edx
lea    0xe8a(%rip),%r14
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rbx),%esi
mov    0xc(%rbx),%edx
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x10(%rbx),%esi
mov    0x14(%rbx),%edx
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x18(%rbx),%esi
mov    0x1c(%rbx),%edx
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x20(%rbx),%esi
mov    0x24(%rbx),%edx
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <matrix2@plt>
mov    %rax,%rbx
lea    0xe3e(%rip),%rdi
call   1030 <puts@plt>
mov    (%rbx),%esi
mov    0x4(%rbx),%edx
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rbx),%esi
mov    0x4(%rbx),%edx
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rbx),%esi
mov    0x4(%rbx),%edx
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rbx),%esi
mov    0x4(%rbx),%edx
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rbx),%esi
mov    0x4(%rbx),%edx
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1070 <matrix3@plt>
mov    %rax,%rbx
lea    0xde5(%rip),%rdi
call   1030 <puts@plt>
mov    (%rbx),%esi
mov    0x4(%rbx),%edx
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rbx),%esi
mov    0xc(%rbx),%edx
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x10(%rbx),%esi
mov    0x14(%rbx),%edx
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x18(%rbx),%esi
mov    0x1c(%rbx),%edx
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x20(%rbx),%esi
mov    0x24(%rbx),%edx
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [9 x i8] c"matrix1\0A\00"
@.str.1 = [7 x i8] c"%d %d\0A\00"
@.str.2 = [9 x i8] c"matrix2\0A\00"
@.str.3 = [9 x i8] c"matrix3\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32
%4 = alloca [2 x i32]*
%5 = alloca i32*
%6 = alloca [5 x [2 x i32]]*
store i32 0, i32* %1
%7 = call i32* (...) @matrix1()
store i32* %7, i32** %2
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %9
9: ; preds = %27, %0
%10 = load i32, i32* %3
%11 = icmp slt i32 %10, 5
br i1 %11, label %12, label %30
12: ; preds = %9
%13 = load i32*, i32** %2
%14 = load i32, i32* %3
%15 = mul nsw i32 %14, 2
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i32, i32* %13, i64 %16
%18 = load i32, i32* %17
%19 = load i32*, i32** %2
%20 = load i32, i32* %3
%21 = mul nsw i32 %20, 2
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i32, i32* %19, i64 %22
%24 = getelementptr inbounds i32, i32* %23, i64 1
%25 = load i32, i32* %24
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %18, i32 %25)
br label %27
27: ; preds = %12
%28 = load i32, i32* %3
%29 = add nsw i32 %28, 1
store i32 %29, i32* %3
br label %9
30: ; preds = %9
%31 = call [2 x i32]* (...) @matrix2()
store [2 x i32]* %31, [2 x i32]** %4
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%33 = load [2 x i32]*, [2 x i32]** %4
%34 = bitcast [2 x i32]* %33 to i32*
store i32* %34, i32** %5
store i32 0, i32* %3
br label %35
35: ; preds = %47, %30
%36 = load i32, i32* %3
%37 = icmp slt i32 %36, 5
br i1 %37, label %38, label %50
38: ; preds = %35
%39 = load i32*, i32** %5
%40 = load i32, i32* %39
%41 = load i32*, i32** %5
%42 = getelementptr inbounds i32, i32* %41, i64 1
%43 = load i32, i32* %42
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %40, i32 %43)
%45 = load [2 x i32]*, [2 x i32]** %4
%46 = getelementptr inbounds [2 x i32], [2 x i32]* %45, i32 1
store [2 x i32]* %46, [2 x i32]** %4
br label %47
47: ; preds = %38
%48 = load i32, i32* %3
%49 = add nsw i32 %48, 1
store i32 %49, i32* %3
br label %35
50: ; preds = %35
%51 = call [5 x [2 x i32]]* (...) @matrix3()
store [5 x [2 x i32]]* %51, [5 x [2 x i32]]** %6
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %3
br label %53
53: ; preds = %70, %50
%54 = load i32, i32* %3
%55 = icmp slt i32 %54, 5
br i1 %55, label %56, label %73
56: ; preds = %53
%57 = load [5 x [2 x i32]]*, [5 x [2 x i32]]** %6
%58 = load i32, i32* %3
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds [5 x [2 x i32]], [5 x [2 x i32]]* %57, i64 0, i64 %59
%61 = getelementptr inbounds [2 x i32], [2 x i32]* %60, i64 0, i64 0
%62 = load i32, i32* %61
%63 = load [5 x [2 x i32]]*, [5 x [2 x i32]]** %6
%64 = load i32, i32* %3
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds [5 x [2 x i32]], [5 x [2 x i32]]* %63, i64 0, i64 %65
%67 = getelementptr inbounds [2 x i32], [2 x i32]* %66, i64 0, i64 1
%68 = load i32, i32* %67
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %62, i32 %68)
br label %70
70: ; preds = %56
%71 = load i32, i32* %3
%72 = add nsw i32 %71, 1
store i32 %72, i32* %3
br label %53
73: ; preds = %53
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [7 x i8] c"%d %d\0A\00"
@str = [8 x i8] c"matrix1\00"
@str.4 = [8 x i8] c"matrix2\00"
@str.5 = [8 x i8] c"matrix3\00"
define i32 @main() {
%1 = tail call i32* (...) @matrix1()
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str, i64 0, i64 0))
%3 = load i32, i32* %1
%4 = getelementptr inbounds i32, i32* %1, i64 1
%5 = load i32, i32* %4
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %3, i32 %5)
%7 = getelementptr inbounds i32, i32* %1, i64 2
%8 = load i32, i32* %7
%9 = getelementptr inbounds i32, i32* %1, i64 3
%10 = load i32, i32* %9
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %8, i32 %10)
%12 = getelementptr inbounds i32, i32* %1, i64 4
%13 = load i32, i32* %12
%14 = getelementptr inbounds i32, i32* %1, i64 5
%15 = load i32, i32* %14
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %13, i32 %15)
%17 = getelementptr inbounds i32, i32* %1, i64 6
%18 = load i32, i32* %17
%19 = getelementptr inbounds i32, i32* %1, i64 7
%20 = load i32, i32* %19
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %18, i32 %20)
%22 = getelementptr inbounds i32, i32* %1, i64 8
%23 = load i32, i32* %22
%24 = getelementptr inbounds i32, i32* %1, i64 9
%25 = load i32, i32* %24
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %23, i32 %25)
%27 = tail call [2 x i32]* (...) @matrix2()
%28 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.4, i64 0, i64 0))
%29 = getelementptr [2 x i32], [2 x i32]* %27, i64 0, i64 0
%30 = getelementptr inbounds [2 x i32], [2 x i32]* %27, i64 0, i64 1
%31 = load i32, i32* %29
%32 = load i32, i32* %30
%33 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %31, i32 %32)
%34 = load i32, i32* %29
%35 = load i32, i32* %30
%36 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %34, i32 %35)
%37 = load i32, i32* %29
%38 = load i32, i32* %30
%39 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %37, i32 %38)
%40 = load i32, i32* %29
%41 = load i32, i32* %30
%42 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %40, i32 %41)
%43 = load i32, i32* %29
%44 = load i32, i32* %30
%45 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %43, i32 %44)
%46 = tail call [5 x [2 x i32]]* (...) @matrix3()
%47 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.5, i64 0, i64 0))
%48 = getelementptr inbounds [5 x [2 x i32]], [5 x [2 x i32]]* %46, i64 0, i64 0, i64 0
%49 = load i32, i32* %48
%50 = getelementptr inbounds [5 x [2 x i32]], [5 x [2 x i32]]* %46, i64 0, i64 0, i64 1
%51 = load i32, i32* %50
%52 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %49, i32 %51)
%53 = getelementptr inbounds [5 x [2 x i32]], [5 x [2 x i32]]* %46, i64 0, i64 1, i64 0
%54 = load i32, i32* %53
%55 = getelementptr inbounds [5 x [2 x i32]], [5 x [2 x i32]]* %46, i64 0, i64 1, i64 1
%56 = load i32, i32* %55
%57 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %54, i32 %56)
%58 = getelementptr inbounds [5 x [2 x i32]], [5 x [2 x i32]]* %46, i64 0, i64 2, i64 0
%59 = load i32, i32* %58
%60 = getelementptr inbounds [5 x [2 x i32]], [5 x [2 x i32]]* %46, i64 0, i64 2, i64 1
%61 = load i32, i32* %60
%62 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %59, i32 %61)
%63 = getelementptr inbounds [5 x [2 x i32]], [5 x [2 x i32]]* %46, i64 0, i64 3, i64 0
%64 = load i32, i32* %63
%65 = getelementptr inbounds [5 x [2 x i32]], [5 x [2 x i32]]* %46, i64 0, i64 3, i64 1
%66 = load i32, i32* %65
%67 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %64, i32 %66)
%68 = getelementptr inbounds [5 x [2 x i32]], [5 x [2 x i32]]* %46, i64 0, i64 4, i64 0
%69 = load i32, i32* %68
%70 = getelementptr inbounds [5 x [2 x i32]], [5 x [2 x i32]]* %46, i64 0, i64 4, i64 1
%71 = load i32, i32* %70
%72 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %69, i32 %71)
ret i32 0
}