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

; 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 @i32_to_f128M(i32 noundef %0, ptr noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i8, align 1
  %9 = alloca i32, align 4
  %10 = alloca i8, align 1
  %11 = alloca i64, align 8
  store i32 %0, ptr %3, align 4, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 1, ptr %8) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 1, ptr %10) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %12 = load ptr, ptr %4, align 8, !tbaa !9
  store ptr %12, ptr %5, align 8, !tbaa !9
  store i32 0, ptr %6, align 4, !tbaa !5
  store i32 0, ptr %7, align 4, !tbaa !5
  %13 = load i32, ptr %3, align 4, !tbaa !5
  %14 = icmp ne i32 %13, 0
  br i1 %14, label %15, label %55

15:                                               ; preds = %2
  %16 = load i32, ptr %3, align 4, !tbaa !5
  %17 = icmp slt i32 %16, 0
  %18 = zext i1 %17 to i8
  store i8 %18, ptr %8, align 1, !tbaa !11
  %19 = load i8, ptr %8, align 1, !tbaa !11, !range !13, !noundef !14
  %20 = trunc i8 %19 to i1
  br i1 %20, label %21, label %24

21:                                               ; preds = %15
  %22 = load i32, ptr %3, align 4, !tbaa !5
  %23 = sub i32 0, %22
  br label %26

24:                                               ; preds = %15
  %25 = load i32, ptr %3, align 4, !tbaa !5
  br label %26

26:                                               ; preds = %24, %21
  %27 = phi i32 [ %23, %21 ], [ %25, %24 ]
  store i32 %27, ptr %9, align 4, !tbaa !5
  %28 = load i32, ptr %9, align 4, !tbaa !5
  %29 = call zeroext i8 @softfloat_countLeadingZeros32(i32 noundef %28)
  %30 = zext i8 %29 to i32
  %31 = add nsw i32 %30, 17
  %32 = trunc i32 %31 to i8
  store i8 %32, ptr %10, align 1, !tbaa !15
  %33 = load i32, ptr %9, align 4, !tbaa !5
  %34 = zext i32 %33 to i64
  %35 = load i8, ptr %10, align 1, !tbaa !15
  %36 = sext i8 %35 to i32
  %37 = zext i32 %36 to i64
  %38 = shl i64 %34, %37
  store i64 %38, ptr %11, align 8, !tbaa !16
  %39 = load i8, ptr %8, align 1, !tbaa !11, !range !13, !noundef !14
  %40 = trunc i8 %39 to i1
  %41 = zext i1 %40 to i32
  %42 = shl i32 %41, 31
  %43 = load i8, ptr %10, align 1, !tbaa !15
  %44 = sext i8 %43 to i32
  %45 = sub nsw i32 16430, %44
  %46 = shl i32 %45, 16
  %47 = add i32 %42, %46
  %48 = zext i32 %47 to i64
  %49 = load i64, ptr %11, align 8, !tbaa !16
  %50 = lshr i64 %49, 32
  %51 = add i64 %48, %50
  %52 = trunc i64 %51 to i32
  store i32 %52, ptr %6, align 4, !tbaa !5
  %53 = load i64, ptr %11, align 8, !tbaa !16
  %54 = trunc i64 %53 to i32
  store i32 %54, ptr %7, align 4, !tbaa !5
  br label %55

55:                                               ; preds = %26, %2
  %56 = load i32, ptr %6, align 4, !tbaa !5
  %57 = load ptr, ptr %5, align 8, !tbaa !9
  %58 = getelementptr inbounds i32, ptr %57, i64 3
  store i32 %56, ptr %58, align 4, !tbaa !5
  %59 = load i32, ptr %7, align 4, !tbaa !5
  %60 = load ptr, ptr %5, align 8, !tbaa !9
  %61 = getelementptr inbounds i32, ptr %60, i64 2
  store i32 %59, ptr %61, align 4, !tbaa !5
  %62 = load ptr, ptr %5, align 8, !tbaa !9
  %63 = getelementptr inbounds i32, ptr %62, i64 1
  store i32 0, ptr %63, align 4, !tbaa !5
  %64 = load ptr, ptr %5, align 8, !tbaa !9
  %65 = getelementptr inbounds i32, ptr %64, i64 0
  store i32 0, ptr %65, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  ret void
}

; 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

; 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 = { 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"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"_Bool", !7, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = !{!7, !7, i64 0}
!16 = !{!17, !17, i64 0}
!17 = !{!"long", !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 void @i32_to_f128M(i32 noundef %0, ptr nocapture noundef writeonly %1) local_unnamed_addr #0 {
  %.not = icmp eq i32 %0, 0
  br i1 %.not, label %17, label %3

3:                                                ; preds = %2
  %4 = tail call i32 @llvm.abs.i32(i32 %0, i1 false)
  %5 = tail call zeroext i8 @softfloat_countLeadingZeros32(i32 noundef %4)
  %6 = add i8 %5, 17
  %7 = zext i32 %4 to i64
  %8 = sext i8 %6 to i32
  %9 = zext nneg i32 %8 to i64
  %10 = shl i64 %7, %9
  %.lobit = and i32 %0, -2147483648
  %11 = lshr i64 %10, 32
  %12 = trunc nuw i64 %11 to i32
  %reass.sub = or disjoint i32 %.lobit, 1076756480
  %13 = shl nsw i32 %8, 16
  %14 = sub i32 %reass.sub, %13
  %15 = add i32 %14, %12
  %16 = trunc i64 %10 to i32
  br label %17

17:                                               ; preds = %3, %2
  %.018 = phi i32 [ %16, %3 ], [ 0, %2 ]
  %.0 = phi i32 [ %15, %3 ], [ 0, %2 ]
  %18 = getelementptr inbounds i8, ptr %1, i64 12
  store i32 %.0, ptr %18, align 4, !tbaa !5
  %19 = getelementptr inbounds i8, ptr %1, i64 8
  store i32 %.018, ptr %19, align 4, !tbaa !5
  %20 = getelementptr inbounds i8, ptr %1, i64 4
  store i32 0, ptr %20, align 4, !tbaa !5
  store i32 0, ptr %1, align 4, !tbaa !5
  ret void
}

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.abs.i32(i32, i1 immarg) #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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass