; LLVM IR from gem5/gem5 :: ext/softfloat (ui64_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 @ui64_to_f128M(i64 noundef %0, ptr noundef %1) #0 {
  %3 = alloca i64, align 8
  %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 ptr, align 8
  %10 = alloca i32, align 4
  store i64 %0, ptr %3, align 8, !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 8, ptr %9) #3
  %11 = load ptr, ptr %4, align 8, !tbaa !9
  store ptr %11, ptr %5, align 8, !tbaa !9
  store i32 0, ptr %6, align 4, !tbaa !11
  store i32 0, ptr %7, align 4, !tbaa !11
  %12 = load ptr, ptr %5, align 8, !tbaa !9
  %13 = getelementptr inbounds i32, ptr %12, i64 1
  store i32 0, ptr %13, align 4, !tbaa !11
  %14 = load ptr, ptr %5, align 8, !tbaa !9
  %15 = getelementptr inbounds i32, ptr %14, i64 0
  store i32 0, ptr %15, align 4, !tbaa !11
  %16 = load i64, ptr %3, align 8, !tbaa !5
  %17 = icmp ne i64 %16, 0
  br i1 %17, label %18, label %74

18:                                               ; preds = %2
  %19 = load i64, ptr %3, align 8, !tbaa !5
  %20 = call zeroext i8 @softfloat_countLeadingZeros64(i64 noundef %19)
  %21 = zext i8 %20 to i32
  %22 = add nsw i32 %21, 17
  %23 = trunc i32 %22 to i8
  store i8 %23, ptr %8, align 1, !tbaa !13
  %24 = load i8, ptr %8, align 1, !tbaa !13
  %25 = zext i8 %24 to i32
  %26 = icmp slt i32 %25, 32
  br i1 %26, label %27, label %55

27:                                               ; preds = %18
  %28 = load ptr, ptr %5, align 8, !tbaa !9
  %29 = getelementptr inbounds i32, ptr %28, i64 1
  store ptr %29, ptr %9, align 8, !tbaa !9
  %30 = load ptr, ptr %9, align 8, !tbaa !9
  %31 = getelementptr inbounds i32, ptr %30, i64 2
  store i32 0, ptr %31, align 4, !tbaa !11
  %32 = load i64, ptr %3, align 8, !tbaa !5
  %33 = lshr i64 %32, 32
  %34 = trunc i64 %33 to i32
  %35 = load ptr, ptr %9, align 8, !tbaa !9
  %36 = getelementptr inbounds i32, ptr %35, i64 1
  store i32 %34, ptr %36, align 4, !tbaa !11
  %37 = load i64, ptr %3, align 8, !tbaa !5
  %38 = trunc i64 %37 to i32
  %39 = load ptr, ptr %9, align 8, !tbaa !9
  %40 = getelementptr inbounds i32, ptr %39, i64 0
  store i32 %38, ptr %40, align 4, !tbaa !11
  %41 = load ptr, ptr %9, align 8, !tbaa !9
  %42 = load i8, ptr %8, align 1, !tbaa !13
  %43 = load ptr, ptr %9, align 8, !tbaa !9
  call void @softfloat_shortShiftLeftM(i8 noundef zeroext 3, ptr noundef %41, i8 noundef zeroext %42, ptr noundef %43)
  %44 = load i8, ptr %8, align 1, !tbaa !13
  %45 = zext i8 %44 to i32
  %46 = sub nsw i32 16462, %45
  %47 = shl i32 %46, 16
  %48 = add i32 0, %47
  %49 = load ptr, ptr %9, align 8, !tbaa !9
  %50 = getelementptr inbounds i32, ptr %49, i64 2
  %51 = load i32, ptr %50, align 4, !tbaa !11
  %52 = add i32 %48, %51
  %53 = load ptr, ptr %9, align 8, !tbaa !9
  %54 = getelementptr inbounds i32, ptr %53, i64 2
  store i32 %52, ptr %54, align 4, !tbaa !11
  store i32 1, ptr %10, align 4
  br label %81

55:                                               ; preds = %18
  %56 = load i8, ptr %8, align 1, !tbaa !13
  %57 = zext i8 %56 to i32
  %58 = sub nsw i32 %57, 32
  %59 = load i64, ptr %3, align 8, !tbaa !5
  %60 = zext i32 %58 to i64
  %61 = shl i64 %59, %60
  store i64 %61, ptr %3, align 8, !tbaa !5
  %62 = load i8, ptr %8, align 1, !tbaa !13
  %63 = zext i8 %62 to i32
  %64 = sub nsw i32 16462, %63
  %65 = shl i32 %64, 16
  %66 = add i32 0, %65
  %67 = zext i32 %66 to i64
  %68 = load i64, ptr %3, align 8, !tbaa !5
  %69 = lshr i64 %68, 32
  %70 = add i64 %67, %69
  %71 = trunc i64 %70 to i32
  store i32 %71, ptr %6, align 4, !tbaa !11
  %72 = load i64, ptr %3, align 8, !tbaa !5
  %73 = trunc i64 %72 to i32
  store i32 %73, ptr %7, align 4, !tbaa !11
  br label %74

74:                                               ; preds = %55, %2
  %75 = load i32, ptr %6, align 4, !tbaa !11
  %76 = load ptr, ptr %5, align 8, !tbaa !9
  %77 = getelementptr inbounds i32, ptr %76, i64 3
  store i32 %75, ptr %77, align 4, !tbaa !11
  %78 = load i32, ptr %7, align 4, !tbaa !11
  %79 = load ptr, ptr %5, align 8, !tbaa !9
  %80 = getelementptr inbounds i32, ptr %79, i64 2
  store i32 %78, ptr %80, align 4, !tbaa !11
  store i32 0, ptr %10, align 4
  br label %81

81:                                               ; preds = %74, %27
  call void @llvm.lifetime.end.p0(i64 8, 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
  %82 = load i32, ptr %10, align 4
  switch i32 %82, label %84 [
    i32 0, label %83
    i32 1, label %83
  ]

83:                                               ; preds = %81, %81
  ret void

84:                                               ; preds = %81
  unreachable
}

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

declare zeroext i8 @softfloat_countLeadingZeros64(i64 noundef) #2

declare void @softfloat_shortShiftLeftM(i8 noundef zeroext, ptr noundef, i8 noundef zeroext, 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 = { 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 = !{!"long", !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 = !{!"int", !7, i64 0}
!13 = !{!7, !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 @ui64_to_f128M(i64 noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %1, i64 4
  store i32 0, ptr %3, align 4, !tbaa !5
  store i32 0, ptr %1, align 4, !tbaa !5
  %.not = icmp eq i64 %0, 0
  br i1 %.not, label %27, label %4

4:                                                ; preds = %2
  %5 = tail call zeroext i8 @softfloat_countLeadingZeros64(i64 noundef %0) #2
  %6 = add i8 %5, 17
  %7 = zext i8 %6 to i32
  %8 = icmp ult i8 %6, 32
  br i1 %8, label %9, label %18

9:                                                ; preds = %4
  %10 = getelementptr inbounds i8, ptr %1, i64 12
  store i32 0, ptr %10, align 4, !tbaa !5
  %11 = lshr i64 %0, 32
  %12 = trunc nuw i64 %11 to i32
  %13 = getelementptr inbounds i8, ptr %1, i64 8
  store i32 %12, ptr %13, align 4, !tbaa !5
  %14 = trunc i64 %0 to i32
  store i32 %14, ptr %3, align 4, !tbaa !5
  tail call void @softfloat_shortShiftLeftM(i8 noundef zeroext 3, ptr noundef nonnull %3, i8 noundef zeroext %6, ptr noundef nonnull %3) #2
  %15 = load i32, ptr %10, align 4, !tbaa !5
  %16 = shl nuw nsw i32 %7, 16
  %reass.sub = sub i32 %15, %16
  %17 = add i32 %reass.sub, 1078853632
  store i32 %17, ptr %10, align 4, !tbaa !5
  br label %30

18:                                               ; preds = %4
  %19 = add nsw i32 %7, -32
  %20 = zext nneg i32 %19 to i64
  %21 = shl i64 %0, %20
  %22 = lshr i64 %21, 32
  %23 = trunc nuw i64 %22 to i32
  %24 = shl nuw nsw i32 %7, 16
  %reass.sub32 = sub i32 %23, %24
  %25 = add i32 %reass.sub32, 1078853632
  %26 = trunc i64 %21 to i32
  br label %27

27:                                               ; preds = %18, %2
  %.026 = phi i32 [ %26, %18 ], [ 0, %2 ]
  %.0 = phi i32 [ %25, %18 ], [ 0, %2 ]
  %28 = getelementptr inbounds i8, ptr %1, i64 12
  store i32 %.0, ptr %28, align 4, !tbaa !5
  %29 = getelementptr inbounds i8, ptr %1, i64 8
  store i32 %.026, ptr %29, align 4, !tbaa !5
  br label %30

30:                                               ; preds = %27, %9
  ret void
}

declare zeroext i8 @softfloat_countLeadingZeros64(i64 noundef) local_unnamed_addr #1

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