int main() {
  const unsigned int DATA_READY_ADDRESS = 0x2000;
  const unsigned int NIOS_READY_ADDRESS = 0x2001;
  const unsigned int MATRIX_DIMENSIONS_ADDRESS = 0x2004;
  const unsigned int BASE_MATRIX_ADDRESS = 0x200C;
  const unsigned int RESULT_MATRIX_ADDRESS = 0x4000000;
  unsigned char *pResultMatrix;
  int *ptrDataReadyValue, *ptrNiosReady, *ptrN, *ptrM;
  char *ptrBaseMatrix, *ptrResultMatrix;
  pResultMatrix = RESULT_MATRIX_ADDRESS;
  ptrDataReadyValue = DATA_READY_ADDRESS;
  ptrNiosReady = NIOS_READY_ADDRESS;
  ptrN = MATRIX_DIMENSIONS_ADDRESS;
  ptrM = MATRIX_DIMENSIONS_ADDRESS + 0x4;
  ptrBaseMatrix = BASE_MATRIX_ADDRESS;
  ptrResultMatrix = RESULT_MATRIX_ADDRESS;
  while (1) {
    if (*ptrDataReadyValue == 1) {
      int a = ProcessImage(ptrBaseMatrix, ptrResultMatrix, ptrN, ptrM);
      if (a == 1) {
        *ptrDataReadyValue = 0;
        *ptrNiosReady = 1;
        printf("Procesamiento de matriz satisfactorio.");
      } else {
        printf("Falla procesamiento de matriz.");
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x2000,-0x8(%rbp)
movl   $0x2001,-0xc(%rbp)
movl   $0x2004,-0x10(%rbp)
movl   $0x200c,-0x14(%rbp)
movl   $0x4000000,-0x18(%rbp)
mov    $0x4000000,%eax
mov    %rax,-0x20(%rbp)
mov    $0x2000,%eax
mov    %rax,-0x28(%rbp)
mov    $0x2001,%eax
mov    %rax,-0x30(%rbp)
mov    $0x2004,%eax
mov    %rax,-0x38(%rbp)
mov    $0x2008,%eax
mov    %rax,-0x40(%rbp)
mov    $0x200c,%eax
mov    %rax,-0x48(%rbp)
mov    $0x4000000,%eax
mov    %rax,-0x50(%rbp)
mov    -0x28(%rbp),%rax
cmpl   $0x1,(%rax)
jne    11fc <main+0xdc>
mov    -0x48(%rbp),%rdi
mov    -0x50(%rbp),%rsi
mov    -0x38(%rbp),%rdx
mov    -0x40(%rbp),%rcx
mov    $0x0,%al
call   1040 <ProcessImage@plt>
mov    %eax,-0x54(%rbp)
cmpl   $0x1,-0x54(%rbp)
jne    11e9 <main+0xc9>
mov    -0x28(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x30(%rbp),%rax
movl   $0x1,(%rax)
lea    0xe23(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11f7 <main+0xd7>
lea    0xe37(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11fc <main+0xdc>
jmp    1191 <main+0x71>

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xefc(%rip),%rbx
lea    0xece(%rip),%r14
jmp    1147 <main+0x27>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %eax,%eax
call   1030 <printf@plt>
cmpl   $0x1,0x2000
01
jne    1147 <main+0x27>
mov    $0x200c,%edi
mov    $0x4000000,%esi
mov    $0x2004,%edx
mov    $0x2008,%ecx
xor    %eax,%eax
call   1040 <ProcessImage@plt>
mov    %rbx,%rdi
cmp    $0x1,%eax
jne    1140 <main+0x20>
movl   $0x0,0x2000
movl   $0x1,0x2001
mov    %r14,%rdi
jmp    1140 <main+0x20>

LLVM IR (-O0):
@.str = [39 x i8] c"Procesamiento de matriz satisfactorio.\00"
@.str.1 = [31 x i8] c"Falla procesamiento de matriz.\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca i32*
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i32
store i32 0, i32* %1
store i32 8192, i32* %2
store i32 8193, i32* %3
store i32 8196, i32* %4
store i32 8204, i32* %5
store i32 67108864, i32* %6
store i8* inttoptr (i64 67108864 to i8*), i8** %7
store i32* inttoptr (i64 8192 to i32*), i32** %8
store i32* inttoptr (i64 8193 to i32*), i32** %9
store i32* inttoptr (i64 8196 to i32*), i32** %10
store i32* inttoptr (i64 8200 to i32*), i32** %11
store i8* inttoptr (i64 8204 to i8*), i8** %12
store i8* inttoptr (i64 67108864 to i8*), i8** %13
br label %15
15: ; preds = %0, %34
%16 = load i32*, i32** %8
%17 = load i32, i32* %16
%18 = icmp eq i32 %17, 1
br i1 %18, label %19, label %34
19: ; preds = %15
%20 = load i8*, i8** %12
%21 = load i8*, i8** %13
%22 = load i32*, i32** %10
%23 = load i32*, i32** %11
%24 = call i32 (i8*, i8*, i32*, i32*, ...) bitcast (i32 (...)* @ProcessImage to i32 (i8*, i8*, i32*, i32*, ...)*)(i8* %20, i8* %21, i32* %22, i32* %23)
store i32 %24, i32* %14
%25 = load i32, i32* %14
%26 = icmp eq i32 %25, 1
br i1 %26, label %27, label %31
27: ; preds = %19
%28 = load i32*, i32** %8
store i32 0, i32* %28
%29 = load i32*, i32** %9
store i32 1, i32* %29
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
br label %33
31: ; preds = %19
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
br label %33
33: ; preds = %31, %27
br label %34
34: ; preds = %33, %15
br label %15
}

LLVM IR (-O2):
@.str = [39 x i8] c"Procesamiento de matriz satisfactorio.\00"
@.str.1 = [31 x i8] c"Falla procesamiento de matriz.\00"
define i32 @main() {
br label %1
1: ; preds = %11, %0
%2 = load i32, i32* inttoptr (i64 8192 to i32*)
%3 = icmp eq i32 %2, 1
br i1 %3, label %4, label %11
4: ; preds = %1
%5 = tail call i32 (i8*, i8*, i32*, i32*, ...) bitcast (i32 (...)* @ProcessImage to i32 (i8*, i8*, i32*, i32*, ...)*)(i8* inttoptr (i64 8204 to i8*), i8* inttoptr (i64 67108864 to i8*), i32* inttoptr (i64 8196 to i32*), i32* inttoptr (i64 8200 to i32*))
%6 = icmp eq i32 %5, 1
br i1 %6, label %7, label %8
7: ; preds = %4
store i32 0, i32* inttoptr (i64 8192 to i32*)
store i32 1, i32* inttoptr (i64 8193 to i32*)
br label %8
8: ; preds = %4, %7
%9 = phi i8* [ getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), %7 ], [ getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), %4 ]
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %9)
br label %11
11: ; preds = %8, %1
br label %1
}