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

; 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.s_lst_vvertice = type { ptr, ptr, ptr, i32, ptr, i32, i32 }
%struct.s_mdconcat = type { ptr, i64, i32 }
%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: nounwind uwtable
define dso_local void @store_vertice_positions(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i64, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %8 = load ptr, ptr %4, align 8, !tbaa !5
  %9 = icmp ne ptr %8, null
  br i1 %9, label %10, label %121

10:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.c_lst_pockets, ptr %11, i32 0, i32 4
  %13 = load ptr, ptr %12, align 8, !tbaa !9
  %14 = getelementptr inbounds %struct.s_lst_vvertice, ptr %13, i32 0, i32 5
  %15 = load i32, ptr %14, align 8, !tbaa !12
  store i32 %15, ptr %6, align 4, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #2
  %16 = load ptr, ptr %3, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.s_mdconcat, ptr %16, i32 0, i32 1
  %18 = load i64, ptr %17, align 8, !tbaa !16
  store i64 %18, ptr %7, align 8, !tbaa !18
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.s_mdconcat, ptr %19, i32 0, i32 1
  %21 = load i64, ptr %20, align 8, !tbaa !16
  %22 = icmp eq i64 %21, 0
  br i1 %22, label %23, label %27

23:                                               ; preds = %10
  %24 = load ptr, ptr %3, align 8, !tbaa !5
  %25 = load i32, ptr %6, align 4, !tbaa !15
  %26 = sext i32 %25 to i64
  call void @alloc_first_md_concat(ptr noundef %24, i64 noundef %26)
  br label %31

27:                                               ; preds = %10
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = load i32, ptr %6, align 4, !tbaa !15
  %30 = sext i32 %29 to i64
  call void @realloc_md_concat(ptr noundef %28, i64 noundef %30)
  br label %31

31:                                               ; preds = %27, %23
  store i32 0, ptr %5, align 4, !tbaa !15
  br label %32

32:                                               ; preds = %117, %31
  %33 = load i32, ptr %5, align 4, !tbaa !15
  %34 = load i32, ptr %6, align 4, !tbaa !15
  %35 = icmp slt i32 %33, %34
  br i1 %35, label %36, label %120

36:                                               ; preds = %32
  %37 = load ptr, ptr %4, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.c_lst_pockets, ptr %37, i32 0, i32 4
  %39 = load ptr, ptr %38, align 8, !tbaa !9
  %40 = getelementptr inbounds %struct.s_lst_vvertice, ptr %39, i32 0, i32 0
  %41 = load ptr, ptr %40, align 8, !tbaa !19
  %42 = load i32, ptr %5, align 4, !tbaa !15
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds %struct.s_vvertice, ptr %41, i64 %43
  %45 = getelementptr inbounds %struct.s_vvertice, ptr %44, i32 0, i32 6
  %46 = load float, ptr %45, align 8, !tbaa !20
  %47 = load ptr, ptr %3, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.s_mdconcat, ptr %47, i32 0, i32 0
  %49 = load ptr, ptr %48, align 8, !tbaa !23
  %50 = load i64, ptr %7, align 8, !tbaa !18
  %51 = load i32, ptr %5, align 4, !tbaa !15
  %52 = sext i32 %51 to i64
  %53 = add i64 %50, %52
  %54 = getelementptr inbounds ptr, ptr %49, i64 %53
  %55 = load ptr, ptr %54, align 8, !tbaa !5
  %56 = getelementptr inbounds float, ptr %55, i64 0
  store float %46, ptr %56, align 4, !tbaa !24
  %57 = load ptr, ptr %4, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.c_lst_pockets, ptr %57, i32 0, i32 4
  %59 = load ptr, ptr %58, align 8, !tbaa !9
  %60 = getelementptr inbounds %struct.s_lst_vvertice, ptr %59, i32 0, i32 0
  %61 = load ptr, ptr %60, align 8, !tbaa !19
  %62 = load i32, ptr %5, align 4, !tbaa !15
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds %struct.s_vvertice, ptr %61, i64 %63
  %65 = getelementptr inbounds %struct.s_vvertice, ptr %64, i32 0, i32 7
  %66 = load float, ptr %65, align 4, !tbaa !25
  %67 = load ptr, ptr %3, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.s_mdconcat, ptr %67, i32 0, i32 0
  %69 = load ptr, ptr %68, align 8, !tbaa !23
  %70 = load i64, ptr %7, align 8, !tbaa !18
  %71 = load i32, ptr %5, align 4, !tbaa !15
  %72 = sext i32 %71 to i64
  %73 = add i64 %70, %72
  %74 = getelementptr inbounds ptr, ptr %69, i64 %73
  %75 = load ptr, ptr %74, align 8, !tbaa !5
  %76 = getelementptr inbounds float, ptr %75, i64 1
  store float %66, ptr %76, align 4, !tbaa !24
  %77 = load ptr, ptr %4, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.c_lst_pockets, ptr %77, i32 0, i32 4
  %79 = load ptr, ptr %78, align 8, !tbaa !9
  %80 = getelementptr inbounds %struct.s_lst_vvertice, ptr %79, i32 0, i32 0
  %81 = load ptr, ptr %80, align 8, !tbaa !19
  %82 = load i32, ptr %5, align 4, !tbaa !15
  %83 = sext i32 %82 to i64
  %84 = getelementptr inbounds %struct.s_vvertice, ptr %81, i64 %83
  %85 = getelementptr inbounds %struct.s_vvertice, ptr %84, i32 0, i32 8
  %86 = load float, ptr %85, align 8, !tbaa !26
  %87 = load ptr, ptr %3, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.s_mdconcat, ptr %87, i32 0, i32 0
  %89 = load ptr, ptr %88, align 8, !tbaa !23
  %90 = load i64, ptr %7, align 8, !tbaa !18
  %91 = load i32, ptr %5, align 4, !tbaa !15
  %92 = sext i32 %91 to i64
  %93 = add i64 %90, %92
  %94 = getelementptr inbounds ptr, ptr %89, i64 %93
  %95 = load ptr, ptr %94, align 8, !tbaa !5
  %96 = getelementptr inbounds float, ptr %95, i64 2
  store float %86, ptr %96, align 4, !tbaa !24
  %97 = load ptr, ptr %4, align 8, !tbaa !5
  %98 = getelementptr inbounds %struct.c_lst_pockets, ptr %97, i32 0, i32 4
  %99 = load ptr, ptr %98, align 8, !tbaa !9
  %100 = getelementptr inbounds %struct.s_lst_vvertice, ptr %99, i32 0, i32 0
  %101 = load ptr, ptr %100, align 8, !tbaa !19
  %102 = load i32, ptr %5, align 4, !tbaa !15
  %103 = sext i32 %102 to i64
  %104 = getelementptr inbounds %struct.s_vvertice, ptr %101, i64 %103
  %105 = getelementptr inbounds %struct.s_vvertice, ptr %104, i32 0, i32 5
  %106 = load float, ptr %105, align 4, !tbaa !27
  %107 = load ptr, ptr %3, align 8, !tbaa !5
  %108 = getelementptr inbounds %struct.s_mdconcat, ptr %107, i32 0, i32 0
  %109 = load ptr, ptr %108, align 8, !tbaa !23
  %110 = load i64, ptr %7, align 8, !tbaa !18
  %111 = load i32, ptr %5, align 4, !tbaa !15
  %112 = sext i32 %111 to i64
  %113 = add i64 %110, %112
  %114 = getelementptr inbounds ptr, ptr %109, i64 %113
  %115 = load ptr, ptr %114, align 8, !tbaa !5
  %116 = getelementptr inbounds float, ptr %115, i64 3
  store float %106, ptr %116, align 4, !tbaa !24
  br label %117

117:                                              ; preds = %36
  %118 = load i32, ptr %5, align 4, !tbaa !15
  %119 = add nsw i32 %118, 1
  store i32 %119, ptr %5, align 4, !tbaa !15
  br label %32, !llvm.loop !28

120:                                              ; preds = %32
  call void @llvm.lifetime.end.p0(i64 8, 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
  br label %121

121:                                              ; preds = %120, %2
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nounwind uwtable
declare dso_local void @alloc_first_md_concat(ptr noundef, i64 noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local void @realloc_md_concat(ptr noundef, i64 noundef) #0

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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, !6, i64 32}
!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, !14, i64 40}
!13 = !{!"s_lst_vvertice", !6, i64 0, !6, i64 8, !6, i64 16, !14, i64 24, !6, i64 32, !14, i64 40, !14, i64 44}
!14 = !{!"int", !7, i64 0}
!15 = !{!14, !14, i64 0}
!16 = !{!17, !11, i64 8}
!17 = !{!"s_mdconcat", !6, i64 0, !11, i64 8, !14, i64 16}
!18 = !{!11, !11, i64 0}
!19 = !{!13, !6, i64 0}
!20 = !{!21, !22, i64 24}
!21 = !{!"s_vvertice", !14, i64 0, !14, i64 4, !14, i64 8, !14, i64 12, !14, i64 16, !22, i64 20, !22, i64 24, !22, i64 28, !22, i64 32, !14, i64 36, !14, i64 40, !7, i64 44, !7, i64 64, !7, i64 96, !22, i64 108}
!22 = !{!"float", !7, i64 0}
!23 = !{!17, !6, i64 0}
!24 = !{!22, !22, i64 0}
!25 = !{!21, !22, i64 28}
!26 = !{!21, !22, i64 32}
!27 = !{!21, !22, i64 20}
!28 = distinct !{!28, !29}
!29 = !{!"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"

%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: nounwind uwtable
define dso_local void @store_vertice_positions(ptr noundef %0, ptr noundef readonly %1) local_unnamed_addr #0 {
  %.not = icmp eq ptr %1, null
  br i1 %.not, label %.loopexit, label %3

3:                                                ; preds = %2
  %4 = getelementptr inbounds i8, ptr %1, i64 32
  %5 = load ptr, ptr %4, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %5, i64 40
  %7 = load i32, ptr %6, align 8, !tbaa !11
  %8 = getelementptr inbounds i8, ptr %0, i64 8
  %9 = load i64, ptr %8, align 8, !tbaa !14
  %10 = icmp eq i64 %9, 0
  %11 = sext i32 %7 to i64
  br i1 %10, label %12, label %13

12:                                               ; preds = %3
  tail call void @alloc_first_md_concat(ptr noundef nonnull %0, i64 noundef %11)
  br label %14

13:                                               ; preds = %3
  tail call void @realloc_md_concat(ptr noundef nonnull %0, i64 noundef %11)
  br label %14

14:                                               ; preds = %13, %12
  %15 = icmp sgt i32 %7, 0
  br i1 %15, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %14
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = load ptr, ptr %16, align 8, !tbaa !16
  %18 = load ptr, ptr %0, align 8, !tbaa !17
  %19 = getelementptr ptr, ptr %18, i64 %9
  %wide.trip.count = zext nneg i32 %7 to i64
  br label %20

20:                                               ; preds = %.lr.ph, %20
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %20 ]
  %21 = getelementptr inbounds %struct.s_vvertice, ptr %17, i64 %indvars.iv, i32 6
  %22 = load float, ptr %21, align 8, !tbaa !18
  %23 = getelementptr ptr, ptr %19, i64 %indvars.iv
  %24 = load ptr, ptr %23, align 8, !tbaa !21
  store float %22, ptr %24, align 4, !tbaa !22
  %25 = getelementptr inbounds %struct.s_vvertice, ptr %17, i64 %indvars.iv, i32 7
  %26 = load float, ptr %25, align 4, !tbaa !23
  %27 = getelementptr inbounds i8, ptr %24, i64 4
  store float %26, ptr %27, align 4, !tbaa !22
  %28 = getelementptr inbounds %struct.s_vvertice, ptr %17, i64 %indvars.iv, i32 8
  %29 = load float, ptr %28, align 8, !tbaa !24
  %30 = getelementptr inbounds i8, ptr %24, i64 8
  store float %29, ptr %30, align 4, !tbaa !22
  %31 = getelementptr inbounds %struct.s_vvertice, ptr %17, i64 %indvars.iv, i32 5
  %32 = load float, ptr %31, align 4, !tbaa !25
  %33 = getelementptr inbounds i8, ptr %24, i64 12
  store float %32, ptr %33, align 4, !tbaa !22
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %.loopexit, label %20, !llvm.loop !26

.loopexit:                                        ; preds = %20, %14, %2
  ret void
}

; Function Attrs: nounwind uwtable
declare dso_local void @alloc_first_md_concat(ptr noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @realloc_md_concat(ptr noundef, i64 noundef) local_unnamed_addr #0

attributes #0 = { 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, !7, i64 32}
!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, !13, i64 40}
!12 = !{!"s_lst_vvertice", !7, i64 0, !7, i64 8, !7, i64 16, !13, i64 24, !7, i64 32, !13, i64 40, !13, i64 44}
!13 = !{!"int", !8, i64 0}
!14 = !{!15, !10, i64 8}
!15 = !{!"s_mdconcat", !7, i64 0, !10, i64 8, !13, i64 16}
!16 = !{!12, !7, i64 0}
!17 = !{!15, !7, i64 0}
!18 = !{!19, !20, i64 24}
!19 = !{!"s_vvertice", !13, i64 0, !13, i64 4, !13, i64 8, !13, i64 12, !13, i64 16, !20, i64 20, !20, i64 24, !20, i64 28, !20, i64 32, !13, i64 36, !13, i64 40, !8, i64 44, !8, i64 64, !8, i64 96, !20, i64 108}
!20 = !{!"float", !8, i64 0}
!21 = !{!7, !7, i64 0}
!22 = !{!20, !20, i64 0}
!23 = !{!19, !20, i64 28}
!24 = !{!19, !20, i64 32}
!25 = !{!19, !20, i64 20}
!26 = distinct !{!26, !27}
!27 = !{!"llvm.loop.mustprogress"}


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