; LLVM IR from zhenrong-wang/co2 :: co2_property_calc_origeqns (phi0t)

; 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"

@coeff0 = external dso_local constant [8 x [2 x double]], align 16

; 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 speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #1

; Function Attrs: nounwind
declare double @exp(double noundef) #2

; 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 @phi0t(double noundef %0) #3 {
  %2 = alloca double, align 8
  %3 = alloca double, align 8
  %4 = alloca double, align 8
  %5 = alloca double, align 8
  %6 = alloca i32, align 4
  store double %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  %7 = load double, ptr getelementptr inbounds ([8 x [2 x double]], ptr @coeff0, i64 0, i64 1), align 16, !tbaa !5
  %8 = load double, ptr getelementptr inbounds ([8 x [2 x double]], ptr @coeff0, i64 0, i64 2), align 16, !tbaa !5
  %9 = load double, ptr %2, align 8, !tbaa !5
  %10 = fdiv double %8, %9
  %11 = fadd double %7, %10
  store double %11, ptr %3, align 8, !tbaa !5
  store i32 3, ptr %6, align 4, !tbaa !9
  br label %12

12:                                               ; preds = %39, %1
  %13 = load i32, ptr %6, align 4, !tbaa !9
  %14 = icmp slt i32 %13, 8
  br i1 %14, label %15, label %42

15:                                               ; preds = %12
  %16 = load i32, ptr %6, align 4, !tbaa !9
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds [8 x [2 x double]], ptr @coeff0, i64 0, i64 %17
  %19 = getelementptr inbounds [2 x double], ptr %18, i64 0, i64 0
  %20 = load double, ptr %19, align 16, !tbaa !5
  store double %20, ptr %4, align 8, !tbaa !5
  %21 = load i32, ptr %6, align 4, !tbaa !9
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [8 x [2 x double]], ptr @coeff0, i64 0, i64 %22
  %24 = getelementptr inbounds [2 x double], ptr %23, i64 0, i64 1
  %25 = load double, ptr %24, align 8, !tbaa !5
  store double %25, ptr %5, align 8, !tbaa !5
  %26 = load double, ptr %4, align 8, !tbaa !5
  %27 = load double, ptr %5, align 8, !tbaa !5
  %28 = fmul double %26, %27
  %29 = load double, ptr %5, align 8, !tbaa !5
  %30 = fneg double %29
  %31 = load double, ptr %2, align 8, !tbaa !5
  %32 = fmul double %30, %31
  %33 = call double @exp(double noundef %32) #4
  %34 = fsub double 1.000000e+00, %33
  %35 = fdiv double 1.000000e+00, %34
  %36 = fsub double %35, 1.000000e+00
  %37 = load double, ptr %3, align 8, !tbaa !5
  %38 = call double @llvm.fmuladd.f64(double %28, double %36, double %37)
  store double %38, ptr %3, align 8, !tbaa !5
  br label %39

39:                                               ; preds = %15
  %40 = load i32, ptr %6, align 4, !tbaa !9
  %41 = add nsw i32 %40, 1
  store i32 %41, ptr %6, align 4, !tbaa !9
  br label %12, !llvm.loop !11

42:                                               ; preds = %12
  %43 = load double, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  ret double %43
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { 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 = { 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 = distinct !{!11, !12}
!12 = !{!"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"

@coeff0 = external dso_local local_unnamed_addr constant [8 x [2 x double]], align 16

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @exp(double noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nofree nounwind willreturn memory(write) uwtable
define dso_local double @phi0t(double noundef %0) local_unnamed_addr #2 {
  %2 = load double, ptr getelementptr inbounds (i8, ptr @coeff0, i64 16), align 16, !tbaa !5
  %3 = load double, ptr getelementptr inbounds (i8, ptr @coeff0, i64 32), align 16, !tbaa !5
  %4 = fdiv double %3, %0
  %5 = fadd double %2, %4
  %6 = load double, ptr getelementptr inbounds (i8, ptr @coeff0, i64 48), align 16, !tbaa !5
  %7 = load double, ptr getelementptr inbounds (i8, ptr @coeff0, i64 56), align 8, !tbaa !5
  %8 = fmul double %6, %7
  %9 = fneg double %7
  %10 = fmul double %9, %0
  %11 = tail call double @exp(double noundef %10) #3
  %12 = fsub double 1.000000e+00, %11
  %13 = fdiv double 1.000000e+00, %12
  %14 = fadd double %13, -1.000000e+00
  %15 = tail call double @llvm.fmuladd.f64(double %8, double %14, double %5)
  %16 = load double, ptr getelementptr inbounds (i8, ptr @coeff0, i64 64), align 16, !tbaa !5
  %17 = load double, ptr getelementptr inbounds (i8, ptr @coeff0, i64 72), align 8, !tbaa !5
  %18 = fmul double %16, %17
  %19 = fneg double %17
  %20 = fmul double %19, %0
  %21 = tail call double @exp(double noundef %20) #3
  %22 = fsub double 1.000000e+00, %21
  %23 = fdiv double 1.000000e+00, %22
  %24 = fadd double %23, -1.000000e+00
  %25 = tail call double @llvm.fmuladd.f64(double %18, double %24, double %15)
  %26 = load double, ptr getelementptr inbounds (i8, ptr @coeff0, i64 80), align 16, !tbaa !5
  %27 = load double, ptr getelementptr inbounds (i8, ptr @coeff0, i64 88), align 8, !tbaa !5
  %28 = fmul double %26, %27
  %29 = fneg double %27
  %30 = fmul double %29, %0
  %31 = tail call double @exp(double noundef %30) #3
  %32 = fsub double 1.000000e+00, %31
  %33 = fdiv double 1.000000e+00, %32
  %34 = fadd double %33, -1.000000e+00
  %35 = tail call double @llvm.fmuladd.f64(double %28, double %34, double %25)
  %36 = load double, ptr getelementptr inbounds (i8, ptr @coeff0, i64 96), align 16, !tbaa !5
  %37 = load double, ptr getelementptr inbounds (i8, ptr @coeff0, i64 104), align 8, !tbaa !5
  %38 = fmul double %36, %37
  %39 = fneg double %37
  %40 = fmul double %39, %0
  %41 = tail call double @exp(double noundef %40) #3
  %42 = fsub double 1.000000e+00, %41
  %43 = fdiv double 1.000000e+00, %42
  %44 = fadd double %43, -1.000000e+00
  %45 = tail call double @llvm.fmuladd.f64(double %38, double %44, double %35)
  %46 = load double, ptr getelementptr inbounds (i8, ptr @coeff0, i64 112), align 16, !tbaa !5
  %47 = load double, ptr getelementptr inbounds (i8, ptr @coeff0, i64 120), align 8, !tbaa !5
  %48 = fmul double %46, %47
  %49 = fneg double %47
  %50 = fmul double %49, %0
  %51 = tail call double @exp(double noundef %50) #3
  %52 = fsub double 1.000000e+00, %51
  %53 = fdiv double 1.000000e+00, %52
  %54 = fadd double %53, -1.000000e+00
  %55 = tail call double @llvm.fmuladd.f64(double %48, double %54, double %45)
  ret double %55
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { mustprogress nofree nounwind willreturn memory(write) "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 = { mustprogress nofree nounwind willreturn memory(write) 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 = { 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"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LCSSAPass,LoopRotatePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass