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

; 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: mustprogress nounwind uwtable
define dso_local void @_ZN6CSolar17SetPotentialSolarEv(ptr noundef nonnull align 8 dereferenceable(418) %0) #0 align 2 {
  %2 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %3 = load ptr, ptr %2, align 8
  %4 = getelementptr inbounds %class.CSolar, ptr %3, i32 0, i32 10
  %5 = load double, ptr %4, align 8, !tbaa !9
  %6 = fcmp oge double %5, 0.000000e+00
  br i1 %6, label %7, label %46

7:                                                ; preds = %1
  %8 = getelementptr inbounds %class.CSolar, ptr %3, i32 0, i32 6
  %9 = load double, ptr %8, align 8, !tbaa !14
  %10 = call noundef double @_ZN6CSolar1mEv(ptr noundef nonnull align 8 dereferenceable(418) %3)
  %11 = call double @pow(double noundef %9, double noundef %10) #3
  %12 = fmul double 1.367000e+03, %11
  %13 = getelementptr inbounds %class.CSolar, ptr %3, i32 0, i32 10
  %14 = load double, ptr %13, align 8, !tbaa !9
  %15 = fmul double %12, %14
  %16 = getelementptr inbounds %class.CSolar, ptr %3, i32 0, i32 0
  %17 = load i32, ptr %16, align 8, !tbaa !15
  %18 = sub nsw i32 %17, 10
  %19 = sitofp i32 %18 to double
  %20 = fmul double 6.283000e+00, %19
  %21 = fdiv double %20, 3.650000e+02
  %22 = call double @cos(double noundef %21) #3
  %23 = call double @llvm.fmuladd.f64(double 3.300000e-02, double %22, double 1.000000e+00)
  %24 = fmul double %15, %23
  %25 = getelementptr inbounds %class.CSolar, ptr %3, i32 0, i32 21
  store double %24, ptr %25, align 8, !tbaa !16
  %26 = getelementptr inbounds %class.CSolar, ptr %3, i32 0, i32 6
  %27 = load double, ptr %26, align 8, !tbaa !14
  %28 = call noundef double @_ZN6CSolar1mEv(ptr noundef nonnull align 8 dereferenceable(418) %3)
  %29 = call double @pow(double noundef %27, double noundef %28) #3
  %30 = fsub double 1.000000e+00, %29
  %31 = fmul double 3.000000e-01, %30
  %32 = fmul double %31, 1.367000e+03
  %33 = getelementptr inbounds %class.CSolar, ptr %3, i32 0, i32 10
  %34 = load double, ptr %33, align 8, !tbaa !9
  %35 = fmul double %32, %34
  %36 = getelementptr inbounds %class.CSolar, ptr %3, i32 0, i32 0
  %37 = load i32, ptr %36, align 8, !tbaa !15
  %38 = sub nsw i32 %37, 10
  %39 = sitofp i32 %38 to double
  %40 = fmul double 6.283000e+00, %39
  %41 = fdiv double %40, 3.650000e+02
  %42 = call double @cos(double noundef %41) #3
  %43 = call double @llvm.fmuladd.f64(double 3.300000e-02, double %42, double 1.000000e+00)
  %44 = fmul double %35, %43
  %45 = getelementptr inbounds %class.CSolar, ptr %3, i32 0, i32 22
  store double %44, ptr %45, align 8, !tbaa !17
  br label %49

46:                                               ; preds = %1
  %47 = getelementptr inbounds %class.CSolar, ptr %3, i32 0, i32 21
  store double 0.000000e+00, ptr %47, align 8, !tbaa !16
  %48 = getelementptr inbounds %class.CSolar, ptr %3, i32 0, i32 22
  store double 0.000000e+00, ptr %48, align 8, !tbaa !17
  br label %49

49:                                               ; preds = %46, %7
  %50 = getelementptr inbounds %class.CSolar, ptr %3, i32 0, i32 22
  %51 = load double, ptr %50, align 8, !tbaa !17
  %52 = getelementptr inbounds %class.CSolar, ptr %3, i32 0, i32 21
  %53 = load double, ptr %52, align 8, !tbaa !16
  %54 = fadd double %51, %53
  %55 = getelementptr inbounds %class.CSolar, ptr %3, i32 0, i32 20
  store double %54, ptr %55, align 8, !tbaa !18
  ret void
}

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_ZN6CSolar1mEv(ptr noundef nonnull align 8 dereferenceable(418)) #0 align 2

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

attributes #0 = { 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 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 }

!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 72}
!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 40}
!15 = !{!10, !11, i64 0}
!16 = !{!10, !12, i64 160}
!17 = !{!10, !12, i64 168}
!18 = !{!10, !12, i64 152}


; 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: mustprogress nounwind uwtable
define dso_local void @_ZN6CSolar17SetPotentialSolarEv(ptr noundef nonnull align 8 dereferenceable(418) %0) local_unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 72
  %3 = load double, ptr %2, align 8, !tbaa !5
  %4 = fcmp ult double %3, 0.000000e+00
  br i1 %4, label %38, label %5

5:                                                ; preds = %1
  %6 = getelementptr inbounds i8, ptr %0, i64 40
  %7 = load double, ptr %6, align 8, !tbaa !12
  %8 = tail call noundef double @_ZN6CSolar1mEv(ptr noundef nonnull align 8 dereferenceable(418) %0)
  %9 = tail call double @pow(double noundef %7, double noundef %8) #3
  %10 = fmul double %9, 1.367000e+03
  %11 = load double, ptr %2, align 8, !tbaa !5
  %12 = fmul double %10, %11
  %13 = load i32, ptr %0, align 8, !tbaa !13
  %14 = add nsw i32 %13, -10
  %15 = sitofp i32 %14 to double
  %16 = fmul double %15, 6.283000e+00
  %17 = fdiv double %16, 3.650000e+02
  %18 = tail call double @cos(double noundef %17) #3
  %19 = tail call double @llvm.fmuladd.f64(double %18, double 3.300000e-02, double 1.000000e+00)
  %20 = fmul double %12, %19
  %21 = getelementptr inbounds i8, ptr %0, i64 160
  store double %20, ptr %21, align 8, !tbaa !14
  %22 = load double, ptr %6, align 8, !tbaa !12
  %23 = tail call noundef double @_ZN6CSolar1mEv(ptr noundef nonnull align 8 dereferenceable(418) %0)
  %24 = tail call double @pow(double noundef %22, double noundef %23) #3
  %25 = fsub double 1.000000e+00, %24
  %26 = fmul double %25, 3.000000e-01
  %27 = fmul double %26, 1.367000e+03
  %28 = load double, ptr %2, align 8, !tbaa !5
  %29 = fmul double %28, %27
  %30 = load i32, ptr %0, align 8, !tbaa !13
  %31 = add nsw i32 %30, -10
  %32 = sitofp i32 %31 to double
  %33 = fmul double %32, 6.283000e+00
  %34 = fdiv double %33, 3.650000e+02
  %35 = tail call double @cos(double noundef %34) #3
  %36 = tail call double @llvm.fmuladd.f64(double %35, double 3.300000e-02, double 1.000000e+00)
  %37 = fmul double %29, %36
  %.pre = load double, ptr %21, align 8, !tbaa !14
  br label %40

38:                                               ; preds = %1
  %39 = getelementptr inbounds i8, ptr %0, i64 160
  store double 0.000000e+00, ptr %39, align 8, !tbaa !14
  br label %40

40:                                               ; preds = %38, %5
  %41 = phi double [ 0.000000e+00, %38 ], [ %.pre, %5 ]
  %.sink = phi double [ 0.000000e+00, %38 ], [ %37, %5 ]
  %42 = getelementptr inbounds i8, ptr %0, i64 168
  store double %.sink, ptr %42, align 8
  %43 = fadd double %.sink, %41
  %44 = getelementptr inbounds i8, ptr %0, i64 152
  store double %43, ptr %44, align 8, !tbaa !15
  ret void
}

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_ZN6CSolar1mEv(ptr noundef nonnull align 8 dereferenceable(418)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @pow(double noundef, double noundef) local_unnamed_addr #2

attributes #0 = { 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 speculatable willreturn memory(none) }
attributes #2 = { 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 #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, !10, i64 72}
!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 40}
!13 = !{!6, !7, i64 0}
!14 = !{!6, !10, i64 160}
!15 = !{!6, !10, i64 152}


; Effective O3 passes: BDCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,MergedLoadStoreMotionPass,ReassociatePass,SROAPass,TailCallElimPass