; 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.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 }
%struct.s_atm = type { i32, float, float, float, float, float, float, float, [5 x i8], [7 x i8], [16 x i8], [16 x i8], [3 x i8], [8 x i8], i32, i32, i32, i32, i32, i32, i32, float, float, float, float, float, float, float, i8, i8, float, float, float, float, i16, ptr, i32 }

; 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: nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #1

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

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @count_pocket_contacted_atms(ptr noundef %0) #3 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i64, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  %11 = icmp ne ptr %10, null
  br i1 %11, label %12, label %24

12:                                               ; preds = %1
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.s_pocket, ptr %13, i32 0, i32 1
  %15 = load ptr, ptr %14, align 8, !tbaa !9
  %16 = icmp ne ptr %15, null
  br i1 %16, label %17, label %24

17:                                               ; preds = %12
  %18 = load ptr, ptr %3, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.s_pocket, ptr %18, i32 0, i32 1
  %20 = load ptr, ptr %19, align 8, !tbaa !9
  %21 = getelementptr inbounds %struct.c_lst_vertices, ptr %20, i32 0, i32 3
  %22 = load i64, ptr %21, align 8, !tbaa !13
  %23 = icmp ule i64 %22, 0
  br i1 %23, label %24, label %25

24:                                               ; preds = %17, %12, %1
  store i32 -1, ptr %2, align 4
  br label %86

25:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  store i32 0, ptr %4, align 4, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  store i32 0, ptr %5, align 4, !tbaa !16
  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
  %26 = load ptr, ptr %3, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.s_pocket, ptr %26, i32 0, i32 1
  %28 = load ptr, ptr %27, align 8, !tbaa !9
  %29 = getelementptr inbounds %struct.c_lst_vertices, ptr %28, i32 0, i32 3
  %30 = load i64, ptr %29, align 8, !tbaa !13
  %31 = mul i64 %30, 4
  %32 = call ptr @llvm.stacksave.p0()
  store ptr %32, ptr %8, align 8
  %33 = alloca i32, i64 %31, align 16
  store i64 %31, ptr %9, align 8
  %34 = load ptr, ptr %3, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.s_pocket, ptr %34, i32 0, i32 1
  %36 = load ptr, ptr %35, align 8, !tbaa !9
  %37 = getelementptr inbounds %struct.c_lst_vertices, ptr %36, i32 0, i32 0
  %38 = load ptr, ptr %37, align 8, !tbaa !17
  store ptr %38, ptr %6, align 8, !tbaa !5
  br label %39

39:                                               ; preds = %79, %25
  %40 = load ptr, ptr %6, align 8, !tbaa !5
  %41 = icmp ne ptr %40, null
  br i1 %41, label %42, label %83

42:                                               ; preds = %39
  %43 = load ptr, ptr %6, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.node_vertice, ptr %43, i32 0, i32 2
  %45 = load ptr, ptr %44, align 8, !tbaa !18
  store ptr %45, ptr %7, align 8, !tbaa !5
  store i32 0, ptr %5, align 4, !tbaa !16
  br label %46

46:                                               ; preds = %76, %42
  %47 = load i32, ptr %5, align 4, !tbaa !16
  %48 = icmp slt i32 %47, 4
  br i1 %48, label %49, label %79

49:                                               ; preds = %46
  %50 = load i32, ptr %4, align 4, !tbaa !16
  %51 = load ptr, ptr %7, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.s_vvertice, ptr %51, i32 0, i32 12
  %53 = load i32, ptr %5, align 4, !tbaa !16
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds [4 x ptr], ptr %52, i64 0, i64 %54
  %56 = load ptr, ptr %55, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.s_atm, ptr %56, i32 0, i32 14
  %58 = load i32, ptr %57, align 8, !tbaa !20
  %59 = call i32 @in_tab(ptr noundef %33, i32 noundef %50, i32 noundef %58)
  %60 = icmp eq i32 %59, 0
  br i1 %60, label %61, label %75

61:                                               ; preds = %49
  %62 = load ptr, ptr %7, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.s_vvertice, ptr %62, i32 0, i32 12
  %64 = load i32, ptr %5, align 4, !tbaa !16
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds [4 x ptr], ptr %63, i64 0, i64 %65
  %67 = load ptr, ptr %66, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.s_atm, ptr %67, i32 0, i32 14
  %69 = load i32, ptr %68, align 8, !tbaa !20
  %70 = load i32, ptr %4, align 4, !tbaa !16
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds i32, ptr %33, i64 %71
  store i32 %69, ptr %72, align 4, !tbaa !16
  %73 = load i32, ptr %4, align 4, !tbaa !16
  %74 = add nsw i32 %73, 1
  store i32 %74, ptr %4, align 4, !tbaa !16
  br label %75

75:                                               ; preds = %61, %49
  br label %76

76:                                               ; preds = %75
  %77 = load i32, ptr %5, align 4, !tbaa !16
  %78 = add nsw i32 %77, 1
  store i32 %78, ptr %5, align 4, !tbaa !16
  br label %46, !llvm.loop !23

79:                                               ; preds = %46
  %80 = load ptr, ptr %6, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.node_vertice, ptr %80, i32 0, i32 0
  %82 = load ptr, ptr %81, align 8, !tbaa !25
  store ptr %82, ptr %6, align 8, !tbaa !5
  br label %39, !llvm.loop !26

83:                                               ; preds = %39
  %84 = load i32, ptr %4, align 4, !tbaa !16
  store i32 %84, ptr %2, align 4
  %85 = load ptr, ptr %8, align 8
  call void @llvm.stackrestore.p0(ptr %85)
  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 4, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  br label %86

86:                                               ; preds = %83, %24
  %87 = load i32, ptr %2, align 4
  ret i32 %87
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind willreturn }
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 8}
!10 = !{!"s_pocket", !6, i64 0, !6, i64 8, !11, i64 16, !11, i64 20, !11, i64 24, !11, i64 28, !7, i64 32, !12, i64 44, !12, i64 48, !12, i64 52, !12, i64 56}
!11 = !{!"float", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !15, i64 24}
!14 = !{!"c_lst_vertices", !6, i64 0, !6, i64 8, !6, i64 16, !15, i64 24}
!15 = !{!"long", !7, i64 0}
!16 = !{!12, !12, i64 0}
!17 = !{!14, !6, i64 0}
!18 = !{!19, !6, i64 16}
!19 = !{!"node_vertice", !6, i64 0, !6, i64 8, !6, i64 16}
!20 = !{!21, !12, i64 88}
!21 = !{!"s_atm", !12, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !11, i64 24, !11, i64 28, !7, i64 32, !7, i64 37, !7, i64 44, !7, i64 60, !7, i64 76, !7, i64 79, !12, i64 88, !12, i64 92, !12, i64 96, !12, i64 100, !12, i64 104, !12, i64 108, !12, i64 112, !11, i64 116, !11, i64 120, !11, i64 124, !11, i64 128, !11, i64 132, !11, i64 136, !11, i64 140, !7, i64 144, !7, i64 145, !11, i64 148, !11, i64 152, !11, i64 156, !11, i64 160, !22, i64 164, !6, i64 168, !12, i64 176}
!22 = !{!"short", !7, i64 0}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}
!25 = !{!19, !6, i64 0}
!26 = distinct !{!26, !24}


; 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: mustprogress nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #0

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

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #0

; Function Attrs: nounwind uwtable
define dso_local i32 @count_pocket_contacted_atms(ptr noundef readonly %0) local_unnamed_addr #2 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %71, label %2

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

5:                                                ; preds = %2
  %6 = getelementptr inbounds i8, ptr %4, i64 24
  %7 = load i64, ptr %6, align 8, !tbaa !12
  %8 = icmp eq i64 %7, 0
  br i1 %8, label %71, label %9

9:                                                ; preds = %5
  %10 = shl i64 %7, 2
  %11 = tail call ptr @llvm.stacksave.p0()
  %12 = alloca i32, i64 %10, align 16
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %.02029 = load ptr, ptr %13, align 8, !tbaa !15
  %.not2630 = icmp eq ptr %.02029, null
  br i1 %.not2630, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %9, %.loopexit
  %.02032 = phi ptr [ %.020, %.loopexit ], [ %.02029, %9 ]
  %.01931 = phi i32 [ %.2.3, %.loopexit ], [ 0, %9 ]
  %14 = getelementptr inbounds i8, ptr %.02032, i64 16
  %15 = load ptr, ptr %14, align 8, !tbaa !16
  %16 = getelementptr inbounds i8, ptr %15, i64 64
  %17 = load ptr, ptr %16, align 8, !tbaa !15
  %18 = getelementptr inbounds i8, ptr %17, i64 88
  %19 = load i32, ptr %18, align 8, !tbaa !18
  %20 = call i32 @in_tab(ptr noundef nonnull %12, i32 noundef %.01931, i32 noundef %19) #3
  %21 = icmp eq i32 %20, 0
  br i1 %21, label %22, label %29

22:                                               ; preds = %.lr.ph
  %23 = load ptr, ptr %16, align 8, !tbaa !15
  %24 = getelementptr inbounds i8, ptr %23, i64 88
  %25 = load i32, ptr %24, align 8, !tbaa !18
  %26 = sext i32 %.01931 to i64
  %27 = getelementptr inbounds i32, ptr %12, i64 %26
  store i32 %25, ptr %27, align 4, !tbaa !21
  %28 = add nsw i32 %.01931, 1
  br label %29

29:                                               ; preds = %.lr.ph, %22
  %.2 = phi i32 [ %28, %22 ], [ %.01931, %.lr.ph ]
  %30 = getelementptr inbounds i8, ptr %15, i64 72
  %31 = load ptr, ptr %30, align 8, !tbaa !15
  %32 = getelementptr inbounds i8, ptr %31, i64 88
  %33 = load i32, ptr %32, align 8, !tbaa !18
  %34 = call i32 @in_tab(ptr noundef nonnull %12, i32 noundef %.2, i32 noundef %33) #3
  %35 = icmp eq i32 %34, 0
  br i1 %35, label %36, label %43

36:                                               ; preds = %29
  %37 = load ptr, ptr %30, align 8, !tbaa !15
  %38 = getelementptr inbounds i8, ptr %37, i64 88
  %39 = load i32, ptr %38, align 8, !tbaa !18
  %40 = sext i32 %.2 to i64
  %41 = getelementptr inbounds i32, ptr %12, i64 %40
  store i32 %39, ptr %41, align 4, !tbaa !21
  %42 = add nsw i32 %.2, 1
  br label %43

43:                                               ; preds = %36, %29
  %.2.1 = phi i32 [ %42, %36 ], [ %.2, %29 ]
  %44 = getelementptr inbounds i8, ptr %15, i64 80
  %45 = load ptr, ptr %44, align 8, !tbaa !15
  %46 = getelementptr inbounds i8, ptr %45, i64 88
  %47 = load i32, ptr %46, align 8, !tbaa !18
  %48 = call i32 @in_tab(ptr noundef nonnull %12, i32 noundef %.2.1, i32 noundef %47) #3
  %49 = icmp eq i32 %48, 0
  br i1 %49, label %50, label %57

50:                                               ; preds = %43
  %51 = load ptr, ptr %44, align 8, !tbaa !15
  %52 = getelementptr inbounds i8, ptr %51, i64 88
  %53 = load i32, ptr %52, align 8, !tbaa !18
  %54 = sext i32 %.2.1 to i64
  %55 = getelementptr inbounds i32, ptr %12, i64 %54
  store i32 %53, ptr %55, align 4, !tbaa !21
  %56 = add nsw i32 %.2.1, 1
  br label %57

57:                                               ; preds = %50, %43
  %.2.2 = phi i32 [ %56, %50 ], [ %.2.1, %43 ]
  %58 = getelementptr inbounds i8, ptr %15, i64 88
  %59 = load ptr, ptr %58, align 8, !tbaa !15
  %60 = getelementptr inbounds i8, ptr %59, i64 88
  %61 = load i32, ptr %60, align 8, !tbaa !18
  %62 = call i32 @in_tab(ptr noundef nonnull %12, i32 noundef %.2.2, i32 noundef %61) #3
  %63 = icmp eq i32 %62, 0
  br i1 %63, label %64, label %.loopexit

64:                                               ; preds = %57
  %65 = load ptr, ptr %58, align 8, !tbaa !15
  %66 = getelementptr inbounds i8, ptr %65, i64 88
  %67 = load i32, ptr %66, align 8, !tbaa !18
  %68 = sext i32 %.2.2 to i64
  %69 = getelementptr inbounds i32, ptr %12, i64 %68
  store i32 %67, ptr %69, align 4, !tbaa !21
  %70 = add nsw i32 %.2.2, 1
  br label %.loopexit

.loopexit:                                        ; preds = %64, %57
  %.2.3 = phi i32 [ %70, %64 ], [ %.2.2, %57 ]
  %.020 = load ptr, ptr %.02032, align 8, !tbaa !15
  %.not26 = icmp eq ptr %.020, null
  br i1 %.not26, label %._crit_edge, label %.lr.ph, !llvm.loop !22

._crit_edge:                                      ; preds = %.loopexit, %9
  %.019.lcssa = phi i32 [ 0, %9 ], [ %.2.3, %.loopexit ]
  call void @llvm.stackrestore.p0(ptr %11)
  br label %71

71:                                               ; preds = %1, %2, %5, %._crit_edge
  %.0 = phi i32 [ %.019.lcssa, %._crit_edge ], [ -1, %5 ], [ -1, %2 ], [ -1, %1 ]
  ret i32 %.0
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn }
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 }

!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 8}
!6 = !{!"s_pocket", !7, i64 0, !7, i64 8, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !8, i64 32, !11, i64 44, !11, i64 48, !11, i64 52, !11, i64 56}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"float", !8, i64 0}
!11 = !{!"int", !8, i64 0}
!12 = !{!13, !14, i64 24}
!13 = !{!"c_lst_vertices", !7, i64 0, !7, i64 8, !7, i64 16, !14, i64 24}
!14 = !{!"long", !8, i64 0}
!15 = !{!7, !7, i64 0}
!16 = !{!17, !7, i64 16}
!17 = !{!"node_vertice", !7, i64 0, !7, i64 8, !7, i64 16}
!18 = !{!19, !11, i64 88}
!19 = !{!"s_atm", !11, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !8, i64 32, !8, i64 37, !8, i64 44, !8, i64 60, !8, i64 76, !8, i64 79, !11, i64 88, !11, i64 92, !11, i64 96, !11, i64 100, !11, i64 104, !11, i64 108, !11, i64 112, !10, i64 116, !10, i64 120, !10, i64 124, !10, i64 128, !10, i64 132, !10, i64 136, !10, i64 140, !8, i64 144, !8, i64 145, !10, i64 148, !10, i64 152, !10, i64 156, !10, i64 160, !20, i64 164, !7, i64 168, !11, i64 176}
!20 = !{!"short", !8, i64 0}
!21 = !{!11, !11, i64 0}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}


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