#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 **createMatrix(int, int);
int getWeightedDirection(int **, int, int);
int /*<<< orphan*/ printMatrix(int **, int, int);
void drawAbsoluteDirections(int(**directionMatrix), int row, int col) {
  int r = row - 4;
  int c = col - 4;
  int i, j;
  int **mat = createMatrix(r, c);
  for (i = 0; i < r; i++) {
    for (j = 0; j < c; j++) {
      mat[i][j] = getWeightedDirection(directionMatrix, i, j);
    }
  }
  printMatrix(mat, r, c);
}


x86 assembly (clang, -O0):
<drawAbsoluteDirections>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x4,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
sub    $0x4,%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1050 <createMatrix@plt>
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11ce <drawAbsoluteDirections+0x9e>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11bb <drawAbsoluteDirections+0x8b>
mov    -0x8(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
call   1030 <getWeightedDirection@plt>
mov    %eax,%edx
mov    -0x28(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x20(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    117d <drawAbsoluteDirections+0x4d>
jmp    11c0 <drawAbsoluteDirections+0x90>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    116a <drawAbsoluteDirections+0x3a>
mov    -0x28(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1040 <printMatrix@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<drawAbsoluteDirections>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %esi,%ebp
mov    %rdi,%r13
lea    -0x4(%rbp),%edi
mov    %rdx,0x10(%rsp)
lea    -0x4(%rdx),%esi
mov    %edi,0xc(%rsp)
mov    %esi,0x8(%rsp)
call   1050 <createMatrix@plt>
mov    %rax,%rbx
cmp    $0x5,%ebp
jl     11c0 <drawAbsoluteDirections+0x90>
mov    0xc(%rsp),%r15d
mov    0x8(%rsp),%r12d
xor    %ebp,%ebp
jmp    1189 <drawAbsoluteDirections+0x59>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbp
cmp    %r15,%rbp
je     11c0 <drawAbsoluteDirections+0x90>
cmpl   $0x5,0x10(%rsp)
jl     1180 <drawAbsoluteDirections+0x50>
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r13,%rdi
mov    %ebp,%esi
mov    %r14d,%edx
call   1030 <getWeightedDirection@plt>
mov    (%rbx,%rbp,8),%rcx
mov    %eax,(%rcx,%r14,4)
add    $0x1,%r14
cmp    %r14,%r12
jne    11a0 <drawAbsoluteDirections+0x70>
jmp    1180 <drawAbsoluteDirections+0x50>
mov    %rbx,%rdi
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%edx
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <printMatrix@plt>

LLVM IR (-O0):
define void @drawAbsoluteDirections(i32** %0, i32 %1, i32 %2) {
%4 = alloca i32**
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32**
store i32** %0, i32*** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%12 = load i32, i32* %5
%13 = sub nsw i32 %12, 4
store i32 %13, i32* %7
%14 = load i32, i32* %6
%15 = sub nsw i32 %14, 4
store i32 %15, i32* %8
%16 = load i32, i32* %7
%17 = load i32, i32* %8
%18 = call i32** @createMatrix(i32 %16, i32 %17)
store i32** %18, i32*** %11
store i32 0, i32* %9
br label %19
19: ; preds = %45, %3
%20 = load i32, i32* %9
%21 = load i32, i32* %7
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %48
23: ; preds = %19
store i32 0, i32* %10
br label %24
24: ; preds = %41, %23
%25 = load i32, i32* %10
%26 = load i32, i32* %8
%27 = icmp slt i32 %25, %26
br i1 %27, label %28, label %44
28: ; preds = %24
%29 = load i32**, i32*** %4
%30 = load i32, i32* %9
%31 = load i32, i32* %10
%32 = call i32 @getWeightedDirection(i32** %29, i32 %30, i32 %31)
%33 = load i32**, i32*** %11
%34 = load i32, i32* %9
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i32*, i32** %33, i64 %35
%37 = load i32*, i32** %36
%38 = load i32, i32* %10
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i32, i32* %37, i64 %39
store i32 %32, i32* %40
br label %41
41: ; preds = %28
%42 = load i32, i32* %10
%43 = add nsw i32 %42, 1
store i32 %43, i32* %10
br label %24
44: ; preds = %24
br label %45
45: ; preds = %44
%46 = load i32, i32* %9
%47 = add nsw i32 %46, 1
store i32 %47, i32* %9
br label %19
48: ; preds = %19
%49 = load i32**, i32*** %11
%50 = load i32, i32* %7
%51 = load i32, i32* %8
%52 = call i32 @printMatrix(i32** %49, i32 %50, i32 %51)
ret void
}

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