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

; 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.s_fparams = type { [2000 x i8], [2000 x i8], [2000 x i8], [8000 x i8], ptr, ptr, ptr, i32, i32, ptr, ptr, ptr, i8, i8, i32, i32, i16, i32, i32, i32, i16, i32, i32, i32, i16, float, float, float, float, float, [20 x ptr], i16, i16, [20 x ptr], i32, [10 x i8] }

@stderr = external global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [35 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
declare i32 @fprintf(ptr 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

declare void @dropPocket(ptr noundef, ptr noundef) #2

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

10:                                               ; preds = %40, %2
  %11 = load ptr, ptr %5, align 8, !tbaa !5
  %12 = icmp ne ptr %11, null
  br i1 %12, label %13, label %42

13:                                               ; preds = %10
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.node_pocket, ptr %14, i32 0, i32 0
  %16 = load ptr, ptr %15, align 8, !tbaa !12
  store ptr %16, ptr %6, align 8, !tbaa !5
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.node_pocket, ptr %17, i32 0, i32 2
  %19 = load ptr, ptr %18, align 8, !tbaa !14
  %20 = getelementptr inbounds %struct.s_pocket, ptr %19, i32 0, i32 1
  %21 = load ptr, ptr %20, align 8, !tbaa !15
  %22 = getelementptr inbounds %struct.c_lst_vertices, ptr %21, i32 0, i32 3
  %23 = load i64, ptr %22, align 8, !tbaa !19
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.s_fparams, ptr %24, i32 0, i32 24
  %26 = load i16, ptr %25, align 4, !tbaa !21
  %27 = zext i16 %26 to i64
  %28 = icmp ult i64 %23, %27
  br i1 %28, label %29, label %32

29:                                               ; preds = %13
  %30 = load ptr, ptr %3, align 8, !tbaa !5
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  call void @dropPocket(ptr noundef %30, ptr noundef %31)
  br label %32

32:                                               ; preds = %29, %13
  %33 = load ptr, ptr %3, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.c_lst_pockets, ptr %33, i32 0, i32 3
  %35 = load i64, ptr %34, align 8, !tbaa !24
  %36 = icmp ule i64 %35, 0
  br i1 %36, label %37, label %40

37:                                               ; preds = %32
  %38 = load ptr, ptr @stderr, align 8, !tbaa !5
  %39 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %38, ptr noundef @.str.1) #4
  br label %40

40:                                               ; preds = %37, %32
  %41 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %41, ptr %5, align 8, !tbaa !5
  br label %10, !llvm.loop !25

42:                                               ; preds = %10
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 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 = { 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, !6, i64 0}
!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 = !{!13, !6, i64 0}
!13 = !{!"node_pocket", !6, i64 0, !6, i64 8, !6, i64 16}
!14 = !{!13, !6, i64 16}
!15 = !{!16, !6, i64 8}
!16 = !{!"s_pocket", !6, i64 0, !6, i64 8, !17, i64 16, !17, i64 20, !17, i64 24, !17, i64 28, !7, i64 32, !18, i64 44, !18, i64 48, !18, i64 52, !18, i64 56}
!17 = !{!"float", !7, i64 0}
!18 = !{!"int", !7, i64 0}
!19 = !{!20, !11, i64 24}
!20 = !{!"c_lst_vertices", !6, i64 0, !6, i64 8, !6, i64 16, !11, i64 24}
!21 = !{!22, !23, i64 14100}
!22 = !{!"s_fparams", !7, i64 0, !7, i64 2000, !7, i64 4000, !7, i64 6000, !6, i64 14000, !6, i64 14008, !6, i64 14016, !18, i64 14024, !18, i64 14028, !6, i64 14032, !6, i64 14040, !6, i64 14048, !7, i64 14056, !7, i64 14057, !18, i64 14060, !18, i64 14064, !23, i64 14068, !18, i64 14072, !18, i64 14076, !18, i64 14080, !23, i64 14084, !18, i64 14088, !18, i64 14092, !18, i64 14096, !23, i64 14100, !17, i64 14104, !17, i64 14108, !17, i64 14112, !17, i64 14116, !17, i64 14120, !7, i64 14128, !23, i64 14288, !23, i64 14290, !7, i64 14296, !18, i64 14456, !7, i64 14460}
!23 = !{!"short", !7, i64 0}
!24 = !{!10, !11, i64 24}
!25 = distinct !{!25, !26}
!26 = !{!"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"

@stderr = external local_unnamed_addr global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [35 x i8], align 1

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #0

declare void @dropPocket(ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @drop_tiny(ptr noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #2 {
  %3 = load ptr, ptr %0, align 8, !tbaa !5
  %.not9 = icmp eq ptr %3, null
  br i1 %.not9, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %2
  %4 = getelementptr inbounds i8, ptr %1, i64 14100
  %5 = getelementptr inbounds i8, ptr %0, i64 24
  br label %6

6:                                                ; preds = %.lr.ph, %24
  %.010 = phi ptr [ %3, %.lr.ph ], [ %7, %24 ]
  %7 = load ptr, ptr %.010, align 8, !tbaa !11
  %8 = getelementptr inbounds i8, ptr %.010, i64 16
  %9 = load ptr, ptr %8, align 8, !tbaa !13
  %10 = getelementptr inbounds i8, ptr %9, i64 8
  %11 = load ptr, ptr %10, align 8, !tbaa !14
  %12 = getelementptr inbounds i8, ptr %11, i64 24
  %13 = load i64, ptr %12, align 8, !tbaa !18
  %14 = load i16, ptr %4, align 4, !tbaa !20
  %15 = zext i16 %14 to i64
  %16 = icmp ult i64 %13, %15
  br i1 %16, label %17, label %18

17:                                               ; preds = %6
  tail call void @dropPocket(ptr noundef nonnull %0, ptr noundef nonnull %.010) #3
  br label %18

18:                                               ; preds = %17, %6
  %19 = load i64, ptr %5, align 8, !tbaa !23
  %20 = icmp eq i64 %19, 0
  br i1 %20, label %21, label %24

21:                                               ; preds = %18
  %22 = load ptr, ptr @stderr, align 8, !tbaa !24
  %23 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %22, ptr noundef nonnull @.str.1) #4
  br label %24

24:                                               ; preds = %21, %18
  %.not = icmp eq ptr %7, null
  br i1 %.not, label %._crit_edge, label %6, !llvm.loop !25

._crit_edge:                                      ; preds = %24, %2
  ret void
}

attributes #0 = { nofree 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 #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 }
attributes #4 = { cold 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 0}
!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 = !{!12, !7, i64 0}
!12 = !{!"node_pocket", !7, i64 0, !7, i64 8, !7, i64 16}
!13 = !{!12, !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, !10, i64 24}
!19 = !{!"c_lst_vertices", !7, i64 0, !7, i64 8, !7, i64 16, !10, i64 24}
!20 = !{!21, !22, i64 14100}
!21 = !{!"s_fparams", !8, i64 0, !8, i64 2000, !8, i64 4000, !8, i64 6000, !7, i64 14000, !7, i64 14008, !7, i64 14016, !17, i64 14024, !17, i64 14028, !7, i64 14032, !7, i64 14040, !7, i64 14048, !8, i64 14056, !8, i64 14057, !17, i64 14060, !17, i64 14064, !22, i64 14068, !17, i64 14072, !17, i64 14076, !17, i64 14080, !22, i64 14084, !17, i64 14088, !17, i64 14092, !17, i64 14096, !22, i64 14100, !16, i64 14104, !16, i64 14108, !16, i64 14112, !16, i64 14116, !16, i64 14120, !8, i64 14128, !22, i64 14288, !22, i64 14290, !8, i64 14296, !17, i64 14456, !8, i64 14460}
!22 = !{!"short", !8, i64 0}
!23 = !{!6, !10, i64 24}
!24 = !{!7, !7, i64 0}
!25 = distinct !{!25, !26}
!26 = !{!"llvm.loop.mustprogress"}


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