; LLVM IR from PetarV-/Algorithms :: Mathematical Algorithms (Matrix Multiplication)

; 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"

@.str = external hidden unnamed_addr constant [6 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #5
  %10 = call noalias noundef nonnull ptr @_Znam(i64 noundef 16) #6
  store ptr %10, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  store i32 0, ptr %3, align 4, !tbaa !9
  br label %11

11:                                               ; preds = %21, %0
  %12 = load i32, ptr %3, align 4, !tbaa !9
  %13 = icmp slt i32 %12, 2
  br i1 %13, label %15, label %14

14:                                               ; preds = %11
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  br label %24

15:                                               ; preds = %11
  %16 = call noalias noundef nonnull ptr @_Znam(i64 noundef 24) #6
  %17 = load ptr, ptr %2, align 8, !tbaa !5
  %18 = load i32, ptr %3, align 4, !tbaa !9
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds ptr, ptr %17, i64 %19
  store ptr %16, ptr %20, align 8, !tbaa !5
  br label %21

21:                                               ; preds = %15
  %22 = load i32, ptr %3, align 4, !tbaa !9
  %23 = add nsw i32 %22, 1
  store i32 %23, ptr %3, align 4, !tbaa !9
  br label %11, !llvm.loop !11

24:                                               ; preds = %14
  %25 = load ptr, ptr %2, align 8, !tbaa !5
  %26 = getelementptr inbounds ptr, ptr %25, i64 0
  %27 = load ptr, ptr %26, align 8, !tbaa !5
  %28 = getelementptr inbounds i64, ptr %27, i64 0
  store i64 1, ptr %28, align 8, !tbaa !13
  %29 = load ptr, ptr %2, align 8, !tbaa !5
  %30 = getelementptr inbounds ptr, ptr %29, i64 0
  %31 = load ptr, ptr %30, align 8, !tbaa !5
  %32 = getelementptr inbounds i64, ptr %31, i64 1
  store i64 2, ptr %32, align 8, !tbaa !13
  %33 = load ptr, ptr %2, align 8, !tbaa !5
  %34 = getelementptr inbounds ptr, ptr %33, i64 0
  %35 = load ptr, ptr %34, align 8, !tbaa !5
  %36 = getelementptr inbounds i64, ptr %35, i64 2
  store i64 3, ptr %36, align 8, !tbaa !13
  %37 = load ptr, ptr %2, align 8, !tbaa !5
  %38 = getelementptr inbounds ptr, ptr %37, i64 1
  %39 = load ptr, ptr %38, align 8, !tbaa !5
  %40 = getelementptr inbounds i64, ptr %39, i64 0
  store i64 4, ptr %40, align 8, !tbaa !13
  %41 = load ptr, ptr %2, align 8, !tbaa !5
  %42 = getelementptr inbounds ptr, ptr %41, i64 1
  %43 = load ptr, ptr %42, align 8, !tbaa !5
  %44 = getelementptr inbounds i64, ptr %43, i64 1
  store i64 5, ptr %44, align 8, !tbaa !13
  %45 = load ptr, ptr %2, align 8, !tbaa !5
  %46 = getelementptr inbounds ptr, ptr %45, i64 1
  %47 = load ptr, ptr %46, align 8, !tbaa !5
  %48 = getelementptr inbounds i64, ptr %47, i64 2
  store i64 6, ptr %48, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #5
  %49 = call noalias noundef nonnull ptr @_Znam(i64 noundef 24) #6
  store ptr %49, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  store i32 0, ptr %5, align 4, !tbaa !9
  br label %50

50:                                               ; preds = %60, %24
  %51 = load i32, ptr %5, align 4, !tbaa !9
  %52 = icmp slt i32 %51, 3
  br i1 %52, label %54, label %53

53:                                               ; preds = %50
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  br label %63

54:                                               ; preds = %50
  %55 = call noalias noundef nonnull ptr @_Znam(i64 noundef 16) #6
  %56 = load ptr, ptr %4, align 8, !tbaa !5
  %57 = load i32, ptr %5, align 4, !tbaa !9
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds ptr, ptr %56, i64 %58
  store ptr %55, ptr %59, align 8, !tbaa !5
  br label %60

60:                                               ; preds = %54
  %61 = load i32, ptr %5, align 4, !tbaa !9
  %62 = add nsw i32 %61, 1
  store i32 %62, ptr %5, align 4, !tbaa !9
  br label %50, !llvm.loop !15

63:                                               ; preds = %53
  %64 = load ptr, ptr %4, align 8, !tbaa !5
  %65 = getelementptr inbounds ptr, ptr %64, i64 0
  %66 = load ptr, ptr %65, align 8, !tbaa !5
  %67 = getelementptr inbounds i64, ptr %66, i64 0
  store i64 7, ptr %67, align 8, !tbaa !13
  %68 = load ptr, ptr %4, align 8, !tbaa !5
  %69 = getelementptr inbounds ptr, ptr %68, i64 0
  %70 = load ptr, ptr %69, align 8, !tbaa !5
  %71 = getelementptr inbounds i64, ptr %70, i64 1
  store i64 8, ptr %71, align 8, !tbaa !13
  %72 = load ptr, ptr %4, align 8, !tbaa !5
  %73 = getelementptr inbounds ptr, ptr %72, i64 1
  %74 = load ptr, ptr %73, align 8, !tbaa !5
  %75 = getelementptr inbounds i64, ptr %74, i64 0
  store i64 9, ptr %75, align 8, !tbaa !13
  %76 = load ptr, ptr %4, align 8, !tbaa !5
  %77 = getelementptr inbounds ptr, ptr %76, i64 1
  %78 = load ptr, ptr %77, align 8, !tbaa !5
  %79 = getelementptr inbounds i64, ptr %78, i64 1
  store i64 10, ptr %79, align 8, !tbaa !13
  %80 = load ptr, ptr %4, align 8, !tbaa !5
  %81 = getelementptr inbounds ptr, ptr %80, i64 2
  %82 = load ptr, ptr %81, align 8, !tbaa !5
  %83 = getelementptr inbounds i64, ptr %82, i64 0
  store i64 11, ptr %83, align 8, !tbaa !13
  %84 = load ptr, ptr %4, align 8, !tbaa !5
  %85 = getelementptr inbounds ptr, ptr %84, i64 2
  %86 = load ptr, ptr %85, align 8, !tbaa !5
  %87 = getelementptr inbounds i64, ptr %86, i64 1
  store i64 12, ptr %87, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  %88 = load ptr, ptr %2, align 8, !tbaa !5
  %89 = load ptr, ptr %4, align 8, !tbaa !5
  %90 = call noundef ptr @_Z14MatrixMultiplyPPxS0_iii(ptr noundef %88, ptr noundef %89, i32 noundef 2, i32 noundef 3, i32 noundef 2)
  store ptr %90, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %91

91:                                               ; preds = %116, %63
  %92 = load i32, ptr %7, align 4, !tbaa !9
  %93 = icmp slt i32 %92, 2
  br i1 %93, label %95, label %94

94:                                               ; preds = %91
  store i32 8, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  br label %119

95:                                               ; preds = %91
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  store i32 0, ptr %9, align 4, !tbaa !9
  br label %96

96:                                               ; preds = %111, %95
  %97 = load i32, ptr %9, align 4, !tbaa !9
  %98 = icmp slt i32 %97, 2
  br i1 %98, label %100, label %99

99:                                               ; preds = %96
  store i32 11, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  br label %114

100:                                              ; preds = %96
  %101 = load ptr, ptr %6, align 8, !tbaa !5
  %102 = load i32, ptr %7, align 4, !tbaa !9
  %103 = sext i32 %102 to i64
  %104 = getelementptr inbounds ptr, ptr %101, i64 %103
  %105 = load ptr, ptr %104, align 8, !tbaa !5
  %106 = load i32, ptr %9, align 4, !tbaa !9
  %107 = sext i32 %106 to i64
  %108 = getelementptr inbounds i64, ptr %105, i64 %107
  %109 = load i64, ptr %108, align 8, !tbaa !13
  %110 = call i32 (ptr, ...) @printf(ptr noundef @.str, i64 noundef %109)
  br label %111

111:                                              ; preds = %100
  %112 = load i32, ptr %9, align 4, !tbaa !9
  %113 = add nsw i32 %112, 1
  store i32 %113, ptr %9, align 4, !tbaa !9
  br label %96, !llvm.loop !16

114:                                              ; preds = %99
  %115 = call i32 (ptr, ...) @printf(ptr noundef @.str.1)
  br label %116

116:                                              ; preds = %114
  %117 = load i32, ptr %7, align 4, !tbaa !9
  %118 = add nsw i32 %117, 1
  store i32 %118, ptr %7, align 4, !tbaa !9
  br label %91, !llvm.loop !17

119:                                              ; preds = %94
  store i32 0, ptr %1, align 4
  store i32 1, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #5
  %120 = load i32, ptr %1, align 4
  ret i32 %120
}

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

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) #2

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_Z14MatrixMultiplyPPxS0_iii(ptr noundef, ptr noundef, i32 noundef, i32 noundef, i32 noundef) #3

declare i32 @printf(ptr noundef, ...) #4

attributes #0 = { mustprogress norecurse 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 = { nobuiltin allocsize(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 #3 = { inlinehint mustprogress 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 #4 = { "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 #5 = { nounwind }
attributes #6 = { builtin allocsize(0) }

!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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !14, i64 0}
!14 = !{!"long long", !7, i64 0}
!15 = distinct !{!15, !12}
!16 = distinct !{!16, !12}
!17 = distinct !{!17, !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"

@.str = external hidden unnamed_addr constant [6 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
.preheader:
  %0 = tail call noalias noundef nonnull dereferenceable(16) ptr @_Znam(i64 noundef 16) #4
  %1 = tail call noalias noundef nonnull dereferenceable(24) ptr @_Znam(i64 noundef 24) #4
  store ptr %1, ptr %0, align 8, !tbaa !5
  %2 = tail call noalias noundef nonnull dereferenceable(24) ptr @_Znam(i64 noundef 24) #4
  %3 = getelementptr inbounds i8, ptr %0, i64 8
  store ptr %2, ptr %3, align 8, !tbaa !5
  store i64 1, ptr %1, align 8, !tbaa !9
  %4 = getelementptr inbounds i8, ptr %1, i64 8
  store i64 2, ptr %4, align 8, !tbaa !9
  %5 = getelementptr inbounds i8, ptr %1, i64 16
  store i64 3, ptr %5, align 8, !tbaa !9
  store i64 4, ptr %2, align 8, !tbaa !9
  %6 = getelementptr inbounds i8, ptr %2, i64 8
  store i64 5, ptr %6, align 8, !tbaa !9
  %7 = getelementptr inbounds i8, ptr %2, i64 16
  store i64 6, ptr %7, align 8, !tbaa !9
  %8 = tail call noalias noundef nonnull dereferenceable(24) ptr @_Znam(i64 noundef 24) #4
  %9 = tail call noalias noundef nonnull dereferenceable(16) ptr @_Znam(i64 noundef 16) #4
  store ptr %9, ptr %8, align 8, !tbaa !5
  %10 = tail call noalias noundef nonnull dereferenceable(16) ptr @_Znam(i64 noundef 16) #4
  %11 = getelementptr inbounds i8, ptr %8, i64 8
  store ptr %10, ptr %11, align 8, !tbaa !5
  %12 = tail call noalias noundef nonnull dereferenceable(16) ptr @_Znam(i64 noundef 16) #4
  %13 = getelementptr inbounds i8, ptr %8, i64 16
  store ptr %12, ptr %13, align 8, !tbaa !5
  store i64 7, ptr %9, align 8, !tbaa !9
  %14 = getelementptr inbounds i8, ptr %9, i64 8
  store i64 8, ptr %14, align 8, !tbaa !9
  store i64 9, ptr %10, align 8, !tbaa !9
  %15 = getelementptr inbounds i8, ptr %10, i64 8
  store i64 10, ptr %15, align 8, !tbaa !9
  store i64 11, ptr %12, align 8, !tbaa !9
  %16 = getelementptr inbounds i8, ptr %12, i64 8
  store i64 12, ptr %16, align 8, !tbaa !9
  %17 = tail call noundef ptr @_Z14MatrixMultiplyPPxS0_iii(ptr noundef nonnull %0, ptr noundef nonnull %8, i32 noundef 2, i32 noundef 3, i32 noundef 2)
  %18 = load ptr, ptr %17, align 8, !tbaa !5
  %19 = load i64, ptr %18, align 8, !tbaa !9
  %20 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i64 noundef %19)
  %21 = load ptr, ptr %17, align 8, !tbaa !5
  %22 = getelementptr inbounds i8, ptr %21, i64 8
  %23 = load i64, ptr %22, align 8, !tbaa !9
  %24 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i64 noundef %23)
  %25 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1)
  %26 = getelementptr inbounds i8, ptr %17, i64 8
  %27 = load ptr, ptr %26, align 8, !tbaa !5
  %28 = load i64, ptr %27, align 8, !tbaa !9
  %29 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i64 noundef %28)
  %30 = load ptr, ptr %26, align 8, !tbaa !5
  %31 = getelementptr inbounds i8, ptr %30, i64 8
  %32 = load i64, ptr %31, align 8, !tbaa !9
  %33 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i64 noundef %32)
  %34 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1)
  ret i32 0
}

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) local_unnamed_addr #1

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_Z14MatrixMultiplyPPxS0_iii(ptr noundef, ptr noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #3

attributes #0 = { mustprogress norecurse 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 = { nobuiltin allocsize(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 #2 = { inlinehint mustprogress 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 #3 = { nofree nounwind "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 #4 = { builtin allocsize(0) }

!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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long long", !7, i64 0}


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