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

declare void @my_free(ptr noundef) #0

; Function Attrs: nounwind uwtable
define dso_local void @dropPocket(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %5 = load ptr, ptr %4, align 8, !tbaa !5
  %6 = getelementptr inbounds %struct.node_pocket, ptr %5, i32 0, i32 1
  %7 = load ptr, ptr %6, align 8, !tbaa !9
  %8 = icmp ne ptr %7, null
  br i1 %8, label %9, label %29

9:                                                ; preds = %2
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.node_pocket, ptr %10, i32 0, i32 0
  %12 = load ptr, ptr %11, align 8, !tbaa !11
  %13 = icmp ne ptr %12, null
  br i1 %13, label %14, label %29

14:                                               ; preds = %9
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.node_pocket, ptr %15, i32 0, i32 0
  %17 = load ptr, ptr %16, align 8, !tbaa !11
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.node_pocket, ptr %18, i32 0, i32 1
  %20 = load ptr, ptr %19, align 8, !tbaa !9
  %21 = getelementptr inbounds %struct.node_pocket, ptr %20, i32 0, i32 0
  store ptr %17, ptr %21, align 8, !tbaa !11
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.node_pocket, ptr %22, i32 0, i32 1
  %24 = load ptr, ptr %23, align 8, !tbaa !9
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.node_pocket, ptr %25, i32 0, i32 0
  %27 = load ptr, ptr %26, align 8, !tbaa !11
  %28 = getelementptr inbounds %struct.node_pocket, ptr %27, i32 0, i32 1
  store ptr %24, ptr %28, align 8, !tbaa !9
  br label %61

29:                                               ; preds = %9, %2
  %30 = load ptr, ptr %4, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.node_pocket, ptr %30, i32 0, i32 0
  %32 = load ptr, ptr %31, align 8, !tbaa !11
  %33 = icmp ne ptr %32, null
  br i1 %33, label %34, label %44

34:                                               ; preds = %29
  %35 = load ptr, ptr %4, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.node_pocket, ptr %35, i32 0, i32 0
  %37 = load ptr, ptr %36, align 8, !tbaa !11
  %38 = getelementptr inbounds %struct.node_pocket, ptr %37, i32 0, i32 1
  store ptr null, ptr %38, align 8, !tbaa !9
  %39 = load ptr, ptr %4, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.node_pocket, ptr %39, i32 0, i32 0
  %41 = load ptr, ptr %40, align 8, !tbaa !11
  %42 = load ptr, ptr %3, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.c_lst_pockets, ptr %42, i32 0, i32 0
  store ptr %41, ptr %43, align 8, !tbaa !12
  br label %60

44:                                               ; preds = %29
  %45 = load ptr, ptr %4, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.node_pocket, ptr %45, i32 0, i32 1
  %47 = load ptr, ptr %46, align 8, !tbaa !9
  %48 = icmp ne ptr %47, null
  br i1 %48, label %49, label %59

49:                                               ; preds = %44
  %50 = load ptr, ptr %4, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.node_pocket, ptr %50, i32 0, i32 1
  %52 = load ptr, ptr %51, align 8, !tbaa !9
  %53 = getelementptr inbounds %struct.node_pocket, ptr %52, i32 0, i32 0
  store ptr null, ptr %53, align 8, !tbaa !11
  %54 = load ptr, ptr %4, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.node_pocket, ptr %54, i32 0, i32 1
  %56 = load ptr, ptr %55, align 8, !tbaa !9
  %57 = load ptr, ptr %3, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.c_lst_pockets, ptr %57, i32 0, i32 1
  store ptr %56, ptr %58, align 8, !tbaa !15
  br label %59

59:                                               ; preds = %49, %44
  br label %60

60:                                               ; preds = %59, %34
  br label %61

61:                                               ; preds = %60, %14
  %62 = load ptr, ptr %4, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.node_pocket, ptr %62, i32 0, i32 2
  %64 = load ptr, ptr %63, align 8, !tbaa !16
  %65 = getelementptr inbounds %struct.s_pocket, ptr %64, i32 0, i32 1
  %66 = load ptr, ptr %65, align 8, !tbaa !17
  call void @c_lst_vertices_free(ptr noundef %66)
  %67 = load ptr, ptr %4, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.node_pocket, ptr %67, i32 0, i32 0
  store ptr null, ptr %68, align 8, !tbaa !11
  %69 = load ptr, ptr %4, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.node_pocket, ptr %69, i32 0, i32 1
  store ptr null, ptr %70, align 8, !tbaa !9
  %71 = load ptr, ptr %3, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.c_lst_pockets, ptr %71, i32 0, i32 3
  %73 = load i64, ptr %72, align 8, !tbaa !21
  %74 = sub i64 %73, 1
  store i64 %74, ptr %72, align 8, !tbaa !21
  %75 = load ptr, ptr %4, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.node_pocket, ptr %75, i32 0, i32 2
  %77 = load ptr, ptr %76, align 8, !tbaa !16
  %78 = getelementptr inbounds %struct.s_pocket, ptr %77, i32 0, i32 0
  %79 = load ptr, ptr %78, align 8, !tbaa !22
  call void @my_free(ptr noundef %79)
  %80 = load ptr, ptr %4, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.node_pocket, ptr %80, i32 0, i32 2
  %82 = load ptr, ptr %81, align 8, !tbaa !16
  %83 = getelementptr inbounds %struct.s_pocket, ptr %82, i32 0, i32 0
  store ptr null, ptr %83, align 8, !tbaa !22
  %84 = load ptr, ptr %4, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.node_pocket, ptr %84, i32 0, i32 2
  %86 = load ptr, ptr %85, align 8, !tbaa !16
  call void @my_free(ptr noundef %86)
  %87 = load ptr, ptr %4, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.node_pocket, ptr %87, i32 0, i32 2
  store ptr null, ptr %88, align 8, !tbaa !16
  %89 = load ptr, ptr %4, align 8, !tbaa !5
  call void @my_free(ptr noundef %89)
  %90 = load ptr, ptr %3, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.c_lst_pockets, ptr %90, i32 0, i32 3
  %92 = load i64, ptr %91, align 8, !tbaa !21
  %93 = icmp eq i64 %92, 0
  br i1 %93, label %94, label %97

94:                                               ; preds = %61
  %95 = load ptr, ptr %3, align 8, !tbaa !5
  %96 = getelementptr inbounds %struct.c_lst_pockets, ptr %95, i32 0, i32 0
  store ptr null, ptr %96, align 8, !tbaa !12
  br label %97

97:                                               ; preds = %94, %61
  ret void
}

declare void @c_lst_vertices_free(ptr noundef) #0

attributes #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 = { 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, !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 = !{!"node_pocket", !6, i64 0, !6, i64 8, !6, i64 16}
!11 = !{!10, !6, i64 0}
!12 = !{!13, !6, i64 0}
!13 = !{!"c_lst_pockets", !6, i64 0, !6, i64 8, !6, i64 16, !14, i64 24, !6, i64 32}
!14 = !{!"long", !7, i64 0}
!15 = !{!13, !6, i64 8}
!16 = !{!10, !6, i64 16}
!17 = !{!18, !6, i64 8}
!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 = !{!13, !14, i64 24}
!22 = !{!18, !6, i64 0}


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

declare void @my_free(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @dropPocket(ptr nocapture noundef %0, ptr noundef %1) local_unnamed_addr #1 {
  %3 = getelementptr inbounds i8, ptr %1, i64 8
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %.not = icmp eq ptr %4, null
  %.pr = load ptr, ptr %1, align 8, !tbaa !10
  %.not29 = icmp eq ptr %.pr, null
  br i1 %.not, label %9, label %5

5:                                                ; preds = %2
  br i1 %.not29, label %12, label %6

6:                                                ; preds = %5
  store ptr %.pr, ptr %4, align 8, !tbaa !10
  %7 = load ptr, ptr %1, align 8, !tbaa !10
  %8 = getelementptr inbounds i8, ptr %7, i64 8
  store ptr %4, ptr %8, align 8, !tbaa !5
  br label %.thread32

9:                                                ; preds = %2
  br i1 %.not29, label %.thread32, label %10

10:                                               ; preds = %9
  %11 = getelementptr inbounds i8, ptr %.pr, i64 8
  store ptr null, ptr %11, align 8, !tbaa !5
  store ptr %.pr, ptr %0, align 8, !tbaa !11
  br label %.thread32

12:                                               ; preds = %5
  store ptr null, ptr %4, align 8, !tbaa !10
  %13 = getelementptr inbounds i8, ptr %0, i64 8
  store ptr %4, ptr %13, align 8, !tbaa !14
  br label %.thread32

.thread32:                                        ; preds = %9, %10, %12, %6
  %14 = getelementptr inbounds i8, ptr %1, i64 16
  %15 = load ptr, ptr %14, align 8, !tbaa !15
  %16 = getelementptr inbounds i8, ptr %15, i64 8
  %17 = load ptr, ptr %16, align 8, !tbaa !16
  tail call void @c_lst_vertices_free(ptr noundef %17) #3
  %18 = getelementptr inbounds i8, ptr %0, i64 24
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %1, i8 0, i64 16, i1 false)
  %19 = load i64, ptr %18, align 8, !tbaa !20
  %20 = add i64 %19, -1
  store i64 %20, ptr %18, align 8, !tbaa !20
  %21 = load ptr, ptr %14, align 8, !tbaa !15
  %22 = load ptr, ptr %21, align 8, !tbaa !21
  tail call void @my_free(ptr noundef %22) #3
  %23 = load ptr, ptr %14, align 8, !tbaa !15
  store ptr null, ptr %23, align 8, !tbaa !21
  tail call void @my_free(ptr noundef nonnull %23) #3
  store ptr null, ptr %14, align 8, !tbaa !15
  tail call void @my_free(ptr noundef nonnull %1) #3
  %24 = load i64, ptr %18, align 8, !tbaa !20
  %25 = icmp eq i64 %24, 0
  br i1 %25, label %26, label %27

26:                                               ; preds = %.thread32
  store ptr null, ptr %0, align 8, !tbaa !11
  br label %27

27:                                               ; preds = %26, %.thread32
  ret void
}

declare void @c_lst_vertices_free(ptr noundef) local_unnamed_addr #0

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

attributes #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 = { 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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = !{!"node_pocket", !7, i64 0, !7, i64 8, !7, i64 16}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!6, !7, i64 0}
!11 = !{!12, !7, i64 0}
!12 = !{!"c_lst_pockets", !7, i64 0, !7, i64 8, !7, i64 16, !13, i64 24, !7, i64 32}
!13 = !{!"long", !8, i64 0}
!14 = !{!12, !7, i64 8}
!15 = !{!6, !7, i64 16}
!16 = !{!17, !7, i64 8}
!17 = !{!"s_pocket", !7, i64 0, !7, i64 8, !18, i64 16, !18, i64 20, !18, i64 24, !18, i64 28, !8, i64 32, !19, i64 44, !19, i64 48, !19, i64 52, !19, i64 56}
!18 = !{!"float", !8, i64 0}
!19 = !{!"int", !8, i64 0}
!20 = !{!12, !13, i64 24}
!21 = !{!17, !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InstCombinePass,JumpThreadingPass,MemCpyOptPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass