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

; 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.12 = external hidden unnamed_addr constant [18 x i8], align 1
@__PRETTY_FUNCTION__._ZN4type11type_shortyEPK7DexType = external hidden unnamed_addr constant [40 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [2 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 @_ZNK7DexType8get_nameEv(ptr noundef nonnull align 8 dereferenceable(16)) #1 align 2

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef signext i8 @_ZN4type11type_shortyEPK7DexType(ptr noundef %0) #3 {
  %2 = alloca i8, align 1
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  %6 = load ptr, ptr %3, align 8, !tbaa !5
  %7 = call noundef ptr @_ZNK7DexType8get_nameEv(ptr noundef nonnull align 8 dereferenceable(16) %6)
  %8 = call noundef ptr @_ZNK9DexString5c_strEv(ptr noundef nonnull align 8 dereferenceable(16) %7)
  store ptr %8, ptr %4, align 8, !tbaa !5
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %9, i64 0
  %11 = load i8, ptr %10, align 1, !tbaa !9
  %12 = sext i8 %11 to i32
  switch i32 %12, label %18 [
    i32 91, label %13
    i32 86, label %14
    i32 90, label %14
    i32 66, label %14
    i32 83, label %14
    i32 67, label %14
    i32 73, label %14
    i32 74, label %14
    i32 70, label %14
    i32 68, label %14
    i32 76, label %14
  ]

13:                                               ; preds = %1
  store i8 76, ptr %2, align 1
  store i32 1, ptr %5, align 4
  br label %22

14:                                               ; preds = %1, %1, %1, %1, %1, %1, %1, %1, %1, %1
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %15, i64 0
  %17 = load i8, ptr %16, align 1, !tbaa !9
  store i8 %17, ptr %2, align 1
  store i32 1, ptr %5, align 4
  br label %22

18:                                               ; preds = %1
  br label %19

19:                                               ; preds = %20, %18
  call void (ptr, ptr, i32, ptr, i32, ptr, ...) @_Z11assert_failPKcS0_jS0_10RedexErrorS0_z(ptr noundef @.str.12, ptr noundef @.str.8, i32 noundef 237, ptr noundef @__PRETTY_FUNCTION__._ZN4type11type_shortyEPK7DexType, i32 noundef 2, ptr noundef @.str.13) #5
  unreachable

20:                                               ; No predecessors!
  br i1 true, label %19, label %21, !llvm.loop !10

21:                                               ; preds = %20
  unreachable

22:                                               ; preds = %14, %13
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  %23 = load i8, ptr %2, align 1
  ret i8 %23
}

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 = { 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 = { nounwind }
attributes #5 = { 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"}
!9 = !{!7, !7, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"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.8 = external hidden unnamed_addr constant [70 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [18 x i8], align 1
@__PRETTY_FUNCTION__._ZN4type11type_shortyEPK7DexType = external hidden unnamed_addr constant [40 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [2 x i8], align 1
@switch.table._ZN4type11type_shortyEPK7DexType = private unnamed_addr constant [26 x i8] c"BCDLFLLIJLLLLLLLLSLLVLLLZL", align 1

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

; 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 #1

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

; Function Attrs: mustprogress uwtable
define dso_local noundef signext i8 @_ZN4type11type_shortyEPK7DexType(ptr noundef nonnull %0) local_unnamed_addr #2 {
  %2 = tail call noundef ptr @_ZNK7DexType8get_nameEv(ptr noundef nonnull align 8 dereferenceable(16) %0)
  %3 = tail call noundef ptr @_ZNK9DexString5c_strEv(ptr noundef nonnull align 8 dereferenceable(16) %2)
  %4 = load i8, ptr %3, align 1, !tbaa !5
  %switch.tableidx = add i8 %4, -66
  %5 = icmp ult i8 %switch.tableidx, 26
  br i1 %5, label %switch.hole_check, label %6

6:                                                ; preds = %switch.hole_check, %1
  tail call void (ptr, ptr, i32, ptr, i32, ptr, ...) @_Z11assert_failPKcS0_jS0_10RedexErrorS0_z(ptr noundef nonnull @.str.12, ptr noundef nonnull @.str.8, i32 noundef 237, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN4type11type_shortyEPK7DexType, i32 noundef 2, ptr noundef nonnull @.str.13) #3
  unreachable

switch.hole_check:                                ; preds = %1
  %switch.maskindex = zext nneg i8 %switch.tableidx to i32
  %switch.shifted = lshr i32 51512727, %switch.maskindex
  %switch.lobit = trunc i32 %switch.shifted to i1
  br i1 %switch.lobit, label %switch.lookup, label %6

switch.lookup:                                    ; preds = %switch.hole_check
  %7 = zext nneg i8 %switch.tableidx to i64
  %switch.gep = getelementptr inbounds [26 x i8], ptr @switch.table._ZN4type11type_shortyEPK7DexType, i64 0, i64 %7
  %switch.load = load i8, ptr %switch.gep, align 1
  ret i8 %switch.load
}

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


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