; LLVM IR from thepowersgang/mrustc :: src/hir/hir_ops.ll (ZNK19EncodedLiteralSlice10read_floatEm)

; 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"

%struct.EncodedLiteralSlice = type { ptr, i64, i64 }
%struct.EncodedLiteral = type { %"class.std::vector.432", %"class.std::vector.437" }
%"class.std::vector.432" = type { %"struct.std::_Vector_base.433" }
%"struct.std::_Vector_base.433" = type { %"struct.std::_Vector_base<unsigned char, std::allocator<unsigned char>>::_Vector_impl" }
%"struct.std::_Vector_base<unsigned char, std::allocator<unsigned char>>::_Vector_impl" = type { %"struct.std::_Vector_base<unsigned char, std::allocator<unsigned char>>::_Vector_impl_data" }
%"struct.std::_Vector_base<unsigned char, std::allocator<unsigned char>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::vector.437" = type { %"struct.std::_Vector_base.438" }
%"struct.std::_Vector_base.438" = type { %"struct.std::_Vector_base<Reloc, std::allocator<Reloc>>::_Vector_impl" }
%"struct.std::_Vector_base<Reloc, std::allocator<Reloc>>::_Vector_impl" = type { %"struct.std::_Vector_base<Reloc, std::allocator<Reloc>>::_Vector_impl_data" }
%"struct.std::_Vector_base<Reloc, std::allocator<Reloc>>::_Vector_impl_data" = type { ptr, ptr, ptr }

@.str.28 = external hidden unnamed_addr constant [74 x i8], align 1
@.str.37 = external hidden unnamed_addr constant [15 x i8], align 1
@__PRETTY_FUNCTION__._ZNK19EncodedLiteralSlice10read_floatEm = external hidden unnamed_addr constant [53 x i8], align 1

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

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

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #1

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 1 dereferenceable(1) ptr @_ZNKSt6vectorIhSaIhEEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #3 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef double @_ZNK19EncodedLiteralSlice10read_floatEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %1) #3 align 2 {
  %3 = alloca double, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca float, align 4
  %7 = alloca double, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i64 %1, ptr %5, align 8, !tbaa !9
  %8 = load ptr, ptr %4, align 8
  %9 = load i64, ptr %5, align 8, !tbaa !9
  %10 = icmp eq i64 %9, 0
  br i1 %10, label %11, label %14

11:                                               ; preds = %2
  %12 = getelementptr inbounds %struct.EncodedLiteralSlice, ptr %8, i32 0, i32 2
  %13 = load i64, ptr %12, align 8, !tbaa !11
  store i64 %13, ptr %5, align 8, !tbaa !9
  br label %14

14:                                               ; preds = %11, %2
  %15 = load i64, ptr %5, align 8, !tbaa !9
  %16 = getelementptr inbounds %struct.EncodedLiteralSlice, ptr %8, i32 0, i32 2
  %17 = load i64, ptr %16, align 8, !tbaa !11
  %18 = icmp ule i64 %15, %17
  br i1 %18, label %19, label %20

19:                                               ; preds = %14
  br label %22

20:                                               ; preds = %14
  call void @__assert_fail(ptr noundef @.str.37, ptr noundef @.str.28, i32 noundef 1446, ptr noundef @__PRETTY_FUNCTION__._ZNK19EncodedLiteralSlice10read_floatEm) #4
  unreachable

21:                                               ; No predecessors!
  br label %22

22:                                               ; preds = %21, %19
  %23 = load i64, ptr %5, align 8, !tbaa !9
  switch i64 %23, label %41 [
    i64 4, label %24
    i64 8, label %33
  ]

24:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  %25 = getelementptr inbounds %struct.EncodedLiteralSlice, ptr %8, i32 0, i32 0
  %26 = load ptr, ptr %25, align 8, !tbaa !13
  %27 = getelementptr inbounds %struct.EncodedLiteral, ptr %26, i32 0, i32 0
  %28 = getelementptr inbounds %struct.EncodedLiteralSlice, ptr %8, i32 0, i32 1
  %29 = load i64, ptr %28, align 8, !tbaa !14
  %30 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNKSt6vectorIhSaIhEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %27, i64 noundef %29) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %6, ptr align 1 %30, i64 4, i1 false)
  %31 = load float, ptr %6, align 4, !tbaa !15
  %32 = fpext float %31 to double
  store double %32, ptr %3, align 8
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  br label %42

33:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %34 = getelementptr inbounds %struct.EncodedLiteralSlice, ptr %8, i32 0, i32 0
  %35 = load ptr, ptr %34, align 8, !tbaa !13
  %36 = getelementptr inbounds %struct.EncodedLiteral, ptr %35, i32 0, i32 0
  %37 = getelementptr inbounds %struct.EncodedLiteralSlice, ptr %8, i32 0, i32 1
  %38 = load i64, ptr %37, align 8, !tbaa !14
  %39 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNKSt6vectorIhSaIhEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %36, i64 noundef %38) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %7, ptr align 1 %39, i64 8, i1 false)
  %40 = load double, ptr %7, align 8, !tbaa !17
  store double %40, ptr %3, align 8
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  br label %42

41:                                               ; preds = %22
  call void @abort() #4
  unreachable

42:                                               ; preds = %33, %24
  %43 = load double, ptr %3, align 8
  ret double %43
}

; Function Attrs: noreturn nounwind
declare void @abort() #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { noreturn nounwind "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 nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { mustprogress 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 = { noreturn nounwind }
attributes #5 = { 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !10, i64 16}
!12 = !{!"_ZTS19EncodedLiteralSlice", !6, i64 0, !10, i64 8, !10, i64 16}
!13 = !{!12, !6, i64 0}
!14 = !{!12, !10, i64 8}
!15 = !{!16, !16, i64 0}
!16 = !{!"float", !7, i64 0}
!17 = !{!18, !18, i64 0}
!18 = !{!"double", !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"

@.str.28 = external hidden unnamed_addr constant [74 x i8], align 1
@.str.37 = external hidden unnamed_addr constant [15 x i8], align 1
@__PRETTY_FUNCTION__._ZNK19EncodedLiteralSlice10read_floatEm = external hidden unnamed_addr constant [53 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 1 dereferenceable(1) ptr @_ZNKSt6vectorIhSaIhEEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef double @_ZNK19EncodedLiteralSlice10read_floatEm(ptr nocapture noundef nonnull readonly align 8 dereferenceable(24) %0, i64 noundef %1) local_unnamed_addr #1 align 2 {
  %3 = icmp eq i64 %1, 0
  %4 = getelementptr inbounds i8, ptr %0, i64 16
  %5 = load i64, ptr %4, align 8
  %.07 = select i1 %3, i64 %5, i64 %1
  %.not = icmp ugt i64 %.07, %5
  br i1 %.not, label %6, label %7

6:                                                ; preds = %2
  tail call void @__assert_fail(ptr noundef nonnull @.str.37, ptr noundef nonnull @.str.28, i32 noundef 1446, ptr noundef nonnull @__PRETTY_FUNCTION__._ZNK19EncodedLiteralSlice10read_floatEm) #2
  unreachable

7:                                                ; preds = %2
  switch i64 %.07, label %19 [
    i64 4, label %8
    i64 8, label %14
  ]

8:                                                ; preds = %7
  %9 = load ptr, ptr %0, align 8, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %0, i64 8
  %11 = load i64, ptr %10, align 8, !tbaa !11
  %12 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNKSt6vectorIhSaIhEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %9, i64 noundef %11) #3
  %.0.copyload2 = load float, ptr %12, align 1
  %13 = fpext float %.0.copyload2 to double
  br label %20

14:                                               ; preds = %7
  %15 = load ptr, ptr %0, align 8, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %0, i64 8
  %17 = load i64, ptr %16, align 8, !tbaa !11
  %18 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNKSt6vectorIhSaIhEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %15, i64 noundef %17) #3
  %.0.copyload = load double, ptr %18, align 1
  br label %20

19:                                               ; preds = %7
  tail call void @abort() #2
  unreachable

20:                                               ; preds = %14, %8
  %.0 = phi double [ %.0.copyload, %14 ], [ %13, %8 ]
  ret double %.0
}

; Function Attrs: noreturn nounwind
declare void @abort() local_unnamed_addr #0

attributes #0 = { noreturn nounwind "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 = { mustprogress 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 = { noreturn nounwind }
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, !7, i64 0}
!6 = !{!"_ZTS19EncodedLiteralSlice", !7, i64 0, !10, i64 8, !10, i64 16}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!6, !10, i64 8}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass