; LLVM IR from chrr/libECP :: src (gc_integrators)

; 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.GCIntegrationTable = type { i32, i32, ptr, ptr, double, double, i32, i32 }

; Function Attrs: nounwind uwtable
define dso_local ptr @GCIntegrationTable_copy(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  %5 = call noalias ptr @calloc(i64 noundef 1, i64 noundef 48) #4
  store ptr %5, ptr %4, align 8, !tbaa !5
  %6 = load ptr, ptr %2, align 8, !tbaa !5
  %7 = getelementptr inbounds %struct.GCIntegrationTable, ptr %6, i32 0, i32 1
  %8 = load i32, ptr %7, align 4, !tbaa !9
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.GCIntegrationTable, ptr %9, i32 0, i32 1
  store i32 %8, ptr %10, align 4, !tbaa !9
  %11 = load ptr, ptr %2, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.GCIntegrationTable, ptr %11, i32 0, i32 0
  %13 = load i32, ptr %12, align 8, !tbaa !13
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.GCIntegrationTable, ptr %14, i32 0, i32 0
  store i32 %13, ptr %15, align 8, !tbaa !13
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.GCIntegrationTable, ptr %16, i32 0, i32 1
  %18 = load i32, ptr %17, align 4, !tbaa !9
  %19 = sext i32 %18 to i64
  %20 = call noalias ptr @calloc(i64 noundef %19, i64 noundef 8) #4
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.GCIntegrationTable, ptr %21, i32 0, i32 2
  store ptr %20, ptr %22, align 8, !tbaa !14
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.GCIntegrationTable, ptr %23, i32 0, i32 1
  %25 = load i32, ptr %24, align 4, !tbaa !9
  %26 = sext i32 %25 to i64
  %27 = call noalias ptr @calloc(i64 noundef %26, i64 noundef 8) #4
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.GCIntegrationTable, ptr %28, i32 0, i32 3
  store ptr %27, ptr %29, align 8, !tbaa !15
  %30 = load ptr, ptr %2, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.GCIntegrationTable, ptr %30, i32 0, i32 4
  %32 = load double, ptr %31, align 8, !tbaa !16
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.GCIntegrationTable, ptr %33, i32 0, i32 4
  store double %32, ptr %34, align 8, !tbaa !16
  %35 = load ptr, ptr %2, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.GCIntegrationTable, ptr %35, i32 0, i32 5
  %37 = load double, ptr %36, align 8, !tbaa !17
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.GCIntegrationTable, ptr %38, i32 0, i32 5
  store double %37, ptr %39, align 8, !tbaa !17
  %40 = load ptr, ptr %2, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.GCIntegrationTable, ptr %40, i32 0, i32 6
  %42 = load i32, ptr %41, align 8, !tbaa !18
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.GCIntegrationTable, ptr %43, i32 0, i32 6
  store i32 %42, ptr %44, align 8, !tbaa !18
  %45 = load ptr, ptr %2, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.GCIntegrationTable, ptr %45, i32 0, i32 7
  %47 = load i32, ptr %46, align 4, !tbaa !19
  %48 = load ptr, ptr %4, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.GCIntegrationTable, ptr %48, i32 0, i32 7
  store i32 %47, ptr %49, align 4, !tbaa !19
  store i32 0, ptr %3, align 4, !tbaa !20
  br label %50

50:                                               ; preds = %83, %1
  %51 = load i32, ptr %3, align 4, !tbaa !20
  %52 = load ptr, ptr %4, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.GCIntegrationTable, ptr %52, i32 0, i32 1
  %54 = load i32, ptr %53, align 4, !tbaa !9
  %55 = icmp slt i32 %51, %54
  br i1 %55, label %56, label %86

56:                                               ; preds = %50
  %57 = load ptr, ptr %2, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.GCIntegrationTable, ptr %57, i32 0, i32 2
  %59 = load ptr, ptr %58, align 8, !tbaa !14
  %60 = load i32, ptr %3, align 4, !tbaa !20
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds double, ptr %59, i64 %61
  %63 = load double, ptr %62, align 8, !tbaa !21
  %64 = load ptr, ptr %4, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.GCIntegrationTable, ptr %64, i32 0, i32 2
  %66 = load ptr, ptr %65, align 8, !tbaa !14
  %67 = load i32, ptr %3, align 4, !tbaa !20
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds double, ptr %66, i64 %68
  store double %63, ptr %69, align 8, !tbaa !21
  %70 = load ptr, ptr %2, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.GCIntegrationTable, ptr %70, i32 0, i32 3
  %72 = load ptr, ptr %71, align 8, !tbaa !15
  %73 = load i32, ptr %3, align 4, !tbaa !20
  %74 = sext i32 %73 to i64
  %75 = getelementptr inbounds double, ptr %72, i64 %74
  %76 = load double, ptr %75, align 8, !tbaa !21
  %77 = load ptr, ptr %4, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.GCIntegrationTable, ptr %77, i32 0, i32 3
  %79 = load ptr, ptr %78, align 8, !tbaa !15
  %80 = load i32, ptr %3, align 4, !tbaa !20
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds double, ptr %79, i64 %81
  store double %76, ptr %82, align 8, !tbaa !21
  br label %83

83:                                               ; preds = %56
  %84 = load i32, ptr %3, align 4, !tbaa !20
  %85 = add nsw i32 %84, 1
  store i32 %85, ptr %3, align 4, !tbaa !20
  br label %50, !llvm.loop !22

86:                                               ; preds = %50
  %87 = load ptr, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  ret ptr %87
}

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

; Function Attrs: nounwind allocsize(0,1)
declare noalias ptr @calloc(i64 noundef, i64 noundef) #2

; 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 allocsize(0,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 #3 = { nounwind }
attributes #4 = { nounwind allocsize(0,1) }

!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, !11, i64 4}
!10 = !{!"", !11, i64 0, !11, i64 4, !6, i64 8, !6, i64 16, !12, i64 24, !12, i64 32, !11, i64 40, !11, i64 44}
!11 = !{!"int", !7, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = !{!10, !11, i64 0}
!14 = !{!10, !6, i64 8}
!15 = !{!10, !6, i64 16}
!16 = !{!10, !12, i64 24}
!17 = !{!10, !12, i64 32}
!18 = !{!10, !11, i64 40}
!19 = !{!10, !11, i64 44}
!20 = !{!11, !11, i64 0}
!21 = !{!12, !12, i64 0}
!22 = distinct !{!22, !23}
!23 = !{!"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"

; Function Attrs: nofree nounwind memory(readwrite, argmem: read) uwtable
define dso_local noalias noundef ptr @GCIntegrationTable_copy(ptr nocapture noundef readonly %0) local_unnamed_addr #0 {
  %2 = tail call noalias dereferenceable_or_null(48) ptr @calloc(i64 noundef 1, i64 noundef 48) #2
  %3 = getelementptr inbounds i8, ptr %0, i64 4
  %4 = load i32, ptr %3, align 4, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %2, i64 4
  store i32 %4, ptr %5, align 4, !tbaa !5
  %6 = load i32, ptr %0, align 8, !tbaa !12
  store i32 %6, ptr %2, align 8, !tbaa !12
  %7 = sext i32 %4 to i64
  %8 = tail call noalias ptr @calloc(i64 noundef %7, i64 noundef 8) #2
  %9 = ptrtoint ptr %8 to i64
  %10 = getelementptr inbounds i8, ptr %2, i64 8
  store ptr %8, ptr %10, align 8, !tbaa !13
  %11 = tail call noalias ptr @calloc(i64 noundef %7, i64 noundef 8) #2
  %12 = ptrtoint ptr %11 to i64
  %13 = getelementptr inbounds i8, ptr %2, i64 16
  store ptr %11, ptr %13, align 8, !tbaa !14
  %14 = getelementptr inbounds i8, ptr %0, i64 24
  %15 = getelementptr inbounds i8, ptr %2, i64 24
  %16 = load <2 x double>, ptr %14, align 8, !tbaa !15
  store <2 x double> %16, ptr %15, align 8, !tbaa !15
  %17 = getelementptr inbounds i8, ptr %0, i64 40
  %18 = getelementptr inbounds i8, ptr %2, i64 40
  %19 = load <2 x i32>, ptr %17, align 8, !tbaa !16
  store <2 x i32> %19, ptr %18, align 8, !tbaa !16
  %20 = icmp sgt i32 %4, 0
  br i1 %20, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %1
  %21 = getelementptr inbounds i8, ptr %0, i64 8
  %22 = load ptr, ptr %21, align 8, !tbaa !13
  %23 = getelementptr inbounds i8, ptr %0, i64 16
  %24 = load ptr, ptr %23, align 8, !tbaa !14
  %wide.trip.count = zext nneg i32 %4 to i64
  %min.iters.check = icmp ult i32 %4, 24
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.memcheck

vector.memcheck:                                  ; preds = %.lr.ph
  %25 = ptrtoint ptr %24 to i64
  %26 = ptrtoint ptr %22 to i64
  %27 = sub i64 %12, %9
  %diff.check = icmp ult i64 %27, 32
  %28 = sub i64 %9, %26
  %diff.check29 = icmp ult i64 %28, 32
  %conflict.rdx = or i1 %diff.check, %diff.check29
  %29 = sub i64 %25, %9
  %diff.check30 = icmp ult i64 %29, 32
  %conflict.rdx31 = or i1 %conflict.rdx, %diff.check30
  %30 = sub i64 %12, %26
  %diff.check32 = icmp ult i64 %30, 32
  %conflict.rdx33 = or i1 %conflict.rdx31, %diff.check32
  %31 = sub i64 %12, %25
  %diff.check34 = icmp ult i64 %31, 32
  %conflict.rdx35 = or i1 %conflict.rdx33, %diff.check34
  br i1 %conflict.rdx35, label %scalar.ph.preheader, label %vector.ph

vector.ph:                                        ; preds = %vector.memcheck
  %n.vec = and i64 %wide.trip.count, 2147483644
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %32 = getelementptr inbounds double, ptr %22, i64 %index
  %33 = getelementptr inbounds i8, ptr %32, i64 16
  %wide.load = load <2 x double>, ptr %32, align 8, !tbaa !15
  %wide.load36 = load <2 x double>, ptr %33, align 8, !tbaa !15
  %34 = getelementptr inbounds double, ptr %8, i64 %index
  %35 = getelementptr inbounds i8, ptr %34, i64 16
  store <2 x double> %wide.load, ptr %34, align 8, !tbaa !15
  store <2 x double> %wide.load36, ptr %35, align 8, !tbaa !15
  %36 = getelementptr inbounds double, ptr %24, i64 %index
  %37 = getelementptr inbounds i8, ptr %36, i64 16
  %wide.load37 = load <2 x double>, ptr %36, align 8, !tbaa !15
  %wide.load38 = load <2 x double>, ptr %37, align 8, !tbaa !15
  %38 = getelementptr inbounds double, ptr %11, i64 %index
  %39 = getelementptr inbounds i8, ptr %38, i64 16
  store <2 x double> %wide.load37, ptr %38, align 8, !tbaa !15
  store <2 x double> %wide.load38, ptr %39, align 8, !tbaa !15
  %index.next = add nuw i64 %index, 4
  %40 = icmp eq i64 %index.next, %n.vec
  br i1 %40, label %middle.block, label %vector.body, !llvm.loop !17

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %n.vec, %wide.trip.count
  br i1 %cmp.n, label %._crit_edge, label %scalar.ph.preheader

scalar.ph.preheader:                              ; preds = %middle.block, %vector.memcheck, %.lr.ph
  %indvars.iv.ph = phi i64 [ 0, %vector.memcheck ], [ 0, %.lr.ph ], [ %n.vec, %middle.block ]
  %xtraiter = and i64 %wide.trip.count, 1
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %scalar.ph.prol.loopexit, label %scalar.ph.prol

scalar.ph.prol:                                   ; preds = %scalar.ph.preheader
  %41 = getelementptr inbounds double, ptr %22, i64 %indvars.iv.ph
  %42 = load double, ptr %41, align 8, !tbaa !15
  %43 = getelementptr inbounds double, ptr %8, i64 %indvars.iv.ph
  store double %42, ptr %43, align 8, !tbaa !15
  %44 = getelementptr inbounds double, ptr %24, i64 %indvars.iv.ph
  %45 = load double, ptr %44, align 8, !tbaa !15
  %46 = getelementptr inbounds double, ptr %11, i64 %indvars.iv.ph
  store double %45, ptr %46, align 8, !tbaa !15
  %indvars.iv.next.prol = or disjoint i64 %indvars.iv.ph, 1
  br label %scalar.ph.prol.loopexit

scalar.ph.prol.loopexit:                          ; preds = %scalar.ph.prol, %scalar.ph.preheader
  %indvars.iv.unr = phi i64 [ %indvars.iv.ph, %scalar.ph.preheader ], [ %indvars.iv.next.prol, %scalar.ph.prol ]
  %47 = add nsw i64 %wide.trip.count, -1
  %48 = icmp eq i64 %indvars.iv.ph, %47
  br i1 %48, label %._crit_edge, label %scalar.ph

scalar.ph:                                        ; preds = %scalar.ph.prol.loopexit, %scalar.ph
  %indvars.iv = phi i64 [ %indvars.iv.next.1, %scalar.ph ], [ %indvars.iv.unr, %scalar.ph.prol.loopexit ]
  %49 = getelementptr inbounds double, ptr %22, i64 %indvars.iv
  %50 = load double, ptr %49, align 8, !tbaa !15
  %51 = getelementptr inbounds double, ptr %8, i64 %indvars.iv
  store double %50, ptr %51, align 8, !tbaa !15
  %52 = getelementptr inbounds double, ptr %24, i64 %indvars.iv
  %53 = load double, ptr %52, align 8, !tbaa !15
  %54 = getelementptr inbounds double, ptr %11, i64 %indvars.iv
  store double %53, ptr %54, align 8, !tbaa !15
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %55 = getelementptr inbounds double, ptr %22, i64 %indvars.iv.next
  %56 = load double, ptr %55, align 8, !tbaa !15
  %57 = getelementptr inbounds double, ptr %8, i64 %indvars.iv.next
  store double %56, ptr %57, align 8, !tbaa !15
  %58 = getelementptr inbounds double, ptr %24, i64 %indvars.iv.next
  %59 = load double, ptr %58, align 8, !tbaa !15
  %60 = getelementptr inbounds double, ptr %11, i64 %indvars.iv.next
  store double %59, ptr %60, align 8, !tbaa !15
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %exitcond.not.1 = icmp eq i64 %indvars.iv.next.1, %wide.trip.count
  br i1 %exitcond.not.1, label %._crit_edge, label %scalar.ph, !llvm.loop !21

._crit_edge:                                      ; preds = %scalar.ph.prol.loopexit, %scalar.ph, %middle.block, %1
  ret ptr %2
}

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @calloc(i64 noundef, i64 noundef) local_unnamed_addr #1

attributes #0 = { nofree nounwind memory(readwrite, argmem: read) 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 = { mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 allocsize(0,1) }

!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 4}
!6 = !{!"", !7, i64 0, !7, i64 4, !10, i64 8, !10, i64 16, !11, i64 24, !11, i64 32, !7, i64 40, !7, i64 44}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"double", !8, i64 0}
!12 = !{!6, !7, i64 0}
!13 = !{!6, !10, i64 8}
!14 = !{!6, !10, i64 16}
!15 = !{!11, !11, i64 0}
!16 = !{!7, !7, i64 0}
!17 = distinct !{!17, !18, !19, !20}
!18 = !{!"llvm.loop.mustprogress"}
!19 = !{!"llvm.loop.isvectorized", i32 1}
!20 = !{!"llvm.loop.unroll.runtime.disable"}
!21 = distinct !{!21, !18, !19}


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