; 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.Domain_t = type { %struct.InnerSolveAttributes_t, %struct.OuterSolveAttributes_t, %struct.DomainOptions_t, ptr, i32, %struct.Vessel_t, %struct.list_t, %struct.list_t, %struct.list_t, %struct.list_t, ptr }
%struct.InnerSolveAttributes_t = type { ptr, double, double, double, [2 x double], [2 x double], [4 x double], [2 x double], [2 x double], [2 x double], [2 x double], [2 x double], [2 x double], double, i32, i32, i32, i32, i32, [2 x i32], i32, i32 }
%struct.OuterSolveAttributes_t = type { i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, double, double, double, double, double, double, i8, i8, i8, i32, i32, i32 }
%struct.DomainOptions_t = type { ptr, double, double, double, i8, i8, i32 }
%struct.Vessel_t = type { %struct.EulerAngle_t, ptr, ptr, ptr, %struct.Point_t, %struct.Point_t, %struct.Force_t }
%struct.EulerAngle_t = type { %struct.VarType_t, %struct.VarType_t, %struct.VarType_t }
%struct.VarType_t = type { ptr, ptr, double, i8, i8, i32, i32 }
%struct.Point_t = type { %struct.VarType_t, %struct.VarType_t, %struct.VarType_t }
%struct.Force_t = type { %struct.VarType_t, %struct.VarType_t, %struct.VarType_t }
%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.VarTypePtr_t = type { ptr, ptr, ptr, i8, i32, i32 }
%struct.ForcePtr_t = type { %struct.VarTypePtr_t, %struct.VarTypePtr_t, %struct.VarTypePtr_t }

; Function Attrs: nounwind uwtable
define dso_local i32 @reset_node_force_to_zero(ptr noundef %0, ptr noundef %1, ptr noundef %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  store ptr null, ptr %7, align 8, !tbaa !5
  %8 = load ptr, ptr %4, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.Domain_t, ptr %8, i32 0, i32 8
  %10 = call i32 @list_iterator_start(ptr noundef %9)
  br label %11

11:                                               ; preds = %16, %3
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.Domain_t, ptr %12, i32 0, i32 8
  %14 = call i32 @list_iterator_hasnext(ptr noundef %13)
  %15 = icmp ne i32 %14, 0
  br i1 %15, label %16, label %35

16:                                               ; preds = %11
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.Domain_t, ptr %17, i32 0, i32 8
  %19 = call ptr @list_iterator_next(ptr noundef %18)
  store ptr %19, ptr %7, align 8, !tbaa !5
  %20 = load ptr, ptr %7, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.Node_t, ptr %20, i32 0, i32 4
  %22 = getelementptr inbounds %struct.ForcePtr_t, ptr %21, i32 0, i32 0
  %23 = getelementptr inbounds %struct.VarTypePtr_t, ptr %22, i32 0, i32 2
  %24 = load ptr, ptr %23, align 8, !tbaa !9
  store double 0.000000e+00, ptr %24, align 8, !tbaa !19
  %25 = load ptr, ptr %7, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.Node_t, ptr %25, i32 0, i32 4
  %27 = getelementptr inbounds %struct.ForcePtr_t, ptr %26, i32 0, i32 1
  %28 = getelementptr inbounds %struct.VarTypePtr_t, ptr %27, i32 0, i32 2
  %29 = load ptr, ptr %28, align 8, !tbaa !20
  store double 0.000000e+00, ptr %29, align 8, !tbaa !19
  %30 = load ptr, ptr %7, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.Node_t, ptr %30, i32 0, i32 4
  %32 = getelementptr inbounds %struct.ForcePtr_t, ptr %31, i32 0, i32 2
  %33 = getelementptr inbounds %struct.VarTypePtr_t, ptr %32, i32 0, i32 2
  %34 = load ptr, ptr %33, align 8, !tbaa !21
  store double 0.000000e+00, ptr %34, align 8, !tbaa !19
  br label %11, !llvm.loop !22

35:                                               ; preds = %11
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.Domain_t, ptr %36, i32 0, i32 8
  %38 = call i32 @list_iterator_stop(ptr noundef %37)
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  ret i32 0
}

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

declare i32 @list_iterator_start(ptr noundef) #2

declare i32 @list_iterator_hasnext(ptr noundef) #2

declare ptr @list_iterator_next(ptr noundef) #2

declare i32 @list_iterator_stop(ptr noundef) #2

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

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 = { "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 384}
!10 = !{!"Node_t", !11, i64 0, !11, i64 120, !11, i64 240, !14, i64 360, !15, i64 368, !16, i64 488, !16, i64 528, !18, i64 568}
!11 = !{!"PointPtr_t", !12, i64 0, !12, i64 40, !12, i64 80}
!12 = !{!"VarTypePtr_t", !6, i64 0, !6, i64 8, !6, i64 16, !13, i64 24, !14, i64 28, !14, i64 32}
!13 = !{!"_Bool", !7, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = !{!"ForcePtr_t", !12, i64 0, !12, i64 40, !12, i64 80}
!16 = !{!"VarType_t", !6, i64 0, !6, i64 8, !17, i64 16, !13, i64 24, !13, i64 25, !14, i64 28, !14, i64 32}
!17 = !{!"double", !7, i64 0}
!18 = !{!"Force_t", !16, i64 0, !16, i64 40, !16, i64 80}
!19 = !{!17, !17, i64 0}
!20 = !{!10, !6, i64 424}
!21 = !{!10, !6, i64 464}
!22 = distinct !{!22, !23}
!23 = !{!"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"

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @reset_node_force_to_zero(ptr noundef %0, ptr nocapture noundef readnone %1, ptr nocapture noundef readnone %2) local_unnamed_addr #0 {
  %4 = getelementptr inbounds i8, ptr %0, i64 1208
  %5 = tail call i32 @list_iterator_start(ptr noundef nonnull %4) #2
  %6 = tail call i32 @list_iterator_hasnext(ptr noundef nonnull %4) #2
  %.not7 = icmp eq i32 %6, 0
  br i1 %.not7, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %3, %.lr.ph
  %7 = tail call ptr @list_iterator_next(ptr noundef nonnull %4) #2
  %8 = getelementptr inbounds i8, ptr %7, i64 384
  %9 = load ptr, ptr %8, align 8, !tbaa !5
  store double 0.000000e+00, ptr %9, align 8, !tbaa !18
  %10 = getelementptr inbounds i8, ptr %7, i64 424
  %11 = load ptr, ptr %10, align 8, !tbaa !19
  store double 0.000000e+00, ptr %11, align 8, !tbaa !18
  %12 = getelementptr inbounds i8, ptr %7, i64 464
  %13 = load ptr, ptr %12, align 8, !tbaa !20
  store double 0.000000e+00, ptr %13, align 8, !tbaa !18
  %14 = tail call i32 @list_iterator_hasnext(ptr noundef nonnull %4) #2
  %.not = icmp eq i32 %14, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !21

._crit_edge:                                      ; preds = %.lr.ph, %3
  %15 = tail call i32 @list_iterator_stop(ptr noundef nonnull %4) #2
  ret i32 0
}

declare i32 @list_iterator_start(ptr noundef) local_unnamed_addr #1

declare i32 @list_iterator_hasnext(ptr noundef) local_unnamed_addr #1

declare ptr @list_iterator_next(ptr noundef) local_unnamed_addr #1

declare i32 @list_iterator_stop(ptr noundef) local_unnamed_addr #1

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 = { "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 }

!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, !9, i64 384}
!6 = !{!"Node_t", !7, i64 0, !7, i64 120, !7, i64 240, !13, i64 360, !14, i64 368, !15, i64 488, !15, i64 528, !17, i64 568}
!7 = !{!"PointPtr_t", !8, i64 0, !8, i64 40, !8, i64 80}
!8 = !{!"VarTypePtr_t", !9, i64 0, !9, i64 8, !9, i64 16, !12, i64 24, !13, i64 28, !13, i64 32}
!9 = !{!"any pointer", !10, i64 0}
!10 = !{!"omnipotent char", !11, i64 0}
!11 = !{!"Simple C/C++ TBAA"}
!12 = !{!"_Bool", !10, i64 0}
!13 = !{!"int", !10, i64 0}
!14 = !{!"ForcePtr_t", !8, i64 0, !8, i64 40, !8, i64 80}
!15 = !{!"VarType_t", !9, i64 0, !9, i64 8, !16, i64 16, !12, i64 24, !12, i64 25, !13, i64 28, !13, i64 32}
!16 = !{!"double", !10, i64 0}
!17 = !{!"Force_t", !15, i64 0, !15, i64 40, !15, i64 80}
!18 = !{!16, !16, i64 0}
!19 = !{!6, !9, i64 424}
!20 = !{!6, !9, i64 464}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass