#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 /*<<< orphan*/ Xil_DCacheEnable();
int /*<<< orphan*/ arrayadd(int *, int *);
int /*<<< orphan*/ arrayadd_interrupt(int *, int *);
int /*<<< orphan*/ arrayadd_soft(int *, int *);
int /*<<< orphan*/ cleanup_platform();
int /*<<< orphan*/ init_platform();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ srand(int);
int target_timer_get_current();
int /*<<< orphan*/ target_timer_initialize();
int main() {
  int tmp1, tmp2, tmp3, tmp4, tmp5, tmp6;
  init_platform();
  printf("Hello! matrixmul\n\r");
  int i, j;
  target_timer_initialize();
  srand(target_timer_get_current());
  int a[50], b[50], c[50], d[50];
  for (i = 0; i < 50; i++) {
    a[i] = i;
  }
  target_timer_initialize();
  tmp1 = target_timer_get_current();
  arrayadd_interrupt(a, b);
  tmp2 = target_timer_get_current();
  target_timer_initialize();
  tmp3 = target_timer_get_current();
  arrayadd(a, c);
  tmp4 = target_timer_get_current();
  Xil_DCacheEnable();
  target_timer_initialize();
  tmp5 = target_timer_get_current();
  arrayadd_soft(a, d);
  tmp6 = target_timer_get_current();
  printf("hard interr time:%d\n", tmp2 - tmp1);
  printf("hard poling time:%d\n", tmp4 - tmp3);
  printf("soft time:%d\n", tmp6 - tmp5);
  printf("end matrixmul\n\r");
  cleanup_platform();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x360,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1070 <init_platform@plt>
lea    0xe40(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x0,%al
call   10a0 <target_timer_initialize@plt>
mov    $0x0,%al
call   1040 <target_timer_get_current@plt>
mov    %eax,%edi
call   1080 <srand@plt>
movl   $0x0,-0x20(%rbp)
cmpl   $0x32,-0x20(%rbp)
jge    1209 <main+0x69>
mov    -0x20(%rbp),%ecx
movslq -0x20(%rbp),%rax
mov    %ecx,-0xf0(%rbp,%rax,4)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11e3 <main+0x43>
mov    $0x0,%al
call   10a0 <target_timer_initialize@plt>
mov    $0x0,%al
call   1040 <target_timer_get_current@plt>
mov    %eax,-0x8(%rbp)
lea    -0xf0(%rbp),%rdi
lea    -0x1c0(%rbp),%rsi
call   10b0 <arrayadd_interrupt@plt>
mov    $0x0,%al
call   1040 <target_timer_get_current@plt>
mov    %eax,-0xc(%rbp)
mov    $0x0,%al
call   10a0 <target_timer_initialize@plt>
mov    $0x0,%al
call   1040 <target_timer_get_current@plt>
mov    %eax,-0x10(%rbp)
lea    -0xf0(%rbp),%rdi
lea    -0x290(%rbp),%rsi
call   10c0 <arrayadd@plt>
mov    $0x0,%al
call   1040 <target_timer_get_current@plt>
mov    %eax,-0x14(%rbp)
mov    $0x0,%al
call   1030 <Xil_DCacheEnable@plt>
mov    $0x0,%al
call   10a0 <target_timer_initialize@plt>
mov    $0x0,%al
call   1040 <target_timer_get_current@plt>
mov    %eax,-0x18(%rbp)
lea    -0xf0(%rbp),%rdi
lea    -0x360(%rbp),%rsi
call   1050 <arrayadd_soft@plt>
mov    $0x0,%al
call   1040 <target_timer_get_current@plt>
mov    %eax,-0x1c(%rbp)
mov    -0xc(%rbp),%esi
sub    -0x8(%rbp),%esi
lea    0xd6c(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x14(%rbp),%esi
sub    -0x10(%rbp),%esi
lea    0xd6d(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x1c(%rbp),%esi
sub    -0x18(%rbp),%esi
lea    0xd6e(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xd6e(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x0,%al
call   1090 <cleanup_platform@plt>
xor    %eax,%eax
add    $0x360,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x348,%rsp
xor    %eax,%eax
call   1070 <init_platform@plt>
lea    0xf01(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
call   10a0 <target_timer_initialize@plt>
xor    %eax,%eax
call   1040 <target_timer_get_current@plt>
mov    %eax,%edi
call   1080 <srand@plt>
movaps 0xe1e(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xe22(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xe26(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xe2a(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xe2e(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0xe32(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
movaps 0xe36(%rip),%xmm0
movaps %xmm0,0x70(%rsp)
movaps 0xe3a(%rip),%xmm0
movaps %xmm0,0x80(%rsp)
movaps 0xe3b(%rip),%xmm0
movaps %xmm0,0x90(%rsp)
movaps 0xe3c(%rip),%xmm0
movaps %xmm0,0xa0(%rsp)
movaps 0xe3d(%rip),%xmm0
movaps %xmm0,0xb0(%rsp)
movaps 0xe3e(%rip),%xmm0
movaps %xmm0,0xc0(%rsp)
movabs $0x3100000030,%rax
mov    %rax,0xd0(%rsp)
xor    %eax,%eax
call   10a0 <target_timer_initialize@plt>
xor    %eax,%eax
call   1040 <target_timer_get_current@plt>
mov    %eax,0xc(%rsp)
lea    0x10(%rsp),%r12
lea    0x280(%rsp),%rsi
mov    %r12,%rdi
call   10b0 <arrayadd_interrupt@plt>
xor    %eax,%eax
call   1040 <target_timer_get_current@plt>
mov    %eax,%r14d
xor    %eax,%eax
call   10a0 <target_timer_initialize@plt>
xor    %eax,%eax
call   1040 <target_timer_get_current@plt>
mov    %eax,%r15d
lea    0x1b0(%rsp),%rsi
mov    %r12,%rdi
call   10c0 <arrayadd@plt>
xor    %eax,%eax
call   1040 <target_timer_get_current@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1030 <Xil_DCacheEnable@plt>
xor    %eax,%eax
call   10a0 <target_timer_initialize@plt>
xor    %eax,%eax
call   1040 <target_timer_get_current@plt>
mov    %eax,%r13d
lea    0xe0(%rsp),%rsi
mov    %r12,%rdi
call   1050 <arrayadd_soft@plt>
xor    %eax,%eax
call   1040 <target_timer_get_current@plt>
mov    %eax,%ebp
sub    0xc(%rsp),%r14d
lea    0xdaf(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1060 <printf@plt>
sub    %r15d,%ebx
lea    0xdb0(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1060 <printf@plt>
sub    %r13d,%ebp
lea    0xdb2(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xdb0(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
call   1090 <cleanup_platform@plt>
xor    %eax,%eax
add    $0x348,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [19 x i8] c"Hello! matrixmul\0A\0D\00"
@.str.1 = [21 x i8] c"hard interr time:%d\0A\00"
@.str.2 = [21 x i8] c"hard poling time:%d\0A\00"
@.str.3 = [14 x i8] c"soft time:%d\0A\00"
@.str.4 = [16 x i8] c"end matrixmul\0A\0D\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca [50 x i32]
%11 = alloca [50 x i32]
%12 = alloca [50 x i32]
%13 = alloca [50 x i32]
store i32 0, i32* %1
%14 = call i32 (...) @init_platform()
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%16 = call i32 (...) @target_timer_initialize()
%17 = call i32 (...) @target_timer_get_current()
%18 = call i32 @srand(i32 %17)
store i32 0, i32* %8
br label %19
19: ; preds = %27, %0
%20 = load i32, i32* %8
%21 = icmp slt i32 %20, 50
br i1 %21, label %22, label %30
22: ; preds = %19
%23 = load i32, i32* %8
%24 = load i32, i32* %8
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [50 x i32], [50 x i32]* %10, i64 0, i64 %25
store i32 %23, i32* %26
br label %27
27: ; preds = %22
%28 = load i32, i32* %8
%29 = add nsw i32 %28, 1
store i32 %29, i32* %8
br label %19
30: ; preds = %19
%31 = call i32 (...) @target_timer_initialize()
%32 = call i32 (...) @target_timer_get_current()
store i32 %32, i32* %2
%33 = getelementptr inbounds [50 x i32], [50 x i32]* %10, i64 0, i64 0
%34 = getelementptr inbounds [50 x i32], [50 x i32]* %11, i64 0, i64 0
%35 = call i32 @arrayadd_interrupt(i32* %33, i32* %34)
%36 = call i32 (...) @target_timer_get_current()
store i32 %36, i32* %3
%37 = call i32 (...) @target_timer_initialize()
%38 = call i32 (...) @target_timer_get_current()
store i32 %38, i32* %4
%39 = getelementptr inbounds [50 x i32], [50 x i32]* %10, i64 0, i64 0
%40 = getelementptr inbounds [50 x i32], [50 x i32]* %12, i64 0, i64 0
%41 = call i32 @arrayadd(i32* %39, i32* %40)
%42 = call i32 (...) @target_timer_get_current()
store i32 %42, i32* %5
%43 = call i32 (...) @Xil_DCacheEnable()
%44 = call i32 (...) @target_timer_initialize()
%45 = call i32 (...) @target_timer_get_current()
store i32 %45, i32* %6
%46 = getelementptr inbounds [50 x i32], [50 x i32]* %10, i64 0, i64 0
%47 = getelementptr inbounds [50 x i32], [50 x i32]* %13, i64 0, i64 0
%48 = call i32 @arrayadd_soft(i32* %46, i32* %47)
%49 = call i32 (...) @target_timer_get_current()
store i32 %49, i32* %7
%50 = load i32, i32* %3
%51 = load i32, i32* %2
%52 = sub nsw i32 %50, %51
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 %52)
%54 = load i32, i32* %5
%55 = load i32, i32* %4
%56 = sub nsw i32 %54, %55
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %56)
%58 = load i32, i32* %7
%59 = load i32, i32* %6
%60 = sub nsw i32 %58, %59
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %60)
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
%63 = call i32 (...) @cleanup_platform()
ret i32 0
}

LLVM IR (-O2):
@.str = [19 x i8] c"Hello! matrixmul\0A\0D\00"
@.str.1 = [21 x i8] c"hard interr time:%d\0A\00"
@.str.2 = [21 x i8] c"hard poling time:%d\0A\00"
@.str.3 = [14 x i8] c"soft time:%d\0A\00"
@.str.4 = [16 x i8] c"end matrixmul\0A\0D\00"
define i32 @main() {
%1 = alloca [50 x i32]
%2 = alloca [50 x i32]
%3 = alloca [50 x i32]
%4 = alloca [50 x i32]
%5 = tail call i32 (...) @init_platform()
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 (...) @target_timer_initialize()
%8 = tail call i32 (...) @target_timer_get_current()
%9 = tail call i32 @srand(i32 %8)
%10 = bitcast [50 x i32]* %1 to i8*
%11 = bitcast [50 x i32]* %2 to i8*
%12 = bitcast [50 x i32]* %3 to i8*
%13 = bitcast [50 x i32]* %4 to i8*
%14 = bitcast [50 x i32]* %1 to <4 x i32>*
store <4 x i32> <i32 0, i32 1, i32 2, i32 3>, <4 x i32>* %14
%15 = getelementptr inbounds [50 x i32], [50 x i32]* %1, i64 0, i64 4
%16 = bitcast i32* %15 to <4 x i32>*
store <4 x i32> <i32 4, i32 5, i32 6, i32 7>, <4 x i32>* %16
%17 = getelementptr inbounds [50 x i32], [50 x i32]* %1, i64 0, i64 8
%18 = bitcast i32* %17 to <4 x i32>*
store <4 x i32> <i32 8, i32 9, i32 10, i32 11>, <4 x i32>* %18
%19 = getelementptr inbounds [50 x i32], [50 x i32]* %1, i64 0, i64 12
%20 = bitcast i32* %19 to <4 x i32>*
store <4 x i32> <i32 12, i32 13, i32 14, i32 15>, <4 x i32>* %20
%21 = getelementptr inbounds [50 x i32], [50 x i32]* %1, i64 0, i64 16
%22 = bitcast i32* %21 to <4 x i32>*
store <4 x i32> <i32 16, i32 17, i32 18, i32 19>, <4 x i32>* %22
%23 = getelementptr inbounds [50 x i32], [50 x i32]* %1, i64 0, i64 20
%24 = bitcast i32* %23 to <4 x i32>*
store <4 x i32> <i32 20, i32 21, i32 22, i32 23>, <4 x i32>* %24
%25 = getelementptr inbounds [50 x i32], [50 x i32]* %1, i64 0, i64 24
%26 = bitcast i32* %25 to <4 x i32>*
store <4 x i32> <i32 24, i32 25, i32 26, i32 27>, <4 x i32>* %26
%27 = getelementptr inbounds [50 x i32], [50 x i32]* %1, i64 0, i64 28
%28 = bitcast i32* %27 to <4 x i32>*
store <4 x i32> <i32 28, i32 29, i32 30, i32 31>, <4 x i32>* %28
%29 = getelementptr inbounds [50 x i32], [50 x i32]* %1, i64 0, i64 32
%30 = bitcast i32* %29 to <4 x i32>*
store <4 x i32> <i32 32, i32 33, i32 34, i32 35>, <4 x i32>* %30
%31 = getelementptr inbounds [50 x i32], [50 x i32]* %1, i64 0, i64 36
%32 = bitcast i32* %31 to <4 x i32>*
store <4 x i32> <i32 36, i32 37, i32 38, i32 39>, <4 x i32>* %32
%33 = getelementptr inbounds [50 x i32], [50 x i32]* %1, i64 0, i64 40
%34 = bitcast i32* %33 to <4 x i32>*
store <4 x i32> <i32 40, i32 41, i32 42, i32 43>, <4 x i32>* %34
%35 = getelementptr inbounds [50 x i32], [50 x i32]* %1, i64 0, i64 44
%36 = bitcast i32* %35 to <4 x i32>*
store <4 x i32> <i32 44, i32 45, i32 46, i32 47>, <4 x i32>* %36
%37 = getelementptr inbounds [50 x i32], [50 x i32]* %1, i64 0, i64 48
store i32 48, i32* %37
%38 = getelementptr inbounds [50 x i32], [50 x i32]* %1, i64 0, i64 49
store i32 49, i32* %38
%39 = tail call i32 (...) @target_timer_initialize()
%40 = tail call i32 (...) @target_timer_get_current()
%41 = getelementptr inbounds [50 x i32], [50 x i32]* %1, i64 0, i64 0
%42 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 0
%43 = call i32 @arrayadd_interrupt(i32* %41, i32* %42)
%44 = call i32 (...) @target_timer_get_current()
%45 = call i32 (...) @target_timer_initialize()
%46 = call i32 (...) @target_timer_get_current()
%47 = getelementptr inbounds [50 x i32], [50 x i32]* %3, i64 0, i64 0
%48 = call i32 @arrayadd(i32* %41, i32* %47)
%49 = call i32 (...) @target_timer_get_current()
%50 = call i32 (...) @Xil_DCacheEnable()
%51 = call i32 (...) @target_timer_initialize()
%52 = call i32 (...) @target_timer_get_current()
%53 = getelementptr inbounds [50 x i32], [50 x i32]* %4, i64 0, i64 0
%54 = call i32 @arrayadd_soft(i32* %41, i32* %53)
%55 = call i32 (...) @target_timer_get_current()
%56 = sub nsw i32 %44, %40
%57 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 %56)
%58 = sub nsw i32 %49, %46
%59 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %58)
%60 = sub nsw i32 %55, %52
%61 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %60)
%62 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
%63 = call i32 (...) @cleanup_platform()
ret i32 0
}