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

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

; 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 @_ZN8dtv_impl16find_common_typeEPK7DexTypeS2_(ptr noundef, ptr noundef) #1

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN8dtv_impl22find_common_array_typeEPK7DexTypeS2_(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i8, align 1
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = call noundef i32 @_ZN4type15get_array_levelEPK7DexType(ptr noundef %13)
  store i32 %14, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = call noundef i32 @_ZN4type15get_array_levelEPK7DexType(ptr noundef %15)
  store i32 %16, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 1, ptr %8) #3
  store i8 0, ptr %8, align 1, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = call noundef ptr @_ZN4type22get_array_element_typeEPK7DexType(ptr noundef %17)
  store ptr %18, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %19 = load ptr, ptr %5, align 8, !tbaa !5
  %20 = call noundef ptr @_ZN4type22get_array_element_typeEPK7DexType(ptr noundef %19)
  store ptr %20, ptr %10, align 8, !tbaa !5
  %21 = load ptr, ptr %9, align 8, !tbaa !5
  %22 = call noundef zeroext i1 @_ZN4type12is_primitiveEPK7DexType(ptr noundef %21)
  br i1 %22, label %26, label %23

23:                                               ; preds = %2
  %24 = load ptr, ptr %10, align 8, !tbaa !5
  %25 = call noundef zeroext i1 @_ZN4type12is_primitiveEPK7DexType(ptr noundef %24)
  br i1 %25, label %26, label %27

26:                                               ; preds = %23, %2
  store i8 1, ptr %8, align 1, !tbaa !11
  br label %27

27:                                               ; preds = %26, %23
  %28 = load i8, ptr %8, align 1, !tbaa !11, !range !13, !noundef !14
  %29 = trunc i8 %28 to i1
  br i1 %29, label %47, label %30

30:                                               ; preds = %27
  %31 = load i32, ptr %6, align 4, !tbaa !9
  %32 = load i32, ptr %7, align 4, !tbaa !9
  %33 = icmp eq i32 %31, %32
  br i1 %33, label %34, label %47

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

40:                                               ; preds = %34
  %41 = load ptr, ptr %11, align 8, !tbaa !5
  %42 = load i32, ptr %6, align 4, !tbaa !9
  %43 = call noundef ptr @_ZN4type15make_array_typeEPK7DexTypej(ptr noundef %41, i32 noundef %42)
  br label %45

44:                                               ; preds = %34
  br label %45

45:                                               ; preds = %44, %40
  %46 = phi ptr [ %43, %40 ], [ null, %44 ]
  store ptr %46, ptr %3, align 8
  store i32 1, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  br label %48

47:                                               ; preds = %30, %27
  store ptr null, ptr %3, align 8
  store i32 1, ptr %12, align 4
  br label %48

48:                                               ; preds = %47, %45
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  %49 = load ptr, ptr %3, align 8
  ret ptr %49
}

declare noundef i32 @_ZN4type15get_array_levelEPK7DexType(ptr noundef) #2

declare noundef ptr @_ZN4type22get_array_element_typeEPK7DexType(ptr noundef) #2

declare noundef zeroext i1 @_ZN4type12is_primitiveEPK7DexType(ptr noundef) #2

declare noundef ptr @_ZN4type15make_array_typeEPK7DexTypej(ptr noundef, i32 noundef) #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 = { 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}
!11 = !{!12, !12, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}


; 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 uwtable
declare dso_local noundef ptr @_ZN8dtv_impl16find_common_typeEPK7DexTypeS2_(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN8dtv_impl22find_common_array_typeEPK7DexTypeS2_(ptr noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = tail call noundef i32 @_ZN4type15get_array_levelEPK7DexType(ptr noundef %0)
  %4 = tail call noundef i32 @_ZN4type15get_array_levelEPK7DexType(ptr noundef %1)
  %5 = tail call noundef ptr @_ZN4type22get_array_element_typeEPK7DexType(ptr noundef %0)
  %6 = tail call noundef ptr @_ZN4type22get_array_element_typeEPK7DexType(ptr noundef %1)
  %7 = tail call noundef zeroext i1 @_ZN4type12is_primitiveEPK7DexType(ptr noundef %5)
  br i1 %7, label %.critedge, label %8

8:                                                ; preds = %2
  %9 = tail call noundef zeroext i1 @_ZN4type12is_primitiveEPK7DexType(ptr noundef %6)
  %10 = icmp ne i32 %3, %4
  %or.cond.not = or i1 %10, %9
  br i1 %or.cond.not, label %.critedge, label %11

11:                                               ; preds = %8
  %12 = tail call noundef ptr @_ZN8dtv_impl16find_common_typeEPK7DexTypeS2_(ptr noundef %5, ptr noundef %6)
  %.not = icmp eq ptr %12, null
  br i1 %.not, label %.critedge, label %13

13:                                               ; preds = %11
  %14 = tail call noundef ptr @_ZN4type15make_array_typeEPK7DexTypej(ptr noundef nonnull %12, i32 noundef %3)
  br label %.critedge

.critedge:                                        ; preds = %2, %8, %13, %11
  %.0 = phi ptr [ %14, %13 ], [ null, %11 ], [ null, %8 ], [ null, %2 ]
  ret ptr %.0
}

declare noundef i32 @_ZN4type15get_array_levelEPK7DexType(ptr noundef) local_unnamed_addr #1

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

declare noundef zeroext i1 @_ZN4type12is_primitiveEPK7DexType(ptr noundef) local_unnamed_addr #1

declare noundef ptr @_ZN4type15make_array_typeEPK7DexTypej(ptr noundef, i32 noundef) local_unnamed_addr #1

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

!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,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass