; LLVM IR from facebook/redex :: libredex/TypeUtil.ll (ZN4type19evaluate_type_checkEPK7DexTypeS2_)

; 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.boost::optional" = type { %"class.boost::optional_detail::tc_optional_base" }
%"class.boost::optional_detail::tc_optional_base" = type { i8, i32 }
%"struct.boost::none_t" = type { i8 }

; 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 uwtable
declare dso_local noundef ptr @_ZN4type16java_lang_ObjectEv() #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN4type10check_castEPK7DexTypeS2_(ptr noundef, ptr noundef) #1

declare noundef ptr @_Z10type_classPK7DexType(ptr noundef) #2

; Function Attrs: mustprogress uwtable
define dso_local i64 @_ZN4type19evaluate_type_checkEPK7DexTypeS2_(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca %"class.boost::optional", align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca %"struct.boost::none_t", align 1
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca %"struct.boost::none_t", align 1
  %13 = alloca %"struct.boost::none_t", align 1
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca %"struct.boost::none_t", align 1
  %17 = alloca %"struct.boost::none_t", align 1
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = icmp eq ptr %18, %19
  br i1 %20, label %21, label %22

21:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  store i32 1, ptr %6, align 4, !tbaa !9
  call void @_ZN5boost8optionalIiEC2EOi(ptr noundef nonnull align 4 dereferenceable(8) %3, ptr noundef nonnull align 4 dereferenceable(4) %6)
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  br label %71

22:                                               ; preds = %2
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  %24 = call noundef ptr @_ZN4type16java_lang_ObjectEv()
  %25 = icmp eq ptr %23, %24
  br i1 %25, label %26, label %27

26:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  store i32 1, ptr %7, align 4, !tbaa !9
  call void @_ZN5boost8optionalIiEC2EOi(ptr noundef nonnull align 4 dereferenceable(8) %3, ptr noundef nonnull align 4 dereferenceable(4) %7)
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  br label %71

27:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %28 = load ptr, ptr %5, align 8, !tbaa !5
  %29 = call noundef ptr @_Z10type_classPK7DexType(ptr noundef %28)
  store ptr %29, ptr %8, align 8, !tbaa !5
  %30 = load ptr, ptr %8, align 8, !tbaa !5
  %31 = icmp eq ptr %30, null
  br i1 %31, label %32, label %33

32:                                               ; preds = %27
  call void @_ZN5boost8optionalIiEC2ENS_6none_tE(ptr noundef nonnull align 4 dereferenceable(8) %3) #4
  store i32 1, ptr %10, align 4
  br label %70

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

38:                                               ; preds = %33
  call void @_ZN5boost8optionalIiEC2ENS_6none_tE(ptr noundef nonnull align 4 dereferenceable(8) %3) #4
  store i32 1, ptr %10, align 4
  br label %69

39:                                               ; preds = %33
  %40 = load ptr, ptr %8, align 8, !tbaa !5
  %41 = call noundef zeroext i1 @_ZNK8DexClass11is_externalEv(ptr noundef nonnull align 8 dereferenceable(176) %40)
  br i1 %41, label %45, label %42

42:                                               ; preds = %39
  %43 = load ptr, ptr %11, align 8, !tbaa !5
  %44 = call noundef zeroext i1 @_ZNK8DexClass11is_externalEv(ptr noundef nonnull align 8 dereferenceable(176) %43)
  br i1 %44, label %45, label %46

45:                                               ; preds = %42, %39
  call void @_ZN5boost8optionalIiEC2ENS_6none_tE(ptr noundef nonnull align 4 dereferenceable(8) %3) #4
  store i32 1, ptr %10, align 4
  br label %69

46:                                               ; preds = %42
  %47 = load ptr, ptr %8, align 8, !tbaa !5
  %48 = call noundef zeroext i1 @_Z12is_interfaceI8DexClassEbPT_(ptr noundef %47)
  br i1 %48, label %68, label %49

49:                                               ; preds = %46
  %50 = load ptr, ptr %11, align 8, !tbaa !5
  %51 = call noundef zeroext i1 @_Z12is_interfaceI8DexClassEbPT_(ptr noundef %50)
  br i1 %51, label %68, label %52

52:                                               ; preds = %49
  %53 = load ptr, ptr %11, align 8, !tbaa !5
  %54 = call noundef ptr @_ZNK8DexClass8get_typeEv(ptr noundef nonnull align 8 dereferenceable(176) %53)
  %55 = load ptr, ptr %8, align 8, !tbaa !5
  %56 = call noundef ptr @_ZNK8DexClass8get_typeEv(ptr noundef nonnull align 8 dereferenceable(176) %55)
  %57 = call noundef zeroext i1 @_ZN4type10check_castEPK7DexTypeS2_(ptr noundef %54, ptr noundef %56)
  br i1 %57, label %58, label %59

58:                                               ; preds = %52
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  store i32 1, ptr %14, align 4, !tbaa !9
  call void @_ZN5boost8optionalIiEC2EOi(ptr noundef nonnull align 4 dereferenceable(8) %3, ptr noundef nonnull align 4 dereferenceable(4) %14)
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  store i32 1, ptr %10, align 4
  br label %69

59:                                               ; preds = %52
  %60 = load ptr, ptr %8, align 8, !tbaa !5
  %61 = call noundef ptr @_ZNK8DexClass8get_typeEv(ptr noundef nonnull align 8 dereferenceable(176) %60)
  %62 = load ptr, ptr %11, align 8, !tbaa !5
  %63 = call noundef ptr @_ZNK8DexClass8get_typeEv(ptr noundef nonnull align 8 dereferenceable(176) %62)
  %64 = call noundef zeroext i1 @_ZN4type10check_castEPK7DexTypeS2_(ptr noundef %61, ptr noundef %63)
  br i1 %64, label %66, label %65

65:                                               ; preds = %59
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #4
  store i32 0, ptr %15, align 4, !tbaa !9
  call void @_ZN5boost8optionalIiEC2EOi(ptr noundef nonnull align 4 dereferenceable(8) %3, ptr noundef nonnull align 4 dereferenceable(4) %15)
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #4
  store i32 1, ptr %10, align 4
  br label %69

66:                                               ; preds = %59
  br label %67

67:                                               ; preds = %66
  call void @_ZN5boost8optionalIiEC2ENS_6none_tE(ptr noundef nonnull align 4 dereferenceable(8) %3) #4
  store i32 1, ptr %10, align 4
  br label %69

68:                                               ; preds = %49, %46
  call void @_ZN5boost8optionalIiEC2ENS_6none_tE(ptr noundef nonnull align 4 dereferenceable(8) %3) #4
  store i32 1, ptr %10, align 4
  br label %69

69:                                               ; preds = %68, %67, %65, %58, %45, %38
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  br label %70

70:                                               ; preds = %69, %32
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  br label %71

71:                                               ; preds = %70, %26, %21
  %72 = getelementptr inbounds %"class.boost::optional", ptr %3, i32 0, i32 0
  %73 = load i64, ptr %72, align 4
  ret i64 %73
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN5boost8optionalIiEC2EOi(ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(4)) unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN5boost8optionalIiEC2ENS_6none_tE(ptr noundef nonnull align 4 dereferenceable(8)) unnamed_addr #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK8DexClass11is_externalEv(ptr noundef nonnull align 8 dereferenceable(176)) #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_Z12is_interfaceI8DexClassEbPT_(ptr noundef) #1

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { "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 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 = { 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 = !{!"int", !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"

%"class.boost::optional" = type { %"class.boost::optional_detail::tc_optional_base" }
%"class.boost::optional_detail::tc_optional_base" = type { i8, i32 }

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

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN4type16java_lang_ObjectEv() local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN4type10check_castEPK7DexTypeS2_(ptr noundef, ptr noundef) local_unnamed_addr #1

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

; Function Attrs: mustprogress uwtable
define dso_local i64 @_ZN4type19evaluate_type_checkEPK7DexTypeS2_(ptr noundef %0, ptr noundef %1) local_unnamed_addr #1 {
  %3 = alloca %"class.boost::optional", align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = icmp eq ptr %1, %0
  br i1 %8, label %9, label %10

9:                                                ; preds = %2
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #4
  store i32 1, ptr %4, align 4, !tbaa !5
  call void @_ZN5boost8optionalIiEC2EOi(ptr noundef nonnull align 4 dereferenceable(8) %3, ptr noundef nonnull align 4 dereferenceable(4) %4)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #4
  br label %43

10:                                               ; preds = %2
  %11 = tail call noundef ptr @_ZN4type16java_lang_ObjectEv()
  %12 = icmp eq ptr %11, %1
  br i1 %12, label %13, label %14

13:                                               ; preds = %10
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #4
  store i32 1, ptr %5, align 4, !tbaa !5
  call void @_ZN5boost8optionalIiEC2EOi(ptr noundef nonnull align 4 dereferenceable(8) %3, ptr noundef nonnull align 4 dereferenceable(4) %5)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #4
  br label %43

14:                                               ; preds = %10
  %15 = tail call noundef ptr @_Z10type_classPK7DexType(ptr noundef %1)
  %16 = icmp eq ptr %15, null
  br i1 %16, label %17, label %18

17:                                               ; preds = %14
  call void @_ZN5boost8optionalIiEC2ENS_6none_tE(ptr noundef nonnull align 4 dereferenceable(8) %3) #4
  br label %43

18:                                               ; preds = %14
  %19 = tail call noundef ptr @_Z10type_classPK7DexType(ptr noundef %0)
  %20 = icmp eq ptr %19, null
  br i1 %20, label %21, label %22

21:                                               ; preds = %18
  call void @_ZN5boost8optionalIiEC2ENS_6none_tE(ptr noundef nonnull align 4 dereferenceable(8) %3) #4
  br label %43

22:                                               ; preds = %18
  %23 = tail call noundef zeroext i1 @_ZNK8DexClass11is_externalEv(ptr noundef nonnull align 8 dereferenceable(176) %15)
  br i1 %23, label %26, label %24

24:                                               ; preds = %22
  %25 = tail call noundef zeroext i1 @_ZNK8DexClass11is_externalEv(ptr noundef nonnull align 8 dereferenceable(176) %19)
  br i1 %25, label %26, label %27

26:                                               ; preds = %24, %22
  call void @_ZN5boost8optionalIiEC2ENS_6none_tE(ptr noundef nonnull align 4 dereferenceable(8) %3) #4
  br label %43

27:                                               ; preds = %24
  %28 = tail call noundef zeroext i1 @_Z12is_interfaceI8DexClassEbPT_(ptr noundef nonnull %15)
  br i1 %28, label %42, label %29

29:                                               ; preds = %27
  %30 = tail call noundef zeroext i1 @_Z12is_interfaceI8DexClassEbPT_(ptr noundef nonnull %19)
  br i1 %30, label %42, label %31

31:                                               ; preds = %29
  %32 = tail call noundef ptr @_ZNK8DexClass8get_typeEv(ptr noundef nonnull align 8 dereferenceable(176) %19)
  %33 = tail call noundef ptr @_ZNK8DexClass8get_typeEv(ptr noundef nonnull align 8 dereferenceable(176) %15)
  %34 = tail call noundef zeroext i1 @_ZN4type10check_castEPK7DexTypeS2_(ptr noundef %32, ptr noundef %33)
  br i1 %34, label %35, label %36

35:                                               ; preds = %31
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #4
  store i32 1, ptr %6, align 4, !tbaa !5
  call void @_ZN5boost8optionalIiEC2EOi(ptr noundef nonnull align 4 dereferenceable(8) %3, ptr noundef nonnull align 4 dereferenceable(4) %6)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #4
  br label %43

36:                                               ; preds = %31
  %37 = tail call noundef ptr @_ZNK8DexClass8get_typeEv(ptr noundef nonnull align 8 dereferenceable(176) %15)
  %38 = tail call noundef ptr @_ZNK8DexClass8get_typeEv(ptr noundef nonnull align 8 dereferenceable(176) %19)
  %39 = tail call noundef zeroext i1 @_ZN4type10check_castEPK7DexTypeS2_(ptr noundef %37, ptr noundef %38)
  br i1 %39, label %41, label %40

40:                                               ; preds = %36
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #4
  store i32 0, ptr %7, align 4, !tbaa !5
  call void @_ZN5boost8optionalIiEC2EOi(ptr noundef nonnull align 4 dereferenceable(8) %3, ptr noundef nonnull align 4 dereferenceable(4) %7)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #4
  br label %43

41:                                               ; preds = %36
  call void @_ZN5boost8optionalIiEC2ENS_6none_tE(ptr noundef nonnull align 4 dereferenceable(8) %3) #4
  br label %43

42:                                               ; preds = %29, %27
  call void @_ZN5boost8optionalIiEC2ENS_6none_tE(ptr noundef nonnull align 4 dereferenceable(8) %3) #4
  br label %43

43:                                               ; preds = %17, %42, %41, %40, %35, %26, %21, %13, %9
  %44 = load i64, ptr %3, align 8
  ret i64 %44
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN5boost8optionalIiEC2EOi(ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(4)) unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN5boost8optionalIiEC2ENS_6none_tE(ptr noundef nonnull align 4 dereferenceable(8)) unnamed_addr #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK8DexClass11is_externalEv(ptr noundef nonnull align 8 dereferenceable(176)) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_Z12is_interfaceI8DexClassEbPT_(ptr noundef) local_unnamed_addr #1

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

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


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