; LLVM IR from Discngine/fpocket :: src (pocket)

; 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.c_lst_pockets = type { ptr, ptr, ptr, i64, ptr }
%struct.node_pocket = type { ptr, ptr, ptr }
%struct.s_pocket = type { ptr, ptr, float, float, float, float, [3 x float], i32, i32, i32, i32 }
%struct.c_lst_vertices = type { ptr, ptr, ptr, i64 }
%struct.node_vertice = type { ptr, ptr, ptr }
%struct.s_vvertice = type { i32, i32, i32, i32, i32, float, float, float, float, i32, i32, [4 x i32], [4 x ptr], [3 x float], float }

; 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: nounwind uwtable
define dso_local void @set_pockets_bary(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca float, align 4
  %6 = alloca float, align 4
  %7 = alloca float, align 4
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #2
  store ptr null, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #2
  store ptr null, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #2
  %10 = load ptr, ptr %2, align 8, !tbaa !5
  %11 = icmp ne ptr %10, null
  br i1 %11, label %12, label %89

12:                                               ; preds = %1
  %13 = load ptr, ptr %2, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.c_lst_pockets, ptr %13, i32 0, i32 3
  %15 = load i64, ptr %14, align 8, !tbaa !9
  %16 = icmp ugt i64 %15, 0
  br i1 %16, label %17, label %89

17:                                               ; preds = %12
  %18 = load ptr, ptr %2, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.c_lst_pockets, ptr %18, i32 0, i32 0
  %20 = load ptr, ptr %19, align 8, !tbaa !12
  store ptr %20, ptr %3, align 8, !tbaa !5
  br label %21

21:                                               ; preds = %63, %17
  %22 = load ptr, ptr %3, align 8, !tbaa !5
  %23 = icmp ne ptr %22, null
  br i1 %23, label %24, label %88

24:                                               ; preds = %21
  %25 = load ptr, ptr %3, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.node_pocket, ptr %25, i32 0, i32 2
  %27 = load ptr, ptr %26, align 8, !tbaa !13
  store ptr %27, ptr %4, align 8, !tbaa !5
  store float 0.000000e+00, ptr %5, align 4, !tbaa !15
  store float 0.000000e+00, ptr %6, align 4, !tbaa !15
  store float 0.000000e+00, ptr %7, align 4, !tbaa !15
  store i32 0, ptr %8, align 4, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #2
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.s_pocket, ptr %28, i32 0, i32 1
  %30 = load ptr, ptr %29, align 8, !tbaa !19
  %31 = getelementptr inbounds %struct.c_lst_vertices, ptr %30, i32 0, i32 0
  %32 = load ptr, ptr %31, align 8, !tbaa !21
  store ptr %32, ptr %9, align 8, !tbaa !5
  br label %33

33:                                               ; preds = %36, %24
  %34 = load ptr, ptr %9, align 8, !tbaa !5
  %35 = icmp ne ptr %34, null
  br i1 %35, label %36, label %63

36:                                               ; preds = %33
  %37 = load ptr, ptr %9, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.node_vertice, ptr %37, i32 0, i32 2
  %39 = load ptr, ptr %38, align 8, !tbaa !23
  %40 = getelementptr inbounds %struct.s_vvertice, ptr %39, i32 0, i32 6
  %41 = load float, ptr %40, align 8, !tbaa !25
  %42 = load float, ptr %5, align 4, !tbaa !15
  %43 = fadd float %42, %41
  store float %43, ptr %5, align 4, !tbaa !15
  %44 = load ptr, ptr %9, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.node_vertice, ptr %44, i32 0, i32 2
  %46 = load ptr, ptr %45, align 8, !tbaa !23
  %47 = getelementptr inbounds %struct.s_vvertice, ptr %46, i32 0, i32 7
  %48 = load float, ptr %47, align 4, !tbaa !27
  %49 = load float, ptr %6, align 4, !tbaa !15
  %50 = fadd float %49, %48
  store float %50, ptr %6, align 4, !tbaa !15
  %51 = load ptr, ptr %9, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.node_vertice, ptr %51, i32 0, i32 2
  %53 = load ptr, ptr %52, align 8, !tbaa !23
  %54 = getelementptr inbounds %struct.s_vvertice, ptr %53, i32 0, i32 8
  %55 = load float, ptr %54, align 8, !tbaa !28
  %56 = load float, ptr %7, align 4, !tbaa !15
  %57 = fadd float %56, %55
  store float %57, ptr %7, align 4, !tbaa !15
  %58 = load i32, ptr %8, align 4, !tbaa !17
  %59 = add nsw i32 %58, 1
  store i32 %59, ptr %8, align 4, !tbaa !17
  %60 = load ptr, ptr %9, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.node_vertice, ptr %60, i32 0, i32 0
  %62 = load ptr, ptr %61, align 8, !tbaa !29
  store ptr %62, ptr %9, align 8, !tbaa !5
  br label %33, !llvm.loop !30

63:                                               ; preds = %33
  %64 = load float, ptr %5, align 4, !tbaa !15
  %65 = load i32, ptr %8, align 4, !tbaa !17
  %66 = sitofp i32 %65 to float
  %67 = fdiv float %64, %66
  %68 = load ptr, ptr %4, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.s_pocket, ptr %68, i32 0, i32 6
  %70 = getelementptr inbounds [3 x float], ptr %69, i64 0, i64 0
  store float %67, ptr %70, align 8, !tbaa !15
  %71 = load float, ptr %6, align 4, !tbaa !15
  %72 = load i32, ptr %8, align 4, !tbaa !17
  %73 = sitofp i32 %72 to float
  %74 = fdiv float %71, %73
  %75 = load ptr, ptr %4, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.s_pocket, ptr %75, i32 0, i32 6
  %77 = getelementptr inbounds [3 x float], ptr %76, i64 0, i64 1
  store float %74, ptr %77, align 4, !tbaa !15
  %78 = load float, ptr %7, align 4, !tbaa !15
  %79 = load i32, ptr %8, align 4, !tbaa !17
  %80 = sitofp i32 %79 to float
  %81 = fdiv float %78, %80
  %82 = load ptr, ptr %4, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.s_pocket, ptr %82, i32 0, i32 6
  %84 = getelementptr inbounds [3 x float], ptr %83, i64 0, i64 2
  store float %81, ptr %84, align 8, !tbaa !15
  %85 = load ptr, ptr %3, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.node_pocket, ptr %85, i32 0, i32 0
  %87 = load ptr, ptr %86, align 8, !tbaa !32
  store ptr %87, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #2
  br label %21, !llvm.loop !33

88:                                               ; preds = %21
  br label %89

89:                                               ; preds = %88, %12, %1
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #2
  ret void
}

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 = { 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 24}
!10 = !{!"c_lst_pockets", !6, i64 0, !6, i64 8, !6, i64 16, !11, i64 24, !6, i64 32}
!11 = !{!"long", !7, i64 0}
!12 = !{!10, !6, i64 0}
!13 = !{!14, !6, i64 16}
!14 = !{!"node_pocket", !6, i64 0, !6, i64 8, !6, i64 16}
!15 = !{!16, !16, i64 0}
!16 = !{!"float", !7, i64 0}
!17 = !{!18, !18, i64 0}
!18 = !{!"int", !7, i64 0}
!19 = !{!20, !6, i64 8}
!20 = !{!"s_pocket", !6, i64 0, !6, i64 8, !16, i64 16, !16, i64 20, !16, i64 24, !16, i64 28, !7, i64 32, !18, i64 44, !18, i64 48, !18, i64 52, !18, i64 56}
!21 = !{!22, !6, i64 0}
!22 = !{!"c_lst_vertices", !6, i64 0, !6, i64 8, !6, i64 16, !11, i64 24}
!23 = !{!24, !6, i64 16}
!24 = !{!"node_vertice", !6, i64 0, !6, i64 8, !6, i64 16}
!25 = !{!26, !16, i64 24}
!26 = !{!"s_vvertice", !18, i64 0, !18, i64 4, !18, i64 8, !18, i64 12, !18, i64 16, !16, i64 20, !16, i64 24, !16, i64 28, !16, i64 32, !18, i64 36, !18, i64 40, !7, i64 44, !7, i64 64, !7, i64 96, !16, i64 108}
!27 = !{!26, !16, i64 28}
!28 = !{!26, !16, i64 32}
!29 = !{!24, !6, i64 0}
!30 = distinct !{!30, !31}
!31 = !{!"llvm.loop.mustprogress"}
!32 = !{!14, !6, i64 0}
!33 = distinct !{!33, !31}


; 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: nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) uwtable
define dso_local void @set_pockets_bary(ptr noundef readonly %0) local_unnamed_addr #0 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %.loopexit, label %2

2:                                                ; preds = %1
  %3 = getelementptr inbounds i8, ptr %0, i64 24
  %4 = load i64, ptr %3, align 8, !tbaa !5
  %.not30 = icmp eq i64 %4, 0
  br i1 %.not30, label %.loopexit, label %.preheader

.preheader:                                       ; preds = %2
  %.02843 = load ptr, ptr %0, align 8, !tbaa !11
  %.not3144 = icmp eq ptr %.02843, null
  br i1 %.not3144, label %.loopexit, label %.lr.ph46

.lr.ph46:                                         ; preds = %.preheader, %._crit_edge
  %.02845 = phi ptr [ %.028, %._crit_edge ], [ %.02843, %.preheader ]
  %5 = getelementptr inbounds i8, ptr %.02845, i64 16
  %6 = load ptr, ptr %5, align 8, !tbaa !12
  %7 = getelementptr inbounds i8, ptr %6, i64 8
  %8 = load ptr, ptr %7, align 8, !tbaa !14
  %.033 = load ptr, ptr %8, align 8, !tbaa !11
  %.not3234 = icmp eq ptr %.033, null
  br i1 %.not3234, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph46, %.lr.ph
  %.039 = phi ptr [ %.0, %.lr.ph ], [ %.033, %.lr.ph46 ]
  %.02438 = phi i32 [ %18, %.lr.ph ], [ 0, %.lr.ph46 ]
  %.02537 = phi float [ %17, %.lr.ph ], [ 0.000000e+00, %.lr.ph46 ]
  %9 = phi <2 x float> [ %14, %.lr.ph ], [ zeroinitializer, %.lr.ph46 ]
  %10 = getelementptr inbounds i8, ptr %.039, i64 16
  %11 = load ptr, ptr %10, align 8, !tbaa !18
  %12 = getelementptr inbounds i8, ptr %11, i64 24
  %13 = load <2 x float>, ptr %12, align 8, !tbaa !20
  %14 = fadd <2 x float> %9, %13
  %15 = getelementptr inbounds i8, ptr %11, i64 32
  %16 = load float, ptr %15, align 8, !tbaa !21
  %17 = fadd float %.02537, %16
  %18 = add nuw nsw i32 %.02438, 1
  %.0 = load ptr, ptr %.039, align 8, !tbaa !11
  %.not32 = icmp eq ptr %.0, null
  br i1 %.not32, label %._crit_edge, label %.lr.ph, !llvm.loop !23

._crit_edge:                                      ; preds = %.lr.ph, %.lr.ph46
  %.025.lcssa = phi float [ 0.000000e+00, %.lr.ph46 ], [ %17, %.lr.ph ]
  %.024.lcssa = phi i32 [ 0, %.lr.ph46 ], [ %18, %.lr.ph ]
  %19 = phi <2 x float> [ zeroinitializer, %.lr.ph46 ], [ %14, %.lr.ph ]
  %20 = uitofp nneg i32 %.024.lcssa to float
  %21 = getelementptr inbounds i8, ptr %6, i64 32
  %22 = insertelement <2 x float> poison, float %20, i64 0
  %23 = shufflevector <2 x float> %22, <2 x float> poison, <2 x i32> zeroinitializer
  %24 = fdiv <2 x float> %19, %23
  store <2 x float> %24, ptr %21, align 8, !tbaa !20
  %25 = fdiv float %.025.lcssa, %20
  %26 = getelementptr inbounds i8, ptr %6, i64 40
  store float %25, ptr %26, align 8, !tbaa !20
  %.028 = load ptr, ptr %.02845, align 8, !tbaa !11
  %.not31 = icmp eq ptr %.028, null
  br i1 %.not31, label %.loopexit, label %.lr.ph46, !llvm.loop !25

.loopexit:                                        ; preds = %._crit_edge, %.preheader, %2, %1
  ret void
}

attributes #0 = { nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) 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 24}
!6 = !{!"c_lst_pockets", !7, i64 0, !7, i64 8, !7, i64 16, !10, i64 24, !7, i64 32}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!7, !7, i64 0}
!12 = !{!13, !7, i64 16}
!13 = !{!"node_pocket", !7, i64 0, !7, i64 8, !7, i64 16}
!14 = !{!15, !7, i64 8}
!15 = !{!"s_pocket", !7, i64 0, !7, i64 8, !16, i64 16, !16, i64 20, !16, i64 24, !16, i64 28, !8, i64 32, !17, i64 44, !17, i64 48, !17, i64 52, !17, i64 56}
!16 = !{!"float", !8, i64 0}
!17 = !{!"int", !8, i64 0}
!18 = !{!19, !7, i64 16}
!19 = !{!"node_vertice", !7, i64 0, !7, i64 8, !7, i64 16}
!20 = !{!16, !16, i64 0}
!21 = !{!22, !16, i64 32}
!22 = !{!"s_vvertice", !17, i64 0, !17, i64 4, !17, i64 8, !17, i64 12, !17, i64 16, !16, i64 20, !16, i64 24, !16, i64 28, !16, i64 32, !17, i64 36, !17, i64 40, !8, i64 44, !8, i64 64, !8, i64 96, !16, i64 108}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}
!25 = distinct !{!25, !24}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass