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

; 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.15 = external hidden unnamed_addr constant [42 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [18 x i8], align 1
@__PRETTY_FUNCTION__._ZN11MethodBlock4iputEP8DexField8LocationS2_ = external hidden unnamed_addr constant [55 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: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

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

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

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

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

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

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

21:                                               ; preds = %6
  %22 = load ptr, ptr %10, align 8, !tbaa !5
  %23 = call noundef zeroext i1 @_Z9is_staticI8DexFieldEbPT_(ptr noundef %22)
  br i1 %23, label %25, label %24

24:                                               ; preds = %21
  br label %27

25:                                               ; preds = %21, %6
  call void (ptr, ptr, i32, ptr, i32, ptr, ...) @_Z11assert_failPKcS0_jS0_10RedexErrorS0_z(ptr noundef @.str.15, ptr noundef @.str.8, i32 noundef 145, ptr noundef @__PRETTY_FUNCTION__._ZN11MethodBlock4iputEP8DexField8LocationS2_, i32 noundef 2, ptr noundef @.str.13) #6
  unreachable

26:                                               ; No predecessors!
  br label %27

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

33:                                               ; preds = %27
  store i16 69, ptr %11, align 2, !tbaa !10
  br label %44

34:                                               ; preds = %27
  store i16 70, ptr %11, align 2, !tbaa !10
  br label %44

35:                                               ; preds = %27
  store i16 72, ptr %11, align 2, !tbaa !10
  br label %44

36:                                               ; preds = %27
  store i16 71, ptr %11, align 2, !tbaa !10
  br label %44

37:                                               ; preds = %27, %27
  store i16 66, ptr %11, align 2, !tbaa !10
  br label %44

38:                                               ; preds = %27, %27
  store i16 67, ptr %11, align 2, !tbaa !10
  br label %44

39:                                               ; preds = %27, %27
  store i16 68, ptr %11, align 2, !tbaa !10
  br label %44

40:                                               ; preds = %27
  br label %41

41:                                               ; preds = %42, %40
  call void (ptr, ptr, i32, ptr, i32, ptr, ...) @_Z11assert_failPKcS0_jS0_10RedexErrorS0_z(ptr noundef @.str.16, ptr noundef @.str.8, i32 noundef 174, ptr noundef @__PRETTY_FUNCTION__._ZN11MethodBlock4iputEP8DexField8LocationS2_, i32 noundef 2, ptr noundef @.str.13) #6
  unreachable

42:                                               ; No predecessors!
  br i1 true, label %41, label %43, !llvm.loop !12

43:                                               ; preds = %42
  br label %44

44:                                               ; preds = %43, %39, %38, %37, %36, %35, %34, %33
  %45 = load i16, ptr %11, align 2, !tbaa !10
  %46 = load ptr, ptr %10, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %13, ptr align 8 %7, i64 16, i1 false), !tbaa.struct !14
  %47 = getelementptr inbounds { ptr, i32 }, ptr %13, i32 0, i32 0
  %48 = load ptr, ptr %47, align 8
  %49 = getelementptr inbounds { ptr, i32 }, ptr %13, i32 0, i32 1
  %50 = load i32, ptr %49, align 8
  call void @_ZN11MethodBlock9ifield_opE8IROpcodeP8DexField8LocationRS3_(ptr noundef nonnull align 8 dereferenceable(16) %18, i16 noundef zeroext %45, ptr noundef %46, ptr %48, i32 %50, ptr noundef nonnull align 8 dereferenceable(12) %8)
  call void @llvm.lifetime.end.p0(i64 1, ptr %12) #7
  call void @llvm.lifetime.end.p0(i64 2, ptr %11) #7
  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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { 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 #5 = { "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 #6 = { noreturn }
attributes #7 = { 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"}
!14 = !{i64 0, i64 8, !5, i64 8, i64 4, !15}
!15 = !{!16, !16, i64 0}
!16 = !{!"int", !7, i64 0}


; 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.15 = external hidden unnamed_addr constant [42 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [18 x i8], align 1
@__PRETTY_FUNCTION__._ZN11MethodBlock4iputEP8DexField8LocationS2_ = external hidden unnamed_addr constant [55 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 @_ZN11MethodBlock9ifield_opE8IROpcodeP8DexField8LocationRS3_(ptr noundef nonnull align 8 dereferenceable(16), i16 noundef zeroext, ptr noundef, ptr, i32, ptr noundef nonnull align 8 dereferenceable(12)) local_unnamed_addr #2 align 2

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

10:                                               ; preds = %6
  %11 = tail call noundef zeroext i1 @_Z9is_staticI8DexFieldEbPT_(ptr noundef nonnull %1)
  br i1 %11, label %12, label %13

12:                                               ; preds = %10, %6
  tail call void (ptr, ptr, i32, ptr, i32, ptr, ...) @_Z11assert_failPKcS0_jS0_10RedexErrorS0_z(ptr noundef nonnull @.str.15, ptr noundef nonnull @.str.8, i32 noundef 145, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN11MethodBlock4iputEP8DexField8LocationS2_, i32 noundef 2, ptr noundef nonnull @.str.13) #4
  unreachable

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

16:                                               ; preds = %13
  br label %23

17:                                               ; preds = %13
  br label %23

18:                                               ; preds = %13
  br label %23

19:                                               ; preds = %13, %13
  br label %23

20:                                               ; preds = %13, %13
  br label %23

21:                                               ; preds = %13, %13
  br label %23

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

23:                                               ; preds = %13, %21, %20, %19, %18, %17, %16
  %.0 = phi i16 [ 68, %21 ], [ 67, %20 ], [ 66, %19 ], [ 71, %18 ], [ 72, %17 ], [ 70, %16 ], [ 69, %13 ]
  call void @_ZN11MethodBlock9ifield_opE8IROpcodeP8DexField8LocationRS3_(ptr noundef nonnull align 8 dereferenceable(16) %0, i16 noundef zeroext %.0, ptr noundef nonnull %1, ptr %2, i32 %3, ptr noundef nonnull align 8 dereferenceable(12) %7)
  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