; LLVM IR from facebook/redex :: libredex/DexOpcode.ll (ZN10dex_opcode13min_srcs_sizeE9DexOpcode)

; 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.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }

@.str = external hidden unnamed_addr constant [16 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [71 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [26 x i8], align 1
@__PRETTY_FUNCTION__._ZN10dex_opcode13min_srcs_sizeE9DexOpcode = external hidden unnamed_addr constant [50 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i8 @_ZN10dex_opcode6formatE9DexOpcode(i16 noundef zeroext) #0

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

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

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

declare void @_Z4showB5cxx119DexOpcode(ptr dead_on_unwind writable sret(%"class.std::__cxx11::basic_string") align 8, i16 noundef zeroext) #3

; Function Attrs: mustprogress nounwind uwtable
declare noundef ptr @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5c_strEv(ptr noundef nonnull align 8 dereferenceable(32)) #4 align 2

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN10dex_opcode13min_srcs_sizeE9DexOpcode(i16 noundef zeroext %0) #0 personality ptr @__gxx_personality_v0 {
  %2 = alloca i32, align 4
  %3 = alloca i16, align 2
  %4 = alloca %"class.std::__cxx11::basic_string", align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  store i16 %0, ptr %3, align 2, !tbaa !5
  %7 = load i16, ptr %3, align 2, !tbaa !5
  %8 = call noundef zeroext i8 @_ZN10dex_opcode6formatE9DexOpcode(i16 noundef zeroext %7)
  %9 = zext i8 %8 to i32
  switch i32 %9, label %26 [
    i32 0, label %10
    i32 1, label %10
    i32 4, label %10
    i32 5, label %10
    i32 7, label %10
    i32 8, label %10
    i32 12, label %10
    i32 13, label %10
    i32 14, label %10
    i32 24, label %10
    i32 26, label %10
    i32 28, label %10
    i32 32, label %10
    i32 35, label %10
    i32 42, label %10
    i32 36, label %10
    i32 39, label %10
    i32 44, label %10
    i32 45, label %10
    i32 2, label %11
    i32 6, label %11
    i32 10, label %11
    i32 11, label %11
    i32 15, label %11
    i32 18, label %11
    i32 20, label %11
    i32 21, label %11
    i32 25, label %11
    i32 27, label %11
    i32 37, label %11
    i32 40, label %11
    i32 3, label %12
    i32 16, label %12
    i32 19, label %12
    i32 22, label %12
    i32 41, label %12
    i32 17, label %13
    i32 29, label %14
    i32 38, label %14
    i32 43, label %14
    i32 9, label %15
    i32 23, label %15
    i32 30, label %15
    i32 31, label %15
    i32 33, label %15
    i32 34, label %15
  ]

10:                                               ; preds = %1, %1, %1, %1, %1, %1, %1, %1, %1, %1, %1, %1, %1, %1, %1, %1, %1, %1, %1
  store i32 0, ptr %2, align 4
  br label %27

11:                                               ; preds = %1, %1, %1, %1, %1, %1, %1, %1, %1, %1, %1, %1
  store i32 1, ptr %2, align 4
  br label %27

12:                                               ; preds = %1, %1, %1, %1, %1
  store i32 2, ptr %2, align 4
  br label %27

13:                                               ; preds = %1
  store i32 3, ptr %2, align 4
  br label %27

14:                                               ; preds = %1, %1, %1
  store i32 0, ptr %2, align 4
  br label %27

15:                                               ; preds = %1, %1, %1, %1, %1, %1
  br label %16

16:                                               ; preds = %24, %15
  call void @llvm.lifetime.start.p0(i64 32, ptr %4) #5
  %17 = load i16, ptr %3, align 2, !tbaa !5
  call void @_Z4showB5cxx119DexOpcode(ptr dead_on_unwind writable sret(%"class.std::__cxx11::basic_string") align 8 %4, i16 noundef zeroext %17)
  %18 = call noundef ptr @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5c_strEv(ptr noundef nonnull align 8 dereferenceable(32) %4) #5
  invoke void (ptr, ptr, i32, ptr, i32, ptr, ...) @_Z11assert_failPKcS0_jS0_10RedexErrorS0_z(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 492, ptr noundef @__PRETTY_FUNCTION__._ZN10dex_opcode13min_srcs_sizeE9DexOpcode, i32 noundef 2, ptr noundef @.str.12, ptr noundef %18) #6
          to label %19 unwind label %20

19:                                               ; preds = %16
  unreachable

20:                                               ; preds = %16
  %21 = landingpad { ptr, i32 }
          cleanup
  %22 = extractvalue { ptr, i32 } %21, 0
  store ptr %22, ptr %5, align 8
  %23 = extractvalue { ptr, i32 } %21, 1
  store i32 %23, ptr %6, align 4
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %4) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr %4) #5
  br label %29

24:                                               ; No predecessors!
  br i1 true, label %16, label %25, !llvm.loop !9

25:                                               ; preds = %24
  br label %26

26:                                               ; preds = %25, %1
  unreachable

27:                                               ; preds = %14, %13, %12, %11, %10
  %28 = load i32, ptr %2, align 4
  ret i32 %28

29:                                               ; preds = %20
  %30 = load ptr, ptr %5, align 8
  %31 = load i32, ptr %6, align 4
  %32 = insertvalue { ptr, i32 } poison, ptr %30, 0
  %33 = insertvalue { ptr, i32 } %32, i32 %31, 1
  resume { ptr, i32 } %33
}

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

%"class.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }

@.str = external hidden unnamed_addr constant [16 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [71 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [26 x i8], align 1
@__PRETTY_FUNCTION__._ZN10dex_opcode13min_srcs_sizeE9DexOpcode = external hidden unnamed_addr constant [50 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i8 @_ZN10dex_opcode6formatE9DexOpcode(i16 noundef zeroext) local_unnamed_addr #0

; 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #2

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

declare void @_Z4showB5cxx119DexOpcode(ptr dead_on_unwind writable sret(%"class.std::__cxx11::basic_string") align 8, i16 noundef zeroext) local_unnamed_addr #3

; Function Attrs: mustprogress nounwind uwtable
declare noundef ptr @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5c_strEv(ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #4 align 2

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: mustprogress uwtable
define dso_local noundef range(i32 0, 4) i32 @_ZN10dex_opcode13min_srcs_sizeE9DexOpcode(i16 noundef zeroext %0) local_unnamed_addr #0 personality ptr @__gxx_personality_v0 {
  %2 = alloca %"class.std::__cxx11::basic_string", align 8
  %3 = tail call noundef zeroext i8 @_ZN10dex_opcode6formatE9DexOpcode(i16 noundef zeroext %0)
  switch i8 %3, label %12 [
    i8 0, label %13
    i8 1, label %13
    i8 4, label %13
    i8 5, label %13
    i8 7, label %13
    i8 8, label %13
    i8 12, label %13
    i8 13, label %13
    i8 14, label %13
    i8 24, label %13
    i8 26, label %13
    i8 28, label %13
    i8 32, label %13
    i8 35, label %13
    i8 42, label %13
    i8 36, label %13
    i8 39, label %13
    i8 44, label %13
    i8 45, label %13
    i8 2, label %4
    i8 6, label %4
    i8 10, label %4
    i8 11, label %4
    i8 15, label %4
    i8 18, label %4
    i8 20, label %4
    i8 21, label %4
    i8 25, label %4
    i8 27, label %4
    i8 37, label %4
    i8 40, label %4
    i8 3, label %5
    i8 16, label %5
    i8 19, label %5
    i8 22, label %5
    i8 41, label %5
    i8 17, label %6
    i8 29, label %13
    i8 38, label %13
    i8 43, label %13
    i8 9, label %7
    i8 23, label %7
    i8 30, label %7
    i8 31, label %7
    i8 33, label %7
    i8 34, label %7
  ]

4:                                                ; preds = %1, %1, %1, %1, %1, %1, %1, %1, %1, %1, %1, %1
  br label %13

5:                                                ; preds = %1, %1, %1, %1, %1
  br label %13

6:                                                ; preds = %1
  br label %13

7:                                                ; preds = %1, %1, %1, %1, %1, %1
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %2) #5
  call void @_Z4showB5cxx119DexOpcode(ptr dead_on_unwind nonnull writable sret(%"class.std::__cxx11::basic_string") align 8 %2, i16 noundef zeroext %0)
  %8 = call noundef ptr @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5c_strEv(ptr noundef nonnull align 8 dereferenceable(32) %2) #5
  invoke void (ptr, ptr, i32, ptr, i32, ptr, ...) @_Z11assert_failPKcS0_jS0_10RedexErrorS0_z(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 492, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN10dex_opcode13min_srcs_sizeE9DexOpcode, i32 noundef 2, ptr noundef nonnull @.str.12, ptr noundef %8) #6
          to label %9 unwind label %10

9:                                                ; preds = %7
  unreachable

10:                                               ; preds = %7
  %11 = landingpad { ptr, i32 }
          cleanup
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %2) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %2) #5
  resume { ptr, i32 } %11

12:                                               ; preds = %1
  unreachable

13:                                               ; preds = %1, %1, %1, %1, %1, %1, %1, %1, %1, %1, %1, %1, %1, %1, %1, %1, %1, %1, %1, %1, %1, %1, %6, %5, %4
  %.0 = phi i32 [ 3, %6 ], [ 2, %5 ], [ 1, %4 ], [ 0, %1 ], [ 0, %1 ], [ 0, %1 ], [ 0, %1 ], [ 0, %1 ], [ 0, %1 ], [ 0, %1 ], [ 0, %1 ], [ 0, %1 ], [ 0, %1 ], [ 0, %1 ], [ 0, %1 ], [ 0, %1 ], [ 0, %1 ], [ 0, %1 ], [ 0, %1 ], [ 0, %1 ], [ 0, %1 ], [ 0, %1 ], [ 0, %1 ], [ 0, %1 ], [ 0, %1 ]
  ret i32 %.0
}

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 = { 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #5 = { nounwind }
attributes #6 = { 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,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass