; LLVM IR from venumb/ZSPACE :: cpp/depends/spa (spa)

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

@b_subcount = external dso_local constant [2 x i32], align 4
@B_TERMS = external dso_local constant [2 x [5 x [3 x double]]], align 16

; Function Attrs: nounwind uwtable
declare dso_local double @rad2deg(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: nounwind uwtable
declare dso_local double @earth_periodic_term_summation(ptr noundef, i32 noundef, double noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local double @earth_values(ptr noundef, i32 noundef, double noundef) #0

; Function Attrs: nounwind uwtable
define dso_local double @earth_heliocentric_latitude(double noundef %0) #0 {
  %2 = alloca double, align 8
  %3 = alloca [2 x double], align 16
  %4 = alloca i32, align 4
  store double %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %3) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #2
  store i32 0, ptr %4, align 4, !tbaa !9
  br label %5

5:                                                ; preds = %22, %1
  %6 = load i32, ptr %4, align 4, !tbaa !9
  %7 = icmp slt i32 %6, 2
  br i1 %7, label %8, label %25

8:                                                ; preds = %5
  %9 = load i32, ptr %4, align 4, !tbaa !9
  %10 = sext i32 %9 to i64
  %11 = getelementptr inbounds [2 x [5 x [3 x double]]], ptr @B_TERMS, i64 0, i64 %10
  %12 = getelementptr inbounds [5 x [3 x double]], ptr %11, i64 0, i64 0
  %13 = load i32, ptr %4, align 4, !tbaa !9
  %14 = sext i32 %13 to i64
  %15 = getelementptr inbounds [2 x i32], ptr @b_subcount, i64 0, i64 %14
  %16 = load i32, ptr %15, align 4, !tbaa !9
  %17 = load double, ptr %2, align 8, !tbaa !5
  %18 = call double @earth_periodic_term_summation(ptr noundef %12, i32 noundef %16, double noundef %17)
  %19 = load i32, ptr %4, align 4, !tbaa !9
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds [2 x double], ptr %3, i64 0, i64 %20
  store double %18, ptr %21, align 8, !tbaa !5
  br label %22

22:                                               ; preds = %8
  %23 = load i32, ptr %4, align 4, !tbaa !9
  %24 = add nsw i32 %23, 1
  store i32 %24, ptr %4, align 4, !tbaa !9
  br label %5, !llvm.loop !11

25:                                               ; preds = %5
  %26 = getelementptr inbounds [2 x double], ptr %3, i64 0, i64 0
  %27 = load double, ptr %2, align 8, !tbaa !5
  %28 = call double @earth_values(ptr noundef %26, i32 noundef 2, double noundef %27)
  %29 = call double @rad2deg(double noundef %28)
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #2
  call void @llvm.lifetime.end.p0(i64 16, ptr %3) #2
  ret double %29
}

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 willreturn memory(argmem: readwrite) }
attributes #2 = { 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"

@b_subcount = external dso_local local_unnamed_addr constant [2 x i32], align 4
@B_TERMS = external dso_local constant [2 x [5 x [3 x double]]], align 16

; Function Attrs: nounwind uwtable
declare dso_local double @rad2deg(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: nounwind uwtable
declare dso_local double @earth_periodic_term_summation(ptr noundef, i32 noundef, double noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local double @earth_values(ptr noundef, i32 noundef, double noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local double @earth_heliocentric_latitude(double noundef %0) local_unnamed_addr #0 {
  %2 = alloca [2 x double], align 16
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %2) #2
  %3 = load i32, ptr @b_subcount, align 4, !tbaa !5
  %4 = tail call double @earth_periodic_term_summation(ptr noundef nonnull @B_TERMS, i32 noundef %3, double noundef %0)
  store double %4, ptr %2, align 16, !tbaa !9
  %5 = load i32, ptr getelementptr inbounds (i8, ptr @b_subcount, i64 4), align 4, !tbaa !5
  %6 = tail call double @earth_periodic_term_summation(ptr noundef nonnull getelementptr inbounds (i8, ptr @B_TERMS, i64 120), i32 noundef %5, double noundef %0)
  %7 = getelementptr inbounds i8, ptr %2, i64 8
  store double %6, ptr %7, align 8, !tbaa !9
  %8 = call double @earth_values(ptr noundef nonnull %2, i32 noundef 2, double noundef %0)
  %9 = call double @rad2deg(double noundef %8)
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %2) #2
  ret double %9
}

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 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}


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