#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 size_t walker_row;
typedef scalar_t__ *cols;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
void find_result_array(int *result_array, int rows, int cols, int start_row,
                       int start_col, int *input_array, int length) {
  static int writer = 0;
  if (writer > (length)) {
    return;
  } else {
    int walker_row = start_row;
    int walker_col = start_col;
    {
      printf("Moving Right\n");
      int end_col = cols - start_col;
      while (walker_col < end_col) {
        result_array[writer++] =
            input_array[(walker_row) * (cols) + walker_col];
        printf("walker_row = %d, alker_col = %d, end_col = %d,written = %d \n",
               walker_row, walker_col, end_col, result_array[writer - 1]);
        walker_col++;
      }
      walker_col--;
    }
    {
      printf("Moving Down\n");
      int end_row = rows - start_row;
      walker_row++;
      while (walker_row < end_row) {
        result_array[writer++] =
            input_array[(walker_row) * (cols) + walker_col];
        printf("walker_row = %d,walker_col =%d, end_row = %d, written = %d\n",
               walker_row, walker_col, end_row, result_array[writer - 1]);
        walker_row++;
      }
      walker_row--;
    }
    {
      printf("Moving Left\n");
      int end_col = start_col;
      walker_col--;
      while (walker_col >= end_col) {
        result_array[writer++] =
            input_array[(walker_row) * (cols) + walker_col];
        printf("walker_row = %d,walker_col = %d, end_col = %d,written = %d \n",
               walker_row, walker_col, end_col, result_array[writer - 1]);
        walker_col--;
      }
      walker_col++;
    }
    {
      printf("Moving Up\n");
      int end_row = start_row;
      walker_row--;
      while (walker_row > end_row) {
        result_array[writer++] =
            input_array[(walker_row) * (cols) + walker_col];
        printf("walker_row = %d,walker_col = %d, end_row = %d, written = %d\n",
               walker_row, walker_col, end_row, result_array[writer - 1]);
        walker_row--;
      }
      walker_row++;
    }
    find_result_array(result_array, rows, cols, start_row + 1, start_col + 1,
                      input_array, length);
  }
}


x86 assembly (clang, -O0):
<find_result_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8d,-0x18(%rbp)
mov    %r9,-0x20(%rbp)
mov    0x2eee(%rip),%eax
cmp    0x10(%rbp),%eax
jle    1154 <find_result_array+0x34>
jmp    13ec <find_result_array+0x2cc>
mov    -0x14(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x28(%rbp)
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
sub    -0x18(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    11eb <find_result_array+0xcb>
mov    -0x20(%rbp),%rax
mov    -0x24(%rbp),%ecx
imul   -0x10(%rbp),%ecx
add    -0x28(%rbp),%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x8(%rbp),%rax
mov    0x2e93(%rip),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,0x2e88(%rip)
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x24(%rbp),%esi
mov    -0x28(%rbp),%edx
mov    -0x2c(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    0x2e6f(%rip),%edi
sub    $0x1,%edi
movslq %edi,%rdi
mov    (%rax,%rdi,4),%r8d
lea    0xe38(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1177 <find_result_array+0x57>
mov    -0x28(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x28(%rbp)
lea    0xe50(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
sub    -0x14(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x30(%rbp),%eax
jge    1288 <find_result_array+0x168>
mov    -0x20(%rbp),%rax
mov    -0x24(%rbp),%ecx
imul   -0x10(%rbp),%ecx
add    -0x28(%rbp),%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x8(%rbp),%rax
mov    0x2df6(%rip),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,0x2deb(%rip)
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x24(%rbp),%esi
mov    -0x28(%rbp),%edx
mov    -0x30(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    0x2dd2(%rip),%edi
sub    $0x1,%edi
movslq %edi,%rdi
mov    (%rax,%rdi,4),%r8d
lea    0xde5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1214 <find_result_array+0xf4>
mov    -0x24(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x24(%rbp)
lea    0xdfc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x28(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x34(%rbp),%eax
jl     1322 <find_result_array+0x202>
mov    -0x20(%rbp),%rax
mov    -0x24(%rbp),%ecx
imul   -0x10(%rbp),%ecx
add    -0x28(%rbp),%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x8(%rbp),%rax
mov    0x2d5c(%rip),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,0x2d51(%rip)
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x24(%rbp),%esi
mov    -0x28(%rbp),%edx
mov    -0x34(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    0x2d38(%rip),%edi
sub    $0x1,%edi
movslq %edi,%rdi
mov    (%rax,%rdi,4),%r8d
lea    0xd94(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x28(%rbp)
jmp    12ae <find_result_array+0x18e>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
lea    0xdac(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x24(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x38(%rbp),%eax
jle    13bc <find_result_array+0x29c>
mov    -0x20(%rbp),%rax
mov    -0x24(%rbp),%ecx
imul   -0x10(%rbp),%ecx
add    -0x28(%rbp),%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x8(%rbp),%rax
mov    0x2cc2(%rip),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,0x2cb7(%rip)
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x24(%rbp),%esi
mov    -0x28(%rbp),%edx
mov    -0x38(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    0x2c9e(%rip),%edi
sub    $0x1,%edi
movslq %edi,%rdi
mov    (%rax,%rdi,4),%r8d
lea    0xd42(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x24(%rbp)
jmp    1348 <find_result_array+0x228>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
mov    -0x18(%rbp),%r8d
add    $0x1,%r8d
mov    -0x20(%rbp),%r9
mov    0x10(%rbp),%eax
mov    %eax,(%rsp)
call   1040 <find_result_array@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_result_array>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
mov    %r9,0x20(%rsp)
mov    %edx,0x18(%rsp)
mov    0xb0(%rsp),%eax
cmp    %eax,0x2ef0(%rip)
jle    1155 <find_result_array+0x35>
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
movslq %r8d,%r13
movslq 0x18(%rsp),%rdx
movslq %ecx,%r14
movslq %esi,%rax
mov    %rax,0x58(%rsp)
mov    %r13d,%r15d
mov    %r14,%rax
imul   %rdx,%rax
add    %r13,%rax
mov    0x20(%rsp),%rcx
lea    (%rcx,%rax,4),%rbx
lea    0x0(,%rdx,4),%rax
mov    %rdx,0x28(%rsp)
lea    0x4(,%rdx,4),%rcx
mov    %rcx,0x48(%rsp)
lea    0x1(%r14),%ecx
mov    %ecx,0x1c(%rsp)
mov    %rax,0x50(%rsp)
neg    %rax
mov    %rax,0x70(%rsp)
mov    %rdi,0x10(%rsp)
jmp    11f9 <find_result_array+0xd9>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x38(%rsp),%r13
add    $0x1,%r13
mov    0x68(%rsp),%r15
add    $0x1,%r15
mov    0x40(%rsp),%rbx
add    0x48(%rsp),%rbx
addl   $0x1,0x1c(%rsp)
mov    0x30(%rsp),%r14
mov    0xb0(%rsp),%eax
cmp    %eax,0x2e41(%rip)
jg     1146 <find_result_array+0x26>
lea    0x1(%r14),%rax
mov    %rax,0x30(%rsp)
lea    0xeea(%rip),%rdi
call   1030 <puts@plt>
mov    0x28(%rsp),%rbp
sub    %r13,%rbp
mov    %r13d,%r12d
cmp    %rbp,%r13
mov    %rbx,0x40(%rsp)
jge    128e <find_result_array+0x16e>
xor    %r12d,%r12d
mov    %r13,%rbx
mov    %r14,%r13
mov    0x10(%rsp),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x40(%rsp),%rax
mov    (%rax,%r12,4),%r8d
movslq 0x2de4(%rip),%rax
lea    0x1(%rax),%ecx
mov    %ecx,0x2ddb(%rip)
mov    %r8d,(%r14,%rax,4)
lea    (%r15,%r12,1),%edx
lea    0xd98(%rip),%rdi
mov    %r13d,%esi
mov    %ebp,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
lea    (%rbx,%r12,1),%rax
add    $0x1,%rax
add    $0x1,%r12
cmp    %rbp,%rax
jl     1240 <find_result_array+0x120>
add    %r15d,%r12d
mov    %r13,%r14
mov    %rbx,%r13
mov    %r15,0x68(%rsp)
mov    %r13,0x38(%rsp)
lea    0xe61(%rip),%rdi
call   1030 <puts@plt>
mov    0x58(%rsp),%rcx
mov    %r14,0x60(%rsp)
sub    %r14,%rcx
mov    0x30(%rsp),%rax
mov    %rax,%r15
cmp    %rcx,%rax
mov    0x50(%rsp),%rbp
lea    0xd75(%rip),%rbx
mov    0x10(%rsp),%rsi
jge    1345 <find_result_array+0x225>
movslq 0x1c(%rsp),%rax
imul   0x28(%rsp),%rax
movslq 0x30(%rsp),%r15
lea    -0x1(%r12),%edi
mov    %edi,0xc(%rsp)
movslq %edi,%rdi
add    %rax,%rdi
mov    0x20(%rsp),%rax
lea    (%rax,%rdi,4),%r14
nopw   0x0(%rax,%rax,1)
mov    (%r14),%r8d
movslq 0x2d2a(%rip),%rax
lea    0x1(%rax),%edi
mov    %edi,0x2d21(%rip)
mov    %r8d,(%rsi,%rax,4)
mov    %rbx,%rdi
mov    %r15d,%esi
mov    0xc(%rsp),%edx
xor    %eax,%eax
mov    %r15,%r13
mov    %rcx,%r15
call   1040 <printf@plt>
mov    %r15,%rcx
mov    %r13,%r15
mov    0x10(%rsp),%rsi
add    $0x1,%r15
add    %rbp,%r14
cmp    %rcx,%r15
jl     1300 <find_result_array+0x1e0>
lea    0xdc0(%rip),%rdi
call   1030 <puts@plt>
add    $0xfffffffe,%r12d
movslq %r12d,%rbp
mov    0x38(%rsp),%rbx
cmp    %rbp,%rbx
jle    1370 <find_result_array+0x250>
mov    0x10(%rsp),%r13
jmp    13de <find_result_array+0x2be>
nopl   0x0(%rax)
lea    -0x1(%r15),%eax
mov    %eax,0xc(%rsp)
imul   0x18(%rsp),%eax
cltq
add    $0x1,%rbp
mov    0x20(%rsp),%rcx
lea    (%rcx,%rax,4),%r14
mov    0x10(%rsp),%r13
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    -0x4(%r14,%rbp,4),%r8d
movslq 0x2c88(%rip),%rax
lea    0x1(%rax),%ecx
mov    %ecx,0x2c7f(%rip)
mov    %r8d,0x0(%r13,%rax,4)
lea    0xcb8(%rip),%rdi
mov    0xc(%rsp),%esi
mov    %r12d,%edx
mov    %ebx,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
add    $0xffffffffffffffff,%rbp
add    $0xffffffff,%r12d
cmp    %rbx,%rbp
jg     13a0 <find_result_array+0x280>
lea    0xd33(%rip),%rdi
call   1030 <puts@plt>
add    $0xfffffffe,%r15d
movslq %r15d,%rbp
mov    0x60(%rsp),%r15
cmp    %r15,%rbp
lea    0xcb6(%rip),%r14
jle    11c0 <find_result_array+0xa0>
mov    %r13,%rdx
add    $0x1,%r12d
movslq %r12d,%rax
mov    0x28(%rsp),%rdi
imul   %rbp,%rdi
add    %rax,%rdi
mov    0x20(%rsp),%rax
lea    (%rax,%rdi,4),%rbx
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%rbx),%r8d
movslq 0x2bfa(%rip),%rax
lea    0x1(%rax),%esi
mov    %esi,0x2bf1(%rip)
mov    %r8d,(%rdx,%rax,4)
mov    %r14,%rdi
mov    %ebp,%esi
mov    %rdx,%r13
mov    %r12d,%edx
mov    %r15d,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x70(%rsp),%rsi
mov    %r13,%rdx
add    $0xffffffffffffffff,%rbp
add    %rsi,%rbx
cmp    %r15,%rbp
jg     1430 <find_result_array+0x310>
jmp    11c0 <find_result_array+0xa0>

LLVM IR (-O0):
@find_result_array.writer = internal global i32 0
@.str = [14 x i8] c"Moving Right\0A\00"
@.str.1 = [61 x i8] c"walker_row = %d, alker_col = %d, end_col = %d,written = %d \0A\00"
@.str.2 = [13 x i8] c"Moving Down\0A\00"
@.str.3 = [60 x i8] c"walker_row = %d,walker_col =%d, end_row = %d, written = %d\0A\00"
@.str.4 = [13 x i8] c"Moving Left\0A\00"
@.str.5 = [61 x i8] c"walker_row = %d,walker_col = %d, end_col = %d,written = %d \0A\00"
@.str.6 = [11 x i8] c"Moving Up\0A\00"
@.str.7 = [61 x i8] c"walker_row = %d,walker_col = %d, end_row = %d, written = %d\0A\00"
define void @find_result_array(i32* %0, i32 %1, i32 %2, i32 %3, i32 %4, i32* %5, i32 %6) {
%8 = alloca i32*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32*
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
store i32* %0, i32** %8
store i32 %1, i32* %9
store i32 %2, i32* %10
store i32 %3, i32* %11
store i32 %4, i32* %12
store i32* %5, i32** %13
store i32 %6, i32* %14
%21 = load i32, i32* @find_result_array.writer
%22 = load i32, i32* %14
%23 = icmp sgt i32 %21, %22
br i1 %23, label %24, label %25
24: ; preds = %7
br label %191
25: ; preds = %7
%26 = load i32, i32* %11
store i32 %26, i32* %15
%27 = load i32, i32* %12
store i32 %27, i32* %16
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%29 = load i32, i32* %10
%30 = load i32, i32* %12
%31 = sub nsw i32 %29, %30
store i32 %31, i32* %17
br label %32
32: ; preds = %36, %25
%33 = load i32, i32* %16
%34 = load i32, i32* %17
%35 = icmp slt i32 %33, %34
br i1 %35, label %36, label %63
36: ; preds = %32
%37 = load i32*, i32** %13
%38 = load i32, i32* %15
%39 = load i32, i32* %10
%40 = mul nsw i32 %38, %39
%41 = load i32, i32* %16
%42 = add nsw i32 %40, %41
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i32, i32* %37, i64 %43
%45 = load i32, i32* %44
%46 = load i32*, i32** %8
%47 = load i32, i32* @find_result_array.writer
%48 = add nsw i32 %47, 1
store i32 %48, i32* @find_result_array.writer
%49 = sext i32 %47 to i64
%50 = getelementptr inbounds i32, i32* %46, i64 %49
store i32 %45, i32* %50
%51 = load i32, i32* %15
%52 = load i32, i32* %16
%53 = load i32, i32* %17
%54 = load i32*, i32** %8
%55 = load i32, i32* @find_result_array.writer
%56 = sub nsw i32 %55, 1
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds i32, i32* %54, i64 %57
%59 = load i32, i32* %58
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.1, i64 0, i64 0), i32 %51, i32 %52, i32 %53, i32 %59)
%61 = load i32, i32* %16
%62 = add nsw i32 %61, 1
store i32 %62, i32* %16
br label %32
63: ; preds = %32
%64 = load i32, i32* %16
%65 = add nsw i32 %64, -1
store i32 %65, i32* %16
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%67 = load i32, i32* %9
%68 = load i32, i32* %11
%69 = sub nsw i32 %67, %68
store i32 %69, i32* %18
%70 = load i32, i32* %15
%71 = add nsw i32 %70, 1
store i32 %71, i32* %15
br label %72
72: ; preds = %76, %63
%73 = load i32, i32* %15
%74 = load i32, i32* %18
%75 = icmp slt i32 %73, %74
br i1 %75, label %76, label %103
76: ; preds = %72
%77 = load i32*, i32** %13
%78 = load i32, i32* %15
%79 = load i32, i32* %10
%80 = mul nsw i32 %78, %79
%81 = load i32, i32* %16
%82 = add nsw i32 %80, %81
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds i32, i32* %77, i64 %83
%85 = load i32, i32* %84
%86 = load i32*, i32** %8
%87 = load i32, i32* @find_result_array.writer
%88 = add nsw i32 %87, 1
store i32 %88, i32* @find_result_array.writer
%89 = sext i32 %87 to i64
%90 = getelementptr inbounds i32, i32* %86, i64 %89
store i32 %85, i32* %90
%91 = load i32, i32* %15
%92 = load i32, i32* %16
%93 = load i32, i32* %18
%94 = load i32*, i32** %8
%95 = load i32, i32* @find_result_array.writer
%96 = sub nsw i32 %95, 1
%97 = sext i32 %96 to i64
%98 = getelementptr inbounds i32, i32* %94, i64 %97
%99 = load i32, i32* %98
%100 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.3, i64 0, i64 0), i32 %91, i32 %92, i32 %93, i32 %99)
%101 = load i32, i32* %15
%102 = add nsw i32 %101, 1
store i32 %102, i32* %15
br label %72
103: ; preds = %72
%104 = load i32, i32* %15
%105 = add nsw i32 %104, -1
store i32 %105, i32* %15
%106 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%107 = load i32, i32* %12
store i32 %107, i32* %19
%108 = load i32, i32* %16
%109 = add nsw i32 %108, -1
store i32 %109, i32* %16
br label %110
110: ; preds = %114, %103
%111 = load i32, i32* %16
%112 = load i32, i32* %19
%113 = icmp sge i32 %111, %112
br i1 %113, label %114, label %141
114: ; preds = %110
%115 = load i32*, i32** %13
%116 = load i32, i32* %15
%117 = load i32, i32* %10
%118 = mul nsw i32 %116, %117
%119 = load i32, i32* %16
%120 = add nsw i32 %118, %119
%121 = sext i32 %120 to i64
%122 = getelementptr inbounds i32, i32* %115, i64 %121
%123 = load i32, i32* %122
%124 = load i32*, i32** %8
%125 = load i32, i32* @find_result_array.writer
%126 = add nsw i32 %125, 1
store i32 %126, i32* @find_result_array.writer
%127 = sext i32 %125 to i64
%128 = getelementptr inbounds i32, i32* %124, i64 %127
store i32 %123, i32* %128
%129 = load i32, i32* %15
%130 = load i32, i32* %16
%131 = load i32, i32* %19
%132 = load i32*, i32** %8
%133 = load i32, i32* @find_result_array.writer
%134 = sub nsw i32 %133, 1
%135 = sext i32 %134 to i64
%136 = getelementptr inbounds i32, i32* %132, i64 %135
%137 = load i32, i32* %136
%138 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.5, i64 0, i64 0), i32 %129, i32 %130, i32 %131, i32 %137)
%139 = load i32, i32* %16
%140 = add nsw i32 %139, -1
store i32 %140, i32* %16
br label %110
141: ; preds = %110
%142 = load i32, i32* %16
%143 = add nsw i32 %142, 1
store i32 %143, i32* %16
%144 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0))
%145 = load i32, i32* %11
store i32 %145, i32* %20
%146 = load i32, i32* %15
%147 = add nsw i32 %146, -1
store i32 %147, i32* %15
br label %148
148: ; preds = %152, %141
%149 = load i32, i32* %15
%150 = load i32, i32* %20
%151 = icmp sgt i32 %149, %150
br i1 %151, label %152, label %179
152: ; preds = %148
%153 = load i32*, i32** %13
%154 = load i32, i32* %15
%155 = load i32, i32* %10
%156 = mul nsw i32 %154, %155
%157 = load i32, i32* %16
%158 = add nsw i32 %156, %157
%159 = sext i32 %158 to i64
%160 = getelementptr inbounds i32, i32* %153, i64 %159
%161 = load i32, i32* %160
%162 = load i32*, i32** %8
%163 = load i32, i32* @find_result_array.writer
%164 = add nsw i32 %163, 1
store i32 %164, i32* @find_result_array.writer
%165 = sext i32 %163 to i64
%166 = getelementptr inbounds i32, i32* %162, i64 %165
store i32 %161, i32* %166
%167 = load i32, i32* %15
%168 = load i32, i32* %16
%169 = load i32, i32* %20
%170 = load i32*, i32** %8
%171 = load i32, i32* @find_result_array.writer
%172 = sub nsw i32 %171, 1
%173 = sext i32 %172 to i64
%174 = getelementptr inbounds i32, i32* %170, i64 %173
%175 = load i32, i32* %174
%176 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.7, i64 0, i64 0), i32 %167, i32 %168, i32 %169, i32 %175)
%177 = load i32, i32* %15
%178 = add nsw i32 %177, -1
store i32 %178, i32* %15
br label %148
179: ; preds = %148
%180 = load i32, i32* %15
%181 = add nsw i32 %180, 1
store i32 %181, i32* %15
%182 = load i32*, i32** %8
%183 = load i32, i32* %9
%184 = load i32, i32* %10
%185 = load i32, i32* %11
%186 = add nsw i32 %185, 1
%187 = load i32, i32* %12
%188 = add nsw i32 %187, 1
%189 = load i32*, i32** %13
%190 = load i32, i32* %14
br label %191
191: ; preds = %24, %179
ret void
}

LLVM IR (-O2):
@find_result_array.writer = internal unnamed_addr global i32 0
@.str.1 = [61 x i8] c"walker_row = %d, alker_col = %d, end_col = %d,written = %d \0A\00"
@.str.3 = [60 x i8] c"walker_row = %d,walker_col =%d, end_row = %d, written = %d\0A\00"
@.str.5 = [61 x i8] c"walker_row = %d,walker_col = %d, end_col = %d,written = %d \0A\00"
@.str.7 = [61 x i8] c"walker_row = %d,walker_col = %d, end_row = %d, written = %d\0A\00"
@str = [13 x i8] c"Moving Right\00"
@str.8 = [12 x i8] c"Moving Down\00"
@str.9 = [12 x i8] c"Moving Left\00"
@str.10 = [10 x i8] c"Moving Up\00"
define void @find_result_array(i32* nocapture %0, i32 %1, i32 %2, i32 %3, i32 %4, i32* nocapture %5, i32 %6) {
%8 = load i32, i32* @find_result_array.writer
%9 = icmp sgt i32 %8, %6
br i1 %9, label %123, label %10
10: ; preds = %7
%11 = sext i32 %4 to i64
%12 = sext i32 %2 to i64
%13 = sext i32 %3 to i64
%14 = sext i32 %1 to i64
br label %15
15: ; preds = %10, %119
%16 = phi i64 [ %13, %10 ], [ %49, %119 ]
%17 = phi i32 [ %3, %10 ], [ %19, %119 ]
%18 = phi i64 [ %11, %10 ], [ %120, %119 ]
%19 = add i32 %17, 1
%20 = sext i32 %19 to i64
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0))
%22 = sub nsw i64 %12, %18
%23 = icmp slt i64 %18, %22
%24 = trunc i64 %18 to i32
br i1 %23, label %25, label %44
25: ; preds = %15
%26 = mul nsw i64 %16, %12
%27 = trunc i64 %22 to i32
%28 = trunc i64 %16 to i32
br label %29
29: ; preds = %25, %29
%30 = phi i64 [ %18, %25 ], [ %40, %29 ]
%31 = add nsw i64 %30, %26
%32 = getelementptr inbounds i32, i32* %5, i64 %31
%33 = load i32, i32* %32
%34 = load i32, i32* @find_result_array.writer
%35 = add nsw i32 %34, 1
store i32 %35, i32* @find_result_array.writer
%36 = sext i32 %34 to i64
%37 = getelementptr inbounds i32, i32* %0, i64 %36
store i32 %33, i32* %37
%38 = trunc i64 %30 to i32
%39 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([61 x i8], [61 x i8]* @.str.1, i64 0, i64 0), i32 %28, i32 %38, i32 %27, i32 %33)
%40 = add nsw i64 %30, 1
%41 = icmp slt i64 %40, %22
br i1 %41, label %29, label %42
42: ; preds = %29
%43 = trunc i64 %40 to i32
br label %44
44: ; preds = %42, %15
%45 = phi i32 [ %24, %15 ], [ %43, %42 ]
%46 = add nsw i32 %45, -1
%47 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.8, i64 0, i64 0))
%48 = sub nsw i64 %14, %16
%49 = add i64 %16, 1
%50 = icmp slt i64 %49, %48
br i1 %50, label %51, label %68
51: ; preds = %44
%52 = sext i32 %46 to i64
%53 = trunc i64 %48 to i32
br label %54
54: ; preds = %51, %54
%55 = phi i64 [ %20, %51 ], [ %66, %54 ]
%56 = mul nsw i64 %55, %12
%57 = add nsw i64 %56, %52
%58 = getelementptr inbounds i32, i32* %5, i64 %57
%59 = load i32, i32* %58
%60 = load i32, i32* @find_result_array.writer
%61 = add nsw i32 %60, 1
store i32 %61, i32* @find_result_array.writer
%62 = sext i32 %60 to i64
%63 = getelementptr inbounds i32, i32* %0, i64 %62
store i32 %59, i32* %63
%64 = trunc i64 %55 to i32
%65 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @.str.3, i64 0, i64 0), i32 %64, i32 %46, i32 %53, i32 %59)
%66 = add nsw i64 %55, 1
%67 = icmp slt i64 %66, %48
br i1 %67, label %54, label %68
68: ; preds = %54, %44
%69 = phi i64 [ %49, %44 ], [ %66, %54 ]
%70 = trunc i64 %69 to i32
%71 = add nsw i32 %70, -1
%72 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.9, i64 0, i64 0))
%73 = add i32 %45, -2
%74 = sext i32 %73 to i64
%75 = icmp sgt i64 %18, %74
br i1 %75, label %94, label %76
76: ; preds = %68
%77 = mul nsw i32 %71, %2
%78 = sext i32 %77 to i64
br label %79
79: ; preds = %76, %79
%80 = phi i64 [ %74, %76 ], [ %90, %79 ]
%81 = add nsw i64 %80, %78
%82 = getelementptr inbounds i32, i32* %5, i64 %81
%83 = load i32, i32* %82
%84 = load i32, i32* @find_result_array.writer
%85 = add nsw i32 %84, 1
store i32 %85, i32* @find_result_array.writer
%86 = sext i32 %84 to i64
%87 = getelementptr inbounds i32, i32* %0, i64 %86
store i32 %83, i32* %87
%88 = trunc i64 %80 to i32
%89 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([61 x i8], [61 x i8]* @.str.5, i64 0, i64 0), i32 %71, i32 %88, i32 %24, i32 %83)
%90 = add nsw i64 %80, -1
%91 = icmp sgt i64 %80, %18
br i1 %91, label %79, label %92
92: ; preds = %79
%93 = trunc i64 %90 to i32
br label %94
94: ; preds = %92, %68
%95 = phi i32 [ %73, %68 ], [ %93, %92 ]
%96 = add nsw i32 %95, 1
%97 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.10, i64 0, i64 0))
%98 = shl i64 %69, 32
%99 = add i64 %98, -8589934592
%100 = ashr exact i64 %99, 32
%101 = icmp sgt i64 %100, %16
br i1 %101, label %102, label %119
102: ; preds = %94
%103 = sext i32 %96 to i64
%104 = trunc i64 %16 to i32
br label %105
105: ; preds = %102, %105
%106 = phi i64 [ %100, %102 ], [ %117, %105 ]
%107 = mul nsw i64 %106, %12
%108 = add nsw i64 %107, %103
%109 = getelementptr inbounds i32, i32* %5, i64 %108
%110 = load i32, i32* %109
%111 = load i32, i32* @find_result_array.writer
%112 = add nsw i32 %111, 1
store i32 %112, i32* @find_result_array.writer
%113 = sext i32 %111 to i64
%114 = getelementptr inbounds i32, i32* %0, i64 %113
store i32 %110, i32* %114
%115 = trunc i64 %106 to i32
%116 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([61 x i8], [61 x i8]* @.str.7, i64 0, i64 0), i32 %115, i32 %96, i32 %104, i32 %110)
%117 = add nsw i64 %106, -1
%118 = icmp sgt i64 %117, %16
br i1 %118, label %105, label %119
119: ; preds = %105, %94
%120 = add i64 %18, 1
%121 = load i32, i32* @find_result_array.writer
%122 = icmp sgt i32 %121, %6
br i1 %122, label %123, label %15
123: ; preds = %119, %7
ret void
}