; LLVM IR from vmartinv/eldiego :: estructuras/rmq.persistent.ll (Z6updateiiP4nodeii)

; 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.node = type { i32, ptr, ptr }

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4nodeC2Ei(ptr noundef nonnull align 8 dereferenceable(24), i32 noundef) unnamed_addr #1 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) #2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4nodeC2EPS_S0_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef, ptr noundef) unnamed_addr #1 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_Z6updateiiP4nodeii(i32 noundef %0, i32 noundef %1, ptr noundef %2, i32 noundef %3, i32 noundef %4) #4 personality ptr @__gxx_personality_v0 {
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  store i32 %0, ptr %7, align 4, !tbaa !5
  store i32 %1, ptr %8, align 4, !tbaa !5
  store ptr %2, ptr %9, align 8, !tbaa !9
  store i32 %3, ptr %10, align 4, !tbaa !5
  store i32 %4, ptr %11, align 4, !tbaa !5
  %16 = load i32, ptr %10, align 4, !tbaa !5
  %17 = add nsw i32 %16, 1
  %18 = load i32, ptr %11, align 4, !tbaa !5
  %19 = icmp eq i32 %17, %18
  br i1 %19, label %20, label %28

20:                                               ; preds = %5
  %21 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 24) #5
  %22 = load i32, ptr %8, align 4, !tbaa !5
  invoke void @_ZN4nodeC2Ei(ptr noundef nonnull align 8 dereferenceable(24) %21, i32 noundef %22)
          to label %23 unwind label %24

23:                                               ; preds = %20
  store ptr %21, ptr %6, align 8
  br label %76

24:                                               ; preds = %20
  %25 = landingpad { ptr, i32 }
          cleanup
  %26 = extractvalue { ptr, i32 } %25, 0
  store ptr %26, ptr %12, align 8
  %27 = extractvalue { ptr, i32 } %25, 1
  store i32 %27, ptr %13, align 4
  call void @_ZdlPvm(ptr noundef %21, i64 noundef 24) #6
  br label %78

28:                                               ; preds = %5
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #7
  %29 = load i32, ptr %10, align 4, !tbaa !5
  %30 = load i32, ptr %11, align 4, !tbaa !5
  %31 = add nsw i32 %29, %30
  %32 = ashr i32 %31, 1
  store i32 %32, ptr %14, align 4, !tbaa !5
  %33 = load i32, ptr %7, align 4, !tbaa !5
  %34 = load i32, ptr %14, align 4, !tbaa !5
  %35 = icmp slt i32 %33, %34
  br i1 %35, label %36, label %55

36:                                               ; preds = %28
  %37 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 24) #5
  %38 = load i32, ptr %7, align 4, !tbaa !5
  %39 = load i32, ptr %8, align 4, !tbaa !5
  %40 = load ptr, ptr %9, align 8, !tbaa !9
  %41 = getelementptr inbounds %struct.node, ptr %40, i32 0, i32 1
  %42 = load ptr, ptr %41, align 8, !tbaa !11
  %43 = load i32, ptr %10, align 4, !tbaa !5
  %44 = load i32, ptr %14, align 4, !tbaa !5
  %45 = invoke noundef ptr @_Z6updateiiP4nodeii(i32 noundef %38, i32 noundef %39, ptr noundef %42, i32 noundef %43, i32 noundef %44)
          to label %46 unwind label %51

46:                                               ; preds = %36
  %47 = load ptr, ptr %9, align 8, !tbaa !9
  %48 = getelementptr inbounds %struct.node, ptr %47, i32 0, i32 2
  %49 = load ptr, ptr %48, align 8, !tbaa !13
  invoke void @_ZN4nodeC2EPS_S0_(ptr noundef nonnull align 8 dereferenceable(24) %37, ptr noundef %45, ptr noundef %49)
          to label %50 unwind label %51

50:                                               ; preds = %46
  store ptr %37, ptr %6, align 8
  store i32 1, ptr %15, align 4
  br label %74

51:                                               ; preds = %46, %36
  %52 = landingpad { ptr, i32 }
          cleanup
  %53 = extractvalue { ptr, i32 } %52, 0
  store ptr %53, ptr %12, align 8
  %54 = extractvalue { ptr, i32 } %52, 1
  store i32 %54, ptr %13, align 4
  call void @_ZdlPvm(ptr noundef %37, i64 noundef 24) #6
  br label %75

55:                                               ; preds = %28
  %56 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 24) #5
  %57 = load ptr, ptr %9, align 8, !tbaa !9
  %58 = getelementptr inbounds %struct.node, ptr %57, i32 0, i32 1
  %59 = load ptr, ptr %58, align 8, !tbaa !11
  %60 = load i32, ptr %7, align 4, !tbaa !5
  %61 = load i32, ptr %8, align 4, !tbaa !5
  %62 = load ptr, ptr %9, align 8, !tbaa !9
  %63 = getelementptr inbounds %struct.node, ptr %62, i32 0, i32 2
  %64 = load ptr, ptr %63, align 8, !tbaa !13
  %65 = load i32, ptr %14, align 4, !tbaa !5
  %66 = load i32, ptr %11, align 4, !tbaa !5
  %67 = invoke noundef ptr @_Z6updateiiP4nodeii(i32 noundef %60, i32 noundef %61, ptr noundef %64, i32 noundef %65, i32 noundef %66)
          to label %68 unwind label %70

68:                                               ; preds = %55
  invoke void @_ZN4nodeC2EPS_S0_(ptr noundef nonnull align 8 dereferenceable(24) %56, ptr noundef %59, ptr noundef %67)
          to label %69 unwind label %70

69:                                               ; preds = %68
  store ptr %56, ptr %6, align 8
  store i32 1, ptr %15, align 4
  br label %74

70:                                               ; preds = %68, %55
  %71 = landingpad { ptr, i32 }
          cleanup
  %72 = extractvalue { ptr, i32 } %71, 0
  store ptr %72, ptr %12, align 8
  %73 = extractvalue { ptr, i32 } %71, 1
  store i32 %73, ptr %13, align 4
  call void @_ZdlPvm(ptr noundef %56, i64 noundef 24) #6
  br label %75

74:                                               ; preds = %69, %50
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #7
  br label %76

75:                                               ; preds = %70, %51
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #7
  br label %78

76:                                               ; preds = %74, %23
  %77 = load ptr, ptr %6, align 8
  ret ptr %77

78:                                               ; preds = %75, %24
  %79 = load ptr, ptr %12, align 8
  %80 = load i32, ptr %13, align 4
  %81 = insertvalue { ptr, i32 } poison, ptr %79, 0
  %82 = insertvalue { ptr, i32 } %81, i32 %80, 1
  resume { ptr, i32 } %82
}

attributes #0 = { nobuiltin allocsize(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 = { 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 = { nobuiltin nounwind "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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 #5 = { builtin allocsize(0) }
attributes #6 = { builtin nounwind }
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)"}
!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, !10, i64 8}
!12 = !{!"_ZTS4node", !6, i64 0, !10, i64 8, !10, i64 16}
!13 = !{!12, !10, i64 16}


; 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: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4nodeC2Ei(ptr noundef nonnull align 8 dereferenceable(24), i32 noundef) unnamed_addr #1 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4nodeC2EPS_S0_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef, ptr noundef) unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef nonnull ptr @_Z6updateiiP4nodeii(i32 noundef %0, i32 noundef %1, ptr nocapture noundef readonly %2, i32 noundef %3, i32 noundef %4) local_unnamed_addr #3 personality ptr @__gxx_personality_v0 {
  %6 = add nsw i32 %3, 1
  %7 = icmp eq i32 %6, %4
  br i1 %7, label %8, label %10

8:                                                ; preds = %5
  %9 = tail call noalias noundef nonnull dereferenceable(24) ptr @_Znwm(i64 noundef 24) #4
  tail call void @_ZN4nodeC2Ei(ptr noundef nonnull align 8 dereferenceable(24) %9, i32 noundef %1)
  br label %32

10:                                               ; preds = %5
  %11 = add nsw i32 %4, %3
  %12 = ashr i32 %11, 1
  %13 = icmp sgt i32 %12, %0
  %14 = tail call noalias noundef nonnull dereferenceable(24) ptr @_Znwm(i64 noundef 24) #4
  %15 = getelementptr inbounds i8, ptr %2, i64 8
  %16 = load ptr, ptr %15, align 8, !tbaa !5
  br i1 %13, label %17, label %24

17:                                               ; preds = %10
  %18 = invoke noundef ptr @_Z6updateiiP4nodeii(i32 noundef %0, i32 noundef %1, ptr noundef %16, i32 noundef %3, i32 noundef %12)
          to label %19 unwind label %22

19:                                               ; preds = %17
  %20 = getelementptr inbounds i8, ptr %2, i64 16
  %21 = load ptr, ptr %20, align 8, !tbaa !11
  tail call void @_ZN4nodeC2EPS_S0_(ptr noundef nonnull align 8 dereferenceable(24) %14, ptr noundef nonnull %18, ptr noundef %21)
  br label %32

22:                                               ; preds = %17
  %23 = landingpad { ptr, i32 }
          cleanup
  br label %31

24:                                               ; preds = %10
  %25 = getelementptr inbounds i8, ptr %2, i64 16
  %26 = load ptr, ptr %25, align 8, !tbaa !11
  %27 = invoke noundef ptr @_Z6updateiiP4nodeii(i32 noundef %0, i32 noundef %1, ptr noundef %26, i32 noundef %12, i32 noundef %4)
          to label %28 unwind label %29

28:                                               ; preds = %24
  tail call void @_ZN4nodeC2EPS_S0_(ptr noundef nonnull align 8 dereferenceable(24) %14, ptr noundef %16, ptr noundef nonnull %27)
  br label %32

29:                                               ; preds = %24
  %30 = landingpad { ptr, i32 }
          cleanup
  br label %31

31:                                               ; preds = %29, %22
  %.pn = phi { ptr, i32 } [ %23, %22 ], [ %30, %29 ]
  tail call void @_ZdlPvm(ptr noundef nonnull %14, i64 noundef 24) #5
  resume { ptr, i32 } %.pn

32:                                               ; preds = %19, %28, %8
  %.1 = phi ptr [ %9, %8 ], [ %14, %19 ], [ %14, %28 ]
  ret ptr %.1
}

attributes #0 = { nobuiltin allocsize(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 = { 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 = { nobuiltin nounwind "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 = { builtin allocsize(0) }
attributes #5 = { builtin 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 8}
!6 = !{!"_ZTS4node", !7, i64 0, !10, i64 8, !10, i64 16}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !10, i64 16}


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