; LLVM IR from facebook/redex :: libredex/IRInstruction.ll (Z22needs_range_conversionPK13IRInstruction)

; 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.8 = external hidden unnamed_addr constant [75 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [28 x i8], align 1
@__PRETTY_FUNCTION__._Z22needs_range_conversionPK13IRInstruction = external hidden unnamed_addr constant [51 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 uwtable
declare dso_local noundef i32 @_ZNK13IRInstruction3srcEt(ptr noundef nonnull align 8 dereferenceable(32), i16 noundef zeroext) #2 align 2

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

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

declare noundef zeroext i16 @_ZN6opcode13to_dex_opcodeE8IROpcode(i16 noundef zeroext) #5

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i8 @_Z18required_bit_widtht(i16 noundef zeroext) #3

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_Z22needs_range_conversionPK13IRInstruction(ptr noundef %0) #2 {
  %2 = alloca i1, align 1
  %3 = alloca ptr, align 8
  %4 = alloca i16, align 2
  %5 = alloca i32, align 4
  %6 = alloca i16, align 2
  %7 = alloca i64, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 2, ptr %4) #6
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %9 = call noundef zeroext i16 @_ZNK13IRInstruction6opcodeEv(ptr noundef nonnull align 8 dereferenceable(32) %8)
  store i16 %9, ptr %4, align 2, !tbaa !9
  %10 = load i16, ptr %4, align 2, !tbaa !9
  %11 = call noundef zeroext i1 @_ZN6opcode14has_range_formE8IROpcode(i16 noundef zeroext %10)
  br i1 %11, label %13, label %12

12:                                               ; preds = %1
  store i1 false, ptr %2, align 1
  store i32 1, ptr %5, align 4
  br label %56

13:                                               ; preds = %1
  %14 = load ptr, ptr %3, align 8, !tbaa !5
  %15 = call noundef i64 @_ZNK13IRInstruction9srcs_sizeEv(ptr noundef nonnull align 8 dereferenceable(32) %14)
  %16 = icmp ugt i64 %15, 5
  br i1 %16, label %17, label %18

17:                                               ; preds = %13
  store i1 true, ptr %2, align 1
  store i32 1, ptr %5, align 4
  br label %56

18:                                               ; preds = %13
  %19 = load i16, ptr %4, align 2, !tbaa !9
  %20 = call noundef zeroext i1 @_ZN6opcode14is_an_internalE8IROpcode(i16 noundef zeroext %19)
  br i1 %20, label %22, label %21

21:                                               ; preds = %18
  br label %24

22:                                               ; preds = %18
  call void (ptr, ptr, i32, ptr, i32, ptr, ...) @_Z11assert_failPKcS0_jS0_10RedexErrorS0_z(ptr noundef @.str.19, ptr noundef @.str.8, i32 noundef 413, ptr noundef @__PRETTY_FUNCTION__._Z22needs_range_conversionPK13IRInstruction, i32 noundef 2, ptr noundef @.str.9) #7
  unreachable

23:                                               ; No predecessors!
  br label %24

24:                                               ; preds = %23, %21
  call void @llvm.lifetime.start.p0(i64 2, ptr %6) #6
  %25 = load i16, ptr %4, align 2, !tbaa !9
  %26 = call noundef zeroext i16 @_ZN6opcode13to_dex_opcodeE8IROpcode(i16 noundef zeroext %25)
  store i16 %26, ptr %6, align 2, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  store i64 0, ptr %7, align 8, !tbaa !13
  br label %27

27:                                               ; preds = %49, %24
  %28 = load i64, ptr %7, align 8, !tbaa !13
  %29 = load ptr, ptr %3, align 8, !tbaa !5
  %30 = call noundef i64 @_ZNK13IRInstruction9srcs_sizeEv(ptr noundef nonnull align 8 dereferenceable(32) %29)
  %31 = icmp ult i64 %28, %30
  br i1 %31, label %33, label %32

32:                                               ; preds = %27
  store i32 2, ptr %5, align 4
  br label %52

33:                                               ; preds = %27
  %34 = load ptr, ptr %3, align 8, !tbaa !5
  %35 = load i64, ptr %7, align 8, !tbaa !13
  %36 = trunc i64 %35 to i16
  %37 = call noundef i32 @_ZNK13IRInstruction3srcEt(ptr noundef nonnull align 8 dereferenceable(32) %34, i16 noundef zeroext %36)
  %38 = trunc i32 %37 to i16
  %39 = call noundef zeroext i8 @_Z18required_bit_widtht(i16 noundef zeroext %38)
  %40 = zext i8 %39 to i32
  %41 = load i16, ptr %6, align 2, !tbaa !11
  %42 = load i64, ptr %7, align 8, !tbaa !13
  %43 = trunc i64 %42 to i16
  %44 = call noundef zeroext i8 @_ZN10dex_opcode13src_bit_widthE9DexOpcodet(i16 noundef zeroext %41, i16 noundef zeroext %43)
  %45 = zext i8 %44 to i32
  %46 = icmp sgt i32 %40, %45
  br i1 %46, label %47, label %48

47:                                               ; preds = %33
  store i1 true, ptr %2, align 1
  store i32 1, ptr %5, align 4
  br label %52

48:                                               ; preds = %33
  br label %49

49:                                               ; preds = %48
  %50 = load i64, ptr %7, align 8, !tbaa !13
  %51 = add i64 %50, 1
  store i64 %51, ptr %7, align 8, !tbaa !13
  br label %27, !llvm.loop !15

52:                                               ; preds = %47, %32
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  %53 = load i32, ptr %5, align 4
  switch i32 %53, label %55 [
    i32 2, label %54
  ]

54:                                               ; preds = %52
  store i1 false, ptr %2, align 1
  store i32 1, ptr %5, align 4
  br label %55

55:                                               ; preds = %54, %52
  call void @llvm.lifetime.end.p0(i64 2, ptr %6) #6
  br label %56

56:                                               ; preds = %55, %17, %12
  call void @llvm.lifetime.end.p0(i64 2, ptr %4) #6
  %57 = load i1, ptr %2, align 1
  ret i1 %57
}

declare noundef zeroext i1 @_ZN6opcode14has_range_formE8IROpcode(i16 noundef zeroext) #5

declare noundef zeroext i8 @_ZN10dex_opcode13src_bit_widthE9DexOpcodet(i16 noundef zeroext, i16 noundef zeroext) #5

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 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 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 = { 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}
!11 = !{!12, !12, i64 0}
!12 = !{!"_ZTS9DexOpcode", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"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.8 = external hidden unnamed_addr constant [75 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [28 x i8], align 1
@__PRETTY_FUNCTION__._Z22needs_range_conversionPK13IRInstruction = external hidden unnamed_addr constant [51 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
declare dso_local noundef i32 @_ZNK13IRInstruction3srcEt(ptr noundef nonnull align 8 dereferenceable(32), i16 noundef zeroext) local_unnamed_addr #1 align 2

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

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

declare noundef zeroext i16 @_ZN6opcode13to_dex_opcodeE8IROpcode(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 #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i8 @_Z18required_bit_widtht(i16 noundef zeroext) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_Z22needs_range_conversionPK13IRInstruction(ptr noundef nonnull %0) local_unnamed_addr #1 {
  %2 = tail call noundef zeroext i16 @_ZNK13IRInstruction6opcodeEv(ptr noundef nonnull align 8 dereferenceable(32) %0)
  %3 = tail call noundef zeroext i1 @_ZN6opcode14has_range_formE8IROpcode(i16 noundef zeroext %2)
  br i1 %3, label %4, label %.critedge

4:                                                ; preds = %1
  %5 = tail call noundef i64 @_ZNK13IRInstruction9srcs_sizeEv(ptr noundef nonnull align 8 dereferenceable(32) %0)
  %6 = icmp ugt i64 %5, 5
  br i1 %6, label %.critedge, label %7

7:                                                ; preds = %4
  %8 = tail call noundef zeroext i1 @_ZN6opcode14is_an_internalE8IROpcode(i16 noundef zeroext %2)
  br i1 %8, label %9, label %10

9:                                                ; preds = %7
  tail call void (ptr, ptr, i32, ptr, i32, ptr, ...) @_Z11assert_failPKcS0_jS0_10RedexErrorS0_z(ptr noundef nonnull @.str.19, ptr noundef nonnull @.str.8, i32 noundef 413, ptr noundef nonnull @__PRETTY_FUNCTION__._Z22needs_range_conversionPK13IRInstruction, i32 noundef 2, ptr noundef nonnull @.str.9) #5
  unreachable

10:                                               ; preds = %7
  %11 = tail call noundef zeroext i16 @_ZN6opcode13to_dex_opcodeE8IROpcode(i16 noundef zeroext %2)
  %12 = tail call noundef i64 @_ZNK13IRInstruction9srcs_sizeEv(ptr noundef nonnull align 8 dereferenceable(32) %0)
  %.not15.not = icmp eq i64 %12, 0
  br i1 %.not15.not, label %.critedge, label %.lr.ph

13:                                               ; preds = %.lr.ph
  %14 = add nuw i64 %.016, 1
  %15 = tail call noundef i64 @_ZNK13IRInstruction9srcs_sizeEv(ptr noundef nonnull align 8 dereferenceable(32) %0)
  %.not = icmp ult i64 %14, %15
  br i1 %.not, label %.lr.ph, label %.critedge, !llvm.loop !5

.lr.ph:                                           ; preds = %10, %13
  %.016 = phi i64 [ %14, %13 ], [ 0, %10 ]
  %16 = trunc i64 %.016 to i16
  %17 = tail call noundef i32 @_ZNK13IRInstruction3srcEt(ptr noundef nonnull align 8 dereferenceable(32) %0, i16 noundef zeroext %16)
  %18 = trunc i32 %17 to i16
  %19 = tail call noundef zeroext i8 @_Z18required_bit_widtht(i16 noundef zeroext %18)
  %20 = tail call noundef zeroext i8 @_ZN10dex_opcode13src_bit_widthE9DexOpcodet(i16 noundef zeroext %11, i16 noundef zeroext %16)
  %21 = icmp ugt i8 %19, %20
  br i1 %21, label %.critedge, label %13

.critedge:                                        ; preds = %.lr.ph, %13, %10, %4, %1
  %.2 = phi i1 [ false, %1 ], [ true, %4 ], [ false, %10 ], [ %21, %13 ], [ %21, %.lr.ph ]
  ret i1 %.2
}

declare noundef zeroext i1 @_ZN6opcode14has_range_formE8IROpcode(i16 noundef zeroext) local_unnamed_addr #4

declare noundef zeroext i8 @_ZN10dex_opcode13src_bit_widthE9DexOpcodet(i16 noundef zeroext, i16 noundef zeroext) local_unnamed_addr #4

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 = { 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 = { 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 #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 }

!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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass