#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*/ generate_matrix(int, int **);
int /*<<< orphan*/ print_matrix(int, int **);
int /*<<< orphan*/ printf(char *, int);
int sum_of_diagonals(int, int **);
int main() {
  int size = 21;
  int matrix[size][size];
  generate_matrix(size, matrix);
  print_matrix(size, matrix);
  printf("sum of diagonals: %d\n", sum_of_diagonals(size, matrix));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x15,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
mov    %rcx,%rax
mov    %rsp,%rdx
mov    %rdx,-0x10(%rbp)
mov    %rcx,%rdx
imul   %rdx,%rdx
lea    0xf(,%rdx,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rsi
sub    %rdx,%rsi
mov    %rsi,-0x28(%rbp)
mov    %rsi,%rsp
mov    %rcx,-0x18(%rbp)
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%edi
call   1050 <generate_matrix@plt>
mov    -0x28(%rbp),%rsi
mov    -0x8(%rbp),%edi
call   1060 <print_matrix@plt>
mov    -0x28(%rbp),%rsi
mov    -0x8(%rbp),%edi
call   1040 <sum_of_diagonals@plt>
mov    %eax,%esi
lea    0xe4a(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x6f0,%rsp
mov    %rsp,%rbx
mov    $0x15,%edi
mov    %rbx,%rsi
call   1050 <generate_matrix@plt>
mov    $0x15,%edi
mov    %rbx,%rsi
call   1060 <print_matrix@plt>
mov    $0x15,%edi
mov    %rbx,%rsi
call   1040 <sum_of_diagonals@plt>
lea    0xe87(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x6f0,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [22 x i8] c"sum of diagonals: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i64
store i32 0, i32* %1
store i32 21, i32* %2
%6 = load i32, i32* %2
%7 = zext i32 %6 to i64
%8 = load i32, i32* %2
%9 = zext i32 %8 to i64
%10 = call i8* @llvm.stacksave()
store i8* %10, i8** %3
%11 = mul nuw i64 %7, %9
%12 = alloca i32, i64 %11
store i64 %7, i64* %4
store i64 %9, i64* %5
%13 = load i32, i32* %2
%14 = bitcast i32* %12 to i32**
%15 = call i32 @generate_matrix(i32 %13, i32** %14)
%16 = load i32, i32* %2
%17 = bitcast i32* %12 to i32**
%18 = call i32 @print_matrix(i32 %16, i32** %17)
%19 = load i32, i32* %2
%20 = bitcast i32* %12 to i32**
%21 = call i32 @sum_of_diagonals(i32 %19, i32** %20)
%22 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %21)
store i32 0, i32* %1
%23 = load i8*, i8** %3
%24 = load i32, i32* %1
ret i32 %24
}

LLVM IR (-O2):
@.str = [22 x i8] c"sum of diagonals: %d\0A\00"
define i32 @main() {
%1 = alloca [441 x i32]
%2 = bitcast [441 x i32]* %1 to i32**
%3 = call i32 @generate_matrix(i32 21, i32** %2)
%4 = call i32 @print_matrix(i32 21, i32** %2)
%5 = call i32 @sum_of_diagonals(i32 21, i32** %2)
%6 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %5)
ret i32 0
}