; LLVM IR from facebook/redex :: libredex/Creators.ll (ZN11MethodBlock4sputEP8DexField8Location)

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

%struct.Location = type <{ ptr, i32, [4 x i8] }>

@.str.8 = external hidden unnamed_addr constant [70 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [41 x i8], align 1
@__PRETTY_FUNCTION__._ZN11MethodBlock4sputEP8DexField8Location = external hidden unnamed_addr constant [45 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: noreturn
declare void @_Z11assert_failPKcS0_jS0_10RedexErrorS0_z(ptr noundef, ptr noundef, i32 noundef, ptr noundef, i32 noundef, ptr noundef, ...) #1

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

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

declare noundef signext i8 @_ZN4type11type_shortyEPK7DexType(ptr noundef) #4

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN11MethodBlock9sfield_opE8IROpcodeP8DexFieldR8Location(ptr noundef nonnull align 8 dereferenceable(16), i16 noundef zeroext, ptr noundef, ptr noundef nonnull align 8 dereferenceable(12)) #3 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN11MethodBlock4sputEP8DexField8Location(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef %1, ptr %2, i32 %3) #3 align 2 {
  %5 = alloca %struct.Location, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i16, align 2
  %9 = alloca i8, align 1
  %10 = getelementptr inbounds { ptr, i32 }, ptr %5, i32 0, i32 0
  store ptr %2, ptr %10, align 8
  %11 = getelementptr inbounds { ptr, i32 }, ptr %5, i32 0, i32 1
  store i32 %3, ptr %11, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  %12 = load ptr, ptr %6, align 8
  %13 = load ptr, ptr %7, align 8, !tbaa !5
  %14 = call noundef zeroext i1 @_ZNK11DexFieldRef11is_concreteEv(ptr noundef nonnull align 8 dereferenceable(26) %13)
  br i1 %14, label %15, label %19

15:                                               ; preds = %4
  %16 = load ptr, ptr %7, align 8, !tbaa !5
  %17 = call noundef zeroext i1 @_Z9is_staticI8DexFieldEbPT_(ptr noundef %16)
  br i1 %17, label %18, label %19

18:                                               ; preds = %15
  br label %21

19:                                               ; preds = %15, %4
  call void (ptr, ptr, i32, ptr, i32, ptr, ...) @_Z11assert_failPKcS0_jS0_10RedexErrorS0_z(ptr noundef @.str.18, ptr noundef @.str.8, i32 noundef 238, ptr noundef @__PRETTY_FUNCTION__._ZN11MethodBlock4sputEP8DexField8Location, i32 noundef 2, ptr noundef @.str.13) #5
  unreachable

20:                                               ; No predecessors!
  br label %21

21:                                               ; preds = %20, %18
  call void @llvm.lifetime.start.p0(i64 2, ptr %8) #6
  call void @llvm.lifetime.start.p0(i64 1, ptr %9) #6
  %22 = load ptr, ptr %7, align 8, !tbaa !5
  %23 = call noundef ptr @_ZNK11DexFieldRef8get_typeEv(ptr noundef nonnull align 8 dereferenceable(26) %22)
  %24 = call noundef signext i8 @_ZN4type11type_shortyEPK7DexType(ptr noundef %23)
  store i8 %24, ptr %9, align 1, !tbaa !9
  %25 = load i8, ptr %9, align 1, !tbaa !9
  %26 = sext i8 %25 to i32
  switch i32 %26, label %34 [
    i32 90, label %27
    i32 66, label %28
    i32 83, label %29
    i32 67, label %30
    i32 73, label %31
    i32 70, label %31
    i32 74, label %32
    i32 68, label %32
    i32 76, label %33
    i32 91, label %33
  ]

27:                                               ; preds = %21
  store i16 83, ptr %8, align 2, !tbaa !10
  br label %38

28:                                               ; preds = %21
  store i16 84, ptr %8, align 2, !tbaa !10
  br label %38

29:                                               ; preds = %21
  store i16 86, ptr %8, align 2, !tbaa !10
  br label %38

30:                                               ; preds = %21
  store i16 85, ptr %8, align 2, !tbaa !10
  br label %38

31:                                               ; preds = %21, %21
  store i16 80, ptr %8, align 2, !tbaa !10
  br label %38

32:                                               ; preds = %21, %21
  store i16 81, ptr %8, align 2, !tbaa !10
  br label %38

33:                                               ; preds = %21, %21
  store i16 82, ptr %8, align 2, !tbaa !10
  br label %38

34:                                               ; preds = %21
  br label %35

35:                                               ; preds = %36, %34
  call void (ptr, ptr, i32, ptr, i32, ptr, ...) @_Z11assert_failPKcS0_jS0_10RedexErrorS0_z(ptr noundef @.str.16, ptr noundef @.str.8, i32 noundef 267, ptr noundef @__PRETTY_FUNCTION__._ZN11MethodBlock4sputEP8DexField8Location, i32 noundef 2, ptr noundef @.str.13) #5
  unreachable

36:                                               ; No predecessors!
  br i1 true, label %35, label %37, !llvm.loop !12

37:                                               ; preds = %36
  br label %38

38:                                               ; preds = %37, %33, %32, %31, %30, %29, %28, %27
  %39 = load i16, ptr %8, align 2, !tbaa !10
  %40 = load ptr, ptr %7, align 8, !tbaa !5
  call void @_ZN11MethodBlock9sfield_opE8IROpcodeP8DexFieldR8Location(ptr noundef nonnull align 8 dereferenceable(16) %12, i16 noundef zeroext %39, ptr noundef %40, ptr noundef nonnull align 8 dereferenceable(12) %5)
  call void @llvm.lifetime.end.p0(i64 1, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 2, ptr %8) #6
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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 = { 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 = { "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 = { noreturn }
attributes #6 = { 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 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"_ZTS8IROpcode", !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"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"

%struct.Location = type <{ ptr, i32, [4 x i8] }>

@.str.8 = external hidden unnamed_addr constant [70 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [41 x i8], align 1
@__PRETTY_FUNCTION__._ZN11MethodBlock4sputEP8DexField8Location = external hidden unnamed_addr constant [45 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 nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK11DexFieldRef11is_concreteEv(ptr noundef nonnull align 8 dereferenceable(26)) local_unnamed_addr #1 align 2

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

declare noundef signext i8 @_ZN4type11type_shortyEPK7DexType(ptr noundef) local_unnamed_addr #3

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN11MethodBlock9sfield_opE8IROpcodeP8DexFieldR8Location(ptr noundef nonnull align 8 dereferenceable(16), i16 noundef zeroext, ptr noundef, ptr noundef nonnull align 8 dereferenceable(12)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN11MethodBlock4sputEP8DexField8Location(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef nonnull %1, ptr %2, i32 %3) local_unnamed_addr #2 align 2 {
  %5 = alloca %struct.Location, align 8
  store ptr %2, ptr %5, align 8
  %6 = getelementptr inbounds i8, ptr %5, i64 8
  store i32 %3, ptr %6, align 8
  %7 = tail call noundef zeroext i1 @_ZNK11DexFieldRef11is_concreteEv(ptr noundef nonnull align 8 dereferenceable(26) %1)
  br i1 %7, label %8, label %10

8:                                                ; preds = %4
  %9 = tail call noundef zeroext i1 @_Z9is_staticI8DexFieldEbPT_(ptr noundef nonnull %1)
  br i1 %9, label %11, label %10

10:                                               ; preds = %8, %4
  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 238, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN11MethodBlock4sputEP8DexField8Location, i32 noundef 2, ptr noundef nonnull @.str.13) #4
  unreachable

11:                                               ; preds = %8
  %12 = tail call noundef ptr @_ZNK11DexFieldRef8get_typeEv(ptr noundef nonnull align 8 dereferenceable(26) %1)
  %13 = tail call noundef signext i8 @_ZN4type11type_shortyEPK7DexType(ptr noundef %12)
  switch i8 %13, label %20 [
    i8 90, label %21
    i8 66, label %14
    i8 83, label %15
    i8 67, label %16
    i8 73, label %17
    i8 70, label %17
    i8 74, label %18
    i8 68, label %18
    i8 76, label %19
    i8 91, label %19
  ]

14:                                               ; preds = %11
  br label %21

15:                                               ; preds = %11
  br label %21

16:                                               ; preds = %11
  br label %21

17:                                               ; preds = %11, %11
  br label %21

18:                                               ; preds = %11, %11
  br label %21

19:                                               ; preds = %11, %11
  br label %21

20:                                               ; preds = %11
  tail call void (ptr, ptr, i32, ptr, i32, ptr, ...) @_Z11assert_failPKcS0_jS0_10RedexErrorS0_z(ptr noundef nonnull @.str.16, ptr noundef nonnull @.str.8, i32 noundef 267, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN11MethodBlock4sputEP8DexField8Location, i32 noundef 2, ptr noundef nonnull @.str.13) #4
  unreachable

21:                                               ; preds = %11, %19, %18, %17, %16, %15, %14
  %.0 = phi i16 [ 82, %19 ], [ 81, %18 ], [ 80, %17 ], [ 85, %16 ], [ 86, %15 ], [ 84, %14 ], [ 83, %11 ]
  call void @_ZN11MethodBlock9sfield_opE8IROpcodeP8DexFieldR8Location(ptr noundef nonnull align 8 dereferenceable(16) %0, i16 noundef zeroext %.0, ptr noundef nonnull %1, ptr noundef nonnull align 8 dereferenceable(12) %5)
  ret void
}

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 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 = { 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 = { "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,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass