; LLVM IR from CactiLab/Sherloc-Cortex-M-CFVD :: Sherloc_runtime/evaluation/src/matmult_int (matmult_int)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

@ArrayA = external dso_local global [20 x [20 x i64]], align 16
@ArrayB = external dso_local global [20 x [20 x i64]], align 16

; Function Attrs: nounwind uwtable
declare dso_local void @InitSeed() #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @RandomInteger() #0

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nounwind uwtable
define dso_local void @initialise_benchmark_matmult_int() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  call void @InitSeed()
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #2
  store i32 0, ptr %1, align 4, !tbaa !5
  br label %3

3:                                                ; preds = %23, %0
  %4 = load i32, ptr %1, align 4, !tbaa !5
  %5 = icmp slt i32 %4, 20
  br i1 %5, label %6, label %26

6:                                                ; preds = %3
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %7

7:                                                ; preds = %19, %6
  %8 = load i32, ptr %2, align 4, !tbaa !5
  %9 = icmp slt i32 %8, 20
  br i1 %9, label %10, label %22

10:                                               ; preds = %7
  %11 = call i32 @RandomInteger()
  %12 = sext i32 %11 to i64
  %13 = load i32, ptr %1, align 4, !tbaa !5
  %14 = sext i32 %13 to i64
  %15 = getelementptr inbounds [20 x [20 x i64]], ptr @ArrayA, i64 0, i64 %14
  %16 = load i32, ptr %2, align 4, !tbaa !5
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds [20 x i64], ptr %15, i64 0, i64 %17
  store i64 %12, ptr %18, align 8, !tbaa !9
  br label %19

19:                                               ; preds = %10
  %20 = load i32, ptr %2, align 4, !tbaa !5
  %21 = add nsw i32 %20, 1
  store i32 %21, ptr %2, align 4, !tbaa !5
  br label %7, !llvm.loop !11

22:                                               ; preds = %7
  br label %23

23:                                               ; preds = %22
  %24 = load i32, ptr %1, align 4, !tbaa !5
  %25 = add nsw i32 %24, 1
  store i32 %25, ptr %1, align 4, !tbaa !5
  br label %3, !llvm.loop !13

26:                                               ; preds = %3
  store i32 0, ptr %1, align 4, !tbaa !5
  br label %27

27:                                               ; preds = %47, %26
  %28 = load i32, ptr %1, align 4, !tbaa !5
  %29 = icmp slt i32 %28, 20
  br i1 %29, label %30, label %50

30:                                               ; preds = %27
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %31

31:                                               ; preds = %43, %30
  %32 = load i32, ptr %2, align 4, !tbaa !5
  %33 = icmp slt i32 %32, 20
  br i1 %33, label %34, label %46

34:                                               ; preds = %31
  %35 = call i32 @RandomInteger()
  %36 = sext i32 %35 to i64
  %37 = load i32, ptr %1, align 4, !tbaa !5
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [20 x [20 x i64]], ptr @ArrayB, i64 0, i64 %38
  %40 = load i32, ptr %2, align 4, !tbaa !5
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds [20 x i64], ptr %39, i64 0, i64 %41
  store i64 %36, ptr %42, align 8, !tbaa !9
  br label %43

43:                                               ; preds = %34
  %44 = load i32, ptr %2, align 4, !tbaa !5
  %45 = add nsw i32 %44, 1
  store i32 %45, ptr %2, align 4, !tbaa !5
  br label %31, !llvm.loop !14

46:                                               ; preds = %31
  br label %47

47:                                               ; preds = %46
  %48 = load i32, ptr %1, align 4, !tbaa !5
  %49 = add nsw i32 %48, 1
  store i32 %49, ptr %1, align 4, !tbaa !5
  br label %27, !llvm.loop !15

50:                                               ; preds = %27
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #2
  ret void
}

attributes #0 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}
!15 = distinct !{!15, !12}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

@ArrayA = external dso_local local_unnamed_addr global [20 x [20 x i64]], align 16
@ArrayB = external dso_local local_unnamed_addr global [20 x [20 x i64]], align 16

; Function Attrs: nounwind uwtable
declare dso_local void @InitSeed() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @RandomInteger() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @initialise_benchmark_matmult_int() local_unnamed_addr #0 {
  tail call void @InitSeed()
  br label %.preheader15

.preheader15:                                     ; preds = %0, %.preheader15
  %indvars.iv = phi i64 [ 0, %0 ], [ %indvars.iv.next, %.preheader15 ]
  %1 = tail call i32 @RandomInteger()
  %2 = sext i32 %1 to i64
  %3 = getelementptr inbounds [20 x [20 x i64]], ptr @ArrayA, i64 0, i64 %indvars.iv, i64 0
  store i64 %2, ptr %3, align 16, !tbaa !5
  %4 = tail call i32 @RandomInteger()
  %5 = sext i32 %4 to i64
  %6 = getelementptr inbounds [20 x [20 x i64]], ptr @ArrayA, i64 0, i64 %indvars.iv, i64 1
  store i64 %5, ptr %6, align 8, !tbaa !5
  %7 = tail call i32 @RandomInteger()
  %8 = sext i32 %7 to i64
  %9 = getelementptr inbounds [20 x [20 x i64]], ptr @ArrayA, i64 0, i64 %indvars.iv, i64 2
  store i64 %8, ptr %9, align 16, !tbaa !5
  %10 = tail call i32 @RandomInteger()
  %11 = sext i32 %10 to i64
  %12 = getelementptr inbounds [20 x [20 x i64]], ptr @ArrayA, i64 0, i64 %indvars.iv, i64 3
  store i64 %11, ptr %12, align 8, !tbaa !5
  %13 = tail call i32 @RandomInteger()
  %14 = sext i32 %13 to i64
  %15 = getelementptr inbounds [20 x [20 x i64]], ptr @ArrayA, i64 0, i64 %indvars.iv, i64 4
  store i64 %14, ptr %15, align 16, !tbaa !5
  %16 = tail call i32 @RandomInteger()
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds [20 x [20 x i64]], ptr @ArrayA, i64 0, i64 %indvars.iv, i64 5
  store i64 %17, ptr %18, align 8, !tbaa !5
  %19 = tail call i32 @RandomInteger()
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds [20 x [20 x i64]], ptr @ArrayA, i64 0, i64 %indvars.iv, i64 6
  store i64 %20, ptr %21, align 16, !tbaa !5
  %22 = tail call i32 @RandomInteger()
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds [20 x [20 x i64]], ptr @ArrayA, i64 0, i64 %indvars.iv, i64 7
  store i64 %23, ptr %24, align 8, !tbaa !5
  %25 = tail call i32 @RandomInteger()
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [20 x [20 x i64]], ptr @ArrayA, i64 0, i64 %indvars.iv, i64 8
  store i64 %26, ptr %27, align 16, !tbaa !5
  %28 = tail call i32 @RandomInteger()
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [20 x [20 x i64]], ptr @ArrayA, i64 0, i64 %indvars.iv, i64 9
  store i64 %29, ptr %30, align 8, !tbaa !5
  %31 = tail call i32 @RandomInteger()
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds [20 x [20 x i64]], ptr @ArrayA, i64 0, i64 %indvars.iv, i64 10
  store i64 %32, ptr %33, align 16, !tbaa !5
  %34 = tail call i32 @RandomInteger()
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds [20 x [20 x i64]], ptr @ArrayA, i64 0, i64 %indvars.iv, i64 11
  store i64 %35, ptr %36, align 8, !tbaa !5
  %37 = tail call i32 @RandomInteger()
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [20 x [20 x i64]], ptr @ArrayA, i64 0, i64 %indvars.iv, i64 12
  store i64 %38, ptr %39, align 16, !tbaa !5
  %40 = tail call i32 @RandomInteger()
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds [20 x [20 x i64]], ptr @ArrayA, i64 0, i64 %indvars.iv, i64 13
  store i64 %41, ptr %42, align 8, !tbaa !5
  %43 = tail call i32 @RandomInteger()
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds [20 x [20 x i64]], ptr @ArrayA, i64 0, i64 %indvars.iv, i64 14
  store i64 %44, ptr %45, align 16, !tbaa !5
  %46 = tail call i32 @RandomInteger()
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds [20 x [20 x i64]], ptr @ArrayA, i64 0, i64 %indvars.iv, i64 15
  store i64 %47, ptr %48, align 8, !tbaa !5
  %49 = tail call i32 @RandomInteger()
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [20 x [20 x i64]], ptr @ArrayA, i64 0, i64 %indvars.iv, i64 16
  store i64 %50, ptr %51, align 16, !tbaa !5
  %52 = tail call i32 @RandomInteger()
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds [20 x [20 x i64]], ptr @ArrayA, i64 0, i64 %indvars.iv, i64 17
  store i64 %53, ptr %54, align 8, !tbaa !5
  %55 = tail call i32 @RandomInteger()
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds [20 x [20 x i64]], ptr @ArrayA, i64 0, i64 %indvars.iv, i64 18
  store i64 %56, ptr %57, align 16, !tbaa !5
  %58 = tail call i32 @RandomInteger()
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds [20 x [20 x i64]], ptr @ArrayA, i64 0, i64 %indvars.iv, i64 19
  store i64 %59, ptr %60, align 8, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 20
  br i1 %exitcond.not, label %.preheader, label %.preheader15, !llvm.loop !9

.preheader:                                       ; preds = %.preheader15, %.preheader
  %indvars.iv26 = phi i64 [ %indvars.iv.next27, %.preheader ], [ 0, %.preheader15 ]
  %61 = tail call i32 @RandomInteger()
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds [20 x [20 x i64]], ptr @ArrayB, i64 0, i64 %indvars.iv26, i64 0
  store i64 %62, ptr %63, align 16, !tbaa !5
  %64 = tail call i32 @RandomInteger()
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds [20 x [20 x i64]], ptr @ArrayB, i64 0, i64 %indvars.iv26, i64 1
  store i64 %65, ptr %66, align 8, !tbaa !5
  %67 = tail call i32 @RandomInteger()
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds [20 x [20 x i64]], ptr @ArrayB, i64 0, i64 %indvars.iv26, i64 2
  store i64 %68, ptr %69, align 16, !tbaa !5
  %70 = tail call i32 @RandomInteger()
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds [20 x [20 x i64]], ptr @ArrayB, i64 0, i64 %indvars.iv26, i64 3
  store i64 %71, ptr %72, align 8, !tbaa !5
  %73 = tail call i32 @RandomInteger()
  %74 = sext i32 %73 to i64
  %75 = getelementptr inbounds [20 x [20 x i64]], ptr @ArrayB, i64 0, i64 %indvars.iv26, i64 4
  store i64 %74, ptr %75, align 16, !tbaa !5
  %76 = tail call i32 @RandomInteger()
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds [20 x [20 x i64]], ptr @ArrayB, i64 0, i64 %indvars.iv26, i64 5
  store i64 %77, ptr %78, align 8, !tbaa !5
  %79 = tail call i32 @RandomInteger()
  %80 = sext i32 %79 to i64
  %81 = getelementptr inbounds [20 x [20 x i64]], ptr @ArrayB, i64 0, i64 %indvars.iv26, i64 6
  store i64 %80, ptr %81, align 16, !tbaa !5
  %82 = tail call i32 @RandomInteger()
  %83 = sext i32 %82 to i64
  %84 = getelementptr inbounds [20 x [20 x i64]], ptr @ArrayB, i64 0, i64 %indvars.iv26, i64 7
  store i64 %83, ptr %84, align 8, !tbaa !5
  %85 = tail call i32 @RandomInteger()
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds [20 x [20 x i64]], ptr @ArrayB, i64 0, i64 %indvars.iv26, i64 8
  store i64 %86, ptr %87, align 16, !tbaa !5
  %88 = tail call i32 @RandomInteger()
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds [20 x [20 x i64]], ptr @ArrayB, i64 0, i64 %indvars.iv26, i64 9
  store i64 %89, ptr %90, align 8, !tbaa !5
  %91 = tail call i32 @RandomInteger()
  %92 = sext i32 %91 to i64
  %93 = getelementptr inbounds [20 x [20 x i64]], ptr @ArrayB, i64 0, i64 %indvars.iv26, i64 10
  store i64 %92, ptr %93, align 16, !tbaa !5
  %94 = tail call i32 @RandomInteger()
  %95 = sext i32 %94 to i64
  %96 = getelementptr inbounds [20 x [20 x i64]], ptr @ArrayB, i64 0, i64 %indvars.iv26, i64 11
  store i64 %95, ptr %96, align 8, !tbaa !5
  %97 = tail call i32 @RandomInteger()
  %98 = sext i32 %97 to i64
  %99 = getelementptr inbounds [20 x [20 x i64]], ptr @ArrayB, i64 0, i64 %indvars.iv26, i64 12
  store i64 %98, ptr %99, align 16, !tbaa !5
  %100 = tail call i32 @RandomInteger()
  %101 = sext i32 %100 to i64
  %102 = getelementptr inbounds [20 x [20 x i64]], ptr @ArrayB, i64 0, i64 %indvars.iv26, i64 13
  store i64 %101, ptr %102, align 8, !tbaa !5
  %103 = tail call i32 @RandomInteger()
  %104 = sext i32 %103 to i64
  %105 = getelementptr inbounds [20 x [20 x i64]], ptr @ArrayB, i64 0, i64 %indvars.iv26, i64 14
  store i64 %104, ptr %105, align 16, !tbaa !5
  %106 = tail call i32 @RandomInteger()
  %107 = sext i32 %106 to i64
  %108 = getelementptr inbounds [20 x [20 x i64]], ptr @ArrayB, i64 0, i64 %indvars.iv26, i64 15
  store i64 %107, ptr %108, align 8, !tbaa !5
  %109 = tail call i32 @RandomInteger()
  %110 = sext i32 %109 to i64
  %111 = getelementptr inbounds [20 x [20 x i64]], ptr @ArrayB, i64 0, i64 %indvars.iv26, i64 16
  store i64 %110, ptr %111, align 16, !tbaa !5
  %112 = tail call i32 @RandomInteger()
  %113 = sext i32 %112 to i64
  %114 = getelementptr inbounds [20 x [20 x i64]], ptr @ArrayB, i64 0, i64 %indvars.iv26, i64 17
  store i64 %113, ptr %114, align 8, !tbaa !5
  %115 = tail call i32 @RandomInteger()
  %116 = sext i32 %115 to i64
  %117 = getelementptr inbounds [20 x [20 x i64]], ptr @ArrayB, i64 0, i64 %indvars.iv26, i64 18
  store i64 %116, ptr %117, align 16, !tbaa !5
  %118 = tail call i32 @RandomInteger()
  %119 = sext i32 %118 to i64
  %120 = getelementptr inbounds [20 x [20 x i64]], ptr @ArrayB, i64 0, i64 %indvars.iv26, i64 19
  store i64 %119, ptr %120, align 8, !tbaa !5
  %indvars.iv.next27 = add nuw nsw i64 %indvars.iv26, 1
  %exitcond29.not = icmp eq i64 %indvars.iv.next27, 20
  br i1 %exitcond29.not, label %121, label %.preheader, !llvm.loop !11

121:                                              ; preds = %.preheader
  ret void
}

attributes #0 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}


; Effective O3 passes: GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass