#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*/ free_matrix(int **, int);
int **get_matrix(int);
int /*<<< orphan*/ magic_square(int **, int);
int /*<<< orphan*/ print_sq_matrix(int **, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int n = 1;
  do {
    printf("Escriba el número n de columnas para el cuadrado\n");
    scanf("%d", &n);
  } while (n % 2 != 1);
  int **M = get_matrix(2 * n - 1);
  magic_square(M, n);
  print_sq_matrix(M, n);
  free_matrix(M, 2 * n - 1);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
lea    0xe83(%rip),%rdi
call   1050 <printf@plt>
lea    0xeaa(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1070 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x1,%edx
jne    1176 <main+0x16>
mov    -0x8(%rbp),%edi
shl    $0x1,%edi
sub    $0x1,%edi
call   1030 <get_matrix@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1080 <magic_square@plt>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1060 <print_sq_matrix@plt>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%esi
shl    $0x1,%esi
sub    $0x1,%esi
call   1040 <free_matrix@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
movl   $0x1,0xc(%rsp)
lea    0xe8b(%rip),%r14
lea    0xe81(%rip),%r15
lea    0xc(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1070 <scanf@plt>
mov    0xc(%rsp),%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
and    $0xfffffffe,%ecx
mov    %eax,%edx
sub    %ecx,%edx
cmp    $0x1,%edx
jne    1190 <main+0x30>
lea    (%rax,%rax,1),%edi
add    $0xffffffff,%edi
call   1040 <get_matrix@plt>
mov    %rax,%rbx
mov    0xc(%rsp),%esi
mov    %rax,%rdi
call   1080 <magic_square@plt>
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
call   1060 <print_sq_matrix@plt>
mov    0xc(%rsp),%eax
lea    (%rax,%rax,1),%esi
add    $0xffffffff,%esi
mov    %rbx,%rdi
call   1050 <free_matrix@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [51 x i8] c"Escriba el n\C3\BAmero n de columnas para el cuadrado\0A\00"
@.str.1 = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32**
store i32 0, i32* %1
store i32 1, i32* %2
br label %4
4: ; preds = %7, %0
%5 = call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
br label %7
7: ; preds = %4
%8 = load i32, i32* %2
%9 = srem i32 %8, 2
%10 = icmp ne i32 %9, 1
br i1 %10, label %4, label %11
11: ; preds = %7
%12 = load i32, i32* %2
%13 = mul nsw i32 2, %12
%14 = sub nsw i32 %13, 1
%15 = call i32** @get_matrix(i32 %14)
store i32** %15, i32*** %3
%16 = load i32**, i32*** %3
%17 = load i32, i32* %2
%18 = call i32 @magic_square(i32** %16, i32 %17)
%19 = load i32**, i32*** %3
%20 = load i32, i32* %2
%21 = call i32 @print_sq_matrix(i32** %19, i32 %20)
%22 = load i32**, i32*** %3
%23 = load i32, i32* %2
%24 = mul nsw i32 2, %23
%25 = sub nsw i32 %24, 1
%26 = call i32 @free_matrix(i32** %22, i32 %25)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@str = [50 x i8] c"Escriba el n\C3\BAmero n de columnas para el cuadrado\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 1, i32* %1
br label %3
3: ; preds = %3, %0
%4 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%6 = load i32, i32* %1
%7 = srem i32 %6, 2
%8 = icmp eq i32 %7, 1
br i1 %8, label %9, label %3
9: ; preds = %3
%10 = shl nsw i32 %6, 1
%11 = add nsw i32 %10, -1
%12 = call i32** @get_matrix(i32 %11)
%13 = load i32, i32* %1
%14 = call i32 @magic_square(i32** %12, i32 %13)
%15 = load i32, i32* %1
%16 = call i32 @print_sq_matrix(i32** %12, i32 %15)
%17 = load i32, i32* %1
%18 = shl nsw i32 %17, 1
%19 = add nsw i32 %18, -1
%20 = call i32 @free_matrix(i32** %12, i32 %19)
ret i32 0
}