; LLVM IR from sd12832/High-Performance-Computing-Files :: d2q9-bgk-serial (total_density)

; 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.t_param = type { i32, i32, i32, i32, double, double, double }
%struct.t_speed = type { [9 x double] }

; 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: nounwind uwtable
define dso_local double @total_density(ptr noundef byval(%struct.t_param) align 8 %0, ptr noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca double, align 8
  store ptr %1, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #2
  store double 0.000000e+00, ptr %7, align 8, !tbaa !9
  store i32 0, ptr %4, align 4, !tbaa !11
  br label %8

8:                                                ; preds = %48, %2
  %9 = load i32, ptr %4, align 4, !tbaa !11
  %10 = getelementptr inbounds %struct.t_param, ptr %0, i32 0, i32 1
  %11 = load i32, ptr %10, align 4, !tbaa !13
  %12 = icmp slt i32 %9, %11
  br i1 %12, label %13, label %51

13:                                               ; preds = %8
  store i32 0, ptr %5, align 4, !tbaa !11
  br label %14

14:                                               ; preds = %44, %13
  %15 = load i32, ptr %5, align 4, !tbaa !11
  %16 = getelementptr inbounds %struct.t_param, ptr %0, i32 0, i32 0
  %17 = load i32, ptr %16, align 8, !tbaa !15
  %18 = icmp slt i32 %15, %17
  br i1 %18, label %19, label %47

19:                                               ; preds = %14
  store i32 0, ptr %6, align 4, !tbaa !11
  br label %20

20:                                               ; preds = %40, %19
  %21 = load i32, ptr %6, align 4, !tbaa !11
  %22 = icmp slt i32 %21, 9
  br i1 %22, label %23, label %43

23:                                               ; preds = %20
  %24 = load ptr, ptr %3, align 8, !tbaa !5
  %25 = load i32, ptr %4, align 4, !tbaa !11
  %26 = getelementptr inbounds %struct.t_param, ptr %0, i32 0, i32 0
  %27 = load i32, ptr %26, align 8, !tbaa !15
  %28 = mul nsw i32 %25, %27
  %29 = load i32, ptr %5, align 4, !tbaa !11
  %30 = add nsw i32 %28, %29
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds %struct.t_speed, ptr %24, i64 %31
  %33 = getelementptr inbounds %struct.t_speed, ptr %32, i32 0, i32 0
  %34 = load i32, ptr %6, align 4, !tbaa !11
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds [9 x double], ptr %33, i64 0, i64 %35
  %37 = load double, ptr %36, align 8, !tbaa !9
  %38 = load double, ptr %7, align 8, !tbaa !9
  %39 = fadd double %38, %37
  store double %39, ptr %7, align 8, !tbaa !9
  br label %40

40:                                               ; preds = %23
  %41 = load i32, ptr %6, align 4, !tbaa !11
  %42 = add nsw i32 %41, 1
  store i32 %42, ptr %6, align 4, !tbaa !11
  br label %20, !llvm.loop !16

43:                                               ; preds = %20
  br label %44

44:                                               ; preds = %43
  %45 = load i32, ptr %5, align 4, !tbaa !11
  %46 = add nsw i32 %45, 1
  store i32 %46, ptr %5, align 4, !tbaa !11
  br label %14, !llvm.loop !18

47:                                               ; preds = %14
  br label %48

48:                                               ; preds = %47
  %49 = load i32, ptr %4, align 4, !tbaa !11
  %50 = add nsw i32 %49, 1
  store i32 %50, ptr %4, align 4, !tbaa !11
  br label %8, !llvm.loop !19

51:                                               ; preds = %8
  %52 = load double, ptr %7, align 8, !tbaa !9
  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
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #2
  ret double %52
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !12, i64 4}
!14 = !{!"", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12, !10, i64 16, !10, i64 24, !10, i64 32}
!15 = !{!14, !12, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = distinct !{!18, !17}
!19 = distinct !{!19, !17}


; 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.t_param = type { i32, i32, i32, i32, double, double, double }
%struct.t_speed = type { [9 x double] }

; Function Attrs: nofree norecurse nosync nounwind memory(argmem: read) uwtable
define dso_local double @total_density(ptr nocapture noundef readonly byval(%struct.t_param) align 8 %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 4
  %4 = load i32, ptr %3, align 4, !tbaa !5
  %5 = icmp sgt i32 %4, 0
  br i1 %5, label %.preheader14.lr.ph, label %._crit_edge21

.preheader14.lr.ph:                               ; preds = %2
  %6 = load i32, ptr %0, align 8, !tbaa !11
  %7 = icmp sgt i32 %6, 0
  br i1 %7, label %.preheader14.us.preheader, label %._crit_edge21

.preheader14.us.preheader:                        ; preds = %.preheader14.lr.ph
  %8 = zext nneg i32 %6 to i64
  %wide.trip.count29 = zext nneg i32 %4 to i64
  br label %.preheader14.us

.preheader14.us:                                  ; preds = %.preheader14.us.preheader, %._crit_edge.us
  %indvars.iv26 = phi i64 [ 0, %.preheader14.us.preheader ], [ %indvars.iv.next27, %._crit_edge.us ]
  %.020.us = phi double [ 0.000000e+00, %.preheader14.us.preheader ], [ %37, %._crit_edge.us ]
  %9 = mul nuw nsw i64 %indvars.iv26, %8
  %10 = getelementptr inbounds %struct.t_speed, ptr %1, i64 %9
  br label %.preheader.us

.preheader.us:                                    ; preds = %.preheader14.us, %.preheader.us
  %indvars.iv = phi i64 [ 0, %.preheader14.us ], [ %indvars.iv.next, %.preheader.us ]
  %.118.us = phi double [ %.020.us, %.preheader14.us ], [ %37, %.preheader.us ]
  %11 = getelementptr inbounds %struct.t_speed, ptr %10, i64 %indvars.iv
  %12 = load double, ptr %11, align 8, !tbaa !12
  %13 = fadd double %.118.us, %12
  %14 = getelementptr inbounds i8, ptr %11, i64 8
  %15 = load double, ptr %14, align 8, !tbaa !12
  %16 = fadd double %13, %15
  %17 = getelementptr inbounds i8, ptr %11, i64 16
  %18 = load double, ptr %17, align 8, !tbaa !12
  %19 = fadd double %16, %18
  %20 = getelementptr inbounds i8, ptr %11, i64 24
  %21 = load double, ptr %20, align 8, !tbaa !12
  %22 = fadd double %19, %21
  %23 = getelementptr inbounds i8, ptr %11, i64 32
  %24 = load double, ptr %23, align 8, !tbaa !12
  %25 = fadd double %22, %24
  %26 = getelementptr inbounds i8, ptr %11, i64 40
  %27 = load double, ptr %26, align 8, !tbaa !12
  %28 = fadd double %25, %27
  %29 = getelementptr inbounds i8, ptr %11, i64 48
  %30 = load double, ptr %29, align 8, !tbaa !12
  %31 = fadd double %28, %30
  %32 = getelementptr inbounds i8, ptr %11, i64 56
  %33 = load double, ptr %32, align 8, !tbaa !12
  %34 = fadd double %31, %33
  %35 = getelementptr inbounds i8, ptr %11, i64 64
  %36 = load double, ptr %35, align 8, !tbaa !12
  %37 = fadd double %34, %36
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %8
  br i1 %exitcond.not, label %._crit_edge.us, label %.preheader.us, !llvm.loop !13

._crit_edge.us:                                   ; preds = %.preheader.us
  %indvars.iv.next27 = add nuw nsw i64 %indvars.iv26, 1
  %exitcond30.not = icmp eq i64 %indvars.iv.next27, %wide.trip.count29
  br i1 %exitcond30.not, label %._crit_edge21, label %.preheader14.us, !llvm.loop !15

._crit_edge21:                                    ; preds = %._crit_edge.us, %.preheader14.lr.ph, %2
  %.0.lcssa = phi double [ 0.000000e+00, %2 ], [ 0.000000e+00, %.preheader14.lr.ph ], [ %37, %._crit_edge.us ]
  ret double %.0.lcssa
}

attributes #0 = { nofree norecurse nosync nounwind memory(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" }

!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, !7, i64 8, !7, i64 12, !10, i64 16, !10, i64 24, !10, i64 32}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"double", !8, i64 0}
!11 = !{!6, !7, i64 0}
!12 = !{!10, !10, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}


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