; LLVM IR from siconos/siconos :: externals/lbl/metis4/pqueue.ll_ (PQueueReset)

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

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

declare ptr @__idxset(i32 noundef, i32 noundef, ptr noundef) #1

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

; Function Attrs: nounwind uwtable
define dso_local void @__PQueueReset(ptr noundef %0) #2 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  %5 = load ptr, ptr %2, align 8, !tbaa !5
  %6 = getelementptr inbounds %struct.PQueueType, ptr %5, i32 0, i32 1
  store i32 0, ptr %6, align 4, !tbaa !9
  %7 = load ptr, ptr %2, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct.PQueueType, ptr %7, i32 0, i32 0
  %9 = load i32, ptr %8, align 8, !tbaa !12
  %10 = icmp eq i32 %9, 1
  br i1 %10, label %11, label %58

11:                                               ; preds = %1
  %12 = load ptr, ptr %2, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.PQueueType, ptr %12, i32 0, i32 5
  %14 = load i32, ptr %13, align 4, !tbaa !13
  %15 = sub nsw i32 0, %14
  %16 = load ptr, ptr %2, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.PQueueType, ptr %16, i32 0, i32 6
  store i32 %15, ptr %17, align 8, !tbaa !14
  %18 = load ptr, ptr %2, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.PQueueType, ptr %18, i32 0, i32 5
  %20 = load i32, ptr %19, align 4, !tbaa !13
  %21 = load ptr, ptr %2, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.PQueueType, ptr %21, i32 0, i32 4
  %23 = load i32, ptr %22, align 8, !tbaa !15
  %24 = add nsw i32 %20, %23
  %25 = add nsw i32 %24, 1
  store i32 %25, ptr %4, align 4, !tbaa !16
  %26 = load ptr, ptr %2, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.PQueueType, ptr %26, i32 0, i32 5
  %28 = load i32, ptr %27, align 4, !tbaa !13
  %29 = load ptr, ptr %2, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.PQueueType, ptr %29, i32 0, i32 8
  %31 = load ptr, ptr %30, align 8, !tbaa !17
  %32 = sext i32 %28 to i64
  %33 = sub i64 0, %32
  %34 = getelementptr inbounds ptr, ptr %31, i64 %33
  store ptr %34, ptr %30, align 8, !tbaa !17
  store i32 0, ptr %3, align 4, !tbaa !16
  br label %35

35:                                               ; preds = %46, %11
  %36 = load i32, ptr %3, align 4, !tbaa !16
  %37 = load i32, ptr %4, align 4, !tbaa !16
  %38 = icmp slt i32 %36, %37
  br i1 %38, label %39, label %49

39:                                               ; preds = %35
  %40 = load ptr, ptr %2, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.PQueueType, ptr %40, i32 0, i32 8
  %42 = load ptr, ptr %41, align 8, !tbaa !17
  %43 = load i32, ptr %3, align 4, !tbaa !16
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds ptr, ptr %42, i64 %44
  store ptr null, ptr %45, align 8, !tbaa !5
  br label %46

46:                                               ; preds = %39
  %47 = load i32, ptr %3, align 4, !tbaa !16
  %48 = add nsw i32 %47, 1
  store i32 %48, ptr %3, align 4, !tbaa !16
  br label %35, !llvm.loop !18

49:                                               ; preds = %35
  %50 = load ptr, ptr %2, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.PQueueType, ptr %50, i32 0, i32 5
  %52 = load i32, ptr %51, align 4, !tbaa !13
  %53 = load ptr, ptr %2, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.PQueueType, ptr %53, i32 0, i32 8
  %55 = load ptr, ptr %54, align 8, !tbaa !17
  %56 = sext i32 %52 to i64
  %57 = getelementptr inbounds ptr, ptr %55, i64 %56
  store ptr %57, ptr %54, align 8, !tbaa !17
  br label %66

58:                                               ; preds = %1
  %59 = load ptr, ptr %2, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.PQueueType, ptr %59, i32 0, i32 2
  %61 = load i32, ptr %60, align 8, !tbaa !20
  %62 = load ptr, ptr %2, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.PQueueType, ptr %62, i32 0, i32 10
  %64 = load ptr, ptr %63, align 8, !tbaa !21
  %65 = call ptr @__idxset(i32 noundef %61, i32 noundef -1, ptr noundef %64)
  br label %66

66:                                               ; preds = %58, %49
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 4}
!10 = !{!"PQueueType", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !11, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !11, i64 0}
!13 = !{!10, !11, i64 20}
!14 = !{!10, !11, i64 24}
!15 = !{!10, !11, i64 16}
!16 = !{!11, !11, i64 0}
!17 = !{!10, !6, i64 40}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = !{!10, !11, i64 8}
!21 = !{!10, !6, i64 56}


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

declare ptr @__idxset(i32 noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @__PQueueReset(ptr nocapture noundef %0) local_unnamed_addr #1 {
  %2 = getelementptr inbounds i8, ptr %0, i64 4
  store i32 0, ptr %2, align 4, !tbaa !5
  %3 = load i32, ptr %0, align 8, !tbaa !11
  %4 = icmp eq i32 %3, 1
  br i1 %4, label %5, label %32

5:                                                ; preds = %1
  %6 = getelementptr inbounds i8, ptr %0, i64 20
  %7 = load i32, ptr %6, align 4, !tbaa !12
  %8 = sub nsw i32 0, %7
  %9 = getelementptr inbounds i8, ptr %0, i64 24
  store i32 %8, ptr %9, align 8, !tbaa !13
  %10 = getelementptr inbounds i8, ptr %0, i64 16
  %11 = load i32, ptr %10, align 8, !tbaa !14
  %12 = add i32 %11, %7
  %13 = getelementptr inbounds i8, ptr %0, i64 40
  %14 = load ptr, ptr %13, align 8, !tbaa !15
  %15 = sext i32 %7 to i64
  %16 = sub nsw i64 0, %15
  %17 = getelementptr inbounds ptr, ptr %14, i64 %16
  store ptr %17, ptr %13, align 8, !tbaa !15
  %.not16 = icmp slt i32 %12, 0
  br i1 %.not16, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %5
  %18 = add nuw i32 %12, 1
  %wide.trip.count = zext i32 %18 to i64
  %xtraiter = and i64 %wide.trip.count, 3
  %19 = icmp ult i32 %12, 3
  br i1 %19, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph.preheader.new

.lr.ph.preheader.new:                             ; preds = %.lr.ph.preheader
  %unroll_iter = and i64 %wide.trip.count, 4294967292
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph, %.lr.ph.preheader.new
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader.new ], [ %indvars.iv.next.3, %.lr.ph ]
  %niter = phi i64 [ 0, %.lr.ph.preheader.new ], [ %niter.next.3, %.lr.ph ]
  %20 = load ptr, ptr %13, align 8, !tbaa !15
  %21 = getelementptr inbounds ptr, ptr %20, i64 %indvars.iv
  store ptr null, ptr %21, align 8, !tbaa !16
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %22 = load ptr, ptr %13, align 8, !tbaa !15
  %23 = getelementptr inbounds ptr, ptr %22, i64 %indvars.iv.next
  store ptr null, ptr %23, align 8, !tbaa !16
  %indvars.iv.next.1 = or disjoint i64 %indvars.iv, 2
  %24 = load ptr, ptr %13, align 8, !tbaa !15
  %25 = getelementptr inbounds ptr, ptr %24, i64 %indvars.iv.next.1
  store ptr null, ptr %25, align 8, !tbaa !16
  %indvars.iv.next.2 = or disjoint i64 %indvars.iv, 3
  %26 = load ptr, ptr %13, align 8, !tbaa !15
  %27 = getelementptr inbounds ptr, ptr %26, i64 %indvars.iv.next.2
  store ptr null, ptr %27, align 8, !tbaa !16
  %indvars.iv.next.3 = add nuw nsw i64 %indvars.iv, 4
  %niter.next.3 = add i64 %niter, 4
  %niter.ncmp.3 = icmp eq i64 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph, !llvm.loop !17

._crit_edge.loopexit.unr-lcssa:                   ; preds = %.lr.ph, %.lr.ph.preheader
  %indvars.iv.unr = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next.3, %.lr.ph ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge.loopexit, label %.lr.ph.epil

.lr.ph.epil:                                      ; preds = %._crit_edge.loopexit.unr-lcssa, %.lr.ph.epil
  %indvars.iv.epil = phi i64 [ %indvars.iv.next.epil, %.lr.ph.epil ], [ %indvars.iv.unr, %._crit_edge.loopexit.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.lr.ph.epil ], [ 0, %._crit_edge.loopexit.unr-lcssa ]
  %28 = load ptr, ptr %13, align 8, !tbaa !15
  %29 = getelementptr inbounds ptr, ptr %28, i64 %indvars.iv.epil
  store ptr null, ptr %29, align 8, !tbaa !16
  %indvars.iv.next.epil = add nuw nsw i64 %indvars.iv.epil, 1
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %._crit_edge.loopexit, label %.lr.ph.epil, !llvm.loop !19

._crit_edge.loopexit:                             ; preds = %.lr.ph.epil, %._crit_edge.loopexit.unr-lcssa
  %.pre = load ptr, ptr %13, align 8, !tbaa !15
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %5
  %30 = phi ptr [ %.pre, %._crit_edge.loopexit ], [ %17, %5 ]
  %31 = getelementptr inbounds ptr, ptr %30, i64 %15
  store ptr %31, ptr %13, align 8, !tbaa !15
  br label %38

32:                                               ; preds = %1
  %33 = getelementptr inbounds i8, ptr %0, i64 8
  %34 = load i32, ptr %33, align 8, !tbaa !21
  %35 = getelementptr inbounds i8, ptr %0, i64 56
  %36 = load ptr, ptr %35, align 8, !tbaa !22
  %37 = tail call ptr @__idxset(i32 noundef %34, i32 noundef -1, ptr noundef %36) #2
  br label %38

38:                                               ; preds = %32, %._crit_edge
  ret void
}

attributes #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 = { 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, !7, i64 4}
!6 = !{!"PQueueType", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !7, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !10, i64 56}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !7, i64 0}
!12 = !{!6, !7, i64 20}
!13 = !{!6, !7, i64 24}
!14 = !{!6, !7, i64 16}
!15 = !{!6, !10, i64 40}
!16 = !{!10, !10, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.unroll.disable"}
!21 = !{!6, !7, i64 8}
!22 = !{!6, !10, i64 56}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass