; 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] }
%struct.s_desc = type { float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, i32, [20 x i32], i32, i32, i32, float, float, i32, i32, i32, i32, i32, [255 x i8], [255 x i8], [8 x i8] }

@stderr = external global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [48 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

; Function Attrs: nounwind uwtable
define dso_local void @dropSmallNpolarPockets(ptr noundef %0, ptr noundef %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca double, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = 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
  store double 0.000000e+00, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  store ptr null, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  store ptr null, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  store ptr null, ptr %8, align 8, !tbaa !5
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = icmp ne ptr %9, null
  br i1 %10, label %11, label %82

11:                                               ; preds = %2
  %12 = load ptr, ptr %3, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.c_lst_pockets, ptr %12, i32 0, i32 0
  %14 = load ptr, ptr %13, align 8, !tbaa !11
  store ptr %14, ptr %6, align 8, !tbaa !5
  br label %15

15:                                               ; preds = %79, %11
  %16 = load ptr, ptr %6, align 8, !tbaa !5
  %17 = icmp ne ptr %16, null
  br i1 %17, label %18, label %81

18:                                               ; preds = %15
  %19 = load ptr, ptr %6, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.node_pocket, ptr %19, i32 0, i32 2
  %21 = load ptr, ptr %20, align 8, !tbaa !14
  store ptr %21, ptr %8, align 8, !tbaa !5
  %22 = load ptr, ptr %6, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.node_pocket, ptr %22, i32 0, i32 0
  %24 = load ptr, ptr %23, align 8, !tbaa !16
  store ptr %24, ptr %7, align 8, !tbaa !5
  %25 = load ptr, ptr %8, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.s_pocket, ptr %25, i32 0, i32 9
  %27 = load i32, ptr %26, align 4, !tbaa !17
  %28 = sitofp i32 %27 to float
  %29 = load ptr, ptr %8, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.s_pocket, ptr %29, i32 0, i32 1
  %31 = load ptr, ptr %30, align 8, !tbaa !21
  %32 = getelementptr inbounds %struct.c_lst_vertices, ptr %31, i32 0, i32 3
  %33 = load i64, ptr %32, align 8, !tbaa !22
  %34 = uitofp i64 %33 to float
  %35 = fdiv float %28, %34
  %36 = fpext float %35 to double
  store double %36, ptr %5, align 8, !tbaa !9
  %37 = load ptr, ptr %8, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.s_pocket, ptr %37, i32 0, i32 1
  %39 = load ptr, ptr %38, align 8, !tbaa !21
  %40 = getelementptr inbounds %struct.c_lst_vertices, ptr %39, i32 0, i32 3
  %41 = load i64, ptr %40, align 8, !tbaa !22
  %42 = load ptr, ptr %4, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.s_fparams, ptr %42, i32 0, i32 24
  %44 = load i16, ptr %43, align 4, !tbaa !24
  %45 = zext i16 %44 to i64
  %46 = icmp ult i64 %41, %45
  br i1 %46, label %68, label %47

47:                                               ; preds = %18
  %48 = load double, ptr %5, align 8, !tbaa !9
  %49 = load ptr, ptr %4, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.s_fparams, ptr %49, i32 0, i32 26
  %51 = load float, ptr %50, align 4, !tbaa !27
  %52 = fcmp une float %51, 0.000000e+00
  br i1 %52, label %63, label %53

53:                                               ; preds = %47
  %54 = load ptr, ptr %8, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.s_pocket, ptr %54, i32 0, i32 0
  %56 = load ptr, ptr %55, align 8, !tbaa !28
  %57 = getelementptr inbounds %struct.s_desc, ptr %56, i32 0, i32 9
  %58 = load float, ptr %57, align 4, !tbaa !29
  %59 = load ptr, ptr %4, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.s_fparams, ptr %59, i32 0, i32 28
  %61 = load float, ptr %60, align 4, !tbaa !31
  %62 = fcmp olt float %58, %61
  br label %63

63:                                               ; preds = %53, %47
  %64 = phi i1 [ true, %47 ], [ %62, %53 ]
  %65 = zext i1 %64 to i32
  %66 = sitofp i32 %65 to double
  %67 = fcmp olt double %48, %66
  br i1 %67, label %68, label %71

68:                                               ; preds = %63, %18
  %69 = load ptr, ptr %3, align 8, !tbaa !5
  %70 = load ptr, ptr %6, align 8, !tbaa !5
  call void @dropPocket(ptr noundef %69, ptr noundef %70)
  br label %71

71:                                               ; preds = %68, %63
  %72 = load ptr, ptr %3, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.c_lst_pockets, ptr %72, i32 0, i32 3
  %74 = load i64, ptr %73, align 8, !tbaa !32
  %75 = icmp ule i64 %74, 0
  br i1 %75, label %76, label %79

76:                                               ; preds = %71
  %77 = load ptr, ptr @stderr, align 8, !tbaa !5
  %78 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %77, ptr noundef @.str.1) #4
  br label %79

79:                                               ; preds = %76, %71
  %80 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %80, ptr %6, align 8, !tbaa !5
  br label %15, !llvm.loop !33

81:                                               ; preds = %15
  br label %86

82:                                               ; preds = %2
  %83 = load ptr, ptr @stderr, align 8, !tbaa !5
  %84 = load ptr, ptr %3, align 8, !tbaa !5
  %85 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %83, ptr noundef @.str.2, ptr noundef %84) #4
  br label %86

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

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

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 = { 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 = { "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, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"c_lst_pockets", !6, i64 0, !6, i64 8, !6, i64 16, !13, i64 24, !6, i64 32}
!13 = !{!"long", !7, i64 0}
!14 = !{!15, !6, i64 16}
!15 = !{!"node_pocket", !6, i64 0, !6, i64 8, !6, i64 16}
!16 = !{!15, !6, i64 0}
!17 = !{!18, !20, i64 52}
!18 = !{!"s_pocket", !6, i64 0, !6, i64 8, !19, i64 16, !19, i64 20, !19, i64 24, !19, i64 28, !7, i64 32, !20, i64 44, !20, i64 48, !20, i64 52, !20, i64 56}
!19 = !{!"float", !7, i64 0}
!20 = !{!"int", !7, i64 0}
!21 = !{!18, !6, i64 8}
!22 = !{!23, !13, i64 24}
!23 = !{!"c_lst_vertices", !6, i64 0, !6, i64 8, !6, i64 16, !13, i64 24}
!24 = !{!25, !26, i64 14100}
!25 = !{!"s_fparams", !7, i64 0, !7, i64 2000, !7, i64 4000, !7, i64 6000, !6, i64 14000, !6, i64 14008, !6, i64 14016, !20, i64 14024, !20, i64 14028, !6, i64 14032, !6, i64 14040, !6, i64 14048, !7, i64 14056, !7, i64 14057, !20, i64 14060, !20, i64 14064, !26, i64 14068, !20, i64 14072, !20, i64 14076, !20, i64 14080, !26, i64 14084, !20, i64 14088, !20, i64 14092, !20, i64 14096, !26, i64 14100, !19, i64 14104, !19, i64 14108, !19, i64 14112, !19, i64 14116, !19, i64 14120, !7, i64 14128, !26, i64 14288, !26, i64 14290, !7, i64 14296, !20, i64 14456, !7, i64 14460}
!26 = !{!"short", !7, i64 0}
!27 = !{!25, !19, i64 14108}
!28 = !{!18, !6, i64 0}
!29 = !{!30, !19, i64 36}
!30 = !{!"s_desc", !19, i64 0, !19, i64 4, !19, i64 8, !19, i64 12, !19, i64 16, !19, i64 20, !19, i64 24, !19, i64 28, !19, i64 32, !19, i64 36, !19, i64 40, !19, i64 44, !19, i64 48, !19, i64 52, !19, i64 56, !19, i64 60, !19, i64 64, !19, i64 68, !19, i64 72, !19, i64 76, !19, i64 80, !19, i64 84, !19, i64 88, !19, i64 92, !19, i64 96, !19, i64 100, !19, i64 104, !20, i64 108, !7, i64 112, !20, i64 192, !20, i64 196, !20, i64 200, !19, i64 204, !19, i64 208, !20, i64 212, !20, i64 216, !20, i64 220, !20, i64 224, !20, i64 228, !7, i64 232, !7, i64 487, !7, i64 742}
!31 = !{!25, !19, i64 14116}
!32 = !{!12, !13, i64 24}
!33 = distinct !{!33, !34}
!34 = !{!"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
@.str.2 = external hidden unnamed_addr constant [48 x i8], align 1

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

; Function Attrs: nounwind uwtable
define dso_local void @dropSmallNpolarPockets(ptr noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #1 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %47, label %3

3:                                                ; preds = %2
  %4 = load ptr, ptr %0, align 8, !tbaa !5
  %.not1920 = icmp eq ptr %4, null
  br i1 %.not1920, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %3
  %5 = getelementptr inbounds i8, ptr %1, i64 14100
  %6 = getelementptr inbounds i8, ptr %1, i64 14108
  %7 = getelementptr inbounds i8, ptr %1, i64 14116
  %8 = getelementptr inbounds i8, ptr %0, i64 24
  br label %9

9:                                                ; preds = %.lr.ph, %46
  %.021 = phi ptr [ %4, %.lr.ph ], [ %12, %46 ]
  %10 = getelementptr inbounds i8, ptr %.021, i64 16
  %11 = load ptr, ptr %10, align 8, !tbaa !11
  %12 = load ptr, ptr %.021, align 8, !tbaa !13
  %13 = getelementptr inbounds i8, ptr %11, i64 52
  %14 = load i32, ptr %13, align 4, !tbaa !14
  %15 = sitofp i32 %14 to float
  %16 = getelementptr inbounds i8, ptr %11, i64 8
  %17 = load ptr, ptr %16, align 8, !tbaa !18
  %18 = getelementptr inbounds i8, ptr %17, i64 24
  %19 = load i64, ptr %18, align 8, !tbaa !19
  %20 = uitofp i64 %19 to float
  %21 = fdiv float %15, %20
  %22 = fpext float %21 to double
  %23 = load i16, ptr %5, align 4, !tbaa !21
  %24 = zext i16 %23 to i64
  %25 = icmp ult i64 %19, %24
  br i1 %25, label %39, label %26

26:                                               ; preds = %9
  %27 = load float, ptr %6, align 4, !tbaa !24
  %28 = fcmp une float %27, 0.000000e+00
  br i1 %28, label %35, label %29

29:                                               ; preds = %26
  %30 = load ptr, ptr %11, align 8, !tbaa !25
  %31 = getelementptr inbounds i8, ptr %30, i64 36
  %32 = load float, ptr %31, align 4, !tbaa !26
  %33 = load float, ptr %7, align 4, !tbaa !28
  %34 = fcmp olt float %32, %33
  br label %35

35:                                               ; preds = %29, %26
  %36 = phi i1 [ true, %26 ], [ %34, %29 ]
  %37 = uitofp i1 %36 to double
  %38 = fcmp olt double %22, %37
  br i1 %38, label %39, label %40

39:                                               ; preds = %35, %9
  tail call void @dropPocket(ptr noundef nonnull %0, ptr noundef nonnull %.021) #3
  br label %40

40:                                               ; preds = %39, %35
  %41 = load i64, ptr %8, align 8, !tbaa !29
  %42 = icmp eq i64 %41, 0
  br i1 %42, label %43, label %46

43:                                               ; preds = %40
  %44 = load ptr, ptr @stderr, align 8, !tbaa !30
  %45 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %44, ptr noundef nonnull @.str.1) #4
  br label %46

46:                                               ; preds = %43, %40
  %.not19 = icmp eq ptr %12, null
  br i1 %.not19, label %.loopexit, label %9, !llvm.loop !31

47:                                               ; preds = %2
  %48 = load ptr, ptr @stderr, align 8, !tbaa !30
  %49 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %48, ptr noundef nonnull @.str.2, ptr noundef null) #4
  br label %.loopexit

.loopexit:                                        ; preds = %46, %3, %47
  ret void
}

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

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 = { 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 }
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 16}
!12 = !{!"node_pocket", !7, i64 0, !7, i64 8, !7, i64 16}
!13 = !{!12, !7, i64 0}
!14 = !{!15, !17, i64 52}
!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 = !{!15, !7, i64 8}
!19 = !{!20, !10, i64 24}
!20 = !{!"c_lst_vertices", !7, i64 0, !7, i64 8, !7, i64 16, !10, i64 24}
!21 = !{!22, !23, i64 14100}
!22 = !{!"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, !23, i64 14068, !17, i64 14072, !17, i64 14076, !17, i64 14080, !23, i64 14084, !17, i64 14088, !17, i64 14092, !17, i64 14096, !23, i64 14100, !16, i64 14104, !16, i64 14108, !16, i64 14112, !16, i64 14116, !16, i64 14120, !8, i64 14128, !23, i64 14288, !23, i64 14290, !8, i64 14296, !17, i64 14456, !8, i64 14460}
!23 = !{!"short", !8, i64 0}
!24 = !{!22, !16, i64 14108}
!25 = !{!15, !7, i64 0}
!26 = !{!27, !16, i64 36}
!27 = !{!"s_desc", !16, i64 0, !16, i64 4, !16, i64 8, !16, i64 12, !16, i64 16, !16, i64 20, !16, i64 24, !16, i64 28, !16, i64 32, !16, i64 36, !16, i64 40, !16, i64 44, !16, i64 48, !16, i64 52, !16, i64 56, !16, i64 60, !16, i64 64, !16, i64 68, !16, i64 72, !16, i64 76, !16, i64 80, !16, i64 84, !16, i64 88, !16, i64 92, !16, i64 96, !16, i64 100, !16, i64 104, !17, i64 108, !8, i64 112, !17, i64 192, !17, i64 196, !17, i64 200, !16, i64 204, !16, i64 208, !17, i64 212, !17, i64 216, !17, i64 220, !17, i64 224, !17, i64 228, !8, i64 232, !8, i64 487, !8, i64 742}
!28 = !{!22, !16, i64 14116}
!29 = !{!6, !10, i64 24}
!30 = !{!7, !7, i64 0}
!31 = distinct !{!31, !32}
!32 = !{!"llvm.loop.mustprogress"}


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