#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, ...);
int /*<<< orphan*/ putchar(char);
int /*<<< orphan*/ puts(char *);
int main() {
  int r, c;
  int m[3][3] = {8, 7, 6, 3, 5, 7, 4, 9, 5};
  puts("Presenting the Magic Square:\n\n");
  for (r = 0; r < 3; r++)
    printf("%d  %d  %d\n", m[r][0], m[r][1], m[r][2]);
  putchar('\n');
  for (r = 0; r < 3; r++)
    printf("Sum for row %d is %d\n", r + 1, m[r][0] + m[r][1] + m[r][2]);
  for (c = 0; c < 3; c++)
    printf("Sum for column %d is %d\n", c + 1, m[0][c] + m[1][c] + m[2][c]);
  printf("Sum for diagonal NW/SE is %d\n", m[0][0] + m[1][1] + m[2][2]);
  printf("Sum for diagonal NE/SW is %d\n", m[0][2] + m[1][1] + m[2][0]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x30(%rbp),%rdi
lea    0xea6(%rip),%rsi
mov    $0x24,%edx
call   1060 <memcpy@plt>
lea    0xeb9(%rip),%rdi
call   1040 <puts@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    11d2 <main+0x92>
movslq -0x8(%rbp),%rcx
lea    -0x30(%rbp),%rax
imul   $0xc,%rcx,%rcx
add    %rcx,%rax
mov    (%rax),%esi
movslq -0x8(%rbp),%rcx
lea    -0x30(%rbp),%rax
imul   $0xc,%rcx,%rcx
add    %rcx,%rax
mov    0x4(%rax),%edx
movslq -0x8(%rbp),%rcx
lea    -0x30(%rbp),%rax
imul   $0xc,%rcx,%rcx
add    %rcx,%rax
mov    0x8(%rax),%ecx
lea    0xe86(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1177 <main+0x37>
mov    $0xa,%edi
call   1030 <putchar@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    1244 <main+0x104>
mov    -0x8(%rbp),%esi
add    $0x1,%esi
movslq -0x8(%rbp),%rcx
lea    -0x30(%rbp),%rax
imul   $0xc,%rcx,%rcx
add    %rcx,%rax
mov    (%rax),%edx
movslq -0x8(%rbp),%rcx
lea    -0x30(%rbp),%rax
imul   $0xc,%rcx,%rcx
add    %rcx,%rax
add    0x4(%rax),%edx
movslq -0x8(%rbp),%rcx
lea    -0x30(%rbp),%rax
imul   $0xc,%rcx,%rcx
add    %rcx,%rax
add    0x8(%rax),%edx
lea    0xe20(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11e3 <main+0xa3>
movl   $0x0,-0xc(%rbp)
cmpl   $0x3,-0xc(%rbp)
jge    128f <main+0x14f>
mov    -0xc(%rbp),%esi
add    $0x1,%esi
movslq -0xc(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%edx
movslq -0xc(%rbp),%rax
add    -0x24(%rbp,%rax,4),%edx
movslq -0xc(%rbp),%rax
add    -0x18(%rbp,%rax,4),%edx
lea    0xdeb(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    124b <main+0x10b>
mov    -0x30(%rbp),%esi
add    -0x20(%rbp),%esi
add    -0x10(%rbp),%esi
lea    0xddf(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x28(%rbp),%esi
add    -0x20(%rbp),%esi
add    -0x18(%rbp),%esi
lea    0xde6(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xec8(%rip),%rdi
call   1040 <puts@plt>
lea    0xedb(%rip),%rbx
mov    %rbx,%rdi
mov    $0x8,%esi
mov    $0x7,%edx
mov    $0x6,%ecx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
mov    $0x5,%edx
mov    $0x7,%ecx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
mov    $0x9,%edx
mov    $0x5,%ecx
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe8b(%rip),%rbx
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x15,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
mov    $0xf,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
mov    $0x12,%edx
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe5e(%rip),%rbx
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0xf,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
mov    $0x15,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
mov    $0x12,%edx
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe34(%rip),%rdi
mov    $0x12,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe3f(%rip),%rdi
mov    $0xf,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.m = [3 x [3 x i32]] [[3 x i32] [i32 8, i32 7, i32 6], [3 x i32] [i32 3, i32 5, i32 7], [3 x i32] [i32 4, i32 9, i32 5]]
@.str = [31 x i8] c"Presenting the Magic Square:\0A\0A\00"
@.str.1 = [12 x i8] c"%d %d %d\0A\00"
@.str.2 = [22 x i8] c"Sum for row %d is %d\0A\00"
@.str.3 = [25 x i8] c"Sum for column %d is %d\0A\00"
@.str.4 = [30 x i8] c"Sum for diagonal NW/SE is %d\0A\00"
@.str.5 = [30 x i8] c"Sum for diagonal NE/SW is %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [3 x [3 x i32]]
store i32 0, i32* %1
%5 = bitcast [3 x [3 x i32]]* %4 to i8*
%6 = call i32 @puts(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %2
br label %7
7: ; preds = %27, %0
%8 = load i32, i32* %2
%9 = icmp slt i32 %8, 3
br i1 %9, label %10, label %30
10: ; preds = %7
%11 = load i32, i32* %2
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %4, i64 0, i64 %12
%14 = getelementptr inbounds [3 x i32], [3 x i32]* %13, i64 0, i64 0
%15 = load i32, i32* %14
%16 = load i32, i32* %2
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %4, i64 0, i64 %17
%19 = getelementptr inbounds [3 x i32], [3 x i32]* %18, i64 0, i64 1
%20 = load i32, i32* %19
%21 = load i32, i32* %2
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %4, i64 0, i64 %22
%24 = getelementptr inbounds [3 x i32], [3 x i32]* %23, i64 0, i64 2
%25 = load i32, i32* %24
%26 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %15, i32 %20, i32 %25)
br label %27
27: ; preds = %10
%28 = load i32, i32* %2
%29 = add nsw i32 %28, 1
store i32 %29, i32* %2
br label %7
30: ; preds = %7
%31 = call i32 @putchar(i8 signext 10)
store i32 0, i32* %2
br label %32
32: ; preds = %56, %30
%33 = load i32, i32* %2
%34 = icmp slt i32 %33, 3
br i1 %34, label %35, label %59
35: ; preds = %32
%36 = load i32, i32* %2
%37 = add nsw i32 %36, 1
%38 = load i32, i32* %2
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %4, i64 0, i64 %39
%41 = getelementptr inbounds [3 x i32], [3 x i32]* %40, i64 0, i64 0
%42 = load i32, i32* %41
%43 = load i32, i32* %2
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %4, i64 0, i64 %44
%46 = getelementptr inbounds [3 x i32], [3 x i32]* %45, i64 0, i64 1
%47 = load i32, i32* %46
%48 = add nsw i32 %42, %47
%49 = load i32, i32* %2
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %4, i64 0, i64 %50
%52 = getelementptr inbounds [3 x i32], [3 x i32]* %51, i64 0, i64 2
%53 = load i32, i32* %52
%54 = add nsw i32 %48, %53
%55 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i32 %37, i32 %54)
br label %56
56: ; preds = %35
%57 = load i32, i32* %2
%58 = add nsw i32 %57, 1
store i32 %58, i32* %2
br label %32
59: ; preds = %32
store i32 0, i32* %3
br label %60
60: ; preds = %84, %59
%61 = load i32, i32* %3
%62 = icmp slt i32 %61, 3
br i1 %62, label %63, label %87
63: ; preds = %60
%64 = load i32, i32* %3
%65 = add nsw i32 %64, 1
%66 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %4, i64 0, i64 0
%67 = load i32, i32* %3
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds [3 x i32], [3 x i32]* %66, i64 0, i64 %68
%70 = load i32, i32* %69
%71 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %4, i64 0, i64 1
%72 = load i32, i32* %3
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds [3 x i32], [3 x i32]* %71, i64 0, i64 %73
%75 = load i32, i32* %74
%76 = add nsw i32 %70, %75
%77 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %4, i64 0, i64 2
%78 = load i32, i32* %3
%79 = sext i32 %78 to i64
%80 = getelementptr inbounds [3 x i32], [3 x i32]* %77, i64 0, i64 %79
%81 = load i32, i32* %80
%82 = add nsw i32 %76, %81
%83 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i32 %65, i32 %82)
br label %84
84: ; preds = %63
%85 = load i32, i32* %3
%86 = add nsw i32 %85, 1
store i32 %86, i32* %3
br label %60
87: ; preds = %60
%88 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %4, i64 0, i64 0
%89 = getelementptr inbounds [3 x i32], [3 x i32]* %88, i64 0, i64 0
%90 = load i32, i32* %89
%91 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %4, i64 0, i64 1
%92 = getelementptr inbounds [3 x i32], [3 x i32]* %91, i64 0, i64 1
%93 = load i32, i32* %92
%94 = add nsw i32 %90, %93
%95 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %4, i64 0, i64 2
%96 = getelementptr inbounds [3 x i32], [3 x i32]* %95, i64 0, i64 2
%97 = load i32, i32* %96
%98 = add nsw i32 %94, %97
%99 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i32 %98)
%100 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %4, i64 0, i64 0
%101 = getelementptr inbounds [3 x i32], [3 x i32]* %100, i64 0, i64 2
%102 = load i32, i32* %101
%103 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %4, i64 0, i64 1
%104 = getelementptr inbounds [3 x i32], [3 x i32]* %103, i64 0, i64 1
%105 = load i32, i32* %104
%106 = add nsw i32 %102, %105
%107 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %4, i64 0, i64 2
%108 = getelementptr inbounds [3 x i32], [3 x i32]* %107, i64 0, i64 0
%109 = load i32, i32* %108
%110 = add nsw i32 %106, %109
%111 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0), i32 %110)
ret i32 0
}

LLVM IR (-O2):
@.str = [31 x i8] c"Presenting the Magic Square:\0A\0A\00"
@.str.1 = [12 x i8] c"%d %d %d\0A\00"
@.str.2 = [22 x i8] c"Sum for row %d is %d\0A\00"
@.str.3 = [25 x i8] c"Sum for column %d is %d\0A\00"
@.str.4 = [30 x i8] c"Sum for diagonal NW/SE is %d\0A\00"
@.str.5 = [30 x i8] c"Sum for diagonal NE/SW is %d\0A\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 8, i32 7, i32 6)
%3 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 3, i32 5, i32 7)
%4 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 4, i32 9, i32 5)
%5 = tail call i32 @putchar(i8 signext 10)
%6 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i32 1, i32 21)
%7 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i32 2, i32 15)
%8 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i32 3, i32 18)
%9 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i32 1, i32 15)
%10 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i32 2, i32 21)
%11 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i32 3, i32 18)
%12 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i32 18)
%13 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0), i32 15)
ret i32 0
}