; LLVM IR from aap/librw :: src/anim.ll (ZN2rw20AnimInterpolatorInfo4findEi)

; 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.rw::AnimInterpolatorInfo" = type { i32, i32, i32, i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }

@_ZN2rwL14interpInfoListE = external hidden global [10 x ptr], align 16

; 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
define dso_local noundef ptr @_ZN2rw20AnimInterpolatorInfo4findEi(i32 noundef %0) #1 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  store i32 %0, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #2
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %6

6:                                                ; preds = %31, %1
  %7 = load i32, ptr %4, align 4, !tbaa !5
  %8 = icmp slt i32 %7, 10
  br i1 %8, label %10, label %9

9:                                                ; preds = %6
  store i32 2, ptr %5, align 4
  br label %34

10:                                               ; preds = %6
  %11 = load i32, ptr %4, align 4, !tbaa !5
  %12 = sext i32 %11 to i64
  %13 = getelementptr inbounds [10 x ptr], ptr @_ZN2rwL14interpInfoListE, i64 0, i64 %12
  %14 = load ptr, ptr %13, align 8, !tbaa !9
  %15 = icmp ne ptr %14, null
  br i1 %15, label %16, label %30

16:                                               ; preds = %10
  %17 = load i32, ptr %4, align 4, !tbaa !5
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds [10 x ptr], ptr @_ZN2rwL14interpInfoListE, i64 0, i64 %18
  %20 = load ptr, ptr %19, align 8, !tbaa !9
  %21 = getelementptr inbounds %"struct.rw::AnimInterpolatorInfo", ptr %20, i32 0, i32 0
  %22 = load i32, ptr %21, align 8, !tbaa !11
  %23 = load i32, ptr %3, align 4, !tbaa !5
  %24 = icmp eq i32 %22, %23
  br i1 %24, label %25, label %30

25:                                               ; preds = %16
  %26 = load i32, ptr %4, align 4, !tbaa !5
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds [10 x ptr], ptr @_ZN2rwL14interpInfoListE, i64 0, i64 %27
  %29 = load ptr, ptr %28, align 8, !tbaa !9
  store ptr %29, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %34

30:                                               ; preds = %16, %10
  br label %31

31:                                               ; preds = %30
  %32 = load i32, ptr %4, align 4, !tbaa !5
  %33 = add nsw i32 %32, 1
  store i32 %33, ptr %4, align 4, !tbaa !5
  br label %6, !llvm.loop !13

34:                                               ; preds = %25, %9
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #2
  %35 = load i32, ptr %5, align 4
  switch i32 %35, label %39 [
    i32 2, label %36
    i32 1, label %37
  ]

36:                                               ; preds = %34
  store ptr null, ptr %2, align 8
  br label %37

37:                                               ; preds = %36, %34
  %38 = load ptr, ptr %2, align 8
  ret ptr %38

39:                                               ; preds = %34
  unreachable
}

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 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"_ZTSN2rw20AnimInterpolatorInfoE", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !10, i64 56, !10, i64 64, !10, i64 72}
!13 = distinct !{!13, !14}
!14 = !{!"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"

@_ZN2rwL14interpInfoListE = external hidden local_unnamed_addr global [10 x ptr], align 16

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(read, inaccessiblemem: none) uwtable
define dso_local noundef ptr @_ZN2rw20AnimInterpolatorInfo4findEi(i32 noundef %0) local_unnamed_addr #0 align 2 {
  %2 = load ptr, ptr @_ZN2rwL14interpInfoListE, align 16, !tbaa !5
  %.not = icmp eq ptr %2, null
  br i1 %.not, label %6, label %3

3:                                                ; preds = %1
  %4 = load i32, ptr %2, align 8, !tbaa !9
  %5 = icmp eq i32 %4, %0
  br i1 %5, label %52, label %6

6:                                                ; preds = %1, %3
  %7 = load ptr, ptr getelementptr inbounds (i8, ptr @_ZN2rwL14interpInfoListE, i64 8), align 8, !tbaa !5
  %.not.1 = icmp eq ptr %7, null
  br i1 %.not.1, label %11, label %8

8:                                                ; preds = %6
  %9 = load i32, ptr %7, align 8, !tbaa !9
  %10 = icmp eq i32 %9, %0
  br i1 %10, label %52, label %11

11:                                               ; preds = %8, %6
  %12 = load ptr, ptr getelementptr inbounds (i8, ptr @_ZN2rwL14interpInfoListE, i64 16), align 16, !tbaa !5
  %.not.2 = icmp eq ptr %12, null
  br i1 %.not.2, label %16, label %13

13:                                               ; preds = %11
  %14 = load i32, ptr %12, align 8, !tbaa !9
  %15 = icmp eq i32 %14, %0
  br i1 %15, label %52, label %16

16:                                               ; preds = %13, %11
  %17 = load ptr, ptr getelementptr inbounds (i8, ptr @_ZN2rwL14interpInfoListE, i64 24), align 8, !tbaa !5
  %.not.3 = icmp eq ptr %17, null
  br i1 %.not.3, label %21, label %18

18:                                               ; preds = %16
  %19 = load i32, ptr %17, align 8, !tbaa !9
  %20 = icmp eq i32 %19, %0
  br i1 %20, label %52, label %21

21:                                               ; preds = %18, %16
  %22 = load ptr, ptr getelementptr inbounds (i8, ptr @_ZN2rwL14interpInfoListE, i64 32), align 16, !tbaa !5
  %.not.4 = icmp eq ptr %22, null
  br i1 %.not.4, label %26, label %23

23:                                               ; preds = %21
  %24 = load i32, ptr %22, align 8, !tbaa !9
  %25 = icmp eq i32 %24, %0
  br i1 %25, label %52, label %26

26:                                               ; preds = %23, %21
  %27 = load ptr, ptr getelementptr inbounds (i8, ptr @_ZN2rwL14interpInfoListE, i64 40), align 8, !tbaa !5
  %.not.5 = icmp eq ptr %27, null
  br i1 %.not.5, label %31, label %28

28:                                               ; preds = %26
  %29 = load i32, ptr %27, align 8, !tbaa !9
  %30 = icmp eq i32 %29, %0
  br i1 %30, label %52, label %31

31:                                               ; preds = %28, %26
  %32 = load ptr, ptr getelementptr inbounds (i8, ptr @_ZN2rwL14interpInfoListE, i64 48), align 16, !tbaa !5
  %.not.6 = icmp eq ptr %32, null
  br i1 %.not.6, label %36, label %33

33:                                               ; preds = %31
  %34 = load i32, ptr %32, align 8, !tbaa !9
  %35 = icmp eq i32 %34, %0
  br i1 %35, label %52, label %36

36:                                               ; preds = %33, %31
  %37 = load ptr, ptr getelementptr inbounds (i8, ptr @_ZN2rwL14interpInfoListE, i64 56), align 8, !tbaa !5
  %.not.7 = icmp eq ptr %37, null
  br i1 %.not.7, label %41, label %38

38:                                               ; preds = %36
  %39 = load i32, ptr %37, align 8, !tbaa !9
  %40 = icmp eq i32 %39, %0
  br i1 %40, label %52, label %41

41:                                               ; preds = %38, %36
  %42 = load ptr, ptr getelementptr inbounds (i8, ptr @_ZN2rwL14interpInfoListE, i64 64), align 16, !tbaa !5
  %.not.8 = icmp eq ptr %42, null
  br i1 %.not.8, label %46, label %43

43:                                               ; preds = %41
  %44 = load i32, ptr %42, align 8, !tbaa !9
  %45 = icmp eq i32 %44, %0
  br i1 %45, label %52, label %46

46:                                               ; preds = %43, %41
  %47 = load ptr, ptr getelementptr inbounds (i8, ptr @_ZN2rwL14interpInfoListE, i64 72), align 8, !tbaa !5
  %.not.9 = icmp eq ptr %47, null
  br i1 %.not.9, label %51, label %48

48:                                               ; preds = %46
  %49 = load i32, ptr %47, align 8, !tbaa !9
  %50 = icmp eq i32 %49, %0
  br i1 %50, label %52, label %51

51:                                               ; preds = %48, %46
  br label %52

52:                                               ; preds = %51, %48, %43, %38, %33, %28, %23, %18, %13, %8, %3
  %spec.select = phi ptr [ %2, %3 ], [ %7, %8 ], [ %12, %13 ], [ %17, %18 ], [ %22, %23 ], [ %27, %28 ], [ %32, %33 ], [ %37, %38 ], [ %42, %43 ], [ %47, %48 ], [ null, %51 ]
  ret ptr %spec.select
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(read, inaccessiblemem: none) 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" }

!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, !11, i64 0}
!10 = !{!"_ZTSN2rw20AnimInterpolatorInfoE", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72}
!11 = !{!"int", !7, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass