; LLVM IR from OpenFAST/openfast :: modules/map/src (lineroutines)

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

%struct.Line_t = type { ptr, %struct.LineOptions, %struct.VarTypePtr_t, %struct.VarTypePtr_t, %struct.VarType_t, ptr, ptr, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, %struct.list_t, ptr, ptr, i32, i32, i32, i32, i32 }
%struct.LineOptions = type { i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 }
%struct.VarTypePtr_t = type { ptr, ptr, ptr, i8, i32, i32 }
%struct.VarType_t = type { ptr, ptr, double, i8, i8, i32, i32 }
%struct.list_t = type { ptr, ptr, ptr, i32, ptr, i32, i32, i32, ptr, %struct.list_attributes_s }
%struct.list_attributes_s = type { ptr, ptr, ptr, i32, ptr, ptr, ptr }
%struct.Node_t = type { %struct.PointPtr_t, %struct.PointPtr_t, %struct.PointPtr_t, i32, %struct.ForcePtr_t, %struct.VarType_t, %struct.VarType_t, %struct.Force_t }
%struct.PointPtr_t = type { %struct.VarTypePtr_t, %struct.VarTypePtr_t, %struct.VarTypePtr_t }
%struct.ForcePtr_t = type { %struct.VarTypePtr_t, %struct.VarTypePtr_t, %struct.VarTypePtr_t }
%struct.Force_t = type { %struct.VarType_t, %struct.VarType_t, %struct.VarType_t }

; 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 willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind uwtable
define dso_local double @set_horizontal_excursion(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca double, align 8
  %4 = alloca double, align 8
  %5 = alloca double, align 8
  %6 = alloca double, align 8
  %7 = alloca double, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  %8 = load ptr, ptr %2, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.Line_t, ptr %8, i32 0, i32 27
  %10 = load ptr, ptr %9, align 8, !tbaa !9
  %11 = getelementptr inbounds %struct.Node_t, ptr %10, i32 0, i32 2
  %12 = getelementptr inbounds %struct.PointPtr_t, ptr %11, i32 0, i32 0
  %13 = getelementptr inbounds %struct.VarTypePtr_t, ptr %12, i32 0, i32 2
  %14 = load ptr, ptr %13, align 8, !tbaa !19
  %15 = load double, ptr %14, align 8, !tbaa !24
  store double %15, ptr %3, align 8, !tbaa !24
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  %16 = load ptr, ptr %2, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.Line_t, ptr %16, i32 0, i32 27
  %18 = load ptr, ptr %17, align 8, !tbaa !9
  %19 = getelementptr inbounds %struct.Node_t, ptr %18, i32 0, i32 2
  %20 = getelementptr inbounds %struct.PointPtr_t, ptr %19, i32 0, i32 1
  %21 = getelementptr inbounds %struct.VarTypePtr_t, ptr %20, i32 0, i32 2
  %22 = load ptr, ptr %21, align 8, !tbaa !25
  %23 = load double, ptr %22, align 8, !tbaa !24
  store double %23, ptr %4, align 8, !tbaa !24
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %24 = load ptr, ptr %2, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.Line_t, ptr %24, i32 0, i32 26
  %26 = load ptr, ptr %25, align 8, !tbaa !26
  %27 = getelementptr inbounds %struct.Node_t, ptr %26, i32 0, i32 2
  %28 = getelementptr inbounds %struct.PointPtr_t, ptr %27, i32 0, i32 0
  %29 = getelementptr inbounds %struct.VarTypePtr_t, ptr %28, i32 0, i32 2
  %30 = load ptr, ptr %29, align 8, !tbaa !19
  %31 = load double, ptr %30, align 8, !tbaa !24
  store double %31, ptr %5, align 8, !tbaa !24
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %32 = load ptr, ptr %2, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.Line_t, ptr %32, i32 0, i32 26
  %34 = load ptr, ptr %33, align 8, !tbaa !26
  %35 = getelementptr inbounds %struct.Node_t, ptr %34, i32 0, i32 2
  %36 = getelementptr inbounds %struct.PointPtr_t, ptr %35, i32 0, i32 1
  %37 = getelementptr inbounds %struct.VarTypePtr_t, ptr %36, i32 0, i32 2
  %38 = load ptr, ptr %37, align 8, !tbaa !25
  %39 = load double, ptr %38, align 8, !tbaa !24
  store double %39, ptr %6, align 8, !tbaa !24
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %40 = load double, ptr %3, align 8, !tbaa !24
  %41 = load double, ptr %5, align 8, !tbaa !24
  %42 = fsub double %40, %41
  %43 = call double @pow(double noundef %42, double noundef 2.000000e+00) #3
  %44 = load double, ptr %4, align 8, !tbaa !24
  %45 = load double, ptr %6, align 8, !tbaa !24
  %46 = fsub double %44, %45
  %47 = call double @pow(double noundef %46, double noundef 2.000000e+00) #3
  %48 = fadd double %43, %47
  %49 = call double @sqrt(double noundef %48) #3
  store double %49, ptr %7, align 8, !tbaa !24
  %50 = load double, ptr %7, align 8, !tbaa !24
  %51 = fcmp ogt double %50, 1.000000e-02
  br i1 %51, label %52, label %54

52:                                               ; preds = %1
  %53 = load double, ptr %7, align 8, !tbaa !24
  br label %55

54:                                               ; preds = %1
  br label %55

55:                                               ; preds = %54, %52
  %56 = phi double [ %53, %52 ], [ 1.000000e-02, %54 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  ret double %56
}

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

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { 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/C++ TBAA"}
!9 = !{!10, !6, i64 448}
!10 = !{!"Line_t", !6, i64 0, !11, i64 8, !13, i64 40, !13, i64 80, !15, i64 120, !6, i64 160, !6, i64 168, !16, i64 176, !16, i64 184, !16, i64 192, !16, i64 200, !16, i64 208, !16, i64 216, !16, i64 224, !16, i64 232, !16, i64 240, !16, i64 248, !16, i64 256, !16, i64 264, !16, i64 272, !16, i64 280, !16, i64 288, !16, i64 296, !16, i64 304, !16, i64 312, !17, i64 320, !6, i64 440, !6, i64 448, !14, i64 456, !14, i64 460, !14, i64 464, !14, i64 468, !14, i64 472}
!11 = !{!"", !12, i64 0, !12, i64 1, !12, i64 2, !12, i64 3, !12, i64 4, !12, i64 5, !12, i64 6, !12, i64 7, !12, i64 8, !12, i64 9, !12, i64 10, !12, i64 11, !12, i64 12, !12, i64 13, !12, i64 14, !12, i64 15, !12, i64 16, !12, i64 17, !12, i64 18, !12, i64 19, !12, i64 20, !12, i64 21, !12, i64 22, !12, i64 23, !12, i64 24, !12, i64 25}
!12 = !{!"_Bool", !7, i64 0}
!13 = !{!"VarTypePtr_t", !6, i64 0, !6, i64 8, !6, i64 16, !12, i64 24, !14, i64 28, !14, i64 32}
!14 = !{!"int", !7, i64 0}
!15 = !{!"VarType_t", !6, i64 0, !6, i64 8, !16, i64 16, !12, i64 24, !12, i64 25, !14, i64 28, !14, i64 32}
!16 = !{!"double", !7, i64 0}
!17 = !{!"", !6, i64 0, !6, i64 8, !6, i64 16, !14, i64 24, !6, i64 32, !14, i64 40, !14, i64 44, !14, i64 48, !6, i64 56, !18, i64 64}
!18 = !{!"list_attributes_s", !6, i64 0, !6, i64 8, !6, i64 16, !14, i64 24, !6, i64 32, !6, i64 40, !6, i64 48}
!19 = !{!20, !6, i64 256}
!20 = !{!"Node_t", !21, i64 0, !21, i64 120, !21, i64 240, !14, i64 360, !22, i64 368, !15, i64 488, !15, i64 528, !23, i64 568}
!21 = !{!"PointPtr_t", !13, i64 0, !13, i64 40, !13, i64 80}
!22 = !{!"ForcePtr_t", !13, i64 0, !13, i64 40, !13, i64 80}
!23 = !{!"Force_t", !15, i64 0, !15, i64 40, !15, i64 80}
!24 = !{!16, !16, i64 0}
!25 = !{!20, !6, i64 296}
!26 = !{!10, !6, i64 440}


; 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 nofree norecurse nosync nounwind willreturn memory(read, inaccessiblemem: none) uwtable
define dso_local double @set_horizontal_excursion(ptr nocapture noundef readonly %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 448
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %3, i64 256
  %5 = load ptr, ptr %4, align 8, !tbaa !18
  %6 = load double, ptr %5, align 8, !tbaa !23
  %7 = getelementptr inbounds i8, ptr %3, i64 296
  %8 = load ptr, ptr %7, align 8, !tbaa !24
  %9 = load double, ptr %8, align 8, !tbaa !23
  %10 = getelementptr inbounds i8, ptr %0, i64 440
  %11 = load ptr, ptr %10, align 8, !tbaa !25
  %12 = getelementptr inbounds i8, ptr %11, i64 256
  %13 = load ptr, ptr %12, align 8, !tbaa !18
  %14 = load double, ptr %13, align 8, !tbaa !23
  %15 = getelementptr inbounds i8, ptr %11, i64 296
  %16 = load ptr, ptr %15, align 8, !tbaa !24
  %17 = load double, ptr %16, align 8, !tbaa !23
  %18 = insertelement <2 x double> poison, double %6, i64 0
  %19 = insertelement <2 x double> %18, double %9, i64 1
  %20 = insertelement <2 x double> poison, double %14, i64 0
  %21 = insertelement <2 x double> %20, double %17, i64 1
  %22 = fsub <2 x double> %19, %21
  %23 = fmul <2 x double> %22, %22
  %shift = shufflevector <2 x double> %23, <2 x double> poison, <2 x i32> <i32 1, i32 poison>
  %24 = fadd <2 x double> %23, %shift
  %25 = extractelement <2 x double> %24, i64 0
  %sqrt = tail call double @llvm.sqrt.f64(double %25)
  %26 = fcmp ogt double %sqrt, 1.000000e-02
  %27 = select i1 %26, double %sqrt, double 1.000000e-02
  ret double %27
}

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

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(read, inaccessiblemem: none) 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) }

!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, !7, i64 448}
!6 = !{!"Line_t", !7, i64 0, !10, i64 8, !12, i64 40, !12, i64 80, !14, i64 120, !7, i64 160, !7, i64 168, !15, i64 176, !15, i64 184, !15, i64 192, !15, i64 200, !15, i64 208, !15, i64 216, !15, i64 224, !15, i64 232, !15, i64 240, !15, i64 248, !15, i64 256, !15, i64 264, !15, i64 272, !15, i64 280, !15, i64 288, !15, i64 296, !15, i64 304, !15, i64 312, !16, i64 320, !7, i64 440, !7, i64 448, !13, i64 456, !13, i64 460, !13, i64 464, !13, i64 468, !13, i64 472}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"", !11, i64 0, !11, i64 1, !11, i64 2, !11, i64 3, !11, i64 4, !11, i64 5, !11, i64 6, !11, i64 7, !11, i64 8, !11, i64 9, !11, i64 10, !11, i64 11, !11, i64 12, !11, i64 13, !11, i64 14, !11, i64 15, !11, i64 16, !11, i64 17, !11, i64 18, !11, i64 19, !11, i64 20, !11, i64 21, !11, i64 22, !11, i64 23, !11, i64 24, !11, i64 25}
!11 = !{!"_Bool", !8, i64 0}
!12 = !{!"VarTypePtr_t", !7, i64 0, !7, i64 8, !7, i64 16, !11, i64 24, !13, i64 28, !13, i64 32}
!13 = !{!"int", !8, i64 0}
!14 = !{!"VarType_t", !7, i64 0, !7, i64 8, !15, i64 16, !11, i64 24, !11, i64 25, !13, i64 28, !13, i64 32}
!15 = !{!"double", !8, i64 0}
!16 = !{!"", !7, i64 0, !7, i64 8, !7, i64 16, !13, i64 24, !7, i64 32, !13, i64 40, !13, i64 44, !13, i64 48, !7, i64 56, !17, i64 64}
!17 = !{!"list_attributes_s", !7, i64 0, !7, i64 8, !7, i64 16, !13, i64 24, !7, i64 32, !7, i64 40, !7, i64 48}
!18 = !{!19, !7, i64 256}
!19 = !{!"Node_t", !20, i64 0, !20, i64 120, !20, i64 240, !13, i64 360, !21, i64 368, !14, i64 488, !14, i64 528, !22, i64 568}
!20 = !{!"PointPtr_t", !12, i64 0, !12, i64 40, !12, i64 80}
!21 = !{!"ForcePtr_t", !12, i64 0, !12, i64 40, !12, i64 80}
!22 = !{!"Force_t", !14, i64 0, !14, i64 40, !14, i64 80}
!23 = !{!15, !15, i64 0}
!24 = !{!19, !7, i64 296}
!25 = !{!6, !7, i64 440}


; Effective O3 passes: AggressiveInstCombinePass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass,VectorCombinePass