; LLVM IR from sourceryinstitute/MORFEUS-Source :: src/FV/src/mesh_optimize/OptMS (SMmatrix)

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

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

declare i32 @SMerror(i32 noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef, i32 noundef, ptr noundef) #1

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

; Function Attrs: nounwind uwtable
define dso_local i32 @SMformVerticalMatrix(i32 noundef %0, ptr noundef %1, ptr noundef %2) #2 {
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  store i32 %0, ptr %5, align 4, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  %12 = load i32, ptr %5, align 4, !tbaa !5
  %13 = sext i32 %12 to i64
  %14 = mul i64 8, %13
  %15 = icmp eq i64 %14, 0
  br i1 %15, label %16, label %18

16:                                               ; preds = %3
  %17 = load ptr, ptr %7, align 8, !tbaa !9
  store ptr null, ptr %17, align 8, !tbaa !9
  br label %30

18:                                               ; preds = %3
  %19 = load i32, ptr %5, align 4, !tbaa !5
  %20 = sext i32 %19 to i64
  %21 = mul i64 8, %20
  %22 = call noalias ptr @malloc(i64 noundef %21) #5
  %23 = load ptr, ptr %7, align 8, !tbaa !9
  store ptr %22, ptr %23, align 8, !tbaa !9
  %24 = load ptr, ptr %7, align 8, !tbaa !9
  %25 = load ptr, ptr %24, align 8, !tbaa !9
  %26 = icmp eq ptr %25, null
  br i1 %26, label %27, label %29

27:                                               ; preds = %18
  %28 = call i32 @SMerror(i32 noundef 97, ptr noundef @.str.6, ptr noundef @.str.1, ptr noundef @.str.2, i32 noundef 55, i32 noundef 0, ptr noundef null)
  store i32 %28, ptr %4, align 4
  store i32 1, ptr %11, align 4
  br label %138

29:                                               ; preds = %18
  br label %30

30:                                               ; preds = %29, %16
  store i32 0, ptr %9, align 4, !tbaa !5
  br label %31

31:                                               ; preds = %67, %30
  %32 = load i32, ptr %9, align 4, !tbaa !5
  %33 = load i32, ptr %5, align 4, !tbaa !5
  %34 = icmp slt i32 %32, %33
  br i1 %34, label %35, label %70

35:                                               ; preds = %31
  %36 = load i32, ptr %5, align 4, !tbaa !5
  %37 = sext i32 %36 to i64
  %38 = mul i64 8, %37
  %39 = icmp eq i64 %38, 0
  br i1 %39, label %40, label %46

40:                                               ; preds = %35
  %41 = load ptr, ptr %7, align 8, !tbaa !9
  %42 = load ptr, ptr %41, align 8, !tbaa !9
  %43 = load i32, ptr %9, align 4, !tbaa !5
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds ptr, ptr %42, i64 %44
  store ptr null, ptr %45, align 8, !tbaa !9
  br label %66

46:                                               ; preds = %35
  %47 = load i32, ptr %5, align 4, !tbaa !5
  %48 = sext i32 %47 to i64
  %49 = mul i64 8, %48
  %50 = call noalias ptr @malloc(i64 noundef %49) #5
  %51 = load ptr, ptr %7, align 8, !tbaa !9
  %52 = load ptr, ptr %51, align 8, !tbaa !9
  %53 = load i32, ptr %9, align 4, !tbaa !5
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds ptr, ptr %52, i64 %54
  store ptr %50, ptr %55, align 8, !tbaa !9
  %56 = load ptr, ptr %7, align 8, !tbaa !9
  %57 = load ptr, ptr %56, align 8, !tbaa !9
  %58 = load i32, ptr %9, align 4, !tbaa !5
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds ptr, ptr %57, i64 %59
  %61 = load ptr, ptr %60, align 8, !tbaa !9
  %62 = icmp eq ptr %61, null
  br i1 %62, label %63, label %65

63:                                               ; preds = %46
  %64 = call i32 @SMerror(i32 noundef 98, ptr noundef @.str.6, ptr noundef @.str.1, ptr noundef @.str.2, i32 noundef 55, i32 noundef 0, ptr noundef null)
  store i32 %64, ptr %4, align 4
  store i32 1, ptr %11, align 4
  br label %138

65:                                               ; preds = %46
  br label %66

66:                                               ; preds = %65, %40
  br label %67

67:                                               ; preds = %66
  %68 = load i32, ptr %9, align 4, !tbaa !5
  %69 = add nsw i32 %68, 1
  store i32 %69, ptr %9, align 4, !tbaa !5
  br label %31, !llvm.loop !11

70:                                               ; preds = %31
  store i32 0, ptr %9, align 4, !tbaa !5
  br label %71

71:                                               ; preds = %134, %70
  %72 = load i32, ptr %9, align 4, !tbaa !5
  %73 = load i32, ptr %5, align 4, !tbaa !5
  %74 = icmp slt i32 %72, %73
  br i1 %74, label %75, label %137

75:                                               ; preds = %71
  %76 = load ptr, ptr %6, align 8, !tbaa !9
  %77 = load i32, ptr %9, align 4, !tbaa !5
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds ptr, ptr %76, i64 %78
  %80 = load ptr, ptr %79, align 8, !tbaa !9
  %81 = load i32, ptr %9, align 4, !tbaa !5
  %82 = sext i32 %81 to i64
  %83 = getelementptr inbounds double, ptr %80, i64 %82
  %84 = load double, ptr %83, align 8, !tbaa !13
  %85 = fadd double %84, 1.000000e+00
  %86 = load ptr, ptr %7, align 8, !tbaa !9
  %87 = load ptr, ptr %86, align 8, !tbaa !9
  %88 = load i32, ptr %9, align 4, !tbaa !5
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds ptr, ptr %87, i64 %89
  %91 = load ptr, ptr %90, align 8, !tbaa !9
  %92 = load i32, ptr %9, align 4, !tbaa !5
  %93 = sext i32 %92 to i64
  %94 = getelementptr inbounds double, ptr %91, i64 %93
  store double %85, ptr %94, align 8, !tbaa !13
  %95 = load i32, ptr %9, align 4, !tbaa !5
  %96 = add nsw i32 %95, 1
  store i32 %96, ptr %10, align 4, !tbaa !5
  br label %97

97:                                               ; preds = %130, %75
  %98 = load i32, ptr %10, align 4, !tbaa !5
  %99 = load i32, ptr %5, align 4, !tbaa !5
  %100 = icmp slt i32 %98, %99
  br i1 %100, label %101, label %133

101:                                              ; preds = %97
  %102 = load ptr, ptr %6, align 8, !tbaa !9
  %103 = load i32, ptr %9, align 4, !tbaa !5
  %104 = sext i32 %103 to i64
  %105 = getelementptr inbounds ptr, ptr %102, i64 %104
  %106 = load ptr, ptr %105, align 8, !tbaa !9
  %107 = load i32, ptr %10, align 4, !tbaa !5
  %108 = sext i32 %107 to i64
  %109 = getelementptr inbounds double, ptr %106, i64 %108
  %110 = load double, ptr %109, align 8, !tbaa !13
  %111 = fadd double %110, 1.000000e+00
  %112 = load ptr, ptr %7, align 8, !tbaa !9
  %113 = load ptr, ptr %112, align 8, !tbaa !9
  %114 = load i32, ptr %10, align 4, !tbaa !5
  %115 = sext i32 %114 to i64
  %116 = getelementptr inbounds ptr, ptr %113, i64 %115
  %117 = load ptr, ptr %116, align 8, !tbaa !9
  %118 = load i32, ptr %9, align 4, !tbaa !5
  %119 = sext i32 %118 to i64
  %120 = getelementptr inbounds double, ptr %117, i64 %119
  store double %111, ptr %120, align 8, !tbaa !13
  %121 = load ptr, ptr %7, align 8, !tbaa !9
  %122 = load ptr, ptr %121, align 8, !tbaa !9
  %123 = load i32, ptr %9, align 4, !tbaa !5
  %124 = sext i32 %123 to i64
  %125 = getelementptr inbounds ptr, ptr %122, i64 %124
  %126 = load ptr, ptr %125, align 8, !tbaa !9
  %127 = load i32, ptr %10, align 4, !tbaa !5
  %128 = sext i32 %127 to i64
  %129 = getelementptr inbounds double, ptr %126, i64 %128
  store double %111, ptr %129, align 8, !tbaa !13
  br label %130

130:                                              ; preds = %101
  %131 = load i32, ptr %10, align 4, !tbaa !5
  %132 = add nsw i32 %131, 1
  store i32 %132, ptr %10, align 4, !tbaa !5
  br label %97, !llvm.loop !15

133:                                              ; preds = %97
  br label %134

134:                                              ; preds = %133
  %135 = load i32, ptr %9, align 4, !tbaa !5
  %136 = add nsw i32 %135, 1
  store i32 %136, ptr %9, align 4, !tbaa !5
  br label %71, !llvm.loop !16

137:                                              ; preds = %71
  store i32 0, ptr %8, align 4, !tbaa !5
  store i32 0, ptr %4, align 4
  store i32 1, ptr %11, align 4
  br label %138

138:                                              ; preds = %137, %63, %27
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  %139 = load i32, ptr %4, align 4
  ret i32 %139
}

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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 = { nounwind 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 #4 = { nounwind }
attributes #5 = { nounwind 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !14, i64 0}
!14 = !{!"double", !7, i64 0}
!15 = distinct !{!15, !12}
!16 = distinct !{!16, !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.1 = external hidden unnamed_addr constant [108 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [21 x i8], align 1

declare i32 @SMerror(i32 noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local i32 @SMformVerticalMatrix(i32 noundef %0, ptr nocapture noundef readonly %1, ptr nocapture noundef %2) local_unnamed_addr #1 {
  %4 = sext i32 %0 to i64
  %5 = shl nsw i64 %4, 3
  %6 = icmp eq i32 %0, 0
  br i1 %6, label %.thread, label %7

.thread:                                          ; preds = %3
  store ptr null, ptr %2, align 8, !tbaa !5
  br label %.loopexit43

7:                                                ; preds = %3
  %8 = tail call noalias ptr @malloc(i64 noundef %5) #3
  store ptr %8, ptr %2, align 8, !tbaa !5
  %9 = icmp eq ptr %8, null
  br i1 %9, label %10, label %12

10:                                               ; preds = %7
  %11 = tail call i32 @SMerror(i32 noundef 97, ptr noundef nonnull @.str.6, ptr noundef nonnull @.str.1, ptr noundef nonnull @.str.2, i32 noundef 55, i32 noundef 0, ptr noundef null) #4
  br label %.loopexit43

12:                                               ; preds = %7
  %13 = icmp sgt i32 %0, 0
  br i1 %13, label %.lr.ph.preheader, label %.loopexit43

.lr.ph.preheader:                                 ; preds = %12
  %wide.trip.count = zext nneg i32 %0 to i64
  br label %.lr.ph

14:                                               ; preds = %.lr.ph
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %.preheader, label %.lr.ph, !llvm.loop !9

.preheader:                                       ; preds = %14
  br i1 %13, label %.lr.ph48, label %.loopexit43

.lr.ph48:                                         ; preds = %.preheader
  %wide.trip.count60 = zext nneg i32 %0 to i64
  br label %24

.lr.ph:                                           ; preds = %.lr.ph.preheader, %14
  %15 = phi ptr [ %8, %.lr.ph.preheader ], [ %18, %14 ]
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next, %14 ]
  %16 = tail call noalias ptr @malloc(i64 noundef %5) #3
  %17 = getelementptr inbounds ptr, ptr %15, i64 %indvars.iv
  store ptr %16, ptr %17, align 8, !tbaa !5
  %18 = load ptr, ptr %2, align 8, !tbaa !5
  %19 = getelementptr inbounds ptr, ptr %18, i64 %indvars.iv
  %20 = load ptr, ptr %19, align 8, !tbaa !5
  %21 = icmp eq ptr %20, null
  br i1 %21, label %22, label %14

22:                                               ; preds = %.lr.ph
  %23 = tail call i32 @SMerror(i32 noundef 98, ptr noundef nonnull @.str.6, ptr noundef nonnull @.str.1, ptr noundef nonnull @.str.2, i32 noundef 55, i32 noundef 0, ptr noundef null) #4
  br label %.loopexit43

.loopexit:                                        ; preds = %.lr.ph46, %24
  %indvars.iv.next51 = add nuw nsw i64 %indvars.iv50, 1
  %exitcond61.not = icmp eq i64 %indvars.iv.next58, %wide.trip.count60
  br i1 %exitcond61.not, label %.loopexit43, label %24, !llvm.loop !11

24:                                               ; preds = %.lr.ph48, %.loopexit
  %indvars.iv57 = phi i64 [ 0, %.lr.ph48 ], [ %indvars.iv.next58, %.loopexit ]
  %indvars.iv50 = phi i64 [ 1, %.lr.ph48 ], [ %indvars.iv.next51, %.loopexit ]
  %25 = getelementptr inbounds ptr, ptr %1, i64 %indvars.iv57
  %26 = load ptr, ptr %25, align 8, !tbaa !5
  %27 = getelementptr inbounds double, ptr %26, i64 %indvars.iv57
  %28 = load double, ptr %27, align 8, !tbaa !12
  %29 = fadd double %28, 1.000000e+00
  %30 = getelementptr inbounds ptr, ptr %18, i64 %indvars.iv57
  %31 = load ptr, ptr %30, align 8, !tbaa !5
  %32 = getelementptr inbounds double, ptr %31, i64 %indvars.iv57
  store double %29, ptr %32, align 8, !tbaa !12
  %indvars.iv.next58 = add nuw nsw i64 %indvars.iv57, 1
  %33 = icmp slt i64 %indvars.iv.next58, %4
  br i1 %33, label %.lr.ph46, label %.loopexit

.lr.ph46:                                         ; preds = %24, %.lr.ph46
  %indvars.iv52 = phi i64 [ %indvars.iv.next53, %.lr.ph46 ], [ %indvars.iv50, %24 ]
  %34 = getelementptr inbounds double, ptr %26, i64 %indvars.iv52
  %35 = load double, ptr %34, align 8, !tbaa !12
  %36 = fadd double %35, 1.000000e+00
  %37 = getelementptr inbounds ptr, ptr %18, i64 %indvars.iv52
  %38 = load ptr, ptr %37, align 8, !tbaa !5
  %39 = getelementptr inbounds double, ptr %38, i64 %indvars.iv57
  store double %36, ptr %39, align 8, !tbaa !12
  %40 = getelementptr inbounds double, ptr %31, i64 %indvars.iv52
  store double %36, ptr %40, align 8, !tbaa !12
  %indvars.iv.next53 = add nuw nsw i64 %indvars.iv52, 1
  %exitcond56.not = icmp eq i64 %indvars.iv.next53, %wide.trip.count60
  br i1 %exitcond56.not, label %.loopexit, label %.lr.ph46, !llvm.loop !14

.loopexit43:                                      ; preds = %.loopexit, %12, %.thread, %.preheader, %22, %10
  %.039 = phi i32 [ %23, %22 ], [ %11, %10 ], [ 0, %.preheader ], [ 0, %.thread ], [ 0, %12 ], [ 0, %.loopexit ]
  ret i32 %.039
}

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #2

attributes #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 = { 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 #2 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 allocsize(0) }
attributes #4 = { 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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = !{!13, !13, i64 0}
!13 = !{!"double", !7, i64 0}
!14 = distinct !{!14, !10}


; Effective O3 passes: ConstraintEliminationPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass