#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 */
scalar_t__ get_sum(int *, int, int, int);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, int *);
int square(int);
int main(int argc, const char *argv[]) {
  int m, n, i, sum = 0;
  scanf("%d", &m);
  n = square(m);
  int a[n];
  for (i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  if (n == 1) {
    printf("%d", a[0]);
    return 0;
  }
  sum += get_sum(a, n, 0, m + 1);
  sum += get_sum(a, n - 1, m - 1, m - 1);
  if (m % 2) {
    sum -= a[(n - 1) / 2];
  }
  printf("%d", sum);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x20(%rbp)
lea    0xe9c(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x14(%rbp),%edi
call   1030 <square@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x28(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x40(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11db <main+0x9b>
mov    -0x40(%rbp),%rsi
movslq -0x1c(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe38(%rip),%rdi
call   1050 <scanf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11a6 <main+0x66>
cmpl   $0x1,-0x18(%rbp)
jne    120a <main+0xca>
mov    -0x40(%rbp),%rax
mov    (%rax),%esi
lea    0xe0e(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x34(%rbp)
jmp    12a6 <main+0x166>
mov    -0x40(%rbp),%rdi
mov    -0x18(%rbp),%esi
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
xor    %edx,%edx
call   1060 <get_sum@plt>
mov    -0x40(%rbp),%rdi
mov    %rax,%rcx
movslq -0x20(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%esi
sub    $0x1,%esi
mov    -0x14(%rbp),%edx
sub    $0x1,%edx
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
call   1060 <get_sum@plt>
mov    %rax,%rcx
movslq -0x20(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x20(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     1289 <main+0x149>
mov    -0x18(%rbp),%eax
sub    $0x1,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x40(%rbp),%rax
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%ecx
mov    -0x20(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%esi
lea    0xd6d(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x34(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xea8(%rip),%rdi
lea    -0x2c(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x2c(%rbp),%edi
call   1030 <square@plt>
mov    %rsp,%rbx
mov    %eax,%r14d
mov    %rsp,%r13
lea    0xf(,%r14,4),%rcx
and    $0xfffffffffffffff0,%rcx
sub    %rcx,%r13
mov    %r13,%rsp
test   %eax,%eax
jle    11c5 <main+0x85>
mov    %rbx,-0x38(%rbp)
lea    0x0(,%r14,4),%rbx
xor    %r12d,%r12d
lea    0xe62(%rip),%r15
xchg   %ax,%ax
lea    (%r12,%r13,1),%rsi
mov    %r15,%rdi
call   1050 <scanf@plt>
add    $0x4,%r12
cmp    %r12,%rbx
jne    11a0 <main+0x60>
cmp    $0x1,%r14d
mov    -0x38(%rbp),%rbx
jne    11c5 <main+0x85>
mov    0x0(%r13),%esi
jmp    1210 <main+0xd0>
mov    -0x2c(%rbp),%ecx
add    $0x1,%ecx
mov    %r13,%rdi
mov    %r14d,%esi
xor    %edx,%edx
call   1060 <get_sum@plt>
mov    %rax,%r15
add    $0xffffffff,%r14d
mov    -0x2c(%rbp),%ecx
add    $0xffffffff,%ecx
mov    %r13,%rdi
mov    %r14d,%esi
mov    %ecx,%edx
call   1060 <get_sum@plt>
mov    %rax,%rsi
add    %r15d,%esi
testb  $0x1,-0x2c(%rbp)
je     1210 <main+0xd0>
mov    %r14d,%eax
shr    $0x1f,%eax
add    %r14d,%eax
sar    %eax
cltq
sub    0x0(%r13,%rax,4),%esi
lea    0xde9(%rip),%rdi
call   1040 <printf@plt>
mov    %rbx,%rsp
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%6 = load i32, i32* %3
%7 = call i32 @square(i32 %6)
%8 = zext i32 %7 to i64
%9 = call i8* @llvm.stacksave()
%10 = alloca i32, i64 %8
%11 = icmp sgt i32 %7, 0
br i1 %11, label %12, label %22
12: ; preds = %2, %12
%13 = phi i64 [ %16, %12 ], [ 0, %2 ]
%14 = getelementptr inbounds i32, i32* %10, i64 %13
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %14)
%16 = add nuw nsw i64 %13, 1
%17 = icmp eq i64 %16, %8
br i1 %17, label %18, label %12
18: ; preds = %12
%19 = icmp eq i32 %7, 1
br i1 %19, label %20, label %22
20: ; preds = %18
%21 = load i32, i32* %10
br label %41
22: ; preds = %2, %18
%23 = load i32, i32* %3
%24 = add nsw i32 %23, 1
%25 = call i64 @get_sum(i32* %10, i32 %7, i32 0, i32 %24)
%26 = add nsw i32 %7, -1
%27 = load i32, i32* %3
%28 = add nsw i32 %27, -1
%29 = call i64 @get_sum(i32* %10, i32 %26, i32 %28, i32 %28)
%30 = add i64 %29, %25
%31 = trunc i64 %30 to i32
%32 = load i32, i32* %3
%33 = and i32 %32, 1
%34 = icmp eq i32 %33, 0
br i1 %34, label %41, label %35
35: ; preds = %22
%36 = sdiv i32 %26, 2
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i32, i32* %10, i64 %37
%39 = load i32, i32* %38
%40 = sub nsw i32 %31, %39
br label %41
41: ; preds = %22, %35, %20
%42 = phi i32 [ %21, %20 ], [ %40, %35 ], [ %31, %22 ]
%43 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %42)
ret i32 0
}