#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 /*<<< 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}};
  int arrow = 0, column = dimension / 2, arrow_cache, column_cache, number = 1;
  magic_matrix[arrow][column] = number;
  for (int i = 1; i < (dimension * dimension); i++) {
    arrow_cache = arrow;
    column_cache = column;
    arrow -= 1;
    column += 1;
    if (arrow == -1) {
      arrow = dimension - 1;
    }
    if (column == dimension) {
      column = 0;
    }
    number++;
    if (magic_matrix[arrow][column] == 0) {
      magic_matrix[arrow][column] = number;
    } else {
      arrow = arrow_cache + 1;
      column = column_cache;
      magic_matrix[arrow][column] = number;
    }
  }
  for (int i = 0; i < dimension; i++) {
    for (int j = 0; j < dimension; j++) {
      printf("%5d", magic_matrix[i][j]);
    }
    printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x9950,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xef0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeff(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
lea    -0x9930(%rbp),%rdi
xor    %esi,%esi
mov    $0x9924,%edx
call   1040 <memset@plt>
movl   $0x0,-0x9934(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x9938(%rbp)
movl   $0x1,-0x9944(%rbp)
mov    -0x9944(%rbp),%edx
movslq -0x9934(%rbp),%rcx
lea    -0x9930(%rbp),%rax
imul   $0x18c,%rcx,%rcx
add    %rcx,%rax
movslq -0x9938(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
movl   $0x1,-0x9948(%rbp)
mov    -0x9948(%rbp),%eax
mov    -0x8(%rbp),%ecx
imul   -0x8(%rbp),%ecx
cmp    %ecx,%eax
jge    1324 <main+0x1f4>
mov    -0x9934(%rbp),%eax
mov    %eax,-0x993c(%rbp)
mov    -0x9938(%rbp),%eax
mov    %eax,-0x9940(%rbp)
mov    -0x9934(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x9934(%rbp)
mov    -0x9938(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x9938(%rbp)
cmpl   $0xffffffff,-0x9934(%rbp)
jne    124a <main+0x11a>
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x9934(%rbp)
mov    -0x9938(%rbp),%eax
cmp    -0x8(%rbp),%eax
jne    1263 <main+0x133>
movl   $0x0,-0x9938(%rbp)
mov    -0x9944(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x9944(%rbp)
movslq -0x9934(%rbp),%rcx
lea    -0x9930(%rbp),%rax
imul   $0x18c,%rcx,%rcx
add    %rcx,%rax
movslq -0x9938(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
jne    12c8 <main+0x198>
mov    -0x9944(%rbp),%edx
movslq -0x9934(%rbp),%rcx
lea    -0x9930(%rbp),%rax
imul   $0x18c,%rcx,%rcx
add    %rcx,%rax
movslq -0x9938(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
jmp    130b <main+0x1db>
mov    -0x993c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x9934(%rbp)
mov    -0x9940(%rbp),%eax
mov    %eax,-0x9938(%rbp)
mov    -0x9944(%rbp),%edx
movslq -0x9934(%rbp),%rcx
lea    -0x9930(%rbp),%rax
imul   $0x18c,%rcx,%rcx
add    %rcx,%rax
movslq -0x9938(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
jmp    1310 <main+0x1e0>
mov    -0x9948(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x9948(%rbp)
jmp    11e6 <main+0xb6>
movl   $0x0,-0x994c(%rbp)
mov    -0x994c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    13bc <main+0x28c>
movl   $0x0,-0x9950(%rbp)
mov    -0x9950(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    139a <main+0x26a>
movslq -0x994c(%rbp),%rcx
lea    -0x9930(%rbp),%rax
imul   $0x18c,%rcx,%rcx
add    %rcx,%rax
movslq -0x9950(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xcf6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x9950(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x9950(%rbp)
jmp    1347 <main+0x217>
lea    0xcb2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x994c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x994c(%rbp)
jmp    132e <main+0x1fe>
xor    %eax,%eax
add    $0x9950,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x9938,%rsp
lea    0xec0(%rip),%rdi
call   1040 <puts@plt>
lea    0xeec(%rip),%rdi
call   1040 <puts@plt>
lea    0xe84(%rip),%rdi
xor    %r14d,%r14d
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe90(%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),%eax
mov    %eax,%r9d
shr    $0x1f,%r9d
add    %eax,%r9d
sar    %r9d
movslq %r9d,%rcx
movl   $0x1,0x10(%rsp,%rcx,4)
mov    %eax,%r8d
imul   %r8d,%r8d
cmp    $0x2,%r8d
jb     124f <main+0xff>
neg    %r8d
mov    $0x2,%edx
jmp    1213 <main+0xc3>
xchg   %ax,%ax
add    $0x1,%r14d
movslq %r14d,%rcx
imul   $0x18c,%rcx,%rcx
movslq %r9d,%rsi
add    %rsp,%rcx
add    $0x10,%rcx
lea    (%rcx,%rsi,4),%rcx
mov    %r9d,%edi
mov    %edx,(%rcx)
lea    (%r8,%rdx,1),%ecx
add    $0x1,%ecx
add    $0x1,%edx
mov    %edi,%r9d
cmp    $0x1,%ecx
je     124f <main+0xff>
lea    0x1(%r9),%ecx
mov    %eax,%ebp
test   %r14d,%r14d
je     1221 <main+0xd1>
mov    %r14d,%ebp
add    $0xffffffff,%ebp
xor    %edi,%edi
cmp    %eax,%ecx
je     122c <main+0xdc>
mov    %ecx,%edi
movslq %ebp,%rsi
movslq %edi,%rcx
imul   $0x18c,%rsi,%rsi
add    %rsp,%rsi
add    $0x10,%rsi
cmpl   $0x0,(%rsi,%rcx,4)
jne    11e0 <main+0x90>
lea    (%rsi,%rcx,4),%rcx
mov    %ebp,%r14d
jmp    11ff <main+0xaf>
test   %eax,%eax
jle    12ad <main+0x15d>
lea    0xdc6(%rip),%r14
xor    %r15d,%r15d
jmp    127f <main+0x12f>
nop
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r15
movslq 0xc(%rsp),%rax
add    $0x18c,%rbx
cmp    %rax,%r15
jge    12ad <main+0x15d>
test   %eax,%eax
jle    1260 <main+0x110>
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%rbx,%rbp,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbp
movslq 0xc(%rsp),%rax
cmp    %rax,%rbp
jl     1290 <main+0x140>
jmp    1260 <main+0x110>
xor    %eax,%eax
add    $0x9938,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
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"
@.str.4 = [4 x i8] c"%5d\00"
@.str.5 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [99 x [99 x i32]]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %1
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0))
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %2)
%16 = bitcast [99 x [99 x i32]]* %3 to i8*
store i32 0, i32* %4
%17 = load i32, i32* %2
%18 = sdiv i32 %17, 2
store i32 %18, i32* %5
store i32 1, i32* %8
%19 = load i32, i32* %8
%20 = load i32, i32* %4
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [99 x [99 x i32]], [99 x [99 x i32]]* %3, i64 0, i64 %21
%23 = load i32, i32* %5
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [99 x i32], [99 x i32]* %22, i64 0, i64 %24
store i32 %19, i32* %25
store i32 1, i32* %9
br label %26
26: ; preds = %80, %0
%27 = load i32, i32* %9
%28 = load i32, i32* %2
%29 = load i32, i32* %2
%30 = mul nsw i32 %28, %29
%31 = icmp slt i32 %27, %30
br i1 %31, label %32, label %83
32: ; preds = %26
%33 = load i32, i32* %4
store i32 %33, i32* %6
%34 = load i32, i32* %5
store i32 %34, i32* %7
%35 = load i32, i32* %4
%36 = sub nsw i32 %35, 1
store i32 %36, i32* %4
%37 = load i32, i32* %5
%38 = add nsw i32 %37, 1
store i32 %38, i32* %5
%39 = load i32, i32* %4
%40 = icmp eq i32 %39, -1
br i1 %40, label %41, label %44
41: ; preds = %32
%42 = load i32, i32* %2
%43 = sub nsw i32 %42, 1
store i32 %43, i32* %4
br label %44
44: ; preds = %41, %32
%45 = load i32, i32* %5
%46 = load i32, i32* %2
%47 = icmp eq i32 %45, %46
br i1 %47, label %48, label %49
48: ; preds = %44
store i32 0, i32* %5
br label %49
49: ; preds = %48, %44
%50 = load i32, i32* %8
%51 = add nsw i32 %50, 1
store i32 %51, i32* %8
%52 = load i32, i32* %4
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds [99 x [99 x i32]], [99 x [99 x i32]]* %3, i64 0, i64 %53
%55 = load i32, i32* %5
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds [99 x i32], [99 x i32]* %54, i64 0, i64 %56
%58 = load i32, i32* %57
%59 = icmp eq i32 %58, 0
br i1 %59, label %60, label %68
60: ; preds = %49
%61 = load i32, i32* %8
%62 = load i32, i32* %4
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds [99 x [99 x i32]], [99 x [99 x i32]]* %3, i64 0, i64 %63
%65 = load i32, i32* %5
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds [99 x i32], [99 x i32]* %64, i64 0, i64 %66
store i32 %61, i32* %67
br label %79
68: ; preds = %49
%69 = load i32, i32* %6
%70 = add nsw i32 %69, 1
store i32 %70, i32* %4
%71 = load i32, i32* %7
store i32 %71, i32* %5
%72 = load i32, i32* %8
%73 = load i32, i32* %4
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds [99 x [99 x i32]], [99 x [99 x i32]]* %3, i64 0, i64 %74
%76 = load i32, i32* %5
%77 = sext i32 %76 to i64
%78 = getelementptr inbounds [99 x i32], [99 x i32]* %75, i64 0, i64 %77
store i32 %72, i32* %78
br label %79
79: ; preds = %68, %60
br label %80
80: ; preds = %79
%81 = load i32, i32* %9
%82 = add nsw i32 %81, 1
store i32 %82, i32* %9
br label %26
83: ; preds = %26
store i32 0, i32* %10
br label %84
84: ; preds = %107, %83
%85 = load i32, i32* %10
%86 = load i32, i32* %2
%87 = icmp slt i32 %85, %86
br i1 %87, label %88, label %110
88: ; preds = %84
store i32 0, i32* %11
br label %89
89: ; preds = %102, %88
%90 = load i32, i32* %11
%91 = load i32, i32* %2
%92 = icmp slt i32 %90, %91
br i1 %92, label %93, label %105
93: ; preds = %89
%94 = load i32, i32* %10
%95 = sext i32 %94 to i64
%96 = getelementptr inbounds [99 x [99 x i32]], [99 x [99 x i32]]* %3, i64 0, i64 %95
%97 = load i32, i32* %11
%98 = sext i32 %97 to i64
%99 = getelementptr inbounds [99 x i32], [99 x i32]* %96, i64 0, i64 %98
%100 = load i32, i32* %99
%101 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %100)
br label %102
102: ; preds = %93
%103 = load i32, i32* %11
%104 = add nsw i32 %103, 1
store i32 %104, i32* %11
br label %89
105: ; preds = %89
%106 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %107
107: ; preds = %105
%108 = load i32, i32* %10
%109 = add nsw i32 %108, 1
store i32 %109, i32* %10
br label %84
110: ; preds = %84
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.4 = [4 x i8] c"%5d\00"
@str = [56 x i8] c"this program creates a magic square of a specified size\00"
@str.6 = [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.6, i64 0, i64 0))
%6 = tail call i32 (i8*, ...) @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 = sdiv i32 %9, 2
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [99 x [99 x i32]], [99 x [99 x i32]]* %2, i64 0, i64 0, i64 %11
store i32 1, i32* %12
%13 = mul i32 %9, %9
%14 = icmp ugt i32 %13, 1
br i1 %14, label %17, label %15
15: ; preds = %17, %0
%16 = icmp sgt i32 %9, 0
br i1 %16, label %41, label %45
17: ; preds = %0, %17
%18 = phi i32 [ %27, %17 ], [ 1, %0 ]
%19 = phi i32 [ %39, %17 ], [ 0, %0 ]
%20 = phi i32 [ %38, %17 ], [ %10, %0 ]
%21 = add nsw i32 %20, 1
%22 = icmp eq i32 %19, 0
%23 = select i1 %22, i32 %9, i32 %19
%24 = add nsw i32 %23, -1
%25 = icmp eq i32 %21, %9
%26 = select i1 %25, i32 0, i32 %21
%27 = add nuw nsw i32 %18, 1
%28 = sext i32 %24 to i64
%29 = sext i32 %26 to i64
%30 = getelementptr inbounds [99 x [99 x i32]], [99 x [99 x i32]]* %2, i64 0, i64 %28, i64 %29
%31 = load i32, i32* %30
%32 = icmp eq i32 %31, 0
%33 = add nsw i32 %19, 1
%34 = sext i32 %33 to i64
%35 = sext i32 %20 to i64
%36 = getelementptr inbounds [99 x [99 x i32]], [99 x [99 x i32]]* %2, i64 0, i64 %34, i64 %35
%37 = select i1 %32, i32* %30, i32* %36
%38 = select i1 %32, i32 %26, i32 %20
%39 = select i1 %32, i32 %24, i32 %33
store i32 %27, i32* %37
%40 = icmp eq i32 %27, %13
br i1 %40, label %15, label %17
41: ; preds = %15, %46
%42 = phi i32 [ %49, %46 ], [ %9, %15 ]
%43 = phi i64 [ %48, %46 ], [ 0, %15 ]
%44 = icmp sgt i32 %42, 0
br i1 %44, label %52, label %46
45: ; preds = %46, %15
ret i32 0
46: ; preds = %52, %41
%47 = call i32 @putchar(i32 10)
%48 = add nuw nsw i64 %43, 1
%49 = load i32, i32* %1
%50 = sext i32 %49 to i64
%51 = icmp slt i64 %48, %50
br i1 %51, label %41, label %45
52: ; preds = %41, %52
%53 = phi i64 [ %57, %52 ], [ 0, %41 ]
%54 = getelementptr inbounds [99 x [99 x i32]], [99 x [99 x i32]]* %2, i64 0, i64 %43, i64 %53
%55 = load i32, i32* %54
%56 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %55)
%57 = add nuw nsw i64 %53, 1
%58 = load i32, i32* %1
%59 = sext i32 %58 to i64
%60 = icmp slt i64 %57, %59
br i1 %60, label %52, label %46
}