; LLVM IR from duc0/ContestNeko :: CPPProjects/Interval.ll (Z10bruteForceR12IntervalListIiE)

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

; 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 noundef i32 @_Z10bruteForceR12IntervalListIiE(ptr noundef nonnull align 8 dereferenceable(84) %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  %12 = load ptr, ptr %2, align 8, !tbaa !5
  %13 = call noundef i32 @_ZNK12IntervalListIiE7getSizeEv(ptr noundef nonnull align 8 dereferenceable(84) %12)
  store i32 %13, ptr %3, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  store i32 0, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  store i32 1, ptr %5, align 4, !tbaa !9
  br label %14

14:                                               ; preds = %65, %1
  %15 = load i32, ptr %5, align 4, !tbaa !9
  %16 = load i32, ptr %3, align 4, !tbaa !9
  %17 = icmp sle i32 %15, %16
  br i1 %17, label %19, label %18

18:                                               ; preds = %14
  store i32 2, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  br label %68

19:                                               ; preds = %14
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %20 = load ptr, ptr %2, align 8, !tbaa !5
  %21 = load i32, ptr %5, align 4, !tbaa !9
  %22 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNK12IntervalListIiE11getIntervalEi(ptr noundef nonnull align 8 dereferenceable(84) %20, i32 noundef %21)
  %23 = call noundef i32 @_ZNK8IntervalIiE7getLeftEv(ptr noundef nonnull align 4 dereferenceable(8) %22)
  store i32 %23, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  store i32 1, ptr %8, align 4, !tbaa !9
  br label %24

24:                                               ; preds = %61, %19
  %25 = load i32, ptr %8, align 4, !tbaa !9
  %26 = load i32, ptr %3, align 4, !tbaa !9
  %27 = icmp sle i32 %25, %26
  br i1 %27, label %29, label %28

28:                                               ; preds = %24
  store i32 5, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  br label %64

29:                                               ; preds = %24
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  %30 = load ptr, ptr %2, align 8, !tbaa !5
  %31 = load i32, ptr %8, align 4, !tbaa !9
  %32 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNK12IntervalListIiE11getIntervalEi(ptr noundef nonnull align 8 dereferenceable(84) %30, i32 noundef %31)
  %33 = call noundef i32 @_ZNK8IntervalIiE7getLeftEv(ptr noundef nonnull align 4 dereferenceable(8) %32)
  store i32 %33, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  store i32 0, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  store i32 1, ptr %11, align 4, !tbaa !9
  br label %34

34:                                               ; preds = %57, %29
  %35 = load i32, ptr %11, align 4, !tbaa !9
  %36 = load i32, ptr %3, align 4, !tbaa !9
  %37 = icmp sle i32 %35, %36
  br i1 %37, label %39, label %38

38:                                               ; preds = %34
  store i32 8, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  br label %60

39:                                               ; preds = %34
  %40 = load ptr, ptr %2, align 8, !tbaa !5
  %41 = load i32, ptr %11, align 4, !tbaa !9
  %42 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNK12IntervalListIiE11getIntervalEi(ptr noundef nonnull align 8 dereferenceable(84) %40, i32 noundef %41)
  %43 = load i32, ptr %7, align 4, !tbaa !9
  %44 = call noundef zeroext i1 @_ZNK8IntervalIiE8containsEi(ptr noundef nonnull align 4 dereferenceable(8) %42, i32 noundef %43)
  br i1 %44, label %51, label %45

45:                                               ; preds = %39
  %46 = load ptr, ptr %2, align 8, !tbaa !5
  %47 = load i32, ptr %11, align 4, !tbaa !9
  %48 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNK12IntervalListIiE11getIntervalEi(ptr noundef nonnull align 8 dereferenceable(84) %46, i32 noundef %47)
  %49 = load i32, ptr %9, align 4, !tbaa !9
  %50 = call noundef zeroext i1 @_ZNK8IntervalIiE8containsEi(ptr noundef nonnull align 4 dereferenceable(8) %48, i32 noundef %49)
  br i1 %50, label %51, label %54

51:                                               ; preds = %45, %39
  %52 = load i32, ptr %10, align 4, !tbaa !9
  %53 = add nsw i32 %52, 1
  store i32 %53, ptr %10, align 4, !tbaa !9
  br label %54

54:                                               ; preds = %51, %45
  %55 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %4, ptr noundef nonnull align 4 dereferenceable(4) %10)
  %56 = load i32, ptr %55, align 4, !tbaa !9
  store i32 %56, ptr %4, align 4, !tbaa !9
  br label %57

57:                                               ; preds = %54
  %58 = load i32, ptr %11, align 4, !tbaa !9
  %59 = add nsw i32 %58, 1
  store i32 %59, ptr %11, align 4, !tbaa !9
  br label %34, !llvm.loop !11

60:                                               ; preds = %38
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  br label %61

61:                                               ; preds = %60
  %62 = load i32, ptr %8, align 4, !tbaa !9
  %63 = add nsw i32 %62, 1
  store i32 %63, ptr %8, align 4, !tbaa !9
  br label %24, !llvm.loop !13

64:                                               ; preds = %28
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  br label %65

65:                                               ; preds = %64
  %66 = load i32, ptr %5, align 4, !tbaa !9
  %67 = add nsw i32 %66, 1
  store i32 %67, ptr %5, align 4, !tbaa !9
  br label %14, !llvm.loop !14

68:                                               ; preds = %18
  %69 = load i32, ptr %4, align 4, !tbaa !9
  store i32 1, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  ret i32 %69
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK12IntervalListIiE7getSizeEv(ptr noundef nonnull align 8 dereferenceable(84)) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(8) ptr @_ZNK12IntervalListIiE11getIntervalEi(ptr noundef nonnull align 8 dereferenceable(84), i32 noundef) #2 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK8IntervalIiE7getLeftEv(ptr noundef nonnull align 4 dereferenceable(8)) #3 align 2

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #3

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 = { 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 = { 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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}


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

; 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
define dso_local noundef i32 @_Z10bruteForceR12IntervalListIiE(ptr noundef nonnull align 8 dereferenceable(84) %0) local_unnamed_addr #1 {
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = tail call noundef i32 @_ZNK12IntervalListIiE7getSizeEv(ptr noundef nonnull align 8 dereferenceable(84) %0)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #3
  store i32 0, ptr %2, align 4, !tbaa !5
  %.not31 = icmp slt i32 %4, 1
  br i1 %.not31, label %._crit_edge35, label %.lr.ph29

._crit_edge35:                                    ; preds = %._crit_edge30.split, %1
  %5 = phi i32 [ 0, %1 ], [ %23, %._crit_edge30.split ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #3
  ret i32 %5

.lr.ph29:                                         ; preds = %1, %._crit_edge30.split
  %.01932 = phi i32 [ %8, %._crit_edge30.split ], [ 1, %1 ]
  %6 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNK12IntervalListIiE11getIntervalEi(ptr noundef nonnull align 8 dereferenceable(84) %0, i32 noundef %.01932)
  %7 = call noundef i32 @_ZNK8IntervalIiE7getLeftEv(ptr noundef nonnull align 4 dereferenceable(8) %6)
  br label %.lr.ph

._crit_edge30.split:                              ; preds = %._crit_edge
  %8 = add nuw i32 %.01932, 1
  %exitcond37.not = icmp eq i32 %.01932, %4
  br i1 %exitcond37.not, label %._crit_edge35, label %.lr.ph29, !llvm.loop !9

.lr.ph:                                           ; preds = %.lr.ph29, %._crit_edge
  %.02027 = phi i32 [ 1, %.lr.ph29 ], [ %11, %._crit_edge ]
  %9 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNK12IntervalListIiE11getIntervalEi(ptr noundef nonnull align 8 dereferenceable(84) %0, i32 noundef %.02027)
  %10 = call noundef i32 @_ZNK8IntervalIiE7getLeftEv(ptr noundef nonnull align 4 dereferenceable(8) %9)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #3
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %12

._crit_edge:                                      ; preds = %21
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #3
  %11 = add nuw i32 %.02027, 1
  %exitcond36.not = icmp eq i32 %.02027, %4
  br i1 %exitcond36.not, label %._crit_edge30.split, label %.lr.ph, !llvm.loop !11

12:                                               ; preds = %.lr.ph, %21
  %.025 = phi i32 [ 1, %.lr.ph ], [ %24, %21 ]
  %13 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNK12IntervalListIiE11getIntervalEi(ptr noundef nonnull align 8 dereferenceable(84) %0, i32 noundef %.025)
  %14 = call noundef zeroext i1 @_ZNK8IntervalIiE8containsEi(ptr noundef nonnull align 4 dereferenceable(8) %13, i32 noundef %7)
  br i1 %14, label %18, label %15

15:                                               ; preds = %12
  %16 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNK12IntervalListIiE11getIntervalEi(ptr noundef nonnull align 8 dereferenceable(84) %0, i32 noundef %.025)
  %17 = call noundef zeroext i1 @_ZNK8IntervalIiE8containsEi(ptr noundef nonnull align 4 dereferenceable(8) %16, i32 noundef %10)
  br i1 %17, label %18, label %21

18:                                               ; preds = %15, %12
  %19 = load i32, ptr %3, align 4, !tbaa !5
  %20 = add nsw i32 %19, 1
  store i32 %20, ptr %3, align 4, !tbaa !5
  br label %21

21:                                               ; preds = %18, %15
  %22 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %2, ptr noundef nonnull align 4 dereferenceable(4) %3)
  %23 = load i32, ptr %22, align 4, !tbaa !5
  store i32 %23, ptr %2, align 4, !tbaa !5
  %24 = add nuw i32 %.025, 1
  %exitcond.not = icmp eq i32 %.025, %4
  br i1 %exitcond.not, label %._crit_edge, label %12, !llvm.loop !12
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK12IntervalListIiE7getSizeEv(ptr noundef nonnull align 8 dereferenceable(84)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(8) ptr @_ZNK12IntervalListIiE11getIntervalEi(ptr noundef nonnull align 8 dereferenceable(84), i32 noundef) local_unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK8IntervalIiE7getLeftEv(ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #2 align 2

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #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 = { 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 = { 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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}


; Effective O3 passes: GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass