#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 quadrado_magico(int **);
void test_quadrado_magico() {
  printf("------------------------------------\n");
  printf("teste Q7: quadrado_magico.\n");
  int mat[3][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
  if (quadrado_magico(mat) == false) {
    printf("    ok.\n");
  } else {
    printf("    not ok.\n");
  }
}


x86 assembly (clang, -O0):
<test_quadrado_magico>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
lea    0xec1(%rip),%rdi
call   1030 <printf@plt>
lea    0xedb(%rip),%rdi
call   1030 <printf@plt>
lea    -0x30(%rbp),%rdi
lea    0xf05(%rip),%rsi
mov    $0x24,%edx
call   1040 <memcpy@plt>
lea    -0x30(%rbp),%rdi
call   1050 <quadrado_magico@plt>
cmp    $0x0,%eax
jne    1188 <test_quadrado_magico+0x58>
lea    0xec4(%rip),%rdi
call   1030 <printf@plt>
jmp    1194 <test_quadrado_magico+0x64>
lea    0xebc(%rip),%rdi
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_quadrado_magico>:
sub    $0x28,%rsp
lea    0xef9(%rip),%rdi
call   1030 <puts@plt>
lea    0xf12(%rip),%rdi
call   1030 <puts@plt>
mov    0xede(%rip),%eax
mov    %eax,0x20(%rsp)
movaps 0xec3(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xea7(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rdi
call   1040 <quadrado_magico@plt>
test   %eax,%eax
lea    0xf02(%rip),%rax
lea    0xeef(%rip),%rdi
cmove  %rax,%rdi
call   1030 <puts@plt>
add    $0x28,%rsp
ret

LLVM IR (-O0):
@.str = [38 x i8] c"------------------------------------\0A\00"
@.str.1 = [28 x i8] c"teste Q7: quadrado_magico.\0A\00"
@__const.test_quadrado_magico.mat = [3 x [3 x i32]] [[3 x i32] [i32 1, i32 2, i32 3], [3 x i32] [i32 4, i32 5, i32 6], [3 x i32] [i32 7, i32 8, i32 9]]
@.str.2 = [9 x i8] c" ok.\0A\00"
@.str.3 = [13 x i8] c" not ok.\0A\00"
define void @test_quadrado_magico() {
%1 = alloca [3 x [3 x i32]]
%2 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%3 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
%4 = bitcast [3 x [3 x i32]]* %1 to i8*
%5 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %1, i64 0, i64 0
%6 = bitcast [3 x i32]* %5 to i32**
%7 = call i32 @quadrado_magico(i32** %6)
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %0
%10 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
br label %13
11: ; preds = %0
%12 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
br label %13
13: ; preds = %11, %9
ret void
}

LLVM IR (-O2):
@__const.test_quadrado_magico.mat = [3 x [3 x i32]] [[3 x i32] [i32 1, i32 2, i32 3], [3 x i32] [i32 4, i32 5, i32 6], [3 x i32] [i32 7, i32 8, i32 9]]
@str = [37 x i8] c"------------------------------------\00"
@str.4 = [27 x i8] c"teste Q7: quadrado_magico.\00"
@str.5 = [12 x i8] c" not ok.\00"
@str.6 = [8 x i8] c" ok.\00"
define void @test_quadrado_magico() {
%1 = alloca [3 x [3 x i32]]
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str, i64 0, i64 0))
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.4, i64 0, i64 0))
%4 = bitcast [3 x [3 x i32]]* %1 to i8*
%5 = bitcast [3 x [3 x i32]]* %1 to i32**
%6 = call i32 @quadrado_magico(i32** %5)
%7 = icmp eq i32 %6, 0
%8 = select i1 %7, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @str.6, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @str.5, i64 0, i64 0)
%9 = call i32 @puts(i8* dereferenceable(1) %8)
ret void
}