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

; 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_shiftNormSigF128M(ptr noundef %0, i8 noundef zeroext %1, ptr noundef %2) #0 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i8, align 1
  %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 ptr %0, ptr %5, align 8, !tbaa !5
  store i8 %1, ptr %6, align 1, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !5
  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 ptr, ptr %5, align 8, !tbaa !5
  %13 = getelementptr inbounds i32, ptr %12, i64 3
  %14 = load i32, ptr %13, align 4, !tbaa !10
  store i32 %14, ptr %8, align 4, !tbaa !10
  %15 = load i32, ptr %8, align 4, !tbaa !10
  %16 = lshr i32 %15, 16
  %17 = and i32 %16, 32767
  store i32 %17, ptr %9, align 4, !tbaa !10
  %18 = load i32, ptr %9, align 4, !tbaa !10
  %19 = icmp ne i32 %18, 0
  br i1 %19, label %20, label %37

20:                                               ; preds = %3
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = load i8, ptr %6, align 1, !tbaa !9
  %23 = load ptr, ptr %7, align 8, !tbaa !5
  call void @softfloat_shortShiftLeftM(i8 noundef zeroext 4, ptr noundef %21, i8 noundef zeroext %22, ptr noundef %23)
  %24 = load i8, ptr %6, align 1, !tbaa !9
  %25 = zext i8 %24 to i32
  %26 = shl i32 65536, %25
  store i32 %26, ptr %10, align 4, !tbaa !10
  %27 = load ptr, ptr %7, align 8, !tbaa !5
  %28 = getelementptr inbounds i32, ptr %27, i64 3
  %29 = load i32, ptr %28, align 4, !tbaa !10
  %30 = load i32, ptr %10, align 4, !tbaa !10
  %31 = sub i32 %30, 1
  %32 = and i32 %29, %31
  %33 = load i32, ptr %10, align 4, !tbaa !10
  %34 = or i32 %32, %33
  %35 = load ptr, ptr %7, align 8, !tbaa !5
  %36 = getelementptr inbounds i32, ptr %35, i64 3
  store i32 %34, ptr %36, align 4, !tbaa !10
  br label %77

37:                                               ; preds = %3
  store i32 16, ptr %9, align 4, !tbaa !10
  %38 = load i32, ptr %8, align 4, !tbaa !10
  %39 = and i32 %38, 2147483647
  store i32 %39, ptr %8, align 4, !tbaa !10
  %40 = load i32, ptr %8, align 4, !tbaa !10
  %41 = icmp ne i32 %40, 0
  br i1 %41, label %64, label %42

42:                                               ; preds = %37
  store i32 -16, ptr %9, align 4, !tbaa !10
  %43 = load ptr, ptr %5, align 8, !tbaa !5
  %44 = getelementptr inbounds i32, ptr %43, i64 2
  %45 = load i32, ptr %44, align 4, !tbaa !10
  store i32 %45, ptr %8, align 4, !tbaa !10
  %46 = load i32, ptr %8, align 4, !tbaa !10
  %47 = icmp ne i32 %46, 0
  br i1 %47, label %63, label %48

48:                                               ; preds = %42
  store i32 -48, ptr %9, align 4, !tbaa !10
  %49 = load ptr, ptr %5, align 8, !tbaa !5
  %50 = getelementptr inbounds i32, ptr %49, i64 1
  %51 = load i32, ptr %50, align 4, !tbaa !10
  store i32 %51, ptr %8, align 4, !tbaa !10
  %52 = load i32, ptr %8, align 4, !tbaa !10
  %53 = icmp ne i32 %52, 0
  br i1 %53, label %62, label %54

54:                                               ; preds = %48
  %55 = load ptr, ptr %5, align 8, !tbaa !5
  %56 = getelementptr inbounds i32, ptr %55, i64 0
  %57 = load i32, ptr %56, align 4, !tbaa !10
  store i32 %57, ptr %8, align 4, !tbaa !10
  %58 = load i32, ptr %8, align 4, !tbaa !10
  %59 = icmp ne i32 %58, 0
  br i1 %59, label %61, label %60

60:                                               ; preds = %54
  store i32 -128, ptr %4, align 4
  store i32 1, ptr %11, align 4
  br label %79

61:                                               ; preds = %54
  store i32 -80, ptr %9, align 4, !tbaa !10
  br label %62

62:                                               ; preds = %61, %48
  br label %63

63:                                               ; preds = %62, %42
  br label %64

64:                                               ; preds = %63, %37
  %65 = load i32, ptr %8, align 4, !tbaa !10
  %66 = call zeroext i8 @softfloat_countLeadingZeros32(i32 noundef %65)
  %67 = zext i8 %66 to i32
  %68 = load i32, ptr %9, align 4, !tbaa !10
  %69 = sub nsw i32 %68, %67
  store i32 %69, ptr %9, align 4, !tbaa !10
  %70 = load ptr, ptr %5, align 8, !tbaa !5
  %71 = load i32, ptr %9, align 4, !tbaa !10
  %72 = sub nsw i32 1, %71
  %73 = load i8, ptr %6, align 1, !tbaa !9
  %74 = zext i8 %73 to i32
  %75 = add nsw i32 %72, %74
  %76 = load ptr, ptr %7, align 8, !tbaa !5
  call void @softfloat_shiftLeftM(i8 noundef zeroext 4, ptr noundef %70, i32 noundef %75, ptr noundef %76)
  br label %77

77:                                               ; preds = %64, %20
  %78 = load i32, ptr %9, align 4, !tbaa !10
  store i32 %78, ptr %4, align 4
  store i32 1, ptr %11, align 4
  br label %79

79:                                               ; preds = %77, %60
  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
  %80 = load i32, ptr %4, align 4
  ret i32 %80
}

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

declare void @softfloat_shortShiftLeftM(i8 noundef zeroext, ptr noundef, i8 noundef zeroext, ptr noundef) #2

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

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

; 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 = { "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 = { 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 #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 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"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 range(i32 -335, 32768) i32 @softfloat_shiftNormSigF128M(ptr noundef %0, i8 noundef zeroext %1, ptr noundef %2) local_unnamed_addr #0 {
  %4 = getelementptr inbounds i8, ptr %0, i64 12
  %5 = load i32, ptr %4, align 4, !tbaa !5
  %6 = lshr i32 %5, 16
  %7 = and i32 %6, 32767
  %.not = icmp eq i32 %7, 0
  br i1 %.not, label %16, label %8

8:                                                ; preds = %3
  tail call void @softfloat_shortShiftLeftM(i8 noundef zeroext 4, ptr noundef nonnull %0, i8 noundef zeroext %1, ptr noundef %2) #3
  %9 = zext nneg i8 %1 to i32
  %10 = shl i32 65536, %9
  %11 = getelementptr inbounds i8, ptr %2, i64 12
  %12 = load i32, ptr %11, align 4, !tbaa !5
  %13 = add i32 %10, -1
  %14 = and i32 %12, %13
  %15 = or i32 %14, %10
  store i32 %15, ptr %11, align 4, !tbaa !5
  br label %32

16:                                               ; preds = %3
  %17 = and i32 %5, 2147483647
  %.not33 = icmp eq i32 %17, 0
  br i1 %.not33, label %18, label %26

18:                                               ; preds = %16
  %19 = getelementptr inbounds i8, ptr %0, i64 8
  %20 = load i32, ptr %19, align 4, !tbaa !5
  %.not34 = icmp eq i32 %20, 0
  br i1 %.not34, label %21, label %26

21:                                               ; preds = %18
  %22 = getelementptr inbounds i8, ptr %0, i64 4
  %23 = load i32, ptr %22, align 4, !tbaa !5
  %.not35 = icmp eq i32 %23, 0
  br i1 %.not35, label %24, label %26

24:                                               ; preds = %21
  %25 = load i32, ptr %0, align 4, !tbaa !5
  %.not36 = icmp eq i32 %25, 0
  br i1 %.not36, label %32, label %26

26:                                               ; preds = %24, %18, %21, %16
  %.027 = phi i32 [ %17, %16 ], [ %20, %18 ], [ %23, %21 ], [ %25, %24 ]
  %.026 = phi i32 [ 16, %16 ], [ -16, %18 ], [ -48, %21 ], [ -80, %24 ]
  %27 = tail call zeroext i8 @softfloat_countLeadingZeros32(i32 noundef %.027)
  %28 = zext i8 %27 to i32
  %29 = sub nsw i32 %.026, %28
  %30 = zext i8 %1 to i32
  %reass.sub = add nuw nsw i32 %30, 1
  %31 = sub nsw i32 %reass.sub, %29
  tail call void @softfloat_shiftLeftM(i8 noundef zeroext 4, ptr noundef nonnull %0, i32 noundef %31, ptr noundef %2) #3
  br label %32

32:                                               ; preds = %8, %26, %24
  %.0 = phi i32 [ -128, %24 ], [ %7, %8 ], [ %29, %26 ]
  ret i32 %.0
}

declare void @softfloat_shortShiftLeftM(i8 noundef zeroext, ptr noundef, i8 noundef zeroext, ptr noundef) local_unnamed_addr #1

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

declare void @softfloat_shiftLeftM(i8 noundef zeroext, ptr noundef, i32 noundef, 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 = { 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 = { 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,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass