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

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

%"class.IRInstruction::reg_range" = type { %"class.boost::iterator_range" }
%"class.boost::iterator_range" = type { %"class.boost::iterator_range_detail::iterator_range_base" }
%"class.boost::iterator_range_detail::iterator_range_base" = type { %"class.boost::iterator_range_detail::iterator_range_base.12" }
%"class.boost::iterator_range_detail::iterator_range_base.12" = type { %"class.boost::iterator_range_detail::iterator_range_base.13" }
%"class.boost::iterator_range_detail::iterator_range_base.13" = type { ptr, ptr }
%class.IRInstruction = type { i16, i16, i32, %union.anon.0, %union.anon.1 }
%union.anon.0 = type { i64 }
%union.anon.1 = type { ptr, [8 x i8] }

; 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 uwtable
define dso_local { ptr, ptr } @_ZNK13IRInstruction4srcsEv(ptr noundef nonnull align 8 dereferenceable(32) %0) #1 align 2 {
  %2 = alloca %"class.IRInstruction::reg_range", align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  %6 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  %7 = getelementptr inbounds %class.IRInstruction, ptr %6, i32 0, i32 1
  %8 = load i16, ptr %7, align 2, !tbaa !9
  %9 = zext i16 %8 to i32
  %10 = icmp sle i32 %9, 4
  br i1 %10, label %11, label %14

11:                                               ; preds = %1
  %12 = getelementptr inbounds %class.IRInstruction, ptr %6, i32 0, i32 4
  %13 = call noundef ptr @_ZSt5beginIKjLm4EEPT_RAT0__S1_(ptr noundef nonnull align 4 dereferenceable(16) %12) #4
  br label %17

14:                                               ; preds = %1
  %15 = getelementptr inbounds %class.IRInstruction, ptr %6, i32 0, i32 4
  %16 = load ptr, ptr %15, align 8, !tbaa !14
  br label %17

17:                                               ; preds = %14, %11
  %18 = phi ptr [ %13, %11 ], [ %16, %14 ]
  store ptr %18, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = getelementptr inbounds %class.IRInstruction, ptr %6, i32 0, i32 1
  %21 = load i16, ptr %20, align 2, !tbaa !9
  %22 = zext i16 %21 to i32
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds i32, ptr %19, i64 %23
  store ptr %24, ptr %5, align 8, !tbaa !5
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  call void @_ZN13IRInstruction9reg_rangeCI2N5boost14iterator_rangeIPKjEEIS4_EET_S5_(ptr noundef nonnull align 8 dereferenceable(16) %2, ptr noundef %25, ptr noundef %26)
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  %27 = getelementptr inbounds %"class.IRInstruction::reg_range", ptr %2, i32 0, i32 0
  %28 = getelementptr inbounds %"class.boost::iterator_range", ptr %27, i32 0, i32 0
  %29 = getelementptr inbounds %"class.boost::iterator_range_detail::iterator_range_base", ptr %28, i32 0, i32 0
  %30 = getelementptr inbounds %"class.boost::iterator_range_detail::iterator_range_base.12", ptr %29, i32 0, i32 0
  %31 = load { ptr, ptr }, ptr %30, align 8
  ret { ptr, ptr } %31
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZSt5beginIKjLm4EEPT_RAT0__S1_(ptr noundef nonnull align 4 dereferenceable(16)) #2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN13IRInstruction9reg_rangeCI2N5boost14iterator_rangeIPKjEEIS4_EET_S5_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef, ptr noundef) unnamed_addr #3 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #3 = { inlinehint 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 = { 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 = !{!10, !12, i64 2}
!10 = !{!"_ZTS13IRInstruction", !11, i64 0, !12, i64 2, !13, i64 4, !7, i64 8, !7, i64 16}
!11 = !{!"_ZTS8IROpcode", !7, i64 0}
!12 = !{!"short", !7, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = !{!7, !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"

%"class.IRInstruction::reg_range" = type { %"class.boost::iterator_range" }
%"class.boost::iterator_range" = type { %"class.boost::iterator_range_detail::iterator_range_base" }
%"class.boost::iterator_range_detail::iterator_range_base" = type { %"class.boost::iterator_range_detail::iterator_range_base.12" }
%"class.boost::iterator_range_detail::iterator_range_base.12" = type { %"class.boost::iterator_range_detail::iterator_range_base.13" }
%"class.boost::iterator_range_detail::iterator_range_base.13" = type { ptr, ptr }

; Function Attrs: mustprogress uwtable
define dso_local { ptr, ptr } @_ZNK13IRInstruction4srcsEv(ptr noundef nonnull align 8 dereferenceable(32) %0) local_unnamed_addr #0 align 2 {
  %2 = alloca %"class.IRInstruction::reg_range", align 8
  %3 = getelementptr inbounds i8, ptr %0, i64 2
  %4 = load i16, ptr %3, align 2, !tbaa !5
  %5 = icmp ult i16 %4, 5
  %6 = getelementptr inbounds i8, ptr %0, i64 16
  br i1 %5, label %7, label %9

7:                                                ; preds = %1
  %8 = tail call noundef ptr @_ZSt5beginIKjLm4EEPT_RAT0__S1_(ptr noundef nonnull align 4 dereferenceable(16) %6) #3
  %.pre = load i16, ptr %3, align 2, !tbaa !5
  br label %11

9:                                                ; preds = %1
  %10 = load ptr, ptr %6, align 8, !tbaa !12
  br label %11

11:                                               ; preds = %9, %7
  %12 = phi i16 [ %.pre, %7 ], [ %4, %9 ]
  %13 = phi ptr [ %8, %7 ], [ %10, %9 ]
  %14 = zext i16 %12 to i64
  %15 = getelementptr inbounds i32, ptr %13, i64 %14
  call void @_ZN13IRInstruction9reg_rangeCI2N5boost14iterator_rangeIPKjEEIS4_EET_S5_(ptr noundef nonnull align 8 dereferenceable(16) %2, ptr noundef %13, ptr noundef %15)
  %.fca.0.load = load ptr, ptr %2, align 8
  %.fca.0.insert = insertvalue { ptr, ptr } poison, ptr %.fca.0.load, 0
  %.fca.1.gep = getelementptr inbounds i8, ptr %2, i64 8
  %.fca.1.load = load ptr, ptr %.fca.1.gep, align 8
  %.fca.1.insert = insertvalue { ptr, ptr } %.fca.0.insert, ptr %.fca.1.load, 1
  ret { ptr, ptr } %.fca.1.insert
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZSt5beginIKjLm4EEPT_RAT0__S1_(ptr noundef nonnull align 4 dereferenceable(16)) local_unnamed_addr #1

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN13IRInstruction9reg_rangeCI2N5boost14iterator_rangeIPKjEEIS4_EET_S5_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef, ptr noundef) unnamed_addr #2 align 2

attributes #0 = { 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 #1 = { 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 #2 = { inlinehint 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 = { 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, !10, i64 2}
!6 = !{!"_ZTS13IRInstruction", !7, i64 0, !10, i64 2, !11, i64 4, !8, i64 8, !8, i64 16}
!7 = !{!"_ZTS8IROpcode", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"short", !8, i64 0}
!11 = !{!"int", !8, i64 0}
!12 = !{!8, !8, i64 0}


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