; LLVM IR from gem5/gem5 :: ext/systemc/src/sysc/datatypes/int/sc_nbutils.ll (ZN5sc_dt7vec_mulEiPKjiS1_Pj)

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN5sc_dt7vec_mulEiPKjiS1_Pj(i32 noundef %0, ptr noundef %1, i32 noundef %2, ptr noundef %3, ptr noundef %4) #1 {
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca ptr, align 8
  %17 = alloca ptr, align 8
  %18 = alloca i32, align 4
  %19 = alloca i32, align 4
  %20 = alloca i32, align 4
  store i32 %0, ptr %6, align 4, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !9
  store i32 %2, ptr %8, align 4, !tbaa !5
  store ptr %3, ptr %9, align 8, !tbaa !9
  store ptr %4, ptr %10, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %21 = load ptr, ptr %7, align 8, !tbaa !9
  %22 = load i32, ptr %6, align 4, !tbaa !5
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds i32, ptr %21, i64 %23
  store ptr %24, ptr %11, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  %25 = load ptr, ptr %9, align 8, !tbaa !9
  %26 = load i32, ptr %8, align 4, !tbaa !5
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds i32, ptr %25, i64 %27
  store ptr %28, ptr %12, align 8, !tbaa !9
  br label %29

29:                                               ; preds = %91, %5
  %30 = load ptr, ptr %7, align 8, !tbaa !9
  %31 = load ptr, ptr %11, align 8, !tbaa !9
  %32 = icmp ult ptr %30, %31
  br i1 %32, label %33, label %94

33:                                               ; preds = %29
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  %34 = load ptr, ptr %7, align 8, !tbaa !9
  %35 = getelementptr inbounds i32, ptr %34, i32 1
  store ptr %35, ptr %7, align 8, !tbaa !9
  %36 = load i32, ptr %34, align 4, !tbaa !5
  store i32 %36, ptr %13, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #3
  %37 = load i32, ptr %13, align 4, !tbaa !5
  %38 = call noundef i32 @_ZN5sc_dt8low_halfEj(i32 noundef %37)
  store i32 %38, ptr %14, align 4, !tbaa !5
  %39 = load i32, ptr %13, align 4, !tbaa !5
  %40 = call noundef i32 @_ZN5sc_dt9high_halfEj(i32 noundef %39)
  store i32 %40, ptr %13, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #3
  store i32 0, ptr %15, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #3
  %41 = load ptr, ptr %10, align 8, !tbaa !9
  %42 = getelementptr inbounds i32, ptr %41, i32 1
  store ptr %42, ptr %10, align 8, !tbaa !9
  store ptr %41, ptr %16, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #3
  %43 = load ptr, ptr %9, align 8, !tbaa !9
  store ptr %43, ptr %17, align 8, !tbaa !9
  br label %44

44:                                               ; preds = %48, %33
  %45 = load ptr, ptr %17, align 8, !tbaa !9
  %46 = load ptr, ptr %12, align 8, !tbaa !9
  %47 = icmp ult ptr %45, %46
  br i1 %47, label %48, label %91

48:                                               ; preds = %44
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #3
  %49 = load ptr, ptr %17, align 8, !tbaa !9
  %50 = getelementptr inbounds i32, ptr %49, i32 1
  store ptr %50, ptr %17, align 8, !tbaa !9
  %51 = load i32, ptr %49, align 4, !tbaa !5
  store i32 %51, ptr %18, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #3
  %52 = load i32, ptr %18, align 4, !tbaa !5
  %53 = call noundef i32 @_ZN5sc_dt8low_halfEj(i32 noundef %52)
  store i32 %53, ptr %19, align 4, !tbaa !5
  %54 = load i32, ptr %18, align 4, !tbaa !5
  %55 = call noundef i32 @_ZN5sc_dt9high_halfEj(i32 noundef %54)
  store i32 %55, ptr %18, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #3
  %56 = load ptr, ptr %16, align 8, !tbaa !9
  %57 = load i32, ptr %56, align 4, !tbaa !5
  %58 = load i32, ptr %14, align 4, !tbaa !5
  %59 = load i32, ptr %19, align 4, !tbaa !5
  %60 = mul i32 %58, %59
  %61 = add i32 %57, %60
  %62 = load i32, ptr %15, align 4, !tbaa !5
  %63 = call noundef i32 @_ZN5sc_dt8low_halfEj(i32 noundef %62)
  %64 = add i32 %61, %63
  store i32 %64, ptr %20, align 4, !tbaa !5
  %65 = load i32, ptr %13, align 4, !tbaa !5
  %66 = load i32, ptr %19, align 4, !tbaa !5
  %67 = mul i32 %65, %66
  %68 = load i32, ptr %14, align 4, !tbaa !5
  %69 = load i32, ptr %18, align 4, !tbaa !5
  %70 = mul i32 %68, %69
  %71 = add i32 %67, %70
  %72 = load i32, ptr %20, align 4, !tbaa !5
  %73 = call noundef i32 @_ZN5sc_dt9high_halfEj(i32 noundef %72)
  %74 = add i32 %71, %73
  %75 = load i32, ptr %15, align 4, !tbaa !5
  %76 = call noundef i32 @_ZN5sc_dt9high_halfEj(i32 noundef %75)
  %77 = add i32 %74, %76
  store i32 %77, ptr %15, align 4, !tbaa !5
  %78 = load i32, ptr %15, align 4, !tbaa !5
  %79 = call noundef i32 @_ZN5sc_dt8low_halfEj(i32 noundef %78)
  %80 = load i32, ptr %20, align 4, !tbaa !5
  %81 = call noundef i32 @_ZN5sc_dt8low_halfEj(i32 noundef %80)
  %82 = call noundef i32 @_ZN5sc_dt6concatEjj(i32 noundef %79, i32 noundef %81)
  %83 = load ptr, ptr %16, align 8, !tbaa !9
  %84 = getelementptr inbounds i32, ptr %83, i32 1
  store ptr %84, ptr %16, align 8, !tbaa !9
  store i32 %82, ptr %83, align 4, !tbaa !5
  %85 = load i32, ptr %13, align 4, !tbaa !5
  %86 = load i32, ptr %18, align 4, !tbaa !5
  %87 = mul i32 %85, %86
  %88 = load i32, ptr %15, align 4, !tbaa !5
  %89 = call noundef i32 @_ZN5sc_dt9high_halfEj(i32 noundef %88)
  %90 = add i32 %87, %89
  store i32 %90, ptr %15, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #3
  br label %44, !llvm.loop !11

91:                                               ; preds = %44
  %92 = load i32, ptr %15, align 4, !tbaa !5
  %93 = load ptr, ptr %16, align 8, !tbaa !9
  store i32 %92, ptr %93, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  br label %29, !llvm.loop !13

94:                                               ; preds = %29
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN5sc_dt8low_halfEj(i32 noundef) #2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN5sc_dt9high_halfEj(i32 noundef) #2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN5sc_dt6concatEjj(i32 noundef, i32 noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { inlinehint mustprogress 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 }

!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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !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"

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN5sc_dt7vec_mulEiPKjiS1_Pj(i32 noundef %0, ptr noundef readonly %1, i32 noundef %2, ptr noundef readonly %3, ptr nocapture noundef %4) local_unnamed_addr #0 {
  %6 = sext i32 %0 to i64
  %7 = getelementptr inbounds i32, ptr %1, i64 %6
  %8 = sext i32 %2 to i64
  %9 = getelementptr inbounds i32, ptr %3, i64 %8
  %10 = icmp sgt i32 %0, 0
  br i1 %10, label %.lr.ph44, label %._crit_edge45

.lr.ph44:                                         ; preds = %5
  %11 = icmp sgt i32 %2, 0
  br i1 %11, label %.lr.ph.us, label %.lr.ph44.split

.lr.ph.us:                                        ; preds = %.lr.ph44, %._crit_edge.us
  %.042.us = phi ptr [ %40, %._crit_edge.us ], [ %1, %.lr.ph44 ]
  %.03341.us = phi ptr [ %41, %._crit_edge.us ], [ %4, %.lr.ph44 ]
  %12 = load i32, ptr %.042.us, align 4, !tbaa !5
  %13 = tail call noundef i32 @_ZN5sc_dt8low_halfEj(i32 noundef %12)
  %14 = tail call noundef i32 @_ZN5sc_dt9high_halfEj(i32 noundef %12)
  br label %15

15:                                               ; preds = %.lr.ph.us, %15
  %.03439.us = phi ptr [ %3, %.lr.ph.us ], [ %16, %15 ]
  %.03538.us = phi ptr [ %.03341.us, %.lr.ph.us ], [ %35, %15 ]
  %.03637.us = phi i32 [ 0, %.lr.ph.us ], [ %38, %15 ]
  %16 = getelementptr inbounds i8, ptr %.03439.us, i64 4
  %17 = load i32, ptr %.03439.us, align 4, !tbaa !5
  %18 = tail call noundef i32 @_ZN5sc_dt8low_halfEj(i32 noundef %17)
  %19 = tail call noundef i32 @_ZN5sc_dt9high_halfEj(i32 noundef %17)
  %20 = load i32, ptr %.03538.us, align 4, !tbaa !5
  %21 = mul i32 %18, %13
  %22 = add i32 %20, %21
  %23 = tail call noundef i32 @_ZN5sc_dt8low_halfEj(i32 noundef %.03637.us)
  %24 = add i32 %22, %23
  %25 = mul i32 %18, %14
  %26 = mul i32 %19, %13
  %27 = add i32 %26, %25
  %28 = tail call noundef i32 @_ZN5sc_dt9high_halfEj(i32 noundef %24)
  %29 = add i32 %27, %28
  %30 = tail call noundef i32 @_ZN5sc_dt9high_halfEj(i32 noundef %.03637.us)
  %31 = add i32 %29, %30
  %32 = tail call noundef i32 @_ZN5sc_dt8low_halfEj(i32 noundef %31)
  %33 = tail call noundef i32 @_ZN5sc_dt8low_halfEj(i32 noundef %24)
  %34 = tail call noundef i32 @_ZN5sc_dt6concatEjj(i32 noundef %32, i32 noundef %33)
  %35 = getelementptr inbounds i8, ptr %.03538.us, i64 4
  store i32 %34, ptr %.03538.us, align 4, !tbaa !5
  %36 = mul i32 %19, %14
  %37 = tail call noundef i32 @_ZN5sc_dt9high_halfEj(i32 noundef %31)
  %38 = add i32 %37, %36
  %39 = icmp ult ptr %16, %9
  br i1 %39, label %15, label %._crit_edge.us, !llvm.loop !9

._crit_edge.us:                                   ; preds = %15
  %40 = getelementptr inbounds i8, ptr %.042.us, i64 4
  %41 = getelementptr inbounds i8, ptr %.03341.us, i64 4
  store i32 %38, ptr %35, align 4, !tbaa !5
  %42 = icmp ult ptr %40, %7
  br i1 %42, label %.lr.ph.us, label %._crit_edge45, !llvm.loop !11

.lr.ph44.split:                                   ; preds = %.lr.ph44, %.lr.ph44.split
  %.042 = phi ptr [ %43, %.lr.ph44.split ], [ %1, %.lr.ph44 ]
  %.03341 = phi ptr [ %47, %.lr.ph44.split ], [ %4, %.lr.ph44 ]
  %43 = getelementptr inbounds i8, ptr %.042, i64 4
  %44 = load i32, ptr %.042, align 4, !tbaa !5
  %45 = tail call noundef i32 @_ZN5sc_dt8low_halfEj(i32 noundef %44)
  %46 = tail call noundef i32 @_ZN5sc_dt9high_halfEj(i32 noundef %44)
  %47 = getelementptr inbounds i8, ptr %.03341, i64 4
  store i32 0, ptr %.03341, align 4, !tbaa !5
  %48 = icmp ult ptr %43, %7
  br i1 %48, label %.lr.ph44.split, label %._crit_edge45, !llvm.loop !11

._crit_edge45:                                    ; preds = %.lr.ph44.split, %._crit_edge.us, %5
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN5sc_dt8low_halfEj(i32 noundef) local_unnamed_addr #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN5sc_dt9high_halfEj(i32 noundef) local_unnamed_addr #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN5sc_dt6concatEjj(i32 noundef, i32 noundef) local_unnamed_addr #1

attributes #0 = { mustprogress 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 = { inlinehint mustprogress 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}


; Effective O3 passes: GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass