#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 */
scalar_t__ search(int *, int, int);
bool searchMatrix0(int **matrix, int rSize, int cSize, int target) {
  for (int i = 0; i < rSize; i++) {
    if (search(matrix[i], cSize, target))
      return true;
  }
  return false;
}


x86 assembly (clang, -O0):
<searchMatrix0>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1178 <searchMatrix0+0x68>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   1030 <search@plt>
cmp    $0x0,%rax
je     1165 <searchMatrix0+0x55>
movl   $0x1,-0x4(%rbp)
jmp    117f <searchMatrix0+0x6f>
jmp    116a <searchMatrix0+0x5a>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    112c <searchMatrix0+0x1c>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<searchMatrix0>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %esi,%esi
jle    117b <searchMatrix0+0x6b>
mov    %ecx,%r14d
mov    %edx,%r12d
mov    %esi,%r15d
mov    %rdi,%r13
mov    (%rdi),%rdi
mov    %edx,%esi
mov    %ecx,%edx
call   1030 <search@plt>
mov    %rax,%rcx
mov    $0x1,%eax
test   %rcx,%rcx
jne    117d <searchMatrix0+0x6d>
mov    %r15d,%ebp
mov    $0x1,%ecx
nopl   0x0(%rax)
mov    %rcx,%rbx
cmp    %rcx,%rbp
je     1171 <searchMatrix0+0x61>
mov    0x0(%r13,%rbx,8),%rdi
mov    %r12d,%esi
mov    %r14d,%edx
call   1030 <search@plt>
lea    0x1(%rbx),%rcx
test   %rax,%rax
je     1150 <searchMatrix0+0x40>
xor    %eax,%eax
cmp    %rbp,%rbx
setb   %al
jmp    117d <searchMatrix0+0x6d>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @searchMatrix0(i32** %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32**
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32** %0, i32*** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i32 0, i32* %10
br label %11
11: ; preds = %27, %4
%12 = load i32, i32* %10
%13 = load i32, i32* %7
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %30
15: ; preds = %11
%16 = load i32**, i32*** %6
%17 = load i32, i32* %10
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i32*, i32** %16, i64 %18
%20 = load i32*, i32** %19
%21 = load i32, i32* %8
%22 = load i32, i32* %9
%23 = call i64 @search(i32* %20, i32 %21, i32 %22)
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %15
store i32 1, i32* %5
br label %31
26: ; preds = %15
br label %27
27: ; preds = %26
%28 = load i32, i32* %10
%29 = add nsw i32 %28, 1
store i32 %29, i32* %10
br label %11
30: ; preds = %11
store i32 0, i32* %5
br label %31
31: ; preds = %30, %25
%32 = load i32, i32* %5
ret i32 %32
}

LLVM IR (-O2):
define i32 @searchMatrix0(i32** nocapture %0, i32 %1, i32 %2, i32 %3) {
%5 = icmp sgt i32 %1, 0
br i1 %5, label %6, label %24
6: ; preds = %4
%7 = zext i32 %1 to i64
%8 = zext i32 %1 to i64
%9 = load i32*, i32** %0
%10 = tail call i64 @search(i32* %9, i32 %2, i32 %3)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %24
12: ; preds = %6, %15
%13 = phi i64 [ %20, %15 ], [ 1, %6 ]
%14 = icmp eq i64 %13, %8
br i1 %14, label %21, label %15
15: ; preds = %12
%16 = getelementptr inbounds i32*, i32** %0, i64 %13
%17 = load i32*, i32** %16
%18 = tail call i64 @search(i32* %17, i32 %2, i32 %3)
%19 = icmp eq i64 %18, 0
%20 = add nuw nsw i64 %13, 1
br i1 %19, label %12, label %21
21: ; preds = %12, %15
%22 = icmp ult i64 %13, %7
%23 = zext i1 %22 to i32
br label %24
24: ; preds = %21, %6, %4
%25 = phi i32 [ 0, %4 ], [ 1, %6 ], [ %23, %21 ]
ret i32 %25
}