; LLVM IR from facebook/redex :: libredex/DexTypeEnvironment.ll (ZN8dtv_impl23find_common_super_classEPK7DexTypeS2_)

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

@.str.9 = external hidden unnamed_addr constant [80 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [7 x i8], align 1
@__PRETTY_FUNCTION__._ZN8dtv_impl23find_common_super_classEPK7DexTypeS2_ = external hidden unnamed_addr constant [83 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: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK8DexClass15get_super_classEv(ptr noundef nonnull align 8 dereferenceable(176)) #1 align 2

declare noundef ptr @_Z10type_classPK7DexType(ptr noundef) #2

; Function Attrs: noreturn
declare void @_Z11assert_failPKcS0_jS0_10RedexErrorS0_z(ptr noundef, ptr noundef, i32 noundef, ptr noundef, i32 noundef, ptr noundef, ...) #3

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN8dtv_impl23find_common_super_classEPK7DexTypeS2_(ptr noundef %0, ptr noundef %1) #4 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = icmp ne ptr %9, null
  br i1 %10, label %11, label %15

11:                                               ; preds = %2
  %12 = load ptr, ptr %5, align 8, !tbaa !5
  %13 = icmp ne ptr %12, null
  br i1 %13, label %14, label %15

14:                                               ; preds = %11
  br label %17

15:                                               ; preds = %11, %2
  call void (ptr, ptr, i32, ptr, i32, ptr, ...) @_Z11assert_failPKcS0_jS0_10RedexErrorS0_z(ptr noundef @.str.11, ptr noundef @.str.9, i32 noundef 59, ptr noundef @__PRETTY_FUNCTION__._ZN8dtv_impl23find_common_super_classEPK7DexTypeS2_, i32 noundef 2, ptr noundef @.str.10) #5
  unreachable

16:                                               ; No predecessors!
  br label %17

17:                                               ; preds = %16, %14
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = load ptr, ptr %5, align 8, !tbaa !5
  %20 = icmp eq ptr %18, %19
  br i1 %20, label %21, label %23

21:                                               ; preds = %17
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %22, ptr %3, align 8
  br label %48

23:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %24, ptr %6, align 8, !tbaa !5
  br label %25

25:                                               ; preds = %45, %23
  %26 = load ptr, ptr %6, align 8, !tbaa !5
  %27 = icmp ne ptr %26, null
  br i1 %27, label %28, label %46

28:                                               ; preds = %25
  %29 = load ptr, ptr %6, align 8, !tbaa !5
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = call noundef zeroext i1 @_ZN4type11is_subclassEPK7DexTypeS2_(ptr noundef %29, ptr noundef %30)
  br i1 %31, label %32, label %34

32:                                               ; preds = %28
  %33 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %33, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %47

34:                                               ; preds = %28
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  %35 = load ptr, ptr %6, align 8, !tbaa !5
  %36 = call noundef ptr @_Z10type_classPK7DexType(ptr noundef %35)
  store ptr %36, ptr %8, align 8, !tbaa !5
  %37 = load ptr, ptr %8, align 8, !tbaa !5
  %38 = icmp ne ptr %37, null
  br i1 %38, label %40, label %39

39:                                               ; preds = %34
  store i32 3, ptr %7, align 4
  br label %43

40:                                               ; preds = %34
  %41 = load ptr, ptr %8, align 8, !tbaa !5
  %42 = call noundef ptr @_ZNK8DexClass15get_super_classEv(ptr noundef nonnull align 8 dereferenceable(176) %41)
  store ptr %42, ptr %6, align 8, !tbaa !5
  store i32 0, ptr %7, align 4
  br label %43

43:                                               ; preds = %40, %39
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  %44 = load i32, ptr %7, align 4
  switch i32 %44, label %50 [
    i32 0, label %45
    i32 3, label %46
  ]

45:                                               ; preds = %43
  br label %25, !llvm.loop !9

46:                                               ; preds = %43, %25
  store ptr null, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %47

47:                                               ; preds = %46, %32
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  br label %48

48:                                               ; preds = %47, %21
  %49 = load ptr, ptr %3, align 8
  ret ptr %49

50:                                               ; preds = %43
  unreachable
}

declare noundef zeroext i1 @_ZN4type11is_subclassEPK7DexTypeS2_(ptr noundef, ptr noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { "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 "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 = { 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 #5 = { noreturn }
attributes #6 = { 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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; 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.9 = external hidden unnamed_addr constant [80 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [7 x i8], align 1
@__PRETTY_FUNCTION__._ZN8dtv_impl23find_common_super_classEPK7DexTypeS2_ = external hidden unnamed_addr constant [83 x i8], align 1

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

declare noundef ptr @_Z10type_classPK7DexType(ptr noundef) local_unnamed_addr #1

; Function Attrs: noreturn
declare void @_Z11assert_failPKcS0_jS0_10RedexErrorS0_z(ptr noundef, ptr noundef, i32 noundef, ptr noundef, i32 noundef, ptr noundef, ...) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN8dtv_impl23find_common_super_classEPK7DexTypeS2_(ptr noundef %0, ptr noundef %1) local_unnamed_addr #3 {
  %3 = icmp ne ptr %0, null
  %4 = icmp ne ptr %1, null
  %or.cond = and i1 %3, %4
  br i1 %or.cond, label %6, label %5

5:                                                ; preds = %2
  tail call void (ptr, ptr, i32, ptr, i32, ptr, ...) @_Z11assert_failPKcS0_jS0_10RedexErrorS0_z(ptr noundef nonnull @.str.11, ptr noundef nonnull @.str.9, i32 noundef 59, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN8dtv_impl23find_common_super_classEPK7DexTypeS2_, i32 noundef 2, ptr noundef nonnull @.str.10) #4
  unreachable

6:                                                ; preds = %2
  %7 = icmp eq ptr %0, %1
  br i1 %7, label %.thread, label %.preheader

.preheader:                                       ; preds = %6, %11
  %.01625 = phi ptr [ %12, %11 ], [ %0, %6 ]
  %8 = tail call noundef zeroext i1 @_ZN4type11is_subclassEPK7DexTypeS2_(ptr noundef nonnull %.01625, ptr noundef nonnull %1)
  br i1 %8, label %.thread, label %9

9:                                                ; preds = %.preheader
  %10 = tail call noundef ptr @_Z10type_classPK7DexType(ptr noundef nonnull %.01625)
  %.not21 = icmp eq ptr %10, null
  br i1 %.not21, label %.thread, label %11

11:                                               ; preds = %9
  %12 = tail call noundef ptr @_ZNK8DexClass15get_super_classEv(ptr noundef nonnull align 8 dereferenceable(176) %10)
  %.not = icmp eq ptr %12, null
  br i1 %.not, label %.thread, label %.preheader

.thread:                                          ; preds = %9, %.preheader, %11, %6
  %.1 = phi ptr [ %0, %6 ], [ null, %9 ], [ null, %11 ], [ %.01625, %.preheader ]
  ret ptr %.1
}

declare noundef zeroext i1 @_ZN4type11is_subclassEPK7DexTypeS2_(ptr 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 = { "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 "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 = { 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 #4 = { noreturn }

!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)"}


; Effective O3 passes: GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass