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


x86 assembly (clang, -O0):
<test_somar_todos>:
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   1050 <memcpy@plt>
lea    -0x30(%rbp),%rdi
call   1040 <somar_todos@plt>
cmp    $0x2d,%eax
jne    1188 <test_somar_todos+0x58>
lea    0xec0(%rip),%rdi
call   1030 <printf@plt>
jmp    1194 <test_somar_todos+0x64>
lea    0xeb8(%rip),%rdi
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_somar_todos>:
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 <somar_todos@plt>
cmp    $0x2d,%eax
lea    0xefd(%rip),%rax
lea    0xeea(%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 = [24 x i8] c"teste Q4: somar_todos.\0A\00"
@__const.test_somar_todos.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_somar_todos() {
%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 ([24 x i8], [24 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 @somar_todos(i32** %6)
%8 = icmp eq i32 %7, 45
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_somar_todos.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 = [23 x i8] c"teste Q4: somar_todos.\00"
@str.5 = [12 x i8] c" not ok.\00"
@str.6 = [8 x i8] c" ok.\00"
define void @test_somar_todos() {
%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 ([23 x i8], [23 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 @somar_todos(i32** %5)
%7 = icmp eq i32 %6, 45
%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
}