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

; 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] }>

@_ZN6CSolar5SDERPE = external dso_local global [9 x double], align 16

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_Z8DegToRadd(double noundef) #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 @_ZN6CSolar14SetDeclinationEv(ptr noundef nonnull align 8 dereferenceable(418) %0) #2 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca double, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %7 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  %8 = load double, ptr @_ZN6CSolar5SDERPE, align 16, !tbaa !9
  %9 = getelementptr inbounds %class.CSolar, ptr %7, i32 0, i32 8
  store double %8, ptr %9, align 8, !tbaa !11
  store i32 2, ptr %4, align 4, !tbaa !15
  br label %10

10:                                               ; preds = %44, %1
  %11 = load i32, ptr %4, align 4, !tbaa !15
  %12 = icmp sle i32 %11, 5
  br i1 %12, label %13, label %47

13:                                               ; preds = %10
  %14 = load i32, ptr %4, align 4, !tbaa !15
  %15 = sub nsw i32 %14, 1
  store i32 %15, ptr %5, align 4, !tbaa !15
  %16 = load i32, ptr %4, align 4, !tbaa !15
  %17 = add nsw i32 %16, 4
  store i32 %17, ptr %6, align 4, !tbaa !15
  %18 = load i32, ptr %5, align 4, !tbaa !15
  %19 = sitofp i32 %18 to double
  %20 = fmul double %19, 1.721000e-02
  %21 = getelementptr inbounds %class.CSolar, ptr %7, i32 0, i32 0
  %22 = load i32, ptr %21, align 8, !tbaa !16
  %23 = sitofp i32 %22 to double
  %24 = fmul double %20, %23
  store double %24, ptr %3, align 8, !tbaa !9
  %25 = getelementptr inbounds %class.CSolar, ptr %7, i32 0, i32 8
  %26 = load double, ptr %25, align 8, !tbaa !11
  %27 = load i32, ptr %4, align 4, !tbaa !15
  %28 = sub nsw i32 %27, 1
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [9 x double], ptr @_ZN6CSolar5SDERPE, i64 0, i64 %29
  %31 = load double, ptr %30, align 8, !tbaa !9
  %32 = load double, ptr %3, align 8, !tbaa !9
  %33 = call double @sin(double noundef %32) #5
  %34 = call double @llvm.fmuladd.f64(double %31, double %33, double %26)
  %35 = load i32, ptr %6, align 4, !tbaa !15
  %36 = sub nsw i32 %35, 1
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [9 x double], ptr @_ZN6CSolar5SDERPE, i64 0, i64 %37
  %39 = load double, ptr %38, align 8, !tbaa !9
  %40 = load double, ptr %3, align 8, !tbaa !9
  %41 = call double @cos(double noundef %40) #5
  %42 = call double @llvm.fmuladd.f64(double %39, double %41, double %34)
  %43 = getelementptr inbounds %class.CSolar, ptr %7, i32 0, i32 8
  store double %42, ptr %43, align 8, !tbaa !11
  br label %44

44:                                               ; preds = %13
  %45 = load i32, ptr %4, align 4, !tbaa !15
  %46 = add nsw i32 %45, 1
  store i32 %46, ptr %4, align 4, !tbaa !15
  br label %10, !llvm.loop !17

47:                                               ; preds = %10
  %48 = getelementptr inbounds %class.CSolar, ptr %7, i32 0, i32 8
  %49 = load double, ptr %48, align 8, !tbaa !11
  %50 = call noundef double @_Z8DegToRadd(double noundef %49)
  %51 = getelementptr inbounds %class.CSolar, ptr %7, i32 0, i32 8
  store double %50, ptr %51, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #5
  ret void
}

; Function Attrs: nounwind
declare double @sin(double noundef) #3

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

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

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 = { 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 #4 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { 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, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = !{!12, !10, i64 56}
!12 = !{!"_ZTS6CSolar", !13, 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, !14, i64 416, !14, i64 417}
!13 = !{!"int", !7, i64 0}
!14 = !{!"bool", !7, i64 0}
!15 = !{!13, !13, i64 0}
!16 = !{!12, !13, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"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"

@_ZN6CSolar5SDERPE = external dso_local local_unnamed_addr global [9 x double], align 16

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_Z8DegToRadd(double noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN6CSolar14SetDeclinationEv(ptr nocapture noundef nonnull align 8 dereferenceable(418) %0) local_unnamed_addr #1 align 2 {
  %2 = load double, ptr @_ZN6CSolar5SDERPE, align 16, !tbaa !5
  %3 = getelementptr inbounds i8, ptr %0, i64 56
  %4 = load i32, ptr %0, align 8, !tbaa !9
  %5 = sitofp i32 %4 to double
  %6 = fmul double %5, 1.721000e-02
  %7 = load double, ptr getelementptr inbounds (i8, ptr @_ZN6CSolar5SDERPE, i64 8), align 8, !tbaa !5
  %8 = tail call double @sin(double noundef %6) #4
  %9 = tail call double @llvm.fmuladd.f64(double %7, double %8, double %2)
  %10 = load double, ptr getelementptr inbounds (i8, ptr @_ZN6CSolar5SDERPE, i64 40), align 8, !tbaa !5
  %11 = tail call double @cos(double noundef %6) #4
  %12 = tail call double @llvm.fmuladd.f64(double %10, double %11, double %9)
  %13 = load i32, ptr %0, align 8, !tbaa !9
  %14 = sitofp i32 %13 to double
  %15 = fmul double %14, 3.442000e-02
  %16 = load double, ptr getelementptr inbounds (i8, ptr @_ZN6CSolar5SDERPE, i64 16), align 16, !tbaa !5
  %17 = tail call double @sin(double noundef %15) #4
  %18 = tail call double @llvm.fmuladd.f64(double %16, double %17, double %12)
  %19 = load double, ptr getelementptr inbounds (i8, ptr @_ZN6CSolar5SDERPE, i64 48), align 16, !tbaa !5
  %20 = tail call double @cos(double noundef %15) #4
  %21 = tail call double @llvm.fmuladd.f64(double %19, double %20, double %18)
  store double %21, ptr %3, align 8, !tbaa !13
  %22 = load i32, ptr %0, align 8, !tbaa !9
  %23 = sitofp i32 %22 to double
  %24 = fmul double %23, 0x3FAA6F3F52FC2656
  %25 = load double, ptr getelementptr inbounds (i8, ptr @_ZN6CSolar5SDERPE, i64 24), align 8, !tbaa !5
  %26 = tail call double @sin(double noundef %24) #4
  %27 = tail call double @llvm.fmuladd.f64(double %25, double %26, double %21)
  %28 = load double, ptr getelementptr inbounds (i8, ptr @_ZN6CSolar5SDERPE, i64 56), align 8, !tbaa !5
  %29 = tail call double @cos(double noundef %24) #4
  %30 = tail call double @llvm.fmuladd.f64(double %28, double %29, double %27)
  store double %30, ptr %3, align 8, !tbaa !13
  %31 = load i32, ptr %0, align 8, !tbaa !9
  %32 = sitofp i32 %31 to double
  %33 = fmul double %32, 0x3FB19F7F8CA8198F
  %34 = load double, ptr getelementptr inbounds (i8, ptr @_ZN6CSolar5SDERPE, i64 32), align 16, !tbaa !5
  %35 = tail call double @sin(double noundef %33) #4
  %36 = tail call double @llvm.fmuladd.f64(double %34, double %35, double %30)
  %37 = load double, ptr getelementptr inbounds (i8, ptr @_ZN6CSolar5SDERPE, i64 64), align 16, !tbaa !5
  %38 = tail call double @cos(double noundef %33) #4
  %39 = tail call double @llvm.fmuladd.f64(double %37, double %38, double %36)
  store double %39, ptr %3, align 8, !tbaa !13
  %40 = tail call noundef double @_Z8DegToRadd(double noundef %39)
  store double %40, ptr %3, align 8, !tbaa !13
  ret void
}

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

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

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

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


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