#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 */
struct matrix_ledpanel {
  int dummy;
};

/* Variables and functions */
scalar_t__ matrix_panel_contains_real(struct matrix_ledpanel *, int, int);
struct matrix_ledpanel *
matrix_get_panel_at_real(struct matrix_ledpanel **panels, int numpanels, int x,
                         int y) {
  while (--numpanels >= 0) {
    if (matrix_panel_contains_real(panels[numpanels], x, y))
      return panels[numpanels];
  }
  return NULL;
}


x86 assembly (clang, -O0):
<matrix_get_panel_at_real>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jl     1172 <matrix_get_panel_at_real+0x62>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   1030 <matrix_panel_contains_real@plt>
cmp    $0x0,%rax
je     116d <matrix_get_panel_at_real+0x5d>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x8(%rbp)
jmp    117a <matrix_get_panel_at_real+0x6a>
jmp    1125 <matrix_get_panel_at_real+0x15>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<matrix_get_panel_at_real>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %ecx,%r15d
mov    %edx,%ebp
mov    %rdi,%r12
mov    %esi,%ebx
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
nop
test   %ebx,%ebx
jle    1152 <matrix_get_panel_at_real+0x42>
mov    -0x8(%r12,%rbx,8),%rdi
mov    %ebp,%esi
mov    %r15d,%edx
call   1030 <matrix_panel_contains_real@plt>
add    $0xffffffffffffffff,%rbx
test   %rax,%rax
je     1130 <matrix_get_panel_at_real+0x20>
mov    %ebx,%eax
mov    (%r12,%rax,8),%r14
mov    %r14,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
%struct.matrix_ledpanel = type { i32 }
define %struct.matrix_ledpanel* @matrix_get_panel_at_real(%struct.matrix_ledpanel** nocapture %0, i32 %1, i32 %2, i32 %3) {
%5 = zext i32 %1 to i64
br label %6
6: ; preds = %11, %4
%7 = phi i64 [ %8, %11 ], [ %5, %4 ]
%8 = add nsw i64 %7, -1
%9 = trunc i64 %7 to i32
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %20
11: ; preds = %6
%12 = getelementptr inbounds %struct.matrix_ledpanel*, %struct.matrix_ledpanel** %0, i64 %8
%13 = load %struct.matrix_ledpanel*, %struct.matrix_ledpanel** %12
%14 = tail call i64 @matrix_panel_contains_real(%struct.matrix_ledpanel* %13, i32 %2, i32 %3)
%15 = icmp eq i64 %14, 0
br i1 %15, label %6, label %16
16: ; preds = %11
%17 = and i64 %8, 4294967295
%18 = getelementptr inbounds %struct.matrix_ledpanel*, %struct.matrix_ledpanel** %0, i64 %17
%19 = load %struct.matrix_ledpanel*, %struct.matrix_ledpanel** %18
br label %20
20: ; preds = %6, %16
%21 = phi %struct.matrix_ledpanel* [ %19, %16 ], [ null, %6 ]
ret %struct.matrix_ledpanel* %21
}