; LLVM IR from facebook/redex :: libredex/IROpcode.ll (ZN6opcode17invoke_for_methodEPK9DexMethod)

; 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.8 = external hidden unnamed_addr constant [70 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [17 x i8], align 1
@__PRETTY_FUNCTION__._ZN6opcode17invoke_for_methodEPK9DexMethod = external hidden unnamed_addr constant [54 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [21 x i8], align 1

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

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i16 @_ZN6opcode17invoke_for_methodEPK9DexMethod(ptr noundef %0) #1 {
  %2 = alloca i16, align 2
  %3 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %5 = call noundef zeroext i1 @_ZNK12DexMethodRef6is_defEv(ptr noundef nonnull align 8 dereferenceable(26) %4)
  br i1 %5, label %6, label %7

6:                                                ; preds = %1
  br label %9

7:                                                ; preds = %1
  call void (ptr, ptr, i32, ptr, i32, ptr, ...) @_Z11assert_failPKcS0_jS0_10RedexErrorS0_z(ptr noundef @.str.17, ptr noundef @.str.8, i32 noundef 1147, ptr noundef @__PRETTY_FUNCTION__._ZN6opcode17invoke_for_methodEPK9DexMethod, i32 noundef 2, ptr noundef @.str.11) #4
  unreachable

8:                                                ; No predecessors!
  br label %9

9:                                                ; preds = %8, %6
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  %11 = call noundef zeroext i1 @_Z9is_staticIK9DexMethodEbPT_(ptr noundef %10)
  br i1 %11, label %12, label %13

12:                                               ; preds = %9
  store i16 90, ptr %2, align 2
  br label %33

13:                                               ; preds = %9
  %14 = load ptr, ptr %3, align 8, !tbaa !5
  %15 = call noundef zeroext i1 @_Z10is_privateIK9DexMethodEbPT_(ptr noundef %14)
  br i1 %15, label %19, label %16

16:                                               ; preds = %13
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  %18 = call noundef zeroext i1 @_Z14is_constructorIK9DexMethodEbPT_(ptr noundef %17)
  br i1 %18, label %19, label %20

19:                                               ; preds = %16, %13
  store i16 89, ptr %2, align 2
  br label %33

20:                                               ; preds = %16
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = call noundef zeroext i1 @_ZNK9DexMethod10is_virtualEv(ptr noundef nonnull align 8 dereferenceable(88) %21)
  br i1 %22, label %23, label %24

23:                                               ; preds = %20
  br label %26

24:                                               ; preds = %20
  call void (ptr, ptr, i32, ptr, i32, ptr, ...) @_Z11assert_failPKcS0_jS0_10RedexErrorS0_z(ptr noundef @.str.18, ptr noundef @.str.8, i32 noundef 1154, ptr noundef @__PRETTY_FUNCTION__._ZN6opcode17invoke_for_methodEPK9DexMethod, i32 noundef 2, ptr noundef @.str.11) #4
  unreachable

25:                                               ; No predecessors!
  br label %26

26:                                               ; preds = %25, %23
  %27 = load ptr, ptr %3, align 8, !tbaa !5
  %28 = call noundef ptr @_ZNK12DexMethodRef9get_classEv(ptr noundef nonnull align 8 dereferenceable(26) %27)
  %29 = call noundef ptr @_Z10type_classPK7DexType(ptr noundef %28)
  %30 = call noundef zeroext i1 @_Z12is_interfaceI8DexClassEbPT_(ptr noundef %29)
  %31 = zext i1 %30 to i64
  %32 = select i1 %30, i16 91, i16 87
  store i16 %32, ptr %2, align 2
  br label %33

33:                                               ; preds = %26, %19, %12
  %34 = load i16, ptr %2, align 2
  ret i16 %34
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZNK12DexMethodRef6is_defEv(ptr noundef nonnull align 8 dereferenceable(26)) #1 align 2

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

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

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

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

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

declare noundef ptr @_Z10type_classPK7DexType(ptr noundef) #3

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

attributes #0 = { 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 #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 = { 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 #3 = { "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)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


; 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.8 = external hidden unnamed_addr constant [70 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [17 x i8], align 1
@__PRETTY_FUNCTION__._ZN6opcode17invoke_for_methodEPK9DexMethod = external hidden unnamed_addr constant [54 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [21 x i8], align 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 #0

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext range(i16 87, 92) i16 @_ZN6opcode17invoke_for_methodEPK9DexMethod(ptr noundef nonnull %0) local_unnamed_addr #1 {
  %2 = tail call noundef zeroext i1 @_ZNK12DexMethodRef6is_defEv(ptr noundef nonnull align 8 dereferenceable(26) %0)
  br i1 %2, label %4, label %3

3:                                                ; preds = %1
  tail call void (ptr, ptr, i32, ptr, i32, ptr, ...) @_Z11assert_failPKcS0_jS0_10RedexErrorS0_z(ptr noundef nonnull @.str.17, ptr noundef nonnull @.str.8, i32 noundef 1147, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN6opcode17invoke_for_methodEPK9DexMethod, i32 noundef 2, ptr noundef nonnull @.str.11) #4
  unreachable

4:                                                ; preds = %1
  %5 = tail call noundef zeroext i1 @_Z9is_staticIK9DexMethodEbPT_(ptr noundef nonnull %0)
  br i1 %5, label %18, label %6

6:                                                ; preds = %4
  %7 = tail call noundef zeroext i1 @_Z10is_privateIK9DexMethodEbPT_(ptr noundef nonnull %0)
  br i1 %7, label %18, label %8

8:                                                ; preds = %6
  %9 = tail call noundef zeroext i1 @_Z14is_constructorIK9DexMethodEbPT_(ptr noundef nonnull %0)
  br i1 %9, label %18, label %10

10:                                               ; preds = %8
  %11 = tail call noundef zeroext i1 @_ZNK9DexMethod10is_virtualEv(ptr noundef nonnull align 8 dereferenceable(88) %0)
  br i1 %11, label %13, label %12

12:                                               ; preds = %10
  tail call void (ptr, ptr, i32, ptr, i32, ptr, ...) @_Z11assert_failPKcS0_jS0_10RedexErrorS0_z(ptr noundef nonnull @.str.18, ptr noundef nonnull @.str.8, i32 noundef 1154, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN6opcode17invoke_for_methodEPK9DexMethod, i32 noundef 2, ptr noundef nonnull @.str.11) #4
  unreachable

13:                                               ; preds = %10
  %14 = tail call noundef ptr @_ZNK12DexMethodRef9get_classEv(ptr noundef nonnull align 8 dereferenceable(26) %0)
  %15 = tail call noundef ptr @_Z10type_classPK7DexType(ptr noundef %14)
  %16 = tail call noundef zeroext i1 @_Z12is_interfaceI8DexClassEbPT_(ptr noundef %15)
  %17 = select i1 %16, i16 91, i16 87
  br label %18

18:                                               ; preds = %6, %8, %4, %13
  %.0 = phi i16 [ %17, %13 ], [ 90, %4 ], [ 89, %8 ], [ 89, %6 ]
  ret i16 %.0
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZNK12DexMethodRef6is_defEv(ptr noundef nonnull align 8 dereferenceable(26)) local_unnamed_addr #1 align 2

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

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

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

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

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

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

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

attributes #0 = { 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 #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 = { 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 #3 = { "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: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass