; LLVM IR from facebook/redex :: service/dataflow (ConstantUses)

; 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.10 = external hidden unnamed_addr constant [82 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.22 = external hidden unnamed_addr constant [18 x i8], align 1
@__PRETTY_FUNCTION__._ZN13constant_uses12ConstantUses15get_type_demandEP7DexType = external hidden unnamed_addr constant [74 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 i8 @_ZN13constant_uses12ConstantUses15get_type_demandEP7DexType(ptr noundef %0) #1 align 2 {
  %2 = alloca i8, align 1
  %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 ptr @_ZNK7DexType5c_strEv(ptr noundef nonnull align 8 dereferenceable(16) %4)
  %6 = getelementptr inbounds i8, ptr %5, i64 0
  %7 = load i8, ptr %6, align 1, !tbaa !9
  %8 = sext i8 %7 to i32
  switch i32 %8, label %17 [
    i32 86, label %9
    i32 66, label %13
    i32 67, label %13
    i32 83, label %13
    i32 73, label %13
    i32 90, label %13
    i32 74, label %14
    i32 70, label %15
    i32 68, label %16
  ]

9:                                                ; preds = %1
  br label %10

10:                                               ; preds = %11, %9
  call void (ptr, ptr, i32, ptr, i32, ptr, ...) @_Z11assert_failPKcS0_jS0_10RedexErrorS0_z(ptr noundef @.str.22, ptr noundef @.str.10, i32 noundef 186, ptr noundef @__PRETTY_FUNCTION__._ZN13constant_uses12ConstantUses15get_type_demandEP7DexType, i32 noundef 2, ptr noundef @.str.11) #2
  unreachable

11:                                               ; No predecessors!
  br i1 true, label %10, label %12, !llvm.loop !10

12:                                               ; preds = %11
  br label %13

13:                                               ; preds = %12, %1, %1, %1, %1, %1
  store i8 1, ptr %2, align 1
  br label %18

14:                                               ; preds = %1
  store i8 4, ptr %2, align 1
  br label %18

15:                                               ; preds = %1
  store i8 2, ptr %2, align 1
  br label %18

16:                                               ; preds = %1
  store i8 8, ptr %2, align 1
  br label %18

17:                                               ; preds = %1
  store i8 16, ptr %2, align 1
  br label %18

18:                                               ; preds = %17, %16, %15, %14, %13
  %19 = load i8, ptr %2, align 1
  ret i8 %19
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZNK7DexType5c_strEv(ptr noundef nonnull align 8 dereferenceable(16)) #1 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 = { 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.10 = external hidden unnamed_addr constant [82 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.22 = external hidden unnamed_addr constant [18 x i8], align 1
@__PRETTY_FUNCTION__._ZN13constant_uses12ConstantUses15get_type_demandEP7DexType = external hidden unnamed_addr constant [74 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(i8 1, 17) i8 @_ZN13constant_uses12ConstantUses15get_type_demandEP7DexType(ptr noundef nonnull %0) local_unnamed_addr #1 align 2 {
  %2 = tail call noundef ptr @_ZNK7DexType5c_strEv(ptr noundef nonnull align 8 dereferenceable(16) %0)
  %3 = load i8, ptr %2, align 1, !tbaa !5
  switch i8 %3, label %8 [
    i8 86, label %4
    i8 66, label %9
    i8 67, label %9
    i8 83, label %9
    i8 73, label %9
    i8 90, label %9
    i8 74, label %5
    i8 70, label %6
    i8 68, label %7
  ]

4:                                                ; preds = %1
  tail call void (ptr, ptr, i32, ptr, i32, ptr, ...) @_Z11assert_failPKcS0_jS0_10RedexErrorS0_z(ptr noundef nonnull @.str.22, ptr noundef nonnull @.str.10, i32 noundef 186, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN13constant_uses12ConstantUses15get_type_demandEP7DexType, i32 noundef 2, ptr noundef nonnull @.str.11) #2
  unreachable

5:                                                ; preds = %1
  br label %9

6:                                                ; preds = %1
  br label %9

7:                                                ; preds = %1
  br label %9

8:                                                ; preds = %1
  br label %9

9:                                                ; preds = %1, %1, %1, %1, %1, %8, %7, %6, %5
  %.0 = phi i8 [ 16, %8 ], [ 8, %7 ], [ 2, %6 ], [ 4, %5 ], [ 1, %1 ], [ 1, %1 ], [ 1, %1 ], [ 1, %1 ], [ 1, %1 ]
  ret i8 %.0
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZNK7DexType5c_strEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #1 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 = { 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,IPSCCPPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass