; LLVM IR from jingweizhanghuai/Morn :: test (test_matrix)

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

%struct.MMatrix = type { i32, i32, ptr }

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

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

10:                                               ; preds = %0
  %11 = load ptr, ptr %2, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.MMatrix, ptr %11, i64 0
  call void @m_UnitMatrix(ptr noundef %12, i32 noundef 4)
  br label %13

13:                                               ; preds = %10
  br label %14

14:                                               ; preds = %13
  br label %15

15:                                               ; preds = %14
  %16 = load ptr, ptr %3, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.MMatrix, ptr %16, i64 0
  call void @m_UnitMatrix(ptr noundef %17, i32 noundef 4)
  br label %18

18:                                               ; preds = %15
  br label %19

19:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.MMatrix, ptr %20, i32 0, i32 2
  %22 = load ptr, ptr %21, align 8, !tbaa !9
  store ptr %22, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  store i32 0, ptr %5, align 4, !tbaa !12
  br label %23

23:                                               ; preds = %47, %19
  %24 = load i32, ptr %5, align 4, !tbaa !12
  %25 = icmp slt i32 %24, 4
  br i1 %25, label %27, label %26

26:                                               ; preds = %23
  store i32 6, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  br label %50

27:                                               ; preds = %23
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  store i32 0, ptr %7, align 4, !tbaa !12
  br label %28

28:                                               ; preds = %43, %27
  %29 = load i32, ptr %7, align 4, !tbaa !12
  %30 = icmp slt i32 %29, 4
  br i1 %30, label %32, label %31

31:                                               ; preds = %28
  store i32 9, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  br label %46

32:                                               ; preds = %28
  %33 = call i32 @m_Rand(i32 noundef 0, i32 noundef 10)
  %34 = sitofp i32 %33 to float
  %35 = load ptr, ptr %4, align 8, !tbaa !5
  %36 = load i32, ptr %5, align 4, !tbaa !12
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds ptr, ptr %35, i64 %37
  %39 = load ptr, ptr %38, align 8, !tbaa !5
  %40 = load i32, ptr %7, align 4, !tbaa !12
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds float, ptr %39, i64 %41
  store float %34, ptr %42, align 4, !tbaa !13
  br label %43

43:                                               ; preds = %32
  %44 = load i32, ptr %7, align 4, !tbaa !12
  %45 = add nsw i32 %44, 1
  store i32 %45, ptr %7, align 4, !tbaa !12
  br label %28, !llvm.loop !15

46:                                               ; preds = %31
  br label %47

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

50:                                               ; preds = %26
  %51 = load ptr, ptr %2, align 8, !tbaa !5
  call void @_PrintMat(ptr noundef @.str, ptr noundef %51)
  %52 = load ptr, ptr %3, align 8, !tbaa !5
  call void @_PrintMat(ptr noundef @.str.1, ptr noundef %52)
  br label %53

53:                                               ; preds = %50
  %54 = load ptr, ptr %2, align 8, !tbaa !5
  %55 = load ptr, ptr %3, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.MMatrix, ptr %55, i64 0
  %57 = load ptr, ptr %3, align 8, !tbaa !5
  %58 = ptrtoint ptr %57 to i64
  %59 = inttoptr i64 %58 to ptr
  call void @m_MatrixMul(ptr noundef %54, ptr noundef %56, ptr noundef %59)
  br label %60

60:                                               ; preds = %53
  br label %61

61:                                               ; preds = %60
  %62 = load ptr, ptr %3, align 8, !tbaa !5
  call void @_PrintMat(ptr noundef @.str.1, ptr noundef %62)
  %63 = load ptr, ptr %2, align 8, !tbaa !5
  call void @mMatrixRelease(ptr noundef %63)
  %64 = load ptr, ptr %3, align 8, !tbaa !5
  call void @mMatrixRelease(ptr noundef %64)
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #3
  %65 = load i32, ptr %1, align 4
  ret i32 %65
}

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

declare ptr @MatrixCreate(i32 noundef, i32 noundef, ptr noundef) #2

declare void @m_UnitMatrix(ptr noundef, i32 noundef) #2

declare i32 @m_Rand(i32 noundef, i32 noundef) #2

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

declare void @_PrintMat(ptr noundef, ptr noundef) #2

declare void @m_MatrixMul(ptr noundef, ptr noundef, ptr noundef) #2

declare void @mMatrixRelease(ptr noundef) #2

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


; 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 [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
.preheader:
  %0 = tail call ptr @MatrixCreate(i32 noundef 4, i32 noundef 4, ptr noundef null) #2
  %1 = tail call ptr @MatrixCreate(i32 noundef 4, i32 noundef 4, ptr noundef null) #2
  tail call void @m_UnitMatrix(ptr noundef %0, i32 noundef 4) #2
  tail call void @m_UnitMatrix(ptr noundef %1, i32 noundef 4) #2
  %2 = getelementptr inbounds i8, ptr %1, i64 8
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = tail call i32 @m_Rand(i32 noundef 0, i32 noundef 10) #2
  %5 = sitofp i32 %4 to float
  %6 = load ptr, ptr %3, align 8, !tbaa !11
  store float %5, ptr %6, align 4, !tbaa !12
  %7 = tail call i32 @m_Rand(i32 noundef 0, i32 noundef 10) #2
  %8 = sitofp i32 %7 to float
  %9 = load ptr, ptr %3, align 8, !tbaa !11
  %10 = getelementptr inbounds i8, ptr %9, i64 4
  store float %8, ptr %10, align 4, !tbaa !12
  %11 = tail call i32 @m_Rand(i32 noundef 0, i32 noundef 10) #2
  %12 = sitofp i32 %11 to float
  %13 = load ptr, ptr %3, align 8, !tbaa !11
  %14 = getelementptr inbounds i8, ptr %13, i64 8
  store float %12, ptr %14, align 4, !tbaa !12
  %15 = tail call i32 @m_Rand(i32 noundef 0, i32 noundef 10) #2
  %16 = sitofp i32 %15 to float
  %17 = load ptr, ptr %3, align 8, !tbaa !11
  %18 = getelementptr inbounds i8, ptr %17, i64 12
  store float %16, ptr %18, align 4, !tbaa !12
  %19 = getelementptr inbounds i8, ptr %3, i64 8
  %20 = tail call i32 @m_Rand(i32 noundef 0, i32 noundef 10) #2
  %21 = sitofp i32 %20 to float
  %22 = load ptr, ptr %19, align 8, !tbaa !11
  store float %21, ptr %22, align 4, !tbaa !12
  %23 = tail call i32 @m_Rand(i32 noundef 0, i32 noundef 10) #2
  %24 = sitofp i32 %23 to float
  %25 = load ptr, ptr %19, align 8, !tbaa !11
  %26 = getelementptr inbounds i8, ptr %25, i64 4
  store float %24, ptr %26, align 4, !tbaa !12
  %27 = tail call i32 @m_Rand(i32 noundef 0, i32 noundef 10) #2
  %28 = sitofp i32 %27 to float
  %29 = load ptr, ptr %19, align 8, !tbaa !11
  %30 = getelementptr inbounds i8, ptr %29, i64 8
  store float %28, ptr %30, align 4, !tbaa !12
  %31 = tail call i32 @m_Rand(i32 noundef 0, i32 noundef 10) #2
  %32 = sitofp i32 %31 to float
  %33 = load ptr, ptr %19, align 8, !tbaa !11
  %34 = getelementptr inbounds i8, ptr %33, i64 12
  store float %32, ptr %34, align 4, !tbaa !12
  %35 = getelementptr inbounds i8, ptr %3, i64 16
  %36 = tail call i32 @m_Rand(i32 noundef 0, i32 noundef 10) #2
  %37 = sitofp i32 %36 to float
  %38 = load ptr, ptr %35, align 8, !tbaa !11
  store float %37, ptr %38, align 4, !tbaa !12
  %39 = tail call i32 @m_Rand(i32 noundef 0, i32 noundef 10) #2
  %40 = sitofp i32 %39 to float
  %41 = load ptr, ptr %35, align 8, !tbaa !11
  %42 = getelementptr inbounds i8, ptr %41, i64 4
  store float %40, ptr %42, align 4, !tbaa !12
  %43 = tail call i32 @m_Rand(i32 noundef 0, i32 noundef 10) #2
  %44 = sitofp i32 %43 to float
  %45 = load ptr, ptr %35, align 8, !tbaa !11
  %46 = getelementptr inbounds i8, ptr %45, i64 8
  store float %44, ptr %46, align 4, !tbaa !12
  %47 = tail call i32 @m_Rand(i32 noundef 0, i32 noundef 10) #2
  %48 = sitofp i32 %47 to float
  %49 = load ptr, ptr %35, align 8, !tbaa !11
  %50 = getelementptr inbounds i8, ptr %49, i64 12
  store float %48, ptr %50, align 4, !tbaa !12
  %51 = getelementptr inbounds i8, ptr %3, i64 24
  %52 = tail call i32 @m_Rand(i32 noundef 0, i32 noundef 10) #2
  %53 = sitofp i32 %52 to float
  %54 = load ptr, ptr %51, align 8, !tbaa !11
  store float %53, ptr %54, align 4, !tbaa !12
  %55 = tail call i32 @m_Rand(i32 noundef 0, i32 noundef 10) #2
  %56 = sitofp i32 %55 to float
  %57 = load ptr, ptr %51, align 8, !tbaa !11
  %58 = getelementptr inbounds i8, ptr %57, i64 4
  store float %56, ptr %58, align 4, !tbaa !12
  %59 = tail call i32 @m_Rand(i32 noundef 0, i32 noundef 10) #2
  %60 = sitofp i32 %59 to float
  %61 = load ptr, ptr %51, align 8, !tbaa !11
  %62 = getelementptr inbounds i8, ptr %61, i64 8
  store float %60, ptr %62, align 4, !tbaa !12
  %63 = tail call i32 @m_Rand(i32 noundef 0, i32 noundef 10) #2
  %64 = sitofp i32 %63 to float
  %65 = load ptr, ptr %51, align 8, !tbaa !11
  %66 = getelementptr inbounds i8, ptr %65, i64 12
  store float %64, ptr %66, align 4, !tbaa !12
  tail call void @_PrintMat(ptr noundef nonnull @.str, ptr noundef %0) #2
  tail call void @_PrintMat(ptr noundef nonnull @.str.1, ptr noundef %1) #2
  tail call void @m_MatrixMul(ptr noundef %0, ptr noundef %1, ptr noundef %1) #2
  tail call void @_PrintMat(ptr noundef nonnull @.str.1, ptr noundef %1) #2
  tail call void @mMatrixRelease(ptr noundef %0) #2
  tail call void @mMatrixRelease(ptr noundef %1) #2
  ret i32 0
}

declare ptr @MatrixCreate(i32 noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

declare void @m_UnitMatrix(ptr noundef, i32 noundef) local_unnamed_addr #1

declare i32 @m_Rand(i32 noundef, i32 noundef) local_unnamed_addr #1

declare void @_PrintMat(ptr noundef, ptr noundef) local_unnamed_addr #1

declare void @m_MatrixMul(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

declare void @mMatrixRelease(ptr noundef) local_unnamed_addr #1

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 = { "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 = { 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, !10, i64 8}
!6 = !{!"MMatrix", !7, i64 0, !7, i64 4, !10, i64 8}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!10, !10, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"float", !8, i64 0}


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