; LLVM IR from gem5/gem5 :: ext/softfloat (s_normRoundPackMToF128M)

; 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: nounwind uwtable
define dso_local void @softfloat_normRoundPackMToF128M(i1 noundef zeroext %0, i32 noundef %1, ptr noundef %2, ptr noundef %3) #0 {
  %5 = alloca i8, align 1
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i64, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = zext i1 %0 to i8
  store i8 %13, ptr %5, align 1, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !11
  store ptr %3, ptr %8, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  %14 = load ptr, ptr %7, align 8, !tbaa !11
  %15 = getelementptr inbounds i32, ptr %14, i64 4
  store ptr %15, ptr %9, align 8, !tbaa !11
  store i64 0, ptr %10, align 8, !tbaa !13
  br label %16

16:                                               ; preds = %42, %4
  %17 = load ptr, ptr %9, align 8, !tbaa !11
  %18 = load i32, ptr %17, align 4, !tbaa !9
  store i32 %18, ptr %11, align 4, !tbaa !9
  %19 = load i32, ptr %11, align 4, !tbaa !9
  %20 = icmp ne i32 %19, 0
  br i1 %20, label %21, label %22

21:                                               ; preds = %16
  br label %45

22:                                               ; preds = %16
  %23 = load i64, ptr %10, align 8, !tbaa !13
  %24 = add nsw i64 %23, 32
  store i64 %24, ptr %10, align 8, !tbaa !13
  %25 = load i64, ptr %10, align 8, !tbaa !13
  %26 = icmp sle i64 160, %25
  br i1 %26, label %27, label %42

27:                                               ; preds = %22
  %28 = load i8, ptr %5, align 1, !tbaa !5, !range !15, !noundef !16
  %29 = trunc i8 %28 to i1
  %30 = zext i1 %29 to i32
  %31 = shl i32 %30, 31
  %32 = add i32 %31, 0
  %33 = add i32 %32, 0
  %34 = load ptr, ptr %8, align 8, !tbaa !11
  %35 = getelementptr inbounds i32, ptr %34, i64 3
  store i32 %33, ptr %35, align 4, !tbaa !9
  %36 = load ptr, ptr %8, align 8, !tbaa !11
  %37 = getelementptr inbounds i32, ptr %36, i64 2
  store i32 0, ptr %37, align 4, !tbaa !9
  %38 = load ptr, ptr %8, align 8, !tbaa !11
  %39 = getelementptr inbounds i32, ptr %38, i64 1
  store i32 0, ptr %39, align 4, !tbaa !9
  %40 = load ptr, ptr %8, align 8, !tbaa !11
  %41 = getelementptr inbounds i32, ptr %40, i64 0
  store i32 0, ptr %41, align 4, !tbaa !9
  store i32 1, ptr %12, align 4
  br label %71

42:                                               ; preds = %22
  %43 = load ptr, ptr %9, align 8, !tbaa !11
  %44 = getelementptr inbounds i32, ptr %43, i64 -1
  store ptr %44, ptr %9, align 8, !tbaa !11
  br label %16

45:                                               ; preds = %21
  %46 = load i32, ptr %11, align 4, !tbaa !9
  %47 = call zeroext i8 @softfloat_countLeadingZeros32(i32 noundef %46)
  %48 = zext i8 %47 to i32
  %49 = sub nsw i32 %48, 15
  %50 = sext i32 %49 to i64
  %51 = load i64, ptr %10, align 8, !tbaa !13
  %52 = add nsw i64 %51, %50
  store i64 %52, ptr %10, align 8, !tbaa !13
  %53 = load i64, ptr %10, align 8, !tbaa !13
  %54 = icmp ne i64 %53, 0
  br i1 %54, label %55, label %65

55:                                               ; preds = %45
  %56 = load i64, ptr %10, align 8, !tbaa !13
  %57 = load i32, ptr %6, align 4, !tbaa !9
  %58 = sext i32 %57 to i64
  %59 = sub nsw i64 %58, %56
  %60 = trunc i64 %59 to i32
  store i32 %60, ptr %6, align 4, !tbaa !9
  %61 = load ptr, ptr %7, align 8, !tbaa !11
  %62 = load i64, ptr %10, align 8, !tbaa !13
  %63 = trunc i64 %62 to i32
  %64 = load ptr, ptr %7, align 8, !tbaa !11
  call void @softfloat_shiftLeftM(i8 noundef zeroext 5, ptr noundef %61, i32 noundef %63, ptr noundef %64)
  br label %65

65:                                               ; preds = %55, %45
  %66 = load i8, ptr %5, align 1, !tbaa !5, !range !15, !noundef !16
  %67 = trunc i8 %66 to i1
  %68 = load i32, ptr %6, align 4, !tbaa !9
  %69 = load ptr, ptr %7, align 8, !tbaa !11
  %70 = load ptr, ptr %8, align 8, !tbaa !11
  call void @softfloat_roundPackMToF128M(i1 noundef zeroext %67, i32 noundef %68, ptr noundef %69, ptr noundef %70)
  store i32 0, ptr %12, align 4
  br label %71

71:                                               ; preds = %65, %27
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  %72 = load i32, ptr %12, align 4
  switch i32 %72, label %74 [
    i32 0, label %73
    i32 1, label %73
  ]

73:                                               ; preds = %71, %71
  ret void

74:                                               ; preds = %71
  unreachable
}

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden zeroext i8 @softfloat_countLeadingZeros32(i32 noundef) #2

declare void @softfloat_shiftLeftM(i8 noundef zeroext, ptr noundef, i32 noundef, ptr noundef) #3

declare void @softfloat_roundPackMToF128M(i1 noundef zeroext, i32 noundef, ptr noundef, ptr noundef) #3

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { inlinehint 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 = { "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 }

!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 = !{!"_Bool", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = !{i8 0, i8 2}
!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"

; Function Attrs: nounwind uwtable
define dso_local void @softfloat_normRoundPackMToF128M(i1 noundef zeroext %0, i32 noundef %1, ptr noundef %2, ptr noundef %3) local_unnamed_addr #0 {
  %5 = getelementptr inbounds i8, ptr %2, i64 16
  %6 = load i32, ptr %5, align 4, !tbaa !5
  %.not30 = icmp eq i32 %6, 0
  br i1 %.not30, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %4
  %7 = getelementptr inbounds i8, ptr %2, i64 12
  %8 = load i32, ptr %7, align 4, !tbaa !5
  %.not = icmp eq i32 %8, 0
  br i1 %.not, label %.lr.ph.1, label %._crit_edge

9:                                                ; preds = %.lr.ph.3
  %10 = select i1 %0, i32 -2147483648, i32 0
  %11 = getelementptr inbounds i8, ptr %3, i64 12
  store i32 %10, ptr %11, align 4, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %3, i64 8
  store i32 0, ptr %12, align 4, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %3, i64 4
  store i32 0, ptr %13, align 4, !tbaa !5
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %26

.lr.ph.1:                                         ; preds = %.lr.ph.preheader
  %14 = getelementptr inbounds i8, ptr %2, i64 8
  %15 = load i32, ptr %14, align 4, !tbaa !5
  %.not.1 = icmp eq i32 %15, 0
  br i1 %.not.1, label %.lr.ph.2, label %._crit_edge

.lr.ph.2:                                         ; preds = %.lr.ph.1
  %16 = getelementptr inbounds i8, ptr %2, i64 4
  %17 = load i32, ptr %16, align 4, !tbaa !5
  %.not.2 = icmp eq i32 %17, 0
  br i1 %.not.2, label %.lr.ph.3, label %._crit_edge

.lr.ph.3:                                         ; preds = %.lr.ph.2
  %18 = load i32, ptr %2, align 4, !tbaa !5
  %.not.3 = icmp eq i32 %18, 0
  br i1 %.not.3, label %9, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph.preheader, %.lr.ph.1, %.lr.ph.2, %.lr.ph.3, %4
  %.022.lcssa = phi i64 [ -15, %4 ], [ 17, %.lr.ph.preheader ], [ 49, %.lr.ph.1 ], [ 81, %.lr.ph.2 ], [ 113, %.lr.ph.3 ]
  %.lcssa = phi i32 [ %6, %4 ], [ %8, %.lr.ph.preheader ], [ %15, %.lr.ph.1 ], [ %17, %.lr.ph.2 ], [ %18, %.lr.ph.3 ]
  %19 = tail call zeroext i8 @softfloat_countLeadingZeros32(i32 noundef %.lcssa)
  %20 = zext i8 %19 to i64
  %21 = add nsw i64 %.022.lcssa, %20
  %.not27 = icmp eq i64 %21, 0
  br i1 %.not27, label %25, label %22

22:                                               ; preds = %._crit_edge
  %23 = trunc nsw i64 %21 to i32
  %24 = sub i32 %1, %23
  tail call void @softfloat_shiftLeftM(i8 noundef zeroext 5, ptr noundef nonnull %2, i32 noundef %23, ptr noundef nonnull %2) #3
  br label %25

25:                                               ; preds = %22, %._crit_edge
  %.0 = phi i32 [ %24, %22 ], [ %1, %._crit_edge ]
  tail call void @softfloat_roundPackMToF128M(i1 noundef zeroext %0, i32 noundef %.0, ptr noundef nonnull %2, ptr noundef %3) #3
  br label %26

26:                                               ; preds = %25, %9
  ret void
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden zeroext i8 @softfloat_countLeadingZeros32(i32 noundef) local_unnamed_addr #1

declare void @softfloat_shiftLeftM(i8 noundef zeroext, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #2

declare void @softfloat_roundPackMToF128M(i1 noundef zeroext, i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #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 = { inlinehint 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 = { "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/C++ TBAA"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,ReassociatePass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass