; LLVM IR from Tiramisu-Compiler/tiramisu :: 3rdParty/isl (isl_tarjan)

; 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.isl_tarjan_graph = type { i32, ptr, ptr, i32, i32, ptr, i32 }
%struct.isl_tarjan_node = type { i32, i32, i32 }

; Function Attrs: nounwind uwtable
declare dso_local ptr @isl_tarjan_graph_free(ptr noundef) #0

; Function Attrs: nounwind uwtable
define dso_local ptr @isl_tarjan_graph_init(ptr noundef %0, i32 noundef %1, ptr noundef %2, ptr noundef %3) #0 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !9
  store ptr %2, ptr %8, align 8, !tbaa !5
  store ptr %3, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #2
  store ptr null, ptr %11, align 8, !tbaa !5
  %13 = load ptr, ptr %6, align 8, !tbaa !5
  %14 = load i32, ptr %7, align 4, !tbaa !9
  %15 = call ptr @isl_tarjan_graph_alloc(ptr noundef %13, i32 noundef %14)
  store ptr %15, ptr %11, align 8, !tbaa !5
  %16 = load ptr, ptr %11, align 8, !tbaa !5
  %17 = icmp ne ptr %16, null
  br i1 %17, label %19, label %18

18:                                               ; preds = %4
  store ptr null, ptr %5, align 8
  store i32 1, ptr %12, align 4
  br label %52

19:                                               ; preds = %4
  %20 = load i32, ptr %7, align 4, !tbaa !9
  %21 = sub nsw i32 %20, 1
  store i32 %21, ptr %10, align 4, !tbaa !9
  br label %22

22:                                               ; preds = %47, %19
  %23 = load i32, ptr %10, align 4, !tbaa !9
  %24 = icmp sge i32 %23, 0
  br i1 %24, label %25, label %50

25:                                               ; preds = %22
  %26 = load ptr, ptr %11, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.isl_tarjan_graph, ptr %26, i32 0, i32 1
  %28 = load ptr, ptr %27, align 8, !tbaa !11
  %29 = load i32, ptr %10, align 4, !tbaa !9
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds %struct.isl_tarjan_node, ptr %28, i64 %30
  %32 = getelementptr inbounds %struct.isl_tarjan_node, ptr %31, i32 0, i32 0
  %33 = load i32, ptr %32, align 4, !tbaa !13
  %34 = icmp sge i32 %33, 0
  br i1 %34, label %35, label %36

35:                                               ; preds = %25
  br label %47

36:                                               ; preds = %25
  %37 = load ptr, ptr %11, align 8, !tbaa !5
  %38 = load i32, ptr %10, align 4, !tbaa !9
  %39 = load ptr, ptr %8, align 8, !tbaa !5
  %40 = load ptr, ptr %9, align 8, !tbaa !5
  %41 = call i32 @isl_tarjan_components(ptr noundef %37, i32 noundef %38, ptr noundef %39, ptr noundef %40)
  %42 = icmp slt i32 %41, 0
  br i1 %42, label %43, label %46

43:                                               ; preds = %36
  %44 = load ptr, ptr %11, align 8, !tbaa !5
  %45 = call ptr @isl_tarjan_graph_free(ptr noundef %44)
  store ptr %45, ptr %5, align 8
  store i32 1, ptr %12, align 4
  br label %52

46:                                               ; preds = %36
  br label %47

47:                                               ; preds = %46, %35
  %48 = load i32, ptr %10, align 4, !tbaa !9
  %49 = add nsw i32 %48, -1
  store i32 %49, ptr %10, align 4, !tbaa !9
  br label %22, !llvm.loop !15

50:                                               ; preds = %22
  %51 = load ptr, ptr %11, align 8, !tbaa !5
  store ptr %51, ptr %5, align 8
  store i32 1, ptr %12, align 4
  br label %52

52:                                               ; preds = %50, %43, %18
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #2
  %53 = load ptr, ptr %5, align 8
  ret ptr %53
}

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

; Function Attrs: nounwind uwtable
declare hidden ptr @isl_tarjan_graph_alloc(ptr noundef, i32 noundef) #0

; Function Attrs: nounwind uwtable
declare hidden i32 @isl_tarjan_components(ptr noundef, i32 noundef, ptr noundef, ptr noundef) #0

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!"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, !6, i64 8}
!12 = !{!"isl_tarjan_graph", !10, i64 0, !6, i64 8, !6, i64 16, !10, i64 24, !10, i64 28, !6, i64 32, !10, i64 40}
!13 = !{!14, !10, i64 0}
!14 = !{!"isl_tarjan_node", !10, i64 0, !10, i64 4, !10, i64 8}
!15 = distinct !{!15, !16}
!16 = !{!"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"

%struct.isl_tarjan_node = type { i32, i32, i32 }

; Function Attrs: nounwind uwtable
declare dso_local ptr @isl_tarjan_graph_free(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local ptr @isl_tarjan_graph_init(ptr noundef %0, i32 noundef %1, ptr noundef %2, ptr noundef %3) local_unnamed_addr #0 {
  %5 = tail call ptr @isl_tarjan_graph_alloc(ptr noundef %0, i32 noundef %1)
  %.not = icmp eq ptr %5, null
  br i1 %.not, label %.loopexit, label %.preheader

.preheader:                                       ; preds = %4
  %6 = icmp sgt i32 %1, 0
  br i1 %6, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %.preheader
  %7 = getelementptr inbounds i8, ptr %5, i64 8
  %8 = zext nneg i32 %1 to i64
  br label %9

9:                                                ; preds = %.lr.ph, %20
  %indvars.iv = phi i64 [ %8, %.lr.ph ], [ %indvars.iv.next, %20 ]
  %indvars.iv.next = add nsw i64 %indvars.iv, -1
  %10 = load ptr, ptr %7, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.isl_tarjan_node, ptr %10, i64 %indvars.iv.next
  %12 = load i32, ptr %11, align 4, !tbaa !11
  %13 = icmp sgt i32 %12, -1
  br i1 %13, label %20, label %14

14:                                               ; preds = %9
  %15 = trunc nuw nsw i64 %indvars.iv.next to i32
  %16 = tail call i32 @isl_tarjan_components(ptr noundef nonnull %5, i32 noundef %15, ptr noundef %2, ptr noundef %3)
  %17 = icmp slt i32 %16, 0
  br i1 %17, label %18, label %20

18:                                               ; preds = %14
  %19 = tail call ptr @isl_tarjan_graph_free(ptr noundef nonnull %5)
  br label %.loopexit

20:                                               ; preds = %14, %9
  %21 = icmp ugt i64 %indvars.iv, 1
  br i1 %21, label %9, label %.loopexit, !llvm.loop !13

.loopexit:                                        ; preds = %20, %.preheader, %4, %18
  %.014 = phi ptr [ %19, %18 ], [ null, %4 ], [ %5, %.preheader ], [ %5, %20 ]
  ret ptr %.014
}

; Function Attrs: nounwind uwtable
declare hidden ptr @isl_tarjan_graph_alloc(ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden i32 @isl_tarjan_components(ptr noundef, i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

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

!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 = !{!"isl_tarjan_graph", !7, i64 0, !10, i64 8, !10, i64 16, !7, i64 24, !7, i64 28, !10, i64 32, !7, i64 40}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!12, !7, i64 0}
!12 = !{!"isl_tarjan_node", !7, i64 0, !7, i64 4, !7, i64 8}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass