; LLVM IR from thepowersgang/mrustc :: src/hir_conv/constant_evaluation.ll (ZNK3MIR4eval8RelocPtr12as_value_ptrEv)

; 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.MIR::eval::RelocPtr" = type { i64 }

@.str.7 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [91 x i8], align 1
@__PRETTY_FUNCTION__._ZNK3MIR4eval8RelocPtr12as_value_ptrEv = external hidden unnamed_addr constant [50 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [20 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK3MIR4eval8RelocPtr13as_allocationEv(ptr noundef nonnull align 8 dereferenceable(8)) #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK3MIR4eval8RelocPtr11as_constantEv(ptr noundef nonnull align 8 dereferenceable(8)) #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK3MIR4eval8RelocPtr12as_staticrefEv(ptr noundef nonnull align 8 dereferenceable(8)) #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZNK3MIR4eval8RelocPtr12as_value_ptrEv(ptr noundef nonnull align 8 dereferenceable(8) %0) #1 align 2 {
  %2 = alloca ptr, align 8
  %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.MIR::eval::RelocPtr", ptr %4, i32 0, i32 0
  %6 = load i64, ptr %5, align 8, !tbaa !9
  %7 = icmp ne i64 %6, 0
  br i1 %7, label %8, label %9

8:                                                ; preds = %1
  br label %11

9:                                                ; preds = %1
  call void @__assert_fail(ptr noundef @.str.7, ptr noundef @.str.8, i32 noundef 821, ptr noundef @__PRETTY_FUNCTION__._ZNK3MIR4eval8RelocPtr12as_value_ptrEv) #3
  unreachable

10:                                               ; No predecessors!
  br label %11

11:                                               ; preds = %10, %8
  %12 = getelementptr inbounds %"class.MIR::eval::RelocPtr", ptr %4, i32 0, i32 0
  %13 = load i64, ptr %12, align 8, !tbaa !9
  %14 = and i64 %13, 3
  switch i64 %14, label %40 [
    i64 0, label %15
    i64 1, label %23
    i64 2, label %31
    i64 3, label %39
  ]

15:                                               ; preds = %11
  %16 = call noundef ptr @_ZNK3MIR4eval8RelocPtr13as_allocationEv(ptr noundef nonnull align 8 dereferenceable(8) %4)
  %17 = icmp ne ptr %16, null
  br i1 %17, label %18, label %19

18:                                               ; preds = %15
  br label %21

19:                                               ; preds = %15
  call void @__assert_fail(ptr noundef @.str.9, ptr noundef @.str.8, i32 noundef 824, ptr noundef @__PRETTY_FUNCTION__._ZNK3MIR4eval8RelocPtr12as_value_ptrEv) #3
  unreachable

20:                                               ; No predecessors!
  br label %21

21:                                               ; preds = %20, %18
  %22 = call noundef ptr @_ZNK3MIR4eval8RelocPtr13as_allocationEv(ptr noundef nonnull align 8 dereferenceable(8) %4)
  store ptr %22, ptr %2, align 8
  br label %41

23:                                               ; preds = %11
  %24 = call noundef ptr @_ZNK3MIR4eval8RelocPtr11as_constantEv(ptr noundef nonnull align 8 dereferenceable(8) %4)
  %25 = icmp ne ptr %24, null
  br i1 %25, label %26, label %27

26:                                               ; preds = %23
  br label %29

27:                                               ; preds = %23
  call void @__assert_fail(ptr noundef @.str.10, ptr noundef @.str.8, i32 noundef 825, ptr noundef @__PRETTY_FUNCTION__._ZNK3MIR4eval8RelocPtr12as_value_ptrEv) #3
  unreachable

28:                                               ; No predecessors!
  br label %29

29:                                               ; preds = %28, %26
  %30 = call noundef ptr @_ZNK3MIR4eval8RelocPtr11as_constantEv(ptr noundef nonnull align 8 dereferenceable(8) %4)
  store ptr %30, ptr %2, align 8
  br label %41

31:                                               ; preds = %11
  %32 = call noundef ptr @_ZNK3MIR4eval8RelocPtr12as_staticrefEv(ptr noundef nonnull align 8 dereferenceable(8) %4)
  %33 = icmp ne ptr %32, null
  br i1 %33, label %34, label %35

34:                                               ; preds = %31
  br label %37

35:                                               ; preds = %31
  call void @__assert_fail(ptr noundef @.str.11, ptr noundef @.str.8, i32 noundef 826, ptr noundef @__PRETTY_FUNCTION__._ZNK3MIR4eval8RelocPtr12as_value_ptrEv) #3
  unreachable

36:                                               ; No predecessors!
  br label %37

37:                                               ; preds = %36, %34
  %38 = call noundef ptr @_ZNK3MIR4eval8RelocPtr12as_staticrefEv(ptr noundef nonnull align 8 dereferenceable(8) %4)
  store ptr %38, ptr %2, align 8
  br label %41

39:                                               ; preds = %11
  call void @__assert_fail(ptr noundef @.str.12, ptr noundef @.str.8, i32 noundef 827, ptr noundef @__PRETTY_FUNCTION__._ZNK3MIR4eval8RelocPtr12as_value_ptrEv) #3
  unreachable

40:                                               ; preds = %11
  call void @abort() #3
  unreachable

41:                                               ; preds = %37, %29, %21
  %42 = load ptr, ptr %2, align 8
  ret ptr %42
}

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

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

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" }
attributes #1 = { mustprogress 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 "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 = { noreturn 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, !11, i64 0}
!10 = !{!"_ZTSN3MIR4eval8RelocPtrE", !11, i64 0}
!11 = !{!"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"

@.str.7 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [91 x i8], align 1
@__PRETTY_FUNCTION__._ZNK3MIR4eval8RelocPtr12as_value_ptrEv = external hidden unnamed_addr constant [50 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [20 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK3MIR4eval8RelocPtr13as_allocationEv(ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK3MIR4eval8RelocPtr11as_constantEv(ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK3MIR4eval8RelocPtr12as_staticrefEv(ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef ptr @_ZNK3MIR4eval8RelocPtr12as_value_ptrEv(ptr noundef nonnull align 8 dereferenceable(8) %0) local_unnamed_addr #0 align 2 {
  %2 = load i64, ptr %0, align 8, !tbaa !5
  %.not = icmp eq i64 %2, 0
  br i1 %.not, label %3, label %4

3:                                                ; preds = %1
  tail call void @__assert_fail(ptr noundef nonnull @.str.7, ptr noundef nonnull @.str.8, i32 noundef 821, ptr noundef nonnull @__PRETTY_FUNCTION__._ZNK3MIR4eval8RelocPtr12as_value_ptrEv) #2
  unreachable

4:                                                ; preds = %1
  %5 = and i64 %2, 3
  switch i64 %5, label %default.unreachable6 [
    i64 0, label %6
    i64 1, label %11
    i64 2, label %16
    i64 3, label %21
  ]

6:                                                ; preds = %4
  %7 = tail call noundef ptr @_ZNK3MIR4eval8RelocPtr13as_allocationEv(ptr noundef nonnull align 8 dereferenceable(8) %0)
  %.not5 = icmp eq ptr %7, null
  br i1 %.not5, label %8, label %9

8:                                                ; preds = %6
  tail call void @__assert_fail(ptr noundef nonnull @.str.9, ptr noundef nonnull @.str.8, i32 noundef 824, ptr noundef nonnull @__PRETTY_FUNCTION__._ZNK3MIR4eval8RelocPtr12as_value_ptrEv) #2
  unreachable

9:                                                ; preds = %6
  %10 = tail call noundef ptr @_ZNK3MIR4eval8RelocPtr13as_allocationEv(ptr noundef nonnull align 8 dereferenceable(8) %0)
  br label %22

11:                                               ; preds = %4
  %12 = tail call noundef ptr @_ZNK3MIR4eval8RelocPtr11as_constantEv(ptr noundef nonnull align 8 dereferenceable(8) %0)
  %.not4 = icmp eq ptr %12, null
  br i1 %.not4, label %13, label %14

13:                                               ; preds = %11
  tail call void @__assert_fail(ptr noundef nonnull @.str.10, ptr noundef nonnull @.str.8, i32 noundef 825, ptr noundef nonnull @__PRETTY_FUNCTION__._ZNK3MIR4eval8RelocPtr12as_value_ptrEv) #2
  unreachable

14:                                               ; preds = %11
  %15 = tail call noundef ptr @_ZNK3MIR4eval8RelocPtr11as_constantEv(ptr noundef nonnull align 8 dereferenceable(8) %0)
  br label %22

16:                                               ; preds = %4
  %17 = tail call noundef ptr @_ZNK3MIR4eval8RelocPtr12as_staticrefEv(ptr noundef nonnull align 8 dereferenceable(8) %0)
  %.not3 = icmp eq ptr %17, null
  br i1 %.not3, label %18, label %19

18:                                               ; preds = %16
  tail call void @__assert_fail(ptr noundef nonnull @.str.11, ptr noundef nonnull @.str.8, i32 noundef 826, ptr noundef nonnull @__PRETTY_FUNCTION__._ZNK3MIR4eval8RelocPtr12as_value_ptrEv) #2
  unreachable

19:                                               ; preds = %16
  %20 = tail call noundef ptr @_ZNK3MIR4eval8RelocPtr12as_staticrefEv(ptr noundef nonnull align 8 dereferenceable(8) %0)
  br label %22

21:                                               ; preds = %4
  tail call void @__assert_fail(ptr noundef nonnull @.str.12, ptr noundef nonnull @.str.8, i32 noundef 827, ptr noundef nonnull @__PRETTY_FUNCTION__._ZNK3MIR4eval8RelocPtr12as_value_ptrEv) #2
  unreachable

default.unreachable6:                             ; preds = %4
  unreachable

22:                                               ; preds = %19, %14, %9
  %.0 = phi ptr [ %20, %19 ], [ %15, %14 ], [ %10, %9 ]
  ret ptr %.0
}

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

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" }
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 = { noreturn 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 = !{!"_ZTSN3MIR4eval8RelocPtrE", !7, i64 0}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}


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