; LLVM IR from siconos/siconos :: externals/lbl/metis4/graph.ll_ (SetUpGraphKway)

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

@.str = external hidden unnamed_addr constant [18 x i8], align 1

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

; Function Attrs: nounwind uwtable
define dso_local void @__SetUpGraphKway(ptr noundef %0, i32 noundef %1, ptr noundef %2, ptr noundef %3) #1 {
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !5
  store ptr %3, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  %10 = load ptr, ptr %5, align 8, !tbaa !5
  call void @__InitGraph(ptr noundef %10)
  %11 = load i32, ptr %6, align 4, !tbaa !9
  %12 = load ptr, ptr %5, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.graphdef, ptr %12, i32 0, i32 2
  store i32 %11, ptr %13, align 8, !tbaa !11
  %14 = load ptr, ptr %7, align 8, !tbaa !5
  %15 = load i32, ptr %6, align 4, !tbaa !9
  %16 = sext i32 %15 to i64
  %17 = getelementptr inbounds i32, ptr %14, i64 %16
  %18 = load i32, ptr %17, align 4, !tbaa !9
  %19 = load ptr, ptr %5, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.graphdef, ptr %19, i32 0, i32 3
  store i32 %18, ptr %20, align 4, !tbaa !13
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.graphdef, ptr %21, i32 0, i32 24
  store i32 1, ptr %22, align 8, !tbaa !14
  %23 = load ptr, ptr %7, align 8, !tbaa !5
  %24 = load ptr, ptr %5, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.graphdef, ptr %24, i32 0, i32 4
  store ptr %23, ptr %25, align 8, !tbaa !15
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.graphdef, ptr %26, i32 0, i32 5
  store ptr null, ptr %27, align 8, !tbaa !16
  %28 = load ptr, ptr %8, align 8, !tbaa !5
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.graphdef, ptr %29, i32 0, i32 7
  store ptr %28, ptr %30, align 8, !tbaa !17
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.graphdef, ptr %31, i32 0, i32 8
  store ptr null, ptr %32, align 8, !tbaa !18
  %33 = load i32, ptr %6, align 4, !tbaa !9
  %34 = mul nsw i32 2, %33
  %35 = call ptr @__idxmalloc(i32 noundef %34, ptr noundef @.str)
  %36 = load ptr, ptr %5, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.graphdef, ptr %36, i32 0, i32 0
  store ptr %35, ptr %37, align 8, !tbaa !19
  %38 = load ptr, ptr %5, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.graphdef, ptr %38, i32 0, i32 0
  %40 = load ptr, ptr %39, align 8, !tbaa !19
  %41 = load ptr, ptr %5, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.graphdef, ptr %41, i32 0, i32 9
  store ptr %40, ptr %42, align 8, !tbaa !20
  %43 = load ptr, ptr %5, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.graphdef, ptr %43, i32 0, i32 0
  %45 = load ptr, ptr %44, align 8, !tbaa !19
  %46 = load i32, ptr %6, align 4, !tbaa !9
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds i32, ptr %45, i64 %47
  %49 = load ptr, ptr %5, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.graphdef, ptr %49, i32 0, i32 11
  store ptr %48, ptr %50, align 8, !tbaa !21
  store i32 0, ptr %9, align 4, !tbaa !9
  br label %51

51:                                               ; preds = %74, %4
  %52 = load i32, ptr %9, align 4, !tbaa !9
  %53 = load i32, ptr %6, align 4, !tbaa !9
  %54 = icmp slt i32 %52, %53
  br i1 %54, label %55, label %77

55:                                               ; preds = %51
  %56 = load ptr, ptr %7, align 8, !tbaa !5
  %57 = load i32, ptr %9, align 4, !tbaa !9
  %58 = add nsw i32 %57, 1
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds i32, ptr %56, i64 %59
  %61 = load i32, ptr %60, align 4, !tbaa !9
  %62 = load ptr, ptr %7, align 8, !tbaa !5
  %63 = load i32, ptr %9, align 4, !tbaa !9
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds i32, ptr %62, i64 %64
  %66 = load i32, ptr %65, align 4, !tbaa !9
  %67 = sub nsw i32 %61, %66
  %68 = load ptr, ptr %5, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.graphdef, ptr %68, i32 0, i32 9
  %70 = load ptr, ptr %69, align 8, !tbaa !20
  %71 = load i32, ptr %9, align 4, !tbaa !9
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds i32, ptr %70, i64 %72
  store i32 %67, ptr %73, align 4, !tbaa !9
  br label %74

74:                                               ; preds = %55
  %75 = load i32, ptr %9, align 4, !tbaa !9
  %76 = add nsw i32 %75, 1
  store i32 %76, ptr %9, align 4, !tbaa !9
  br label %51, !llvm.loop !22

77:                                               ; preds = %51
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  ret void
}

declare void @__InitGraph(ptr noundef) #2

declare ptr @__idxmalloc(i32 noundef, ptr noundef) #2

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { "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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 16}
!12 = !{!"graphdef", !6, i64 0, !6, i64 8, !10, i64 16, !10, i64 20, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !10, i64 88, !10, i64 92, !6, i64 96, !6, i64 104, !10, i64 112, !6, i64 120, !6, i64 128, !6, i64 136, !6, i64 144, !6, i64 152, !6, i64 160, !6, i64 168, !10, i64 176, !6, i64 184, !6, i64 192, !6, i64 200, !6, i64 208}
!13 = !{!12, !10, i64 20}
!14 = !{!12, !10, i64 176}
!15 = !{!12, !6, i64 24}
!16 = !{!12, !6, i64 32}
!17 = !{!12, !6, i64 48}
!18 = !{!12, !6, i64 56}
!19 = !{!12, !6, i64 0}
!20 = !{!12, !6, i64 64}
!21 = !{!12, !6, i64 80}
!22 = distinct !{!22, !23}
!23 = !{!"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"

@.str = external hidden unnamed_addr constant [18 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @__SetUpGraphKway(ptr noundef %0, i32 noundef %1, ptr noundef %2, ptr noundef %3) local_unnamed_addr #0 {
  tail call void @__InitGraph(ptr noundef %0) #2
  %5 = getelementptr inbounds i8, ptr %0, i64 16
  store i32 %1, ptr %5, align 8, !tbaa !5
  %6 = sext i32 %1 to i64
  %7 = getelementptr inbounds i32, ptr %2, i64 %6
  %8 = load i32, ptr %7, align 4, !tbaa !11
  %9 = getelementptr inbounds i8, ptr %0, i64 20
  store i32 %8, ptr %9, align 4, !tbaa !12
  %10 = getelementptr inbounds i8, ptr %0, i64 176
  store i32 1, ptr %10, align 8, !tbaa !13
  %11 = getelementptr inbounds i8, ptr %0, i64 24
  store ptr %2, ptr %11, align 8, !tbaa !14
  %12 = getelementptr inbounds i8, ptr %0, i64 32
  store ptr null, ptr %12, align 8, !tbaa !15
  %13 = getelementptr inbounds i8, ptr %0, i64 48
  store ptr %3, ptr %13, align 8, !tbaa !16
  %14 = getelementptr inbounds i8, ptr %0, i64 56
  store ptr null, ptr %14, align 8, !tbaa !17
  %15 = shl nsw i32 %1, 1
  %16 = tail call ptr @__idxmalloc(i32 noundef %15, ptr noundef nonnull @.str) #2
  store ptr %16, ptr %0, align 8, !tbaa !18
  %17 = getelementptr inbounds i8, ptr %0, i64 64
  store ptr %16, ptr %17, align 8, !tbaa !19
  %18 = getelementptr inbounds i32, ptr %16, i64 %6
  %19 = getelementptr inbounds i8, ptr %0, i64 80
  store ptr %18, ptr %19, align 8, !tbaa !20
  %20 = icmp sgt i32 %1, 0
  br i1 %20, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %4
  %wide.trip.count = zext nneg i32 %1 to i64
  %min.iters.check = icmp ult i32 %1, 12
  br i1 %min.iters.check, label %.lr.ph.preheader34, label %vector.memcheck

vector.memcheck:                                  ; preds = %.lr.ph.preheader
  %21 = shl nuw nsw i64 %wide.trip.count, 2
  %scevgep = getelementptr i8, ptr %16, i64 %21
  %22 = getelementptr i8, ptr %2, i64 %21
  %scevgep30 = getelementptr i8, ptr %22, i64 4
  %bound0 = icmp ult ptr %16, %scevgep30
  %bound1 = icmp ugt ptr %scevgep, %2
  %found.conflict = and i1 %bound0, %bound1
  br i1 %found.conflict, label %.lr.ph.preheader34, label %vector.ph

vector.ph:                                        ; preds = %vector.memcheck
  %n.vec = and i64 %wide.trip.count, 2147483640
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %23 = or disjoint i64 %index, 1
  %24 = getelementptr inbounds i32, ptr %2, i64 %23
  %25 = getelementptr inbounds i8, ptr %24, i64 16
  %wide.load = load <4 x i32>, ptr %24, align 4, !tbaa !11, !alias.scope !21
  %wide.load31 = load <4 x i32>, ptr %25, align 4, !tbaa !11, !alias.scope !21
  %26 = getelementptr inbounds i32, ptr %2, i64 %index
  %27 = getelementptr inbounds i8, ptr %26, i64 16
  %wide.load32 = load <4 x i32>, ptr %26, align 4, !tbaa !11, !alias.scope !21
  %wide.load33 = load <4 x i32>, ptr %27, align 4, !tbaa !11, !alias.scope !21
  %28 = sub nsw <4 x i32> %wide.load, %wide.load32
  %29 = sub nsw <4 x i32> %wide.load31, %wide.load33
  %30 = getelementptr inbounds i32, ptr %16, i64 %index
  %31 = getelementptr inbounds i8, ptr %30, i64 16
  store <4 x i32> %28, ptr %30, align 4, !tbaa !11, !alias.scope !24, !noalias !21
  store <4 x i32> %29, ptr %31, align 4, !tbaa !11, !alias.scope !24, !noalias !21
  %index.next = add nuw i64 %index, 8
  %32 = icmp eq i64 %index.next, %n.vec
  br i1 %32, label %middle.block, label %vector.body, !llvm.loop !26

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %n.vec, %wide.trip.count
  br i1 %cmp.n, label %._crit_edge, label %.lr.ph.preheader34

.lr.ph.preheader34:                               ; preds = %middle.block, %vector.memcheck, %.lr.ph.preheader
  %indvars.iv.ph = phi i64 [ 0, %vector.memcheck ], [ 0, %.lr.ph.preheader ], [ %n.vec, %middle.block ]
  %xtraiter = and i64 %wide.trip.count, 3
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.lr.ph.prol.loopexit, label %.lr.ph.prol

.lr.ph.prol:                                      ; preds = %.lr.ph.preheader34, %.lr.ph.prol
  %indvars.iv.prol = phi i64 [ %indvars.iv.next.prol, %.lr.ph.prol ], [ %indvars.iv.ph, %.lr.ph.preheader34 ]
  %prol.iter = phi i64 [ %prol.iter.next, %.lr.ph.prol ], [ 0, %.lr.ph.preheader34 ]
  %indvars.iv.next.prol = add nuw nsw i64 %indvars.iv.prol, 1
  %33 = getelementptr inbounds i32, ptr %2, i64 %indvars.iv.next.prol
  %34 = load i32, ptr %33, align 4, !tbaa !11
  %35 = getelementptr inbounds i32, ptr %2, i64 %indvars.iv.prol
  %36 = load i32, ptr %35, align 4, !tbaa !11
  %37 = sub nsw i32 %34, %36
  %38 = getelementptr inbounds i32, ptr %16, i64 %indvars.iv.prol
  store i32 %37, ptr %38, align 4, !tbaa !11
  %prol.iter.next = add i64 %prol.iter, 1
  %prol.iter.cmp.not = icmp eq i64 %prol.iter.next, %xtraiter
  br i1 %prol.iter.cmp.not, label %.lr.ph.prol.loopexit, label %.lr.ph.prol, !llvm.loop !30

.lr.ph.prol.loopexit:                             ; preds = %.lr.ph.prol, %.lr.ph.preheader34
  %indvars.iv.unr = phi i64 [ %indvars.iv.ph, %.lr.ph.preheader34 ], [ %indvars.iv.next.prol, %.lr.ph.prol ]
  %39 = sub nsw i64 %indvars.iv.ph, %wide.trip.count
  %40 = icmp ugt i64 %39, -4
  br i1 %40, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.prol.loopexit, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next.3, %.lr.ph ], [ %indvars.iv.unr, %.lr.ph.prol.loopexit ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %41 = getelementptr inbounds i32, ptr %2, i64 %indvars.iv.next
  %42 = load i32, ptr %41, align 4, !tbaa !11
  %43 = getelementptr inbounds i32, ptr %2, i64 %indvars.iv
  %44 = load i32, ptr %43, align 4, !tbaa !11
  %45 = sub nsw i32 %42, %44
  %46 = getelementptr inbounds i32, ptr %16, i64 %indvars.iv
  store i32 %45, ptr %46, align 4, !tbaa !11
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %47 = getelementptr inbounds i32, ptr %2, i64 %indvars.iv.next.1
  %48 = load i32, ptr %47, align 4, !tbaa !11
  %49 = getelementptr inbounds i32, ptr %2, i64 %indvars.iv.next
  %50 = load i32, ptr %49, align 4, !tbaa !11
  %51 = sub nsw i32 %48, %50
  %52 = getelementptr inbounds i32, ptr %16, i64 %indvars.iv.next
  store i32 %51, ptr %52, align 4, !tbaa !11
  %indvars.iv.next.2 = add nuw nsw i64 %indvars.iv, 3
  %53 = getelementptr inbounds i32, ptr %2, i64 %indvars.iv.next.2
  %54 = load i32, ptr %53, align 4, !tbaa !11
  %55 = getelementptr inbounds i32, ptr %2, i64 %indvars.iv.next.1
  %56 = load i32, ptr %55, align 4, !tbaa !11
  %57 = sub nsw i32 %54, %56
  %58 = getelementptr inbounds i32, ptr %16, i64 %indvars.iv.next.1
  store i32 %57, ptr %58, align 4, !tbaa !11
  %indvars.iv.next.3 = add nuw nsw i64 %indvars.iv, 4
  %59 = getelementptr inbounds i32, ptr %2, i64 %indvars.iv.next.3
  %60 = load i32, ptr %59, align 4, !tbaa !11
  %61 = getelementptr inbounds i32, ptr %2, i64 %indvars.iv.next.2
  %62 = load i32, ptr %61, align 4, !tbaa !11
  %63 = sub nsw i32 %60, %62
  %64 = getelementptr inbounds i32, ptr %16, i64 %indvars.iv.next.2
  store i32 %63, ptr %64, align 4, !tbaa !11
  %exitcond.not.3 = icmp eq i64 %indvars.iv.next.3, %wide.trip.count
  br i1 %exitcond.not.3, label %._crit_edge, label %.lr.ph, !llvm.loop !32

._crit_edge:                                      ; preds = %.lr.ph.prol.loopexit, %.lr.ph, %middle.block, %4
  ret void
}

declare void @__InitGraph(ptr noundef) local_unnamed_addr #1

declare ptr @__idxmalloc(i32 noundef, ptr noundef) local_unnamed_addr #1

attributes #0 = { 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 #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 }

!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 16}
!6 = !{!"graphdef", !7, i64 0, !7, i64 8, !10, i64 16, !10, i64 20, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !7, i64 56, !7, i64 64, !7, i64 72, !7, i64 80, !10, i64 88, !10, i64 92, !7, i64 96, !7, i64 104, !10, i64 112, !7, i64 120, !7, i64 128, !7, i64 136, !7, i64 144, !7, i64 152, !7, i64 160, !7, i64 168, !10, i64 176, !7, i64 184, !7, i64 192, !7, i64 200, !7, i64 208}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!10, !10, i64 0}
!12 = !{!6, !10, i64 20}
!13 = !{!6, !10, i64 176}
!14 = !{!6, !7, i64 24}
!15 = !{!6, !7, i64 32}
!16 = !{!6, !7, i64 48}
!17 = !{!6, !7, i64 56}
!18 = !{!6, !7, i64 0}
!19 = !{!6, !7, i64 64}
!20 = !{!6, !7, i64 80}
!21 = !{!22}
!22 = distinct !{!22, !23}
!23 = distinct !{!23, !"LVerDomain"}
!24 = !{!25}
!25 = distinct !{!25, !23}
!26 = distinct !{!26, !27, !28, !29}
!27 = !{!"llvm.loop.mustprogress"}
!28 = !{!"llvm.loop.isvectorized", i32 1}
!29 = !{!"llvm.loop.unroll.runtime.disable"}
!30 = distinct !{!30, !31}
!31 = !{!"llvm.loop.unroll.disable"}
!32 = distinct !{!32, !27, !28}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,SROAPass,SimplifyCFGPass,TailCallElimPass