; LLVM IR from USDA-ARS-ACSL/MAIZSIM :: Crop source/solar.ll (ZN6CSolar14SetPARFractionEv)

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

%class.CSolar = type <{ i32, [4 x i8], double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, i8, i8, [6 x i8] }>

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIdERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #0

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6CSolar14SetPARFractionEv(ptr noundef nonnull align 8 dereferenceable(418) %0) #2 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca double, align 8
  %4 = alloca double, align 8
  %5 = alloca double, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %6 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  %7 = getelementptr inbounds %class.CSolar, ptr %6, i32 0, i32 35
  %8 = load double, ptr %7, align 8, !tbaa !9
  %9 = getelementptr inbounds %class.CSolar, ptr %6, i32 0, i32 35
  %10 = load double, ptr %9, align 8, !tbaa !9
  %11 = getelementptr inbounds %class.CSolar, ptr %6, i32 0, i32 38
  %12 = load double, ptr %11, align 8, !tbaa !14
  %13 = fadd double %10, %12
  %14 = fdiv double %8, %13
  store double %14, ptr %3, align 8, !tbaa !15
  %15 = getelementptr inbounds %class.CSolar, ptr %6, i32 0, i32 54
  %16 = load i8, ptr %15, align 1, !tbaa !16, !range !17, !noundef !18
  %17 = trunc i8 %16 to i1
  br i1 %17, label %18, label %35

18:                                               ; preds = %1
  %19 = getelementptr inbounds %class.CSolar, ptr %6, i32 0, i32 6
  %20 = load double, ptr %19, align 8, !tbaa !19
  %21 = fcmp oge double %20, 0x3FE6666666666666
  br i1 %21, label %22, label %23

22:                                               ; preds = %18
  store double 4.500000e-01, ptr %3, align 8, !tbaa !15
  br label %34

23:                                               ; preds = %18
  %24 = getelementptr inbounds %class.CSolar, ptr %6, i32 0, i32 6
  %25 = load double, ptr %24, align 8, !tbaa !19
  %26 = fcmp ole double %25, 3.000000e-01
  br i1 %26, label %27, label %28

27:                                               ; preds = %23
  store double 5.500000e-01, ptr %3, align 8, !tbaa !15
  br label %33

28:                                               ; preds = %23
  %29 = getelementptr inbounds %class.CSolar, ptr %6, i32 0, i32 6
  %30 = load double, ptr %29, align 8, !tbaa !19
  %31 = fneg double %30
  %32 = call double @llvm.fmuladd.f64(double %31, double 2.500000e-01, double 6.250000e-01)
  store double %32, ptr %3, align 8, !tbaa !15
  br label %33

33:                                               ; preds = %28, %27
  br label %34

34:                                               ; preds = %33, %22
  br label %35

35:                                               ; preds = %34, %1
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  store double 1.000000e-08, ptr %4, align 8, !tbaa !15
  %36 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIdERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %4, ptr noundef nonnull align 8 dereferenceable(8) %3)
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  store double 0x3FEFFFFFFAA19C47, ptr %5, align 8, !tbaa !15
  %37 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIdERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %36, ptr noundef nonnull align 8 dereferenceable(8) %5)
  %38 = load double, ptr %37, align 8, !tbaa !15
  %39 = getelementptr inbounds %class.CSolar, ptr %6, i32 0, i32 31
  store double %38, ptr %39, align 8, !tbaa !20
  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 void
}

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIdERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #0

attributes #0 = { inlinehint mustprogress 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 willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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++ TBAA"}
!9 = !{!10, !12, i64 272}
!10 = !{!"_ZTS6CSolar", !11, i64 0, !12, i64 8, !12, i64 16, !12, i64 24, !12, i64 32, !12, i64 40, !12, i64 48, !12, i64 56, !12, i64 64, !12, i64 72, !12, i64 80, !12, i64 88, !12, i64 96, !12, i64 104, !12, i64 112, !12, i64 120, !12, i64 128, !12, i64 136, !12, i64 144, !12, i64 152, !12, i64 160, !12, i64 168, !12, i64 176, !12, i64 184, !12, i64 192, !12, i64 200, !12, i64 208, !12, i64 216, !12, i64 224, !12, i64 232, !12, i64 240, !12, i64 248, !12, i64 256, !12, i64 264, !12, i64 272, !12, i64 280, !12, i64 288, !12, i64 296, !12, i64 304, !12, i64 312, !12, i64 320, !12, i64 328, !12, i64 336, !12, i64 344, !12, i64 352, !12, i64 360, !12, i64 368, !12, i64 376, !12, i64 384, !12, i64 392, !12, i64 400, !12, i64 408, !13, i64 416, !13, i64 417}
!11 = !{!"int", !7, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = !{!"bool", !7, i64 0}
!14 = !{!10, !12, i64 296}
!15 = !{!12, !12, i64 0}
!16 = !{!10, !13, i64 417}
!17 = !{i8 0, i8 2}
!18 = !{}
!19 = !{!10, !12, i64 40}
!20 = !{!10, !12, i64 240}


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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIdERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) 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 nounwind uwtable
define dso_local void @_ZN6CSolar14SetPARFractionEv(ptr nocapture noundef nonnull align 8 dereferenceable(418) %0) local_unnamed_addr #2 align 2 {
  %2 = alloca double, align 8
  %3 = alloca double, align 8
  %4 = alloca double, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #4
  %5 = getelementptr inbounds i8, ptr %0, i64 272
  %6 = load double, ptr %5, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %0, i64 296
  %8 = load double, ptr %7, align 8, !tbaa !12
  %9 = fadd double %6, %8
  %10 = fdiv double %6, %9
  store double %10, ptr %2, align 8, !tbaa !13
  %11 = getelementptr inbounds i8, ptr %0, i64 417
  %12 = load i8, ptr %11, align 1, !tbaa !14, !range !15, !noundef !16
  %13 = trunc nuw i8 %12 to i1
  br i1 %13, label %14, label %25

14:                                               ; preds = %1
  %15 = getelementptr inbounds i8, ptr %0, i64 40
  %16 = load double, ptr %15, align 8, !tbaa !17
  %17 = fcmp ult double %16, 0x3FE6666666666666
  br i1 %17, label %19, label %18

18:                                               ; preds = %14
  store double 4.500000e-01, ptr %2, align 8, !tbaa !13
  br label %25

19:                                               ; preds = %14
  %20 = fcmp ugt double %16, 3.000000e-01
  br i1 %20, label %22, label %21

21:                                               ; preds = %19
  store double 5.500000e-01, ptr %2, align 8, !tbaa !13
  br label %25

22:                                               ; preds = %19
  %23 = fneg double %16
  %24 = tail call double @llvm.fmuladd.f64(double %23, double 2.500000e-01, double 6.250000e-01)
  store double %24, ptr %2, align 8, !tbaa !13
  br label %25

25:                                               ; preds = %18, %22, %21, %1
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #4
  store double 1.000000e-08, ptr %3, align 8, !tbaa !13
  %26 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIdERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %3, ptr noundef nonnull align 8 dereferenceable(8) %2)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #4
  store double 0x3FEFFFFFFAA19C47, ptr %4, align 8, !tbaa !13
  %27 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIdERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %26, ptr noundef nonnull align 8 dereferenceable(8) %4)
  %28 = load double, ptr %27, align 8, !tbaa !13
  %29 = getelementptr inbounds i8, ptr %0, i64 240
  store double %28, ptr %29, align 8, !tbaa !18
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #4
  ret void
}

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIdERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #0

attributes #0 = { inlinehint mustprogress 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 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 = { 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, !10, i64 272}
!6 = !{!"_ZTS6CSolar", !7, 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, !10, i64 128, !10, i64 136, !10, i64 144, !10, i64 152, !10, i64 160, !10, i64 168, !10, i64 176, !10, i64 184, !10, i64 192, !10, i64 200, !10, i64 208, !10, i64 216, !10, i64 224, !10, i64 232, !10, i64 240, !10, i64 248, !10, i64 256, !10, i64 264, !10, i64 272, !10, i64 280, !10, i64 288, !10, i64 296, !10, i64 304, !10, i64 312, !10, i64 320, !10, i64 328, !10, i64 336, !10, i64 344, !10, i64 352, !10, i64 360, !10, i64 368, !10, i64 376, !10, i64 384, !10, i64 392, !10, i64 400, !10, i64 408, !11, i64 416, !11, i64 417}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"double", !8, i64 0}
!11 = !{!"bool", !8, i64 0}
!12 = !{!6, !10, i64 296}
!13 = !{!10, !10, i64 0}
!14 = !{!6, !11, i64 417}
!15 = !{i8 0, i8 2}
!16 = !{}
!17 = !{!6, !10, i64 40}
!18 = !{!6, !10, i64 240}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass