; LLVM IR from thekyria/elabtsaot2 :: powersystem/load.ll (ZNK9elabtsaot4Load4typeEv)

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

%"class.elabtsaot::Load" = type { i32, i32, double, double, %"class.std::complex", double, double, double, double }
%"class.std::complex" = type { { double, double } }

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i32 @_ZNK9elabtsaot4Load4typeEv(ptr noundef nonnull align 8 dereferenceable(72) %0) #0 align 2 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  %4 = load ptr, ptr %3, align 8
  %5 = getelementptr inbounds %"class.elabtsaot::Load", ptr %4, i32 0, i32 5
  %6 = load double, ptr %5, align 8, !tbaa !9
  %7 = fcmp oeq double %6, 0.000000e+00
  br i1 %7, label %8, label %13

8:                                                ; preds = %1
  %9 = getelementptr inbounds %"class.elabtsaot::Load", ptr %4, i32 0, i32 6
  %10 = load double, ptr %9, align 8, !tbaa !14
  %11 = fcmp oeq double %10, 0.000000e+00
  br i1 %11, label %12, label %13

12:                                               ; preds = %8
  store i32 0, ptr %2, align 4
  br label %32

13:                                               ; preds = %8, %1
  %14 = getelementptr inbounds %"class.elabtsaot::Load", ptr %4, i32 0, i32 5
  %15 = load double, ptr %14, align 8, !tbaa !9
  %16 = fcmp oeq double %15, 1.000000e+00
  br i1 %16, label %17, label %22

17:                                               ; preds = %13
  %18 = getelementptr inbounds %"class.elabtsaot::Load", ptr %4, i32 0, i32 6
  %19 = load double, ptr %18, align 8, !tbaa !14
  %20 = fcmp oeq double %19, 1.000000e+00
  br i1 %20, label %21, label %22

21:                                               ; preds = %17
  store i32 1, ptr %2, align 4
  br label %32

22:                                               ; preds = %17, %13
  %23 = getelementptr inbounds %"class.elabtsaot::Load", ptr %4, i32 0, i32 5
  %24 = load double, ptr %23, align 8, !tbaa !9
  %25 = fcmp oeq double %24, 2.000000e+00
  br i1 %25, label %26, label %31

26:                                               ; preds = %22
  %27 = getelementptr inbounds %"class.elabtsaot::Load", ptr %4, i32 0, i32 6
  %28 = load double, ptr %27, align 8, !tbaa !14
  %29 = fcmp oeq double %28, 2.000000e+00
  br i1 %29, label %30, label %31

30:                                               ; preds = %26
  store i32 2, ptr %2, align 4
  br label %32

31:                                               ; preds = %26, %22
  store i32 3, ptr %2, align 4
  br label %32

32:                                               ; preds = %31, %30, %21, %12
  %33 = load i32, ptr %2, align 4
  ret i32 %33
}

attributes #0 = { 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" }

!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, !12, i64 40}
!10 = !{!"_ZTSN9elabtsaot4LoadE", !11, i64 0, !11, i64 4, !12, i64 8, !12, i64 16, !13, i64 24, !12, i64 40, !12, i64 48, !12, i64 56, !12, i64 64}
!11 = !{!"int", !7, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = !{!"_ZTSSt7complexIdE", !7, i64 0}
!14 = !{!10, !12, i64 48}


; 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: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) uwtable
define dso_local noundef range(i32 0, 4) i32 @_ZNK9elabtsaot4Load4typeEv(ptr nocapture noundef nonnull readonly align 8 dereferenceable(72) %0) local_unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 40
  %3 = load double, ptr %2, align 8, !tbaa !5
  %4 = fcmp oeq double %3, 0.000000e+00
  %5 = getelementptr inbounds i8, ptr %0, i64 48
  %6 = load double, ptr %5, align 8
  %7 = fcmp oeq double %6, 0.000000e+00
  %or.cond = select i1 %4, i1 %7, i1 false
  br i1 %or.cond, label %14, label %8

8:                                                ; preds = %1
  %9 = fcmp oeq double %3, 1.000000e+00
  %10 = fcmp oeq double %6, 1.000000e+00
  %or.cond5 = select i1 %9, i1 %10, i1 false
  br i1 %or.cond5, label %14, label %11

11:                                               ; preds = %8
  %12 = fcmp oeq double %3, 2.000000e+00
  %13 = fcmp oeq double %6, 2.000000e+00
  %or.cond8 = select i1 %12, i1 %13, i1 false
  %spec.select = select i1 %or.cond8, i32 2, i32 3
  br label %14

14:                                               ; preds = %11, %8, %1
  %.0 = phi i32 [ 0, %1 ], [ 1, %8 ], [ %spec.select, %11 ]
  ret i32 %.0
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) 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" }

!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, !10, i64 40}
!6 = !{!"_ZTSN9elabtsaot4LoadE", !7, i64 0, !7, i64 4, !10, i64 8, !10, i64 16, !11, i64 24, !10, i64 40, !10, i64 48, !10, i64 56, !10, i64 64}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"double", !8, i64 0}
!11 = !{!"_ZTSSt7complexIdE", !8, i64 0}


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