; LLVM IR from zhenrong-wang/co2 :: co2_property_calc (dens_pt)

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

@__const.dens_pt.del_ini = external hidden unnamed_addr constant [12 x double], align 16

; Function Attrs: nounwind uwtable
declare dso_local i32 @is_vld_prop(ptr noundef) #0

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i1 @llvm.is.fpclass.f64(double, i32 immarg) #1

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

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

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

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

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

; Function Attrs: nounwind uwtable
define dso_local i32 @dens_pt(ptr noundef %0, double noundef %1, double noundef %2) #0 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca double, align 8
  %7 = alloca double, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca double, align 8
  %11 = alloca double, align 8
  %12 = alloca double, align 8
  %13 = alloca %struct.co2_prop, align 8
  %14 = alloca [12 x double], align 16
  %15 = alloca double, align 8
  %16 = alloca double, align 8
  %17 = alloca double, align 8
  %18 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store double %1, ptr %6, align 8, !tbaa !9
  store double %2, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %19 = load double, ptr %7, align 8, !tbaa !9
  %20 = fdiv double 0x4073020D1B71758E, %19
  store double %20, ptr %10, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.start.p0(i64 128, ptr %13) #4
  call void @llvm.lifetime.start.p0(i64 96, ptr %14) #4
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %14, ptr align 16 @__const.dens_pt.del_ini, i64 96, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #4
  store i32 0, ptr %8, align 4, !tbaa !11
  br label %21

21:                                               ; preds = %88, %3
  %22 = load i32, ptr %8, align 4, !tbaa !11
  %23 = icmp slt i32 %22, 12
  br i1 %23, label %24, label %91

24:                                               ; preds = %21
  %25 = load i32, ptr %8, align 4, !tbaa !11
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [12 x double], ptr %14, i64 0, i64 %26
  %28 = load double, ptr %27, align 8, !tbaa !9
  store double %28, ptr %15, align 8, !tbaa !9
  store i32 0, ptr %9, align 4, !tbaa !11
  %29 = load double, ptr %15, align 8, !tbaa !9
  %30 = load double, ptr %6, align 8, !tbaa !9
  %31 = load double, ptr %10, align 8, !tbaa !9
  call void @calcfd_dfd_pt(ptr noundef %11, ptr noundef %12, double noundef %29, double noundef %30, double noundef %31)
  %32 = load double, ptr %15, align 8, !tbaa !9
  %33 = load double, ptr %11, align 8, !tbaa !9
  %34 = load double, ptr %12, align 8, !tbaa !9
  %35 = fdiv double %33, %34
  %36 = fsub double %32, %35
  store double %36, ptr %17, align 8, !tbaa !9
  br label %37

37:                                               ; preds = %58, %24
  %38 = load double, ptr %17, align 8, !tbaa !9
  store double %38, ptr %16, align 8, !tbaa !9
  %39 = load double, ptr %16, align 8, !tbaa !9
  %40 = load double, ptr %6, align 8, !tbaa !9
  %41 = load double, ptr %10, align 8, !tbaa !9
  call void @calcfd_dfd_pt(ptr noundef %11, ptr noundef %12, double noundef %39, double noundef %40, double noundef %41)
  %42 = load double, ptr %16, align 8, !tbaa !9
  %43 = load double, ptr %11, align 8, !tbaa !9
  %44 = load double, ptr %12, align 8, !tbaa !9
  %45 = fdiv double %43, %44
  %46 = fsub double %42, %45
  store double %46, ptr %17, align 8, !tbaa !9
  %47 = load i32, ptr %9, align 4, !tbaa !11
  %48 = add nsw i32 %47, 1
  store i32 %48, ptr %9, align 4, !tbaa !11
  br label %49

49:                                               ; preds = %37
  %50 = load i32, ptr %9, align 4, !tbaa !11
  %51 = icmp slt i32 %50, 100
  br i1 %51, label %52, label %58

52:                                               ; preds = %49
  %53 = load double, ptr %17, align 8, !tbaa !9
  %54 = load double, ptr %16, align 8, !tbaa !9
  %55 = fsub double %53, %54
  %56 = call double @llvm.fabs.f64(double %55)
  %57 = fcmp ogt double %56, 0x3EB0C6F7A0B5ED8D
  br label %58

58:                                               ; preds = %52, %49
  %59 = phi i1 [ false, %49 ], [ %57, %52 ]
  br i1 %59, label %37, label %60, !llvm.loop !13

60:                                               ; preds = %58
  %61 = load i32, ptr %9, align 4, !tbaa !11
  %62 = icmp eq i32 %61, 100
  br i1 %62, label %63, label %64

63:                                               ; preds = %60
  br label %88

64:                                               ; preds = %60
  %65 = load double, ptr %17, align 8, !tbaa !9
  %66 = call i1 @llvm.is.fpclass.f64(double %65, i32 3)
  br i1 %66, label %87, label %67

67:                                               ; preds = %64
  %68 = load double, ptr %7, align 8, !tbaa !9
  %69 = load double, ptr %17, align 8, !tbaa !9
  %70 = fmul double %69, 4.676000e+02
  call void @co2_prop_calc_tr(ptr noundef %13, double noundef %68, double noundef %70)
  %71 = call i32 @is_vld_prop(ptr noundef %13)
  %72 = icmp eq i32 %71, -1
  br i1 %72, label %82, label %73

73:                                               ; preds = %67
  %74 = load double, ptr %6, align 8, !tbaa !9
  %75 = getelementptr inbounds %struct.co2_prop, ptr %13, i32 0, i32 0
  %76 = load double, ptr %75, align 8, !tbaa !15
  %77 = fsub double %74, %76
  %78 = call double @llvm.fabs.f64(double %77)
  %79 = load double, ptr %6, align 8, !tbaa !9
  %80 = fdiv double %78, %79
  %81 = fcmp ogt double %80, 1.000000e-03
  br i1 %81, label %82, label %83

82:                                               ; preds = %73, %67
  br label %88

83:                                               ; preds = %73
  %84 = load double, ptr %17, align 8, !tbaa !9
  %85 = fmul double %84, 4.676000e+02
  %86 = load ptr, ptr %5, align 8, !tbaa !5
  store double %85, ptr %86, align 8, !tbaa !9
  store i32 0, ptr %4, align 4
  store i32 1, ptr %18, align 4
  br label %92

87:                                               ; preds = %64
  br label %88

88:                                               ; preds = %87, %82, %63
  %89 = load i32, ptr %8, align 4, !tbaa !11
  %90 = add nsw i32 %89, 1
  store i32 %90, ptr %8, align 4, !tbaa !11
  br label %21, !llvm.loop !17

91:                                               ; preds = %21
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %18, align 4
  br label %92

92:                                               ; preds = %91, %83
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 96, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 128, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  %93 = load i32, ptr %4, align 4
  ret i32 %93
}

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 speculatable willreturn memory(none) }
attributes #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{!16, !10, i64 0}
!16 = !{!"", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !10, i64 56, !10, i64 64, !10, i64 72, !10, i64 80, !10, i64 88, !10, i64 96, !10, i64 104, !10, i64 112, !10, i64 120}
!17 = distinct !{!17, !14}


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

@__const.dens_pt.del_ini = external hidden unnamed_addr constant [12 x double], align 16

; Function Attrs: nounwind uwtable
declare dso_local i32 @is_vld_prop(ptr noundef) local_unnamed_addr #0

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

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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 1) i32 @dens_pt(ptr nocapture noundef writeonly %0, double noundef %1, double noundef %2) local_unnamed_addr #0 {
  %4 = alloca double, align 8
  %5 = alloca double, align 8
  %6 = alloca %struct.co2_prop, align 8
  %7 = fdiv double 0x4073020D1B71758E, %2
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #3
  call void @llvm.lifetime.start.p0(i64 128, ptr nonnull %6) #3
  br label %8

8:                                                ; preds = %3, %.critedge.thread
  %indvars.iv = phi i64 [ 0, %3 ], [ %indvars.iv.next, %.critedge.thread ]
  %9 = getelementptr inbounds [12 x double], ptr @__const.dens_pt.del_ini, i64 0, i64 %indvars.iv
  %10 = load double, ptr %9, align 8, !tbaa !5
  call void @calcfd_dfd_pt(ptr noundef nonnull %4, ptr noundef nonnull %5, double noundef %10, double noundef %1, double noundef %7)
  %11 = load double, ptr %4, align 8, !tbaa !5
  %12 = load double, ptr %5, align 8, !tbaa !5
  %13 = fdiv double %11, %12
  %14 = fsub double %10, %13
  br label %15

15:                                               ; preds = %16, %8
  %.027 = phi i32 [ 0, %8 ], [ %21, %16 ]
  %.0 = phi double [ %14, %8 ], [ %20, %16 ]
  call void @calcfd_dfd_pt(ptr noundef nonnull %4, ptr noundef nonnull %5, double noundef %.0, double noundef %1, double noundef %7)
  %exitcond.not = icmp eq i32 %.027, 99
  br i1 %exitcond.not, label %.critedge.thread, label %16

16:                                               ; preds = %15
  %17 = load double, ptr %4, align 8, !tbaa !5
  %18 = load double, ptr %5, align 8, !tbaa !5
  %19 = fdiv double %17, %18
  %20 = fsub double %.0, %19
  %21 = add nuw nsw i32 %.027, 1
  %22 = fsub double %20, %.0
  %23 = call double @llvm.fabs.f64(double %22)
  %24 = fcmp ogt double %23, 0x3EB0C6F7A0B5ED8D
  br i1 %24, label %15, label %.critedge, !llvm.loop !9

.critedge:                                        ; preds = %16
  %25 = icmp eq i32 %21, 100
  %26 = fcmp uno double %20, 0.000000e+00
  %or.cond = select i1 %25, i1 true, i1 %26
  br i1 %or.cond, label %.critedge.thread, label %27

27:                                               ; preds = %.critedge
  %28 = fmul double %20, 4.676000e+02
  call void @co2_prop_calc_tr(ptr noundef nonnull %6, double noundef %2, double noundef %28)
  %29 = call i32 @is_vld_prop(ptr noundef nonnull %6)
  %30 = icmp eq i32 %29, -1
  br i1 %30, label %.critedge.thread, label %31

31:                                               ; preds = %27
  %32 = load double, ptr %6, align 8, !tbaa !11
  %33 = fsub double %1, %32
  %34 = call double @llvm.fabs.f64(double %33)
  %35 = fdiv double %34, %1
  %36 = fcmp ogt double %35, 1.000000e-03
  br i1 %36, label %.critedge.thread, label %37

37:                                               ; preds = %31
  store double %28, ptr %0, align 8, !tbaa !5
  br label %.loopexit

.critedge.thread:                                 ; preds = %15, %27, %31, %.critedge
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond35.not = icmp eq i64 %indvars.iv.next, 12
  br i1 %exitcond35.not, label %.loopexit, label %8, !llvm.loop !13

.loopexit:                                        ; preds = %.critedge.thread, %37
  %.025 = phi i32 [ 0, %37 ], [ -1, %.critedge.thread ]
  call void @llvm.lifetime.end.p0(i64 128, ptr nonnull %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #3
  ret i32 %.025
}

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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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, !6, i64 0}
!6 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!12, !6, i64 0}
!12 = !{!"", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !6, i64 120}
!13 = distinct !{!13, !10}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass