; LLVM IR from facebook/redex :: service/cse (CommonSubexpressionElimination)

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

%union.CseLocation = type { ptr }

@.str.108 = external hidden unnamed_addr constant [95 x i8], align 1
@.str.109 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.110 = external hidden unnamed_addr constant [57 x i8], align 1
@__PRETTY_FUNCTION__._ZN8cse_impl11SharedState14may_be_barrierEPK13IRInstructionP7DexType = external hidden unnamed_addr constant [77 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 void @_ZN11CseLocationC2E19CseSpecialLocations(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) unnamed_addr #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 uwtable
define dso_local noundef zeroext i1 @_ZN8cse_impl11SharedState14may_be_barrierEPK13IRInstructionP7DexType(ptr noundef nonnull align 8 dereferenceable(520) %0, ptr noundef %1, ptr noundef %2) #3 align 2 {
  %4 = alloca i1, align 1
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i16, align 2
  %9 = alloca i32, align 4
  %10 = alloca %union.CseLocation, align 8
  %11 = alloca %union.CseLocation, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  %12 = load ptr, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 2, ptr %8) #6
  %13 = load ptr, ptr %6, align 8, !tbaa !5
  %14 = call noundef zeroext i16 @_ZNK13IRInstruction6opcodeEv(ptr noundef nonnull align 8 dereferenceable(32) %13)
  store i16 %14, ptr %8, align 2, !tbaa !9
  %15 = load i16, ptr %8, align 2, !tbaa !9
  %16 = zext i16 %15 to i32
  switch i32 %16, label %18 [
    i32 16, label %17
    i32 17, label %17
    i32 24, label %17
  ]

17:                                               ; preds = %3, %3, %3
  store i1 true, ptr %4, align 1
  store i32 1, ptr %9, align 4
  br label %59

18:                                               ; preds = %3
  %19 = load i16, ptr %8, align 2, !tbaa !9
  %20 = call noundef zeroext i1 @_ZN6opcode10is_an_aputE8IROpcode(i16 noundef zeroext %19)
  br i1 %20, label %27, label %21

21:                                               ; preds = %18
  %22 = load i16, ptr %8, align 2, !tbaa !9
  %23 = call noundef zeroext i1 @_ZN6opcode10is_an_iputE8IROpcode(i16 noundef zeroext %22)
  br i1 %23, label %27, label %24

24:                                               ; preds = %21
  %25 = load i16, ptr %8, align 2, !tbaa !9
  %26 = call noundef zeroext i1 @_ZN6opcode10is_an_sputE8IROpcode(i16 noundef zeroext %25)
  br i1 %26, label %27, label %28

27:                                               ; preds = %24, %21, %18
  store i1 true, ptr %4, align 1
  store i32 1, ptr %9, align 4
  br label %59

28:                                               ; preds = %24
  %29 = load i16, ptr %8, align 2, !tbaa !9
  %30 = call noundef zeroext i1 @_ZN6opcode12is_an_invokeE8IROpcode(i16 noundef zeroext %29)
  br i1 %30, label %31, label %36

31:                                               ; preds = %28
  %32 = load ptr, ptr %6, align 8, !tbaa !5
  %33 = load ptr, ptr %7, align 8, !tbaa !5
  %34 = call noundef zeroext i1 @_ZN8cse_impl11SharedState14is_invoke_safeEPK13IRInstructionP7DexType(ptr noundef nonnull align 8 dereferenceable(520) %12, ptr noundef %32, ptr noundef %33)
  %35 = xor i1 %34, true
  store i1 %35, ptr %4, align 1
  store i32 1, ptr %9, align 4
  br label %59

36:                                               ; preds = %28
  br label %37

37:                                               ; preds = %36
  %38 = load ptr, ptr %6, align 8, !tbaa !5
  %39 = call noundef zeroext i1 @_ZNK13IRInstruction9has_fieldEv(ptr noundef nonnull align 8 dereferenceable(32) %38)
  br i1 %39, label %40, label %58

40:                                               ; preds = %37
  %41 = load i16, ptr %8, align 2, !tbaa !9
  %42 = call noundef zeroext i1 @_ZN6opcode10is_an_igetE8IROpcode(i16 noundef zeroext %41)
  br i1 %42, label %46, label %43

43:                                               ; preds = %40
  %44 = load i16, ptr %8, align 2, !tbaa !9
  %45 = call noundef zeroext i1 @_ZN6opcode10is_an_sgetE8IROpcode(i16 noundef zeroext %44)
  br i1 %45, label %46, label %47

46:                                               ; preds = %43, %40
  br label %49

47:                                               ; preds = %43
  call void (ptr, ptr, i32, ptr, i32, ptr, ...) @_Z11assert_failPKcS0_jS0_10RedexErrorS0_z(ptr noundef @.str.110, ptr noundef @.str.108, i32 noundef 1323, ptr noundef @__PRETTY_FUNCTION__._ZN8cse_impl11SharedState14may_be_barrierEPK13IRInstructionP7DexType, i32 noundef 2, ptr noundef @.str.109) #7
  unreachable

48:                                               ; No predecessors!
  br label %49

49:                                               ; preds = %48, %46
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #6
  %50 = load i16, ptr %8, align 2, !tbaa !9
  %51 = load ptr, ptr %6, align 8, !tbaa !5
  %52 = call noundef ptr @_ZNK13IRInstruction9get_fieldEv(ptr noundef nonnull align 8 dereferenceable(32) %51)
  %53 = call ptr @_Z18get_field_location8IROpcodePK11DexFieldRef(i16 noundef zeroext %50, ptr noundef %52)
  %54 = getelementptr inbounds %union.CseLocation, ptr %10, i32 0, i32 0
  store ptr %53, ptr %54, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #6
  call void @_ZN11CseLocationC2E19CseSpecialLocations(ptr noundef nonnull align 8 dereferenceable(8) %11, i64 noundef 0)
  %55 = call noundef zeroext i1 @_ZeqRK11CseLocationS1_(ptr noundef nonnull align 8 dereferenceable(8) %10, ptr noundef nonnull align 8 dereferenceable(8) %11)
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #6
  br i1 %55, label %56, label %57

56:                                               ; preds = %49
  store i1 true, ptr %4, align 1
  store i32 1, ptr %9, align 4
  br label %59

57:                                               ; preds = %49
  br label %58

58:                                               ; preds = %57, %37
  store i1 false, ptr %4, align 1
  store i32 1, ptr %9, align 4
  br label %59

59:                                               ; preds = %58, %56, %31, %27, %17
  call void @llvm.lifetime.end.p0(i64 2, ptr %8) #6
  %60 = load i1, ptr %4, align 1
  ret i1 %60
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN6opcode12is_an_invokeE8IROpcode(i16 noundef zeroext) #4

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i16 @_ZNK13IRInstruction6opcodeEv(ptr noundef nonnull align 8 dereferenceable(32)) #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN6opcode10is_an_aputE8IROpcode(i16 noundef zeroext) #4

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN6opcode10is_an_iputE8IROpcode(i16 noundef zeroext) #4

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN6opcode10is_an_sputE8IROpcode(i16 noundef zeroext) #4

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN8cse_impl11SharedState14is_invoke_safeEPK13IRInstructionP7DexType(ptr noundef nonnull align 8 dereferenceable(520), ptr noundef, ptr noundef) #3 align 2

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN6opcode10is_an_igetE8IROpcode(i16 noundef zeroext) #4

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN6opcode10is_an_sgetE8IROpcode(i16 noundef zeroext) #4

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZeqRK11CseLocationS1_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #4

declare ptr @_Z18get_field_location8IROpcodePK11DexFieldRef(i16 noundef zeroext, ptr noundef) #5

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

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 = { inlinehint 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 = { "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 = { nounwind }
attributes #7 = { 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 = !{!10, !10, i64 0}
!10 = !{!"_ZTS8IROpcode", !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"

%union.CseLocation = type { ptr }

@.str.108 = external hidden unnamed_addr constant [95 x i8], align 1
@.str.109 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.110 = external hidden unnamed_addr constant [57 x i8], align 1
@__PRETTY_FUNCTION__._ZN8cse_impl11SharedState14may_be_barrierEPK13IRInstructionP7DexType = external hidden unnamed_addr constant [77 x i8], align 1

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

; Function Attrs: mustprogress 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 void @_ZN11CseLocationC2E19CseSpecialLocations(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) unnamed_addr #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, ...) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN8cse_impl11SharedState14may_be_barrierEPK13IRInstructionP7DexType(ptr noundef nonnull align 8 dereferenceable(520) %0, ptr noundef nonnull %1, ptr noundef %2) local_unnamed_addr #3 align 2 {
  %4 = alloca %union.CseLocation, align 8
  %5 = alloca %union.CseLocation, align 8
  %6 = tail call noundef zeroext i16 @_ZNK13IRInstruction6opcodeEv(ptr noundef nonnull align 8 dereferenceable(32) %1)
  switch i16 %6, label %7 [
    i16 16, label %30
    i16 17, label %30
    i16 24, label %30
  ]

7:                                                ; preds = %3
  %8 = tail call noundef zeroext i1 @_ZN6opcode10is_an_aputE8IROpcode(i16 noundef zeroext %6)
  br i1 %8, label %30, label %9

9:                                                ; preds = %7
  %10 = tail call noundef zeroext i1 @_ZN6opcode10is_an_iputE8IROpcode(i16 noundef zeroext %6)
  br i1 %10, label %30, label %11

11:                                               ; preds = %9
  %12 = tail call noundef zeroext i1 @_ZN6opcode10is_an_sputE8IROpcode(i16 noundef zeroext %6)
  br i1 %12, label %30, label %13

13:                                               ; preds = %11
  %14 = tail call noundef zeroext i1 @_ZN6opcode12is_an_invokeE8IROpcode(i16 noundef zeroext %6)
  br i1 %14, label %15, label %18

15:                                               ; preds = %13
  %16 = tail call noundef zeroext i1 @_ZN8cse_impl11SharedState14is_invoke_safeEPK13IRInstructionP7DexType(ptr noundef nonnull align 8 dereferenceable(520) %0, ptr noundef nonnull %1, ptr noundef %2)
  %17 = xor i1 %16, true
  br label %30

18:                                               ; preds = %13
  %19 = tail call noundef zeroext i1 @_ZNK13IRInstruction9has_fieldEv(ptr noundef nonnull align 8 dereferenceable(32) %1)
  br i1 %19, label %20, label %29

20:                                               ; preds = %18
  %21 = tail call noundef zeroext i1 @_ZN6opcode10is_an_igetE8IROpcode(i16 noundef zeroext %6)
  br i1 %21, label %25, label %22

22:                                               ; preds = %20
  %23 = tail call noundef zeroext i1 @_ZN6opcode10is_an_sgetE8IROpcode(i16 noundef zeroext %6)
  br i1 %23, label %25, label %24

24:                                               ; preds = %22
  tail call void (ptr, ptr, i32, ptr, i32, ptr, ...) @_Z11assert_failPKcS0_jS0_10RedexErrorS0_z(ptr noundef nonnull @.str.110, ptr noundef nonnull @.str.108, i32 noundef 1323, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN8cse_impl11SharedState14may_be_barrierEPK13IRInstructionP7DexType, i32 noundef 2, ptr noundef nonnull @.str.109) #6
  unreachable

25:                                               ; preds = %20, %22
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #7
  %26 = tail call noundef ptr @_ZNK13IRInstruction9get_fieldEv(ptr noundef nonnull align 8 dereferenceable(32) %1)
  %27 = tail call ptr @_Z18get_field_location8IROpcodePK11DexFieldRef(i16 noundef zeroext %6, ptr noundef %26)
  store ptr %27, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #7
  call void @_ZN11CseLocationC2E19CseSpecialLocations(ptr noundef nonnull align 8 dereferenceable(8) %5, i64 noundef 0)
  %28 = call noundef zeroext i1 @_ZeqRK11CseLocationS1_(ptr noundef nonnull align 8 dereferenceable(8) %4, ptr noundef nonnull align 8 dereferenceable(8) %5)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #7
  br i1 %28, label %30, label %29

29:                                               ; preds = %25, %18
  br label %30

30:                                               ; preds = %25, %7, %9, %11, %3, %3, %3, %29, %15
  %.0 = phi i1 [ %17, %15 ], [ false, %29 ], [ true, %3 ], [ true, %3 ], [ true, %3 ], [ true, %11 ], [ true, %9 ], [ true, %7 ], [ true, %25 ]
  ret i1 %.0
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN6opcode12is_an_invokeE8IROpcode(i16 noundef zeroext) local_unnamed_addr #4

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i16 @_ZNK13IRInstruction6opcodeEv(ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN6opcode10is_an_aputE8IROpcode(i16 noundef zeroext) local_unnamed_addr #4

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN6opcode10is_an_iputE8IROpcode(i16 noundef zeroext) local_unnamed_addr #4

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN6opcode10is_an_sputE8IROpcode(i16 noundef zeroext) local_unnamed_addr #4

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN8cse_impl11SharedState14is_invoke_safeEPK13IRInstructionP7DexType(ptr noundef nonnull align 8 dereferenceable(520), ptr noundef, ptr noundef) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZNK13IRInstruction9has_fieldEv(ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #3 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN6opcode10is_an_igetE8IROpcode(i16 noundef zeroext) local_unnamed_addr #4

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN6opcode10is_an_sgetE8IROpcode(i16 noundef zeroext) local_unnamed_addr #4

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZeqRK11CseLocationS1_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #4

declare ptr @_Z18get_field_location8IROpcodePK11DexFieldRef(i16 noundef zeroext, ptr noundef) local_unnamed_addr #5

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZNK13IRInstruction9get_fieldEv(ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #3 align 2

attributes #0 = { mustprogress 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 = { inlinehint 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 = { "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)"}


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