#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*/ create_magic_matrix(int, int **);
int /*<<< orphan*/ print_magic_matrix(int, int **);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int main(void) {
  int dimension;
  printf("this program creates a magic square of a specified size\n");
  printf("an odd number between 1-99\n");
  printf("enter size of magic square: ");
  scanf("%d", &dimension);
  int magic_matrix[99][99] = {{0}};
  create_magic_matrix(dimension, magic_matrix);
  print_magic_matrix(dimension, magic_matrix);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x9930,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe97(%rip),%rdi
call   1040 <printf@plt>
lea    0xec4(%rip),%rdi
call   1040 <printf@plt>
lea    0xed4(%rip),%rdi
call   1040 <printf@plt>
lea    0xee5(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1060 <scanf@plt>
lea    -0x9930(%rbp),%rdi
xor    %esi,%esi
mov    $0x9924,%edx
call   1050 <memset@plt>
mov    -0x8(%rbp),%edi
lea    -0x9930(%rbp),%rsi
call   1070 <create_magic_matrix@plt>
mov    -0x8(%rbp),%edi
lea    -0x9930(%rbp),%rsi
call   1030 <print_magic_matrix@plt>
xor    %eax,%eax
add    $0x9930,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x9940,%rsp
lea    0xeb1(%rip),%rdi
call   1030 <puts@plt>
lea    0xedd(%rip),%rdi
call   1030 <puts@plt>
lea    0xe79(%rip),%rdi
call   1050 <printf@plt>
lea    0xe8a(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1070 <scanf@plt>
lea    0x10(%rsp),%rbx
mov    $0x9924,%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1060 <memset@plt>
mov    0xc(%rsp),%edi
mov    %rbx,%rsi
call   1080 <create_magic_matrix@plt>
mov    0xc(%rsp),%edi
mov    %rbx,%rsi
call   1040 <print_magic_matrix@plt>
xor    %eax,%eax
add    $0x9940,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [57 x i8] c"this program creates a magic square of a specified size\0A\00"
@.str.1 = [28 x i8] c"an odd number between 1-99\0A\00"
@.str.2 = [29 x i8] c"enter size of magic square: \00"
@.str.3 = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [99 x [99 x i32]]
store i32 0, i32* %1
%4 = call i32 @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %2)
%8 = bitcast [99 x [99 x i32]]* %3 to i8*
%9 = load i32, i32* %2
%10 = getelementptr inbounds [99 x [99 x i32]], [99 x [99 x i32]]* %3, i64 0, i64 0
%11 = bitcast [99 x i32]* %10 to i32**
%12 = call i32 @create_magic_matrix(i32 %9, i32** %11)
%13 = load i32, i32* %2
%14 = getelementptr inbounds [99 x [99 x i32]], [99 x [99 x i32]]* %3, i64 0, i64 0
%15 = bitcast [99 x i32]* %14 to i32**
%16 = call i32 @print_magic_matrix(i32 %13, i32** %15)
ret i32 0
}

LLVM IR (-O2):
@.str.2 = [29 x i8] c"enter size of magic square: \00"
@.str.3 = [3 x i8] c"%d\00"
@str = [56 x i8] c"this program creates a magic square of a specified size\00"
@str.4 = [27 x i8] c"an odd number between 1-99\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [99 x [99 x i32]]
%3 = bitcast i32* %1 to i8*
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @str, i64 0, i64 0))
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.4, i64 0, i64 0))
%6 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %1)
%8 = bitcast [99 x [99 x i32]]* %2 to i8*
%9 = load i32, i32* %1
%10 = bitcast [99 x [99 x i32]]* %2 to i32**
%11 = call i32 @create_magic_matrix(i32 %9, i32** %10)
%12 = load i32, i32* %1
%13 = call i32 @print_magic_matrix(i32 %12, i32** %10)
ret i32 0
}