#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 is_magic(int, int **);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  enum { N = 3 };
  int m[N][N] = {{2, 7, 6}, {9, 5, 1}, {4, 3, 8}};
  int i, j, is_mag;
  for (i = 0; i < N; i++) {
    for (j = 0; j < N; j++)
      printf("%d\t", m[i][j]);
    printf("\n");
  }
  is_mag = is_magic(N, (int **)&m[0][0]);
  printf("The matrix is ");
  if (is_mag)
    printf("magic!\n");
  else
    printf("not magic!\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x40(%rbp),%rdi
lea    0xeaf(%rip),%rsi
mov    $0x24,%edx
call   1050 <memcpy@plt>
movl   $0x0,-0x44(%rbp)
cmpl   $0x3,-0x44(%rbp)
jge    11cb <main+0x9b>
movl   $0x0,-0x48(%rbp)
cmpl   $0x3,-0x48(%rbp)
jge    11af <main+0x7f>
movslq -0x44(%rbp),%rcx
lea    -0x40(%rbp),%rax
imul   $0xc,%rcx,%rcx
add    %rcx,%rax
movslq -0x48(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
jmp    1173 <main+0x43>
lea    0xe8b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    1162 <main+0x32>
lea    -0x40(%rbp),%rsi
mov    $0x3,%edi
call   1030 <is_magic@plt>
mov    %eax,-0x4c(%rbp)
lea    0xe45(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x0,-0x4c(%rbp)
je     1207 <main+0xd7>
lea    0xe40(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1215 <main+0xe5>
lea    0xe29(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x30,%rsp
mov    0xed5(%rip),%eax
mov    %eax,0x20(%rsp)
movaps 0xeba(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xe9e(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0xeb7(%rip),%rbx
mov    %rbx,%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
mov    $0x7,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
mov    $0x6,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %rbx,%rdi
mov    $0x9,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
mov    $0x5,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
mov    $0x8,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %rsp,%rsi
mov    $0x3,%edi
call   1050 <is_magic@plt>
mov    %eax,%ebx
lea    0xe00(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
test   %ebx,%ebx
lea    0xdff(%rip),%rax
lea    0xdfc(%rip),%rdi
cmove  %rax,%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.m = [3 x [3 x i32]] [[3 x i32] [i32 2, i32 7, i32 6], [3 x i32] [i32 9, i32 5, i32 1], [3 x i32] [i32 4, i32 3, i32 8]]
@.str = [4 x i8] c"%d\09\00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [15 x i8] c"The matrix is \00"
@.str.3 = [8 x i8] c"magic!\0A\00"
@.str.4 = [12 x i8] c"not magic!\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [3 x [3 x i32]]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = bitcast [3 x [3 x i32]]* %6 to i8*
store i32 0, i32* %7
br label %11
11: ; preds = %32, %2
%12 = load i32, i32* %7
%13 = icmp slt i32 %12, 3
br i1 %13, label %14, label %35
14: ; preds = %11
store i32 0, i32* %8
br label %15
15: ; preds = %27, %14
%16 = load i32, i32* %8
%17 = icmp slt i32 %16, 3
br i1 %17, label %18, label %30
18: ; preds = %15
%19 = load i32, i32* %7
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %6, i64 0, i64 %20
%22 = load i32, i32* %8
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [3 x i32], [3 x i32]* %21, i64 0, i64 %23
%25 = load i32, i32* %24
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %25)
br label %27
27: ; preds = %18
%28 = load i32, i32* %8
%29 = add nsw i32 %28, 1
store i32 %29, i32* %8
br label %15
30: ; preds = %15
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %32
32: ; preds = %30
%33 = load i32, i32* %7
%34 = add nsw i32 %33, 1
store i32 %34, i32* %7
br label %11
35: ; preds = %11
%36 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %6, i64 0, i64 0
%37 = getelementptr inbounds [3 x i32], [3 x i32]* %36, i64 0, i64 0
%38 = bitcast i32* %37 to i32**
%39 = call i32 @is_magic(i32 3, i32** %38)
store i32 %39, i32* %9
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%41 = load i32, i32* %9
%42 = icmp ne i32 %41, 0
br i1 %42, label %43, label %45
43: ; preds = %35
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
br label %47
45: ; preds = %35
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
br label %47
47: ; preds = %45, %43
ret i32 0
}

LLVM IR (-O2):
@__const.main.m = [3 x [3 x i32]] [[3 x i32] [i32 2, i32 7, i32 6], [3 x i32] [i32 9, i32 5, i32 1], [3 x i32] [i32 4, i32 3, i32 8]]
@.str = [4 x i8] c"%d\09\00"
@.str.2 = [15 x i8] c"The matrix is \00"
@str = [11 x i8] c"not magic!\00"
@str.5 = [7 x i8] c"magic!\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [3 x [3 x i32]]
%4 = bitcast [3 x [3 x i32]]* %3 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 2)
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 7)
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 6)
%8 = tail call i32 @putchar(i32 10)
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 9)
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 5)
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 1)
%12 = tail call i32 @putchar(i32 10)
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 4)
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 3)
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 8)
%16 = tail call i32 @putchar(i32 10)
%17 = bitcast [3 x [3 x i32]]* %3 to i32**
%18 = call i32 @is_magic(i32 3, i32** %17)
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%20 = icmp eq i32 %18, 0
%21 = select i1 %20, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @str.5, i64 0, i64 0)
%22 = call i32 @puts(i8* dereferenceable(1) %21)
ret i32 0
}