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

; 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_th.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_th(ptr noundef, ptr noundef, double noundef, double noundef, double noundef) #0

; Function Attrs: nounwind uwtable
define dso_local i32 @dens_th(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 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
  %18 = load double, ptr %6, align 8, !tbaa !9
  %19 = fdiv double 0x4073020D1B71758E, %18
  store double %19, 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_th.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
  store i32 0, ptr %8, align 4, !tbaa !11
  br label %20

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

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

38:                                               ; preds = %59, %23
  %39 = load double, ptr %16, align 8, !tbaa !9
  store double %39, ptr %15, align 8, !tbaa !9
  %40 = load double, ptr %15, align 8, !tbaa !9
  %41 = load double, ptr %10, align 8, !tbaa !9
  %42 = load double, ptr %7, align 8, !tbaa !9
  call void @calcfd_dfd_th(ptr noundef %11, ptr noundef %12, double noundef %40, double noundef %41, double noundef %42)
  %43 = load double, ptr %15, align 8, !tbaa !9
  %44 = load double, ptr %11, align 8, !tbaa !9
  %45 = load double, ptr %12, align 8, !tbaa !9
  %46 = fdiv double %44, %45
  %47 = fsub double %43, %46
  store double %47, ptr %16, align 8, !tbaa !9
  %48 = load i32, ptr %9, align 4, !tbaa !11
  %49 = add nsw i32 %48, 1
  store i32 %49, ptr %9, align 4, !tbaa !11
  br label %50

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

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

59:                                               ; preds = %53, %50
  %60 = phi i1 [ false, %50 ], [ %58, %53 ]
  br i1 %60, label %38, label %61, !llvm.loop !13

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

64:                                               ; preds = %61
  br label %89

65:                                               ; preds = %61
  %66 = load double, ptr %16, align 8, !tbaa !9
  %67 = call i1 @llvm.is.fpclass.f64(double %66, i32 3)
  br i1 %67, label %88, label %68

68:                                               ; preds = %65
  %69 = load double, ptr %6, align 8, !tbaa !9
  %70 = load double, ptr %16, align 8, !tbaa !9
  %71 = fmul double %70, 4.676000e+02
  call void @co2_prop_calc_tr(ptr noundef %13, double noundef %69, double noundef %71)
  %72 = call i32 @is_vld_prop(ptr noundef %13)
  %73 = icmp eq i32 %72, 0
  br i1 %73, label %74, label %87

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

83:                                               ; preds = %74
  %84 = load double, ptr %16, 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 %17, align 4
  br label %93

87:                                               ; preds = %74, %68
  br label %89

88:                                               ; preds = %65
  br label %89

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

92:                                               ; preds = %20
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %17, align 4
  br label %93

93:                                               ; preds = %92, %83
  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
  %94 = load i32, ptr %4, align 4
  ret i32 %94
}

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 56}
!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_th.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_th(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_th(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, %1
  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
  %8 = getelementptr inbounds i8, ptr %6, i64 56
  br label %9

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

16:                                               ; preds = %17, %9
  %.026 = phi i32 [ 0, %9 ], [ %22, %17 ]
  %.0 = phi double [ %15, %9 ], [ %21, %17 ]
  call void @calcfd_dfd_th(ptr noundef nonnull %4, ptr noundef nonnull %5, double noundef %.0, double noundef %7, double noundef %2)
  %exitcond.not = icmp eq i32 %.026, 99
  br i1 %exitcond.not, label %.critedge.thread, label %17

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

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

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

32:                                               ; preds = %28
  %33 = load double, ptr %8, align 8, !tbaa !11
  %34 = fsub double %2, %33
  %35 = fdiv double %34, %2
  %36 = call double @llvm.fabs.f64(double %35)
  %37 = fcmp olt double %36, 1.000000e-04
  br i1 %37, label %38, label %.critedge.thread

38:                                               ; preds = %32
  store double %29, ptr %0, align 8, !tbaa !5
  br label %.loopexit

.critedge.thread:                                 ; preds = %16, %28, %32, %.critedge
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond34.not = icmp eq i64 %indvars.iv.next, 12
  br i1 %exitcond34.not, label %.loopexit, label %9, !llvm.loop !13

.loopexit:                                        ; preds = %.critedge.thread, %38
  %.024 = phi i32 [ 0, %38 ], [ -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 %.024
}

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 56}
!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,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass