#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*/ atoi(char *);
void *malloc(int);
int /*<<< orphan*/ printf(char *, char *);
scalar_t__ searchMatrix(int **, int, int, int /*<<< orphan*/);
int main(int argc, char **argv) {
  int row = 3;
  int col = 4;
  int **mat = malloc(row * sizeof(int *));
  mat[0] = malloc(col * sizeof(int));
  mat[0][0] = 1;
  mat[0][1] = 3;
  mat[0][2] = 5;
  mat[0][3] = 7;
  mat[1] = malloc(col * sizeof(int));
  mat[1][0] = 10;
  mat[1][1] = 11;
  mat[1][2] = 16;
  mat[1][3] = 20;
  mat[2] = malloc(col * sizeof(int));
  mat[2][0] = 23;
  mat[2][1] = 30;
  mat[2][2] = 34;
  mat[2][3] = 50;
  printf("%s\n", searchMatrix(mat, row, col, atoi(argv[1])) ? "true" : "false");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x3,-0x14(%rbp)
movl   $0x4,-0x18(%rbp)
movslq -0x14(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x20(%rbp)
movslq -0x18(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
movl   $0x1,(%rax)
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
movl   $0x3,0x4(%rax)
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
movl   $0x5,0x8(%rax)
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
movl   $0x7,0xc(%rax)
movslq -0x18(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,0x8(%rax)
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%rax
movl   $0xa,(%rax)
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%rax
movl   $0xb,0x4(%rax)
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%rax
movl   $0x10,0x8(%rax)
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%rax
movl   $0x14,0xc(%rax)
movslq -0x18(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,0x10(%rax)
mov    -0x20(%rbp),%rax
mov    0x10(%rax),%rax
movl   $0x17,(%rax)
mov    -0x20(%rbp),%rax
mov    0x10(%rax),%rax
movl   $0x1e,0x4(%rax)
mov    -0x20(%rbp),%rax
mov    0x10(%rax),%rax
movl   $0x22,0x8(%rax)
mov    -0x20(%rbp),%rax
mov    0x10(%rax),%rax
movl   $0x32,0xc(%rax)
mov    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <atoi@plt>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    %eax,%ecx
call   1040 <searchMatrix@plt>
mov    %rax,%rcx
lea    0xd5c(%rip),%rsi
lea    0xd50(%rip),%rax
cmp    $0x0,%rcx
cmovne %rax,%rsi
lea    0xd3d(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    $0x18,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
mov    $0x10,%edi
call   1050 <malloc@plt>
mov    %rax,(%rbx)
movaps 0xe98(%rip),%xmm0
movups %xmm0,(%rax)
mov    $0x10,%edi
call   1050 <malloc@plt>
mov    %rax,0x8(%rbx)
movaps 0xe90(%rip),%xmm0
movups %xmm0,(%rax)
mov    $0x10,%edi
call   1050 <malloc@plt>
mov    %rax,0x10(%rbx)
movaps 0xe88(%rip),%xmm0
movups %xmm0,(%rax)
mov    0x8(%r14),%rdi
call   1060 <atoi@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
mov    $0x4,%edx
mov    %eax,%ecx
call   1040 <searchMatrix@plt>
test   %rax,%rax
lea    0xe77(%rip),%rax
lea    0xe6b(%rip),%rsi
cmove  %rax,%rsi
lea    0xe5c(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [5 x i8] c"true\00"
@.str.2 = [6 x i8] c"false\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 3, i32* %6
store i32 4, i32* %7
%9 = load i32, i32* %6
%10 = sext i32 %9 to i64
%11 = mul i64 %10, 8
%12 = trunc i64 %11 to i32
%13 = call i8* @malloc(i32 %12)
%14 = bitcast i8* %13 to i32**
store i32** %14, i32*** %8
%15 = load i32, i32* %7
%16 = sext i32 %15 to i64
%17 = mul i64 %16, 4
%18 = trunc i64 %17 to i32
%19 = call i8* @malloc(i32 %18)
%20 = bitcast i8* %19 to i32*
%21 = load i32**, i32*** %8
%22 = getelementptr inbounds i32*, i32** %21, i64 0
store i32* %20, i32** %22
%23 = load i32**, i32*** %8
%24 = getelementptr inbounds i32*, i32** %23, i64 0
%25 = load i32*, i32** %24
%26 = getelementptr inbounds i32, i32* %25, i64 0
store i32 1, i32* %26
%27 = load i32**, i32*** %8
%28 = getelementptr inbounds i32*, i32** %27, i64 0
%29 = load i32*, i32** %28
%30 = getelementptr inbounds i32, i32* %29, i64 1
store i32 3, i32* %30
%31 = load i32**, i32*** %8
%32 = getelementptr inbounds i32*, i32** %31, i64 0
%33 = load i32*, i32** %32
%34 = getelementptr inbounds i32, i32* %33, i64 2
store i32 5, i32* %34
%35 = load i32**, i32*** %8
%36 = getelementptr inbounds i32*, i32** %35, i64 0
%37 = load i32*, i32** %36
%38 = getelementptr inbounds i32, i32* %37, i64 3
store i32 7, i32* %38
%39 = load i32, i32* %7
%40 = sext i32 %39 to i64
%41 = mul i64 %40, 4
%42 = trunc i64 %41 to i32
%43 = call i8* @malloc(i32 %42)
%44 = bitcast i8* %43 to i32*
%45 = load i32**, i32*** %8
%46 = getelementptr inbounds i32*, i32** %45, i64 1
store i32* %44, i32** %46
%47 = load i32**, i32*** %8
%48 = getelementptr inbounds i32*, i32** %47, i64 1
%49 = load i32*, i32** %48
%50 = getelementptr inbounds i32, i32* %49, i64 0
store i32 10, i32* %50
%51 = load i32**, i32*** %8
%52 = getelementptr inbounds i32*, i32** %51, i64 1
%53 = load i32*, i32** %52
%54 = getelementptr inbounds i32, i32* %53, i64 1
store i32 11, i32* %54
%55 = load i32**, i32*** %8
%56 = getelementptr inbounds i32*, i32** %55, i64 1
%57 = load i32*, i32** %56
%58 = getelementptr inbounds i32, i32* %57, i64 2
store i32 16, i32* %58
%59 = load i32**, i32*** %8
%60 = getelementptr inbounds i32*, i32** %59, i64 1
%61 = load i32*, i32** %60
%62 = getelementptr inbounds i32, i32* %61, i64 3
store i32 20, i32* %62
%63 = load i32, i32* %7
%64 = sext i32 %63 to i64
%65 = mul i64 %64, 4
%66 = trunc i64 %65 to i32
%67 = call i8* @malloc(i32 %66)
%68 = bitcast i8* %67 to i32*
%69 = load i32**, i32*** %8
%70 = getelementptr inbounds i32*, i32** %69, i64 2
store i32* %68, i32** %70
%71 = load i32**, i32*** %8
%72 = getelementptr inbounds i32*, i32** %71, i64 2
%73 = load i32*, i32** %72
%74 = getelementptr inbounds i32, i32* %73, i64 0
store i32 23, i32* %74
%75 = load i32**, i32*** %8
%76 = getelementptr inbounds i32*, i32** %75, i64 2
%77 = load i32*, i32** %76
%78 = getelementptr inbounds i32, i32* %77, i64 1
store i32 30, i32* %78
%79 = load i32**, i32*** %8
%80 = getelementptr inbounds i32*, i32** %79, i64 2
%81 = load i32*, i32** %80
%82 = getelementptr inbounds i32, i32* %81, i64 2
store i32 34, i32* %82
%83 = load i32**, i32*** %8
%84 = getelementptr inbounds i32*, i32** %83, i64 2
%85 = load i32*, i32** %84
%86 = getelementptr inbounds i32, i32* %85, i64 3
store i32 50, i32* %86
%87 = load i32**, i32*** %8
%88 = load i32, i32* %6
%89 = load i32, i32* %7
%90 = load i8**, i8*** %5
%91 = getelementptr inbounds i8*, i8** %90, i64 1
%92 = load i8*, i8** %91
%93 = call i32 @atoi(i8* %92)
%94 = call i64 @searchMatrix(i32** %87, i32 %88, i32 %89, i32 %93)
%95 = icmp ne i64 %94, 0
%96 = zext i1 %95 to i64
%97 = select i1 %95, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0)
%98 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %97)
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [5 x i8] c"true\00"
@.str.2 = [6 x i8] c"false\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = tail call dereferenceable_or_null(24) i8* @malloc(i32 24)
%4 = bitcast i8* %3 to i32**
%5 = tail call dereferenceable_or_null(16) i8* @malloc(i32 16)
%6 = bitcast i8* %3 to i8**
store i8* %5, i8** %6
%7 = bitcast i8* %5 to <4 x i32>*
store <4 x i32> <i32 1, i32 3, i32 5, i32 7>, <4 x i32>* %7
%8 = tail call dereferenceable_or_null(16) i8* @malloc(i32 16)
%9 = getelementptr inbounds i32*, i32** %4, i64 1
%10 = bitcast i32** %9 to i8**
store i8* %8, i8** %10
%11 = bitcast i8* %8 to <4 x i32>*
store <4 x i32> <i32 10, i32 11, i32 16, i32 20>, <4 x i32>* %11
%12 = tail call dereferenceable_or_null(16) i8* @malloc(i32 16)
%13 = getelementptr inbounds i32*, i32** %4, i64 2
%14 = bitcast i32** %13 to i8**
store i8* %12, i8** %14
%15 = bitcast i8* %12 to <4 x i32>*
store <4 x i32> <i32 23, i32 30, i32 34, i32 50>, <4 x i32>* %15
%16 = getelementptr inbounds i8*, i8** %1, i64 1
%17 = load i8*, i8** %16
%18 = tail call i32 @atoi(i8* %17)
%19 = tail call i64 @searchMatrix(i32** %4, i32 3, i32 4, i32 %18)
%20 = icmp eq i64 %19, 0
%21 = select i1 %20, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0)
%22 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %21)
ret i32 0
}