; LLVM IR from FSmallenburg/EDMD :: Grow (mdgrow)

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

@maxscheduletime = external dso_local global double, align 8
@eventlisttime = external dso_local global double, align 8
@nempty = external dso_local global i32, align 4
@root = external dso_local global ptr, align 8
@numeventlists = external dso_local global i32, align 4
@.str.15 = external hidden unnamed_addr constant [75 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [21 x i8], align 1
@eventlist = external dso_local global [100012 x %struct.sevent], align 16
@eventpool = external dso_local global [100012 x ptr], align 16
@.str.17 = external hidden unnamed_addr constant [35 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

declare i32 @printf(ptr noundef, ...) #1

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) #2

; Function Attrs: nounwind uwtable
define dso_local void @initeventpool() #3 {
  %1 = alloca i32, align 4
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = load double, ptr @maxscheduletime, align 8, !tbaa !5
  %5 = load double, ptr @eventlisttime, align 8, !tbaa !5
  %6 = fdiv double %4, %5
  %7 = call double @llvm.ceil.f64(double %6)
  %8 = fptosi double %7 to i32
  store i32 %8, ptr @numeventlists, align 4, !tbaa !9
  %9 = load i32, ptr @numeventlists, align 4, !tbaa !9
  %10 = sitofp i32 %9 to double
  %11 = load double, ptr @eventlisttime, align 8, !tbaa !5
  %12 = fmul double %10, %11
  store double %12, ptr @maxscheduletime, align 8, !tbaa !5
  %13 = load i32, ptr @numeventlists, align 4, !tbaa !9
  %14 = icmp sgt i32 %13, 500000
  br i1 %14, label %15, label %18

15:                                               ; preds = %0
  %16 = load i32, ptr @numeventlists, align 4, !tbaa !9
  %17 = call i32 (ptr, ...) @printf(ptr noundef @.str.15, i32 noundef %16)
  call void @exit(i32 noundef 3) #5
  unreachable

18:                                               ; preds = %0
  %19 = load i32, ptr @numeventlists, align 4, !tbaa !9
  %20 = call i32 (ptr, ...) @printf(ptr noundef @.str.16, i32 noundef %19)
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #6
  store i32 0, ptr %1, align 4, !tbaa !9
  br label %21

21:                                               ; preds = %46, %18
  %22 = load i32, ptr %1, align 4, !tbaa !9
  %23 = icmp slt i32 %22, 100012
  br i1 %23, label %24, label %49

24:                                               ; preds = %21
  %25 = load i32, ptr %1, align 4, !tbaa !9
  %26 = sub nsw i32 100012, %25
  %27 = sub nsw i32 %26, 1
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [100012 x %struct.sevent], ptr @eventlist, i64 0, i64 %28
  store ptr %29, ptr %2, align 8, !tbaa !11
  %30 = load ptr, ptr %2, align 8, !tbaa !11
  %31 = load i32, ptr %1, align 4, !tbaa !9
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds [100012 x ptr], ptr @eventpool, i64 0, i64 %32
  store ptr %30, ptr %33, align 8, !tbaa !11
  %34 = load i32, ptr %1, align 4, !tbaa !9
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds [100012 x ptr], ptr @eventpool, i64 0, i64 %35
  %37 = load ptr, ptr %36, align 8, !tbaa !11
  %38 = getelementptr inbounds %struct.sevent, ptr %37, i32 0, i32 1
  store ptr null, ptr %38, align 8, !tbaa !13
  %39 = load i32, ptr %1, align 4, !tbaa !9
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds [100012 x ptr], ptr @eventpool, i64 0, i64 %40
  %42 = load ptr, ptr %41, align 8, !tbaa !11
  %43 = getelementptr inbounds %struct.sevent, ptr %42, i32 0, i32 2
  store ptr null, ptr %43, align 8, !tbaa !15
  %44 = load i32, ptr @nempty, align 4, !tbaa !9
  %45 = add nsw i32 %44, 1
  store i32 %45, ptr @nempty, align 4, !tbaa !9
  br label %46

46:                                               ; preds = %24
  %47 = load i32, ptr %1, align 4, !tbaa !9
  %48 = add nsw i32 %47, 1
  store i32 %48, ptr %1, align 4, !tbaa !9
  br label %21, !llvm.loop !16

49:                                               ; preds = %21
  %50 = load i32, ptr @nempty, align 4, !tbaa !9
  %51 = add nsw i32 %50, -1
  store i32 %51, ptr @nempty, align 4, !tbaa !9
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds [100012 x ptr], ptr @eventpool, i64 0, i64 %52
  %54 = load ptr, ptr %53, align 8, !tbaa !11
  store ptr %54, ptr @root, align 8, !tbaa !11
  %55 = load ptr, ptr @root, align 8, !tbaa !11
  %56 = getelementptr inbounds %struct.sevent, ptr %55, i32 0, i32 0
  store double 0xC2374876E7FFFD71, ptr %56, align 8, !tbaa !18
  %57 = load ptr, ptr @root, align 8, !tbaa !11
  %58 = getelementptr inbounds %struct.sevent, ptr %57, i32 0, i32 8
  store i8 -56, ptr %58, align 8, !tbaa !19
  %59 = load ptr, ptr @root, align 8, !tbaa !11
  %60 = getelementptr inbounds %struct.sevent, ptr %59, i32 0, i32 3
  store ptr null, ptr %60, align 8, !tbaa !20
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #6
  %61 = load i32, ptr @nempty, align 4, !tbaa !9
  %62 = add nsw i32 %61, -1
  store i32 %62, ptr @nempty, align 4, !tbaa !9
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds [100012 x ptr], ptr @eventpool, i64 0, i64 %63
  %65 = load ptr, ptr %64, align 8, !tbaa !11
  store ptr %65, ptr %3, align 8, !tbaa !11
  %66 = load ptr, ptr %3, align 8, !tbaa !11
  %67 = getelementptr inbounds %struct.sevent, ptr %66, i32 0, i32 0
  store double 0.000000e+00, ptr %67, align 8, !tbaa !18
  %68 = load ptr, ptr %3, align 8, !tbaa !11
  %69 = getelementptr inbounds %struct.sevent, ptr %68, i32 0, i32 8
  store i8 100, ptr %69, align 8, !tbaa !19
  %70 = load ptr, ptr %3, align 8, !tbaa !11
  %71 = load ptr, ptr @root, align 8, !tbaa !11
  %72 = getelementptr inbounds %struct.sevent, ptr %71, i32 0, i32 2
  store ptr %70, ptr %72, align 8, !tbaa !15
  %73 = load ptr, ptr @root, align 8, !tbaa !11
  %74 = load ptr, ptr %3, align 8, !tbaa !11
  %75 = getelementptr inbounds %struct.sevent, ptr %74, i32 0, i32 3
  store ptr %73, ptr %75, align 8, !tbaa !20
  %76 = load i32, ptr @nempty, align 4, !tbaa !9
  %77 = sub nsw i32 100012, %76
  %78 = call i32 (ptr, ...) @printf(ptr noundef @.str.17, i32 noundef %77)
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #6
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.ceil.f64(double) #4

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { noreturn 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 #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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { noreturn nounwind }
attributes #6 = { 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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = !{!14, !12, i64 8}
!14 = !{!"sevent", !6, i64 0, !12, i64 8, !12, i64 16, !12, i64 24, !12, i64 32, !12, i64 40, !12, i64 48, !12, i64 56, !7, i64 64, !10, i64 68, !10, i64 72}
!15 = !{!14, !12, i64 16}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{!14, !6, i64 0}
!19 = !{!14, !7, i64 64}
!20 = !{!14, !12, i64 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"

%struct.sevent = type { double, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i8, i32, i32 }

@maxscheduletime = external dso_local local_unnamed_addr global double, align 8
@eventlisttime = external dso_local local_unnamed_addr global double, align 8
@nempty = external dso_local local_unnamed_addr global i32, align 4
@root = external dso_local local_unnamed_addr global ptr, align 8
@numeventlists = external dso_local local_unnamed_addr global i32, align 4
@.str.15 = external hidden unnamed_addr constant [75 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [21 x i8], align 1
@eventlist = external dso_local global [100012 x %struct.sevent], align 16
@eventpool = external dso_local local_unnamed_addr global [100012 x ptr], align 16
@.str.17 = external hidden unnamed_addr constant [35 x i8], align 1

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

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @initeventpool() local_unnamed_addr #2 {
  %1 = load double, ptr @maxscheduletime, align 8, !tbaa !5
  %2 = load double, ptr @eventlisttime, align 8, !tbaa !5
  %3 = fdiv double %1, %2
  %4 = tail call double @llvm.ceil.f64(double %3)
  %5 = fptosi double %4 to i32
  store i32 %5, ptr @numeventlists, align 4, !tbaa !9
  %6 = sitofp i32 %5 to double
  %7 = fmul double %2, %6
  store double %7, ptr @maxscheduletime, align 8, !tbaa !5
  %8 = icmp sgt i32 %5, 500000
  br i1 %8, label %9, label %11

9:                                                ; preds = %0
  %10 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.15, i32 noundef %5)
  tail call void @exit(i32 noundef 3) #5
  unreachable

11:                                               ; preds = %0
  %12 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.16, i32 noundef %5)
  %nempty.promoted = load i32, ptr @nempty, align 4, !tbaa !9
  br label %13

13:                                               ; preds = %13, %11
  %indvars.iv = phi i64 [ 0, %11 ], [ %indvars.iv.next.3, %13 ]
  %14 = sub nuw nsw i64 100011, %indvars.iv
  %15 = getelementptr inbounds [100012 x %struct.sevent], ptr @eventlist, i64 0, i64 %14
  %16 = getelementptr inbounds [100012 x ptr], ptr @eventpool, i64 0, i64 %indvars.iv
  store ptr %15, ptr %16, align 16, !tbaa !11
  %17 = getelementptr inbounds i8, ptr %15, i64 8
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %17, i8 0, i64 16, i1 false)
  %18 = sub nuw nsw i64 100011, %indvars.iv.next
  %19 = getelementptr inbounds [100012 x %struct.sevent], ptr @eventlist, i64 0, i64 %18
  %20 = getelementptr inbounds [100012 x ptr], ptr @eventpool, i64 0, i64 %indvars.iv.next
  store ptr %19, ptr %20, align 8, !tbaa !11
  %21 = getelementptr inbounds i8, ptr %19, i64 8
  %indvars.iv.next.1 = or disjoint i64 %indvars.iv, 2
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %21, i8 0, i64 16, i1 false)
  %22 = sub nuw nsw i64 100011, %indvars.iv.next.1
  %23 = getelementptr inbounds [100012 x %struct.sevent], ptr @eventlist, i64 0, i64 %22
  %24 = getelementptr inbounds [100012 x ptr], ptr @eventpool, i64 0, i64 %indvars.iv.next.1
  store ptr %23, ptr %24, align 16, !tbaa !11
  %25 = getelementptr inbounds i8, ptr %23, i64 8
  %indvars.iv.next.2 = or disjoint i64 %indvars.iv, 3
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %25, i8 0, i64 16, i1 false)
  %26 = sub nuw nsw i64 100011, %indvars.iv.next.2
  %27 = getelementptr inbounds [100012 x %struct.sevent], ptr @eventlist, i64 0, i64 %26
  %28 = getelementptr inbounds [100012 x ptr], ptr @eventpool, i64 0, i64 %indvars.iv.next.2
  store ptr %27, ptr %28, align 8, !tbaa !11
  %29 = getelementptr inbounds i8, ptr %27, i64 8
  %indvars.iv.next.3 = add nuw nsw i64 %indvars.iv, 4
  %exitcond.not.3 = icmp eq i64 %indvars.iv.next.3, 100012
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %29, i8 0, i64 16, i1 false)
  br i1 %exitcond.not.3, label %30, label %13, !llvm.loop !13

30:                                               ; preds = %13
  %31 = add i32 %nempty.promoted, 100011
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds [100012 x ptr], ptr @eventpool, i64 0, i64 %32
  %34 = load ptr, ptr %33, align 8, !tbaa !11
  store ptr %34, ptr @root, align 8, !tbaa !11
  store double 0xC2374876E7FFFD71, ptr %34, align 8, !tbaa !15
  %35 = getelementptr inbounds i8, ptr %34, i64 64
  store i8 -56, ptr %35, align 8, !tbaa !17
  %36 = getelementptr inbounds i8, ptr %34, i64 24
  store ptr null, ptr %36, align 8, !tbaa !18
  %37 = add i32 %nempty.promoted, 100010
  store i32 %37, ptr @nempty, align 4, !tbaa !9
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [100012 x ptr], ptr @eventpool, i64 0, i64 %38
  %40 = load ptr, ptr %39, align 8, !tbaa !11
  store double 0.000000e+00, ptr %40, align 8, !tbaa !15
  %41 = getelementptr inbounds i8, ptr %40, i64 64
  store i8 100, ptr %41, align 8, !tbaa !17
  %42 = getelementptr inbounds i8, ptr %34, i64 16
  store ptr %40, ptr %42, align 8, !tbaa !19
  %43 = getelementptr inbounds i8, ptr %40, i64 24
  store ptr %34, ptr %43, align 8, !tbaa !18
  %44 = sub i32 2, %nempty.promoted
  %45 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.17, i32 noundef %44)
  ret void
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.ceil.f64(double) #3

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

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 = { noreturn 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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { noreturn 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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{!16, !6, i64 0}
!16 = !{!"sevent", !6, i64 0, !12, i64 8, !12, i64 16, !12, i64 24, !12, i64 32, !12, i64 40, !12, i64 48, !12, i64 56, !7, i64 64, !10, i64 68, !10, i64 72}
!17 = !{!16, !7, i64 64}
!18 = !{!16, !12, i64 24}
!19 = !{!16, !12, i64 16}


; Effective O3 passes: CorrelatedValuePropagationPass,DSEPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LCSSAPass,LICMPass,LoopRotatePass,LoopUnrollPass,MemCpyOptPass,SROAPass,SimplifyCFGPass,TailCallElimPass