#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 */
typedef int /*<<< orphan*/ uint8_t;

/* Variables and functions */
int /*<<< orphan*/ *center_matrix(int /*<<< orphan*/ *, int, int, int, int);
int /*<<< orphan*/ *corner_matrix(int /*<<< orphan*/ *, int, int, int, int,
                                  int);
int /*<<< orphan*/ *edge_matrix(int /*<<< orphan*/ *, int, int, int, int, int);
int is_corner(int, int, int, int, int);
int is_edge(int, int, int, int, int);
uint8_t *get_matrix_at(uint8_t *data, int y, int x, int height, int width,
                       int size) {
  int median = size / 2;
  uint8_t *matrix;
  int type;
  if ((type = is_corner(y, x, height, width, median))) {
    matrix = corner_matrix(data, y, x, width, size, type);
  } else if ((type = is_edge(y, x, height, width, median))) {
    matrix = edge_matrix(data, y, x, width, size, type);
  } else {
    matrix = center_matrix(data, y, x, width, size);
  }
  return matrix;
}


x86 assembly (clang, -O0):
<get_matrix_at>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8d,-0x18(%rbp)
mov    %r9d,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x20(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
mov    -0x20(%rbp),%r8d
call   1040 <is_corner@plt>
mov    %eax,-0x2c(%rbp)
cmp    $0x0,%eax
je     11bf <get_matrix_at+0x6f>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x18(%rbp),%ecx
mov    -0x1c(%rbp),%r8d
mov    -0x2c(%rbp),%r9d
call   1030 <corner_matrix@plt>
mov    %rax,-0x28(%rbp)
jmp    1222 <get_matrix_at+0xd2>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
mov    -0x20(%rbp),%r8d
call   1070 <is_edge@plt>
mov    %eax,-0x2c(%rbp)
cmp    $0x0,%eax
je     1203 <get_matrix_at+0xb3>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x18(%rbp),%ecx
mov    -0x1c(%rbp),%r8d
mov    -0x2c(%rbp),%r9d
call   1050 <edge_matrix@plt>
mov    %rax,-0x28(%rbp)
jmp    121d <get_matrix_at+0xcd>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x18(%rbp),%ecx
mov    -0x1c(%rbp),%r8d
call   1060 <center_matrix@plt>
mov    %rax,-0x28(%rbp)
jmp    1222 <get_matrix_at+0xd2>
mov    -0x28(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_matrix_at>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9d,%r12d
mov    %r8d,%r14d
mov    %ecx,%r13d
mov    %edx,%r15d
mov    %esi,%ebp
mov    %rdi,(%rsp)
mov    %r9d,%ebx
shr    $0x1f,%ebx
add    %r9d,%ebx
sar    %ebx
mov    %esi,%edi
mov    %edx,%esi
mov    %ecx,%edx
mov    %r8d,%ecx
mov    %ebx,%r8d
call   1040 <is_corner@plt>
test   %eax,%eax
je     11b2 <get_matrix_at+0x62>
mov    (%rsp),%rdi
mov    %ebp,%esi
mov    %r15d,%edx
mov    %r14d,%ecx
mov    %r12d,%r8d
mov    %eax,%r9d
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <corner_matrix@plt>
mov    %ebp,%edi
mov    %r15d,%esi
mov    %r13d,%edx
mov    %r14d,%ecx
mov    %ebx,%r8d
call   1070 <is_edge@plt>
test   %eax,%eax
je     11ee <get_matrix_at+0x9e>
mov    (%rsp),%rdi
mov    %ebp,%esi
mov    %r15d,%edx
mov    %r14d,%ecx
mov    %r12d,%r8d
mov    %eax,%r9d
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <edge_matrix@plt>
mov    (%rsp),%rdi
mov    %ebp,%esi
mov    %r15d,%edx
mov    %r14d,%ecx
mov    %r12d,%r8d
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <center_matrix@plt>

LLVM IR (-O0):
define i32* @get_matrix_at(i32* %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5) {
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32*
%15 = alloca i32
store i32* %0, i32** %7
store i32 %1, i32* %8
store i32 %2, i32* %9
store i32 %3, i32* %10
store i32 %4, i32* %11
store i32 %5, i32* %12
%16 = load i32, i32* %12
%17 = sdiv i32 %16, 2
store i32 %17, i32* %13
%18 = load i32, i32* %8
%19 = load i32, i32* %9
%20 = load i32, i32* %10
%21 = load i32, i32* %11
%22 = load i32, i32* %13
%23 = call i32 @is_corner(i32 %18, i32 %19, i32 %20, i32 %21, i32 %22)
store i32 %23, i32* %15
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %33
25: ; preds = %6
%26 = load i32*, i32** %7
%27 = load i32, i32* %8
%28 = load i32, i32* %9
%29 = load i32, i32* %11
%30 = load i32, i32* %12
%31 = load i32, i32* %15
%32 = call i32* @corner_matrix(i32* %26, i32 %27, i32 %28, i32 %29, i32 %30, i32 %31)
store i32* %32, i32** %14
br label %57
33: ; preds = %6
%34 = load i32, i32* %8
%35 = load i32, i32* %9
%36 = load i32, i32* %10
%37 = load i32, i32* %11
%38 = load i32, i32* %13
%39 = call i32 @is_edge(i32 %34, i32 %35, i32 %36, i32 %37, i32 %38)
store i32 %39, i32* %15
%40 = icmp ne i32 %39, 0
br i1 %40, label %41, label %49
41: ; preds = %33
%42 = load i32*, i32** %7
%43 = load i32, i32* %8
%44 = load i32, i32* %9
%45 = load i32, i32* %11
%46 = load i32, i32* %12
%47 = load i32, i32* %15
%48 = call i32* @edge_matrix(i32* %42, i32 %43, i32 %44, i32 %45, i32 %46, i32 %47)
store i32* %48, i32** %14
br label %56
49: ; preds = %33
%50 = load i32*, i32** %7
%51 = load i32, i32* %8
%52 = load i32, i32* %9
%53 = load i32, i32* %11
%54 = load i32, i32* %12
%55 = call i32* @center_matrix(i32* %50, i32 %51, i32 %52, i32 %53, i32 %54)
store i32* %55, i32** %14
br label %56
56: ; preds = %49, %41
br label %57
57: ; preds = %56, %25
%58 = load i32*, i32** %14
ret i32* %58
}

LLVM IR (-O2):
define i32* @get_matrix_at(i32* %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5) {
%7 = sdiv i32 %5, 2
%8 = tail call i32 @is_corner(i32 %1, i32 %2, i32 %3, i32 %4, i32 %7)
%9 = icmp eq i32 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %6
%11 = tail call i32* @corner_matrix(i32* %0, i32 %1, i32 %2, i32 %4, i32 %5, i32 %8)
br label %19
12: ; preds = %6
%13 = tail call i32 @is_edge(i32 %1, i32 %2, i32 %3, i32 %4, i32 %7)
%14 = icmp eq i32 %13, 0
br i1 %14, label %17, label %15
15: ; preds = %12
%16 = tail call i32* @edge_matrix(i32* %0, i32 %1, i32 %2, i32 %4, i32 %5, i32 %13)
br label %19
17: ; preds = %12
%18 = tail call i32* @center_matrix(i32* %0, i32 %1, i32 %2, i32 %4, i32 %5)
br label %19
19: ; preds = %15, %17, %10
%20 = phi i32* [ %11, %10 ], [ %16, %15 ], [ %18, %17 ]
ret i32* %20
}