#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 *searchMatrix(int *, int *);
int /*<<< orphan*/ searchMatrix1(int *, int *, int **);
int main() {
  int matriz[4][5] = {{1, 2, 3, 4, 5},
                      {6, 7, 8, 9, 10},
                      {11, 12, 13, 14, 15},
                      {16, 17, 18, 19, 20}};
  int *p, **pp, number = 20, *n, *endn;
  p = &matriz[0][0];
  n = &number;
  pp = &endn;
  printf("RETORNO DA FUNÇÃO 1== searchMatrix\n\n");
  endn = searchMatrix(p, n);
  if (endn == NULL) {
    printf("O numero não está na Matriz!\n\n");
  } else {
    printf("endereço da posição do numero na matriz:%p\n", endn);
    printf("numero: %d\n\n\n", *endn);
  }
  printf(" RETORNO DA FUNÇÃO 2== SearchMatrix1\n\n");
  searchMatrix1(p, n, pp);
  if (endn == NULL) {
    printf("O numero não está na Matriz!\n\n");
  } else {
    printf("endereço da posição do numero na matriz:%p\n", endn);
    printf("numero: %d\n\n\n", *endn);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x60(%rbp),%rdi
lea    0xea3(%rip),%rsi
mov    $0x50,%edx
call   1060 <memcpy@plt>
movl   $0x14,-0x74(%rbp)
lea    -0x60(%rbp),%rax
mov    %rax,-0x68(%rbp)
lea    -0x74(%rbp),%rax
mov    %rax,-0x80(%rbp)
lea    -0x88(%rbp),%rax
mov    %rax,-0x70(%rbp)
lea    0xec0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x68(%rbp),%rdi
mov    -0x80(%rbp),%rsi
call   1050 <searchMatrix@plt>
mov    %rax,-0x88(%rbp)
cmpq   $0x0,-0x88(%rbp)
jne    11cc <main+0x8c>
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11f8 <main+0xb8>
mov    -0x88(%rbp),%rsi
lea    0xebe(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x88(%rbp),%rax
mov    (%rax),%esi
lea    0xed6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xed6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x68(%rbp),%rdi
mov    -0x80(%rbp),%rsi
mov    -0x70(%rbp),%rdx
call   1030 <searchMatrix1@plt>
cmpq   $0x0,-0x88(%rbp)
jne    1238 <main+0xf8>
lea    0xe4b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1264 <main+0x124>
mov    -0x88(%rbp),%rsi
lea    0xe52(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x88(%rbp),%rax
mov    (%rax),%esi
lea    0xe6a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x60,%rsp
movaps 0xef4(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0xed8(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xebc(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xea0(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xe84(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movl   $0x14,0x4(%rsp)
lea    0xefd(%rip),%rdi
call   1040 <puts@plt>
lea    0x10(%rsp),%rdi
lea    0x4(%rsp),%rsi
call   1060 <searchMatrix@plt>
mov    %rax,0x8(%rsp)
test   %rax,%rax
je     11d4 <main+0x94>
mov    %rax,%rbx
lea    0xe98(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rbx),%esi
lea    0xeb4(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11e0 <main+0xa0>
lea    0xf00(%rip),%rdi
call   1040 <puts@plt>
lea    0xecc(%rip),%rdi
call   1040 <puts@plt>
lea    0x10(%rsp),%rdi
lea    0x4(%rsp),%rsi
lea    0x8(%rsp),%rdx
call   1030 <searchMatrix1@plt>
mov    0x8(%rsp),%rsi
test   %rsi,%rsi
je     122f <main+0xef>
lea    0xe3f(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rsp),%rax
mov    (%rax),%esi
lea    0xe59(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    123b <main+0xfb>
lea    0xea5(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.matriz = [4 x [5 x i32]] [[5 x i32] [i32 1, i32 2, i32 3, i32 4, i32 5], [5 x i32] [i32 6, i32 7, i32 8, i32 9, i32 10], [5 x i32] [i32 11, i32 12, i32 13, i32 14, i32 15], [5 x i32] [i32 16, i32 17, i32 18, i32 19, i32 20]]
@.str = [39 x i8] c"RETORNO DA FUN\C3\87\C3\83O 1== searchMatrix\0A\0A\00"
@.str.1 = [33 x i8] c"O numero n\C3\A3o est\C3\A1 na Matriz!\0A\0A\00"
@.str.2 = [47 x i8] c"endere\C3\A7o da posi\C3\A7\C3\A3o do numero na matriz:%p\0A\00"
@.str.3 = [14 x i8] c"numero: %d\0A\0A\0A\00"
@.str.4 = [41 x i8] c" RETORNO DA FUN\C3\87\C3\83O 2== SearchMatrix1\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [4 x [5 x i32]]
%3 = alloca i32*
%4 = alloca i32**
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32*
store i32 0, i32* %1
%8 = bitcast [4 x [5 x i32]]* %2 to i8*
store i32 20, i32* %5
%9 = getelementptr inbounds [4 x [5 x i32]], [4 x [5 x i32]]* %2, i64 0, i64 0
%10 = getelementptr inbounds [5 x i32], [5 x i32]* %9, i64 0, i64 0
store i32* %10, i32** %3
store i32* %5, i32** %6
store i32** %7, i32*** %4
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
%12 = load i32*, i32** %3
%13 = load i32*, i32** %6
%14 = call i32* @searchMatrix(i32* %12, i32* %13)
store i32* %14, i32** %7
%15 = load i32*, i32** %7
%16 = icmp eq i32* %15, null
br i1 %16, label %17, label %19
17: ; preds = %0
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
br label %25
19: ; preds = %0
%20 = load i32*, i32** %7
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.2, i64 0, i64 0), i32* %20)
%22 = load i32*, i32** %7
%23 = load i32, i32* %22
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %23)
br label %25
25: ; preds = %19, %17
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.4, i64 0, i64 0))
%27 = load i32*, i32** %3
%28 = load i32*, i32** %6
%29 = load i32**, i32*** %4
%30 = call i32 @searchMatrix1(i32* %27, i32* %28, i32** %29)
%31 = load i32*, i32** %7
%32 = icmp eq i32* %31, null
br i1 %32, label %33, label %35
33: ; preds = %25
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
br label %41
35: ; preds = %25
%36 = load i32*, i32** %7
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.2, i64 0, i64 0), i32* %36)
%38 = load i32*, i32** %7
%39 = load i32, i32* %38
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %39)
br label %41
41: ; preds = %35, %33
ret i32 0
}

LLVM IR (-O2):
@__const.main.matriz = [4 x [5 x i32]] [[5 x i32] [i32 1, i32 2, i32 3, i32 4, i32 5], [5 x i32] [i32 6, i32 7, i32 8, i32 9, i32 10], [5 x i32] [i32 11, i32 12, i32 13, i32 14, i32 15], [5 x i32] [i32 16, i32 17, i32 18, i32 19, i32 20]]
@.str.2 = [47 x i8] c"endere\C3\A7o da posi\C3\A7\C3\A3o do numero na matriz:%p\0A\00"
@.str.3 = [14 x i8] c"numero: %d\0A\0A\0A\00"
@str = [38 x i8] c"RETORNO DA FUN\C3\87\C3\83O 1== searchMatrix\0A\00"
@str.5 = [40 x i8] c" RETORNO DA FUN\C3\87\C3\83O 2== SearchMatrix1\0A\00"
@str.7 = [32 x i8] c"O numero n\C3\A3o est\C3\A1 na Matriz!\0A\00"
define i32 @main() {
%1 = alloca [4 x [5 x i32]]
%2 = alloca i32
%3 = alloca i32*
%4 = bitcast [4 x [5 x i32]]* %1 to i8*
%5 = bitcast i32* %2 to i8*
store i32 20, i32* %2
%6 = bitcast i32** %3 to i8*
%7 = getelementptr inbounds [4 x [5 x i32]], [4 x [5 x i32]]* %1, i64 0, i64 0, i64 0
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str, i64 0, i64 0))
%9 = call i32* @searchMatrix(i32* %7, i32* %2)
store i32* %9, i32** %3
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %13
11: ; preds = %0
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.7, i64 0, i64 0))
br label %17
13: ; preds = %0
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str.2, i64 0, i64 0), i32* %9)
%15 = load i32, i32* %9
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %15)
br label %17
17: ; preds = %13, %11
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.5, i64 0, i64 0))
%19 = call i32 @searchMatrix1(i32* %7, i32* %2, i32** %3)
%20 = load i32*, i32** %3
%21 = icmp eq i32* %20, null
br i1 %21, label %22, label %24
22: ; preds = %17
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.7, i64 0, i64 0))
br label %29
24: ; preds = %17
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str.2, i64 0, i64 0), i32* %20)
%26 = load i32*, i32** %3
%27 = load i32, i32* %26
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %27)
br label %29
29: ; preds = %24, %22
ret i32 0
}