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

; 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 i32 @softfloat_normSubnormalF128SigM(ptr noundef %0) #0 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %9 = getelementptr inbounds i32, ptr %8, i64 3
  store ptr %9, ptr %4, align 8, !tbaa !5
  store i64 0, ptr %5, align 8, !tbaa !9
  br label %10

10:                                               ; preds = %22, %1
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = load i32, ptr %11, align 4, !tbaa !11
  store i32 %12, ptr %6, align 4, !tbaa !11
  %13 = load i32, ptr %6, align 4, !tbaa !11
  %14 = icmp ne i32 %13, 0
  br i1 %14, label %15, label %16

15:                                               ; preds = %10
  br label %25

16:                                               ; preds = %10
  %17 = load i64, ptr %5, align 8, !tbaa !9
  %18 = add nsw i64 %17, 32
  store i64 %18, ptr %5, align 8, !tbaa !9
  %19 = load i64, ptr %5, align 8, !tbaa !9
  %20 = icmp sle i64 128, %19
  br i1 %20, label %21, label %22

21:                                               ; preds = %16
  store i32 1, ptr %2, align 4
  store i32 1, ptr %7, align 4
  br label %44

22:                                               ; preds = %16
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = getelementptr inbounds i32, ptr %23, i64 -1
  store ptr %24, ptr %4, align 8, !tbaa !5
  br label %10

25:                                               ; preds = %15
  %26 = load i32, ptr %6, align 4, !tbaa !11
  %27 = call zeroext i8 @softfloat_countLeadingZeros32(i32 noundef %26)
  %28 = zext i8 %27 to i32
  %29 = sub nsw i32 %28, 15
  %30 = sext i32 %29 to i64
  %31 = load i64, ptr %5, align 8, !tbaa !9
  %32 = add nsw i64 %31, %30
  store i64 %32, ptr %5, align 8, !tbaa !9
  %33 = load i64, ptr %5, align 8, !tbaa !9
  %34 = icmp ne i64 %33, 0
  br i1 %34, label %35, label %40

35:                                               ; preds = %25
  %36 = load ptr, ptr %3, align 8, !tbaa !5
  %37 = load i64, ptr %5, align 8, !tbaa !9
  %38 = trunc i64 %37 to i32
  %39 = load ptr, ptr %3, align 8, !tbaa !5
  call void @softfloat_shiftLeftM(i8 noundef zeroext 4, ptr noundef %36, i32 noundef %38, ptr noundef %39)
  br label %40

40:                                               ; preds = %35, %25
  %41 = load i64, ptr %5, align 8, !tbaa !9
  %42 = sub nsw i64 1, %41
  %43 = trunc i64 %42 to i32
  store i32 %43, ptr %2, align 4
  store i32 1, ptr %7, align 4
  br label %44

44:                                               ; preds = %40, %21
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  %45 = load i32, ptr %2, align 4
  ret i32 %45
}

; 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

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


; 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 i32 @softfloat_normSubnormalF128SigM(ptr noundef %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 12
  %3 = load i32, ptr %2, align 4, !tbaa !5
  %.not21 = icmp eq i32 %3, 0
  br i1 %.not21, label %.lr.ph.preheader, label %._crit_edge

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

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

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

._crit_edge:                                      ; preds = %.lr.ph.preheader, %.lr.ph.1, %.lr.ph.2, %1
  %.013.lcssa = phi i64 [ -15, %1 ], [ 17, %.lr.ph.preheader ], [ 49, %.lr.ph.1 ], [ 81, %.lr.ph.2 ]
  %.lcssa = phi i32 [ %3, %1 ], [ %5, %.lr.ph.preheader ], [ %7, %.lr.ph.1 ], [ %8, %.lr.ph.2 ]
  %9 = tail call zeroext i8 @softfloat_countLeadingZeros32(i32 noundef %.lcssa)
  %10 = zext i8 %9 to i64
  %11 = add nsw i64 %.013.lcssa, %10
  %.not18 = icmp eq i64 %11, 0
  br i1 %.not18, label %.loopexit, label %12

12:                                               ; preds = %._crit_edge
  %13 = trunc nsw i64 %11 to i32
  tail call void @softfloat_shiftLeftM(i8 noundef zeroext 4, ptr noundef nonnull %0, i32 noundef %13, ptr noundef nonnull %0) #3
  %14 = sub nsw i32 1, %13
  br label %.loopexit

.loopexit:                                        ; preds = %.lr.ph.2, %12, %._crit_edge
  %.0 = phi i32 [ %14, %12 ], [ 1, %._crit_edge ], [ 1, %.lr.ph.2 ]
  ret i32 %.0
}

; 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

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,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,ReassociatePass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass