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

; 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.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.MAP_ConstraintStateType = type { ptr, ptr, i32, ptr, i32, ptr, i32, ptr, i32, ptr, i32 }
%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 }

; 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

declare i32 @list_iterator_start(ptr noundef) #1

declare i32 @list_iterator_hasnext(ptr noundef) #1

declare ptr @list_iterator_next(ptr noundef) #1

declare i32 @list_iterator_stop(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @associate_vartype_ptr(ptr noundef, ptr noundef, i32 noundef) #2

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

9:                                                ; preds = %2
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.Domain_t, ptr %10, i32 0, i32 7
  %12 = call i32 @list_iterator_start(ptr noundef %11)
  br label %13

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

18:                                               ; preds = %13
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.Domain_t, ptr %19, i32 0, i32 7
  %21 = call ptr @list_iterator_next(ptr noundef %20)
  store ptr %21, ptr %6, align 8, !tbaa !5
  %22 = load ptr, ptr %6, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.Line_t, ptr %22, i32 0, i32 2
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.MAP_ConstraintStateType, ptr %24, i32 0, i32 1
  %26 = load ptr, ptr %25, align 8, !tbaa !11
  %27 = load i32, ptr %7, align 4, !tbaa !9
  %28 = add nsw i32 %27, 1
  %29 = call i32 @associate_vartype_ptr(ptr noundef %23, ptr noundef %26, i32 noundef %28)
  store i32 %29, ptr %8, align 4, !tbaa !9
  %30 = load ptr, ptr %6, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.Line_t, ptr %30, i32 0, i32 3
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.MAP_ConstraintStateType, ptr %32, i32 0, i32 3
  %34 = load ptr, ptr %33, align 8, !tbaa !13
  %35 = load i32, ptr %7, align 4, !tbaa !9
  %36 = add nsw i32 %35, 1
  %37 = call i32 @associate_vartype_ptr(ptr noundef %31, ptr noundef %34, i32 noundef %36)
  store i32 %37, ptr %8, align 4, !tbaa !9
  %38 = load i32, ptr %7, align 4, !tbaa !9
  %39 = add nsw i32 %38, 1
  store i32 %39, ptr %7, align 4, !tbaa !9
  br label %13, !llvm.loop !14

40:                                               ; preds = %13
  %41 = load ptr, ptr %3, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.Domain_t, ptr %41, i32 0, i32 7
  %43 = call i32 @list_iterator_stop(ptr noundef %42)
  store i32 0, ptr %7, align 4, !tbaa !9
  %44 = load ptr, ptr %3, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.Domain_t, ptr %44, i32 0, i32 8
  %46 = call i32 @list_iterator_start(ptr noundef %45)
  br label %47

47:                                               ; preds = %90, %40
  %48 = load ptr, ptr %3, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.Domain_t, ptr %48, i32 0, i32 8
  %50 = call i32 @list_iterator_hasnext(ptr noundef %49)
  %51 = icmp ne i32 %50, 0
  br i1 %51, label %52, label %91

52:                                               ; preds = %47
  %53 = load ptr, ptr %3, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.Domain_t, ptr %53, i32 0, i32 8
  %55 = call ptr @list_iterator_next(ptr noundef %54)
  store ptr %55, ptr %5, align 8, !tbaa !5
  %56 = load ptr, ptr %5, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.Node_t, ptr %56, i32 0, i32 3
  %58 = load i32, ptr %57, align 8, !tbaa !16
  %59 = icmp eq i32 %58, 2
  br i1 %59, label %60, label %90

60:                                               ; preds = %52
  %61 = load ptr, ptr %5, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.Node_t, ptr %61, i32 0, i32 2
  %63 = getelementptr inbounds %struct.PointPtr_t, ptr %62, i32 0, i32 0
  %64 = load ptr, ptr %4, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.MAP_ConstraintStateType, ptr %64, i32 0, i32 5
  %66 = load ptr, ptr %65, align 8, !tbaa !25
  %67 = load i32, ptr %7, align 4, !tbaa !9
  %68 = add nsw i32 %67, 1
  %69 = call i32 @associate_vartype_ptr(ptr noundef %63, ptr noundef %66, i32 noundef %68)
  store i32 %69, ptr %8, align 4, !tbaa !9
  %70 = load ptr, ptr %5, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.Node_t, ptr %70, i32 0, i32 2
  %72 = getelementptr inbounds %struct.PointPtr_t, ptr %71, i32 0, i32 1
  %73 = load ptr, ptr %4, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.MAP_ConstraintStateType, ptr %73, i32 0, i32 7
  %75 = load ptr, ptr %74, align 8, !tbaa !26
  %76 = load i32, ptr %7, align 4, !tbaa !9
  %77 = add nsw i32 %76, 1
  %78 = call i32 @associate_vartype_ptr(ptr noundef %72, ptr noundef %75, i32 noundef %77)
  store i32 %78, ptr %8, align 4, !tbaa !9
  %79 = load ptr, ptr %5, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.Node_t, ptr %79, i32 0, i32 2
  %81 = getelementptr inbounds %struct.PointPtr_t, ptr %80, i32 0, i32 2
  %82 = load ptr, ptr %4, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.MAP_ConstraintStateType, ptr %82, i32 0, i32 9
  %84 = load ptr, ptr %83, align 8, !tbaa !27
  %85 = load i32, ptr %7, align 4, !tbaa !9
  %86 = add nsw i32 %85, 1
  %87 = call i32 @associate_vartype_ptr(ptr noundef %81, ptr noundef %84, i32 noundef %86)
  store i32 %87, ptr %8, align 4, !tbaa !9
  %88 = load i32, ptr %7, align 4, !tbaa !9
  %89 = add nsw i32 %88, 1
  store i32 %89, ptr %7, align 4, !tbaa !9
  br label %90

90:                                               ; preds = %60, %52
  br label %47, !llvm.loop !28

91:                                               ; preds = %47
  %92 = load ptr, ptr %3, align 8, !tbaa !5
  %93 = getelementptr inbounds %struct.Domain_t, ptr %92, i32 0, i32 8
  %94 = call i32 @list_iterator_stop(ptr noundef %93)
  br label %95

95:                                               ; preds = %91
  br label %96

96:                                               ; preds = %95
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, 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
  ret i32 0
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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 }

!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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 8}
!12 = !{!"MAP_ConstraintStateType", !6, i64 0, !6, i64 8, !10, i64 16, !6, i64 24, !10, i64 32, !6, i64 40, !10, i64 48, !6, i64 56, !10, i64 64, !6, i64 72, !10, i64 80}
!13 = !{!12, !6, i64 24}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{!17, !10, i64 360}
!17 = !{!"Node_t", !18, i64 0, !18, i64 120, !18, i64 240, !10, i64 360, !21, i64 368, !22, i64 488, !22, i64 528, !24, i64 568}
!18 = !{!"PointPtr_t", !19, i64 0, !19, i64 40, !19, i64 80}
!19 = !{!"VarTypePtr_t", !6, i64 0, !6, i64 8, !6, i64 16, !20, i64 24, !10, i64 28, !10, i64 32}
!20 = !{!"_Bool", !7, i64 0}
!21 = !{!"ForcePtr_t", !19, i64 0, !19, i64 40, !19, i64 80}
!22 = !{!"VarType_t", !6, i64 0, !6, i64 8, !23, i64 16, !20, i64 24, !20, i64 25, !10, i64 28, !10, i64 32}
!23 = !{!"double", !7, i64 0}
!24 = !{!"Force_t", !22, i64 0, !22, i64 40, !22, i64 80}
!25 = !{!12, !6, i64 40}
!26 = !{!12, !6, i64 56}
!27 = !{!12, !6, i64 72}
!28 = distinct !{!28, !15}


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

declare i32 @list_iterator_start(ptr noundef) local_unnamed_addr #0

declare i32 @list_iterator_hasnext(ptr noundef) local_unnamed_addr #0

declare ptr @list_iterator_next(ptr noundef) local_unnamed_addr #0

declare i32 @list_iterator_stop(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @associate_vartype_ptr(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

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

.lr.ph:                                           ; preds = %2
  %6 = getelementptr inbounds i8, ptr %1, i64 8
  %7 = getelementptr inbounds i8, ptr %1, i64 24
  br label %8

8:                                                ; preds = %.lr.ph, %8
  %.027 = phi i32 [ 0, %.lr.ph ], [ %12, %8 ]
  %9 = tail call ptr @list_iterator_next(ptr noundef nonnull %3) #2
  %10 = getelementptr inbounds i8, ptr %9, i64 40
  %11 = load ptr, ptr %6, align 8, !tbaa !5
  %12 = add nuw nsw i32 %.027, 1
  %13 = tail call i32 @associate_vartype_ptr(ptr noundef nonnull %10, ptr noundef %11, i32 noundef %12)
  %14 = getelementptr inbounds i8, ptr %9, i64 80
  %15 = load ptr, ptr %7, align 8, !tbaa !11
  %16 = tail call i32 @associate_vartype_ptr(ptr noundef nonnull %14, ptr noundef %15, i32 noundef %12)
  %17 = tail call i32 @list_iterator_hasnext(ptr noundef nonnull %3) #2
  %.not = icmp eq i32 %17, 0
  br i1 %.not, label %._crit_edge, label %8, !llvm.loop !12

._crit_edge:                                      ; preds = %8, %2
  %18 = tail call i32 @list_iterator_stop(ptr noundef nonnull %3) #2
  %19 = getelementptr inbounds i8, ptr %0, i64 1208
  %20 = tail call i32 @list_iterator_start(ptr noundef nonnull %19) #2
  %21 = tail call i32 @list_iterator_hasnext(ptr noundef nonnull %19) #2
  %.not2528 = icmp eq i32 %21, 0
  br i1 %.not2528, label %._crit_edge32, label %.lr.ph31

.lr.ph31:                                         ; preds = %._crit_edge
  %22 = getelementptr inbounds i8, ptr %1, i64 40
  %23 = getelementptr inbounds i8, ptr %1, i64 56
  %24 = getelementptr inbounds i8, ptr %1, i64 72
  br label %25

25:                                               ; preds = %.lr.ph31, %41
  %.129 = phi i32 [ 0, %.lr.ph31 ], [ %.2, %41 ]
  %26 = tail call ptr @list_iterator_next(ptr noundef nonnull %19) #2
  %27 = getelementptr inbounds i8, ptr %26, i64 360
  %28 = load i32, ptr %27, align 8, !tbaa !14
  %29 = icmp eq i32 %28, 2
  br i1 %29, label %30, label %41

30:                                               ; preds = %25
  %31 = getelementptr inbounds i8, ptr %26, i64 240
  %32 = load ptr, ptr %22, align 8, !tbaa !23
  %33 = add nsw i32 %.129, 1
  %34 = tail call i32 @associate_vartype_ptr(ptr noundef nonnull %31, ptr noundef %32, i32 noundef %33)
  %35 = getelementptr inbounds i8, ptr %26, i64 280
  %36 = load ptr, ptr %23, align 8, !tbaa !24
  %37 = tail call i32 @associate_vartype_ptr(ptr noundef nonnull %35, ptr noundef %36, i32 noundef %33)
  %38 = getelementptr inbounds i8, ptr %26, i64 320
  %39 = load ptr, ptr %24, align 8, !tbaa !25
  %40 = tail call i32 @associate_vartype_ptr(ptr noundef nonnull %38, ptr noundef %39, i32 noundef %33)
  br label %41

41:                                               ; preds = %30, %25
  %.2 = phi i32 [ %33, %30 ], [ %.129, %25 ]
  %42 = tail call i32 @list_iterator_hasnext(ptr noundef nonnull %19) #2
  %.not25 = icmp eq i32 %42, 0
  br i1 %.not25, label %._crit_edge32, label %25, !llvm.loop !26

._crit_edge32:                                    ; preds = %41, %._crit_edge
  %43 = tail call i32 @list_iterator_stop(ptr noundef nonnull %19) #2
  ret i32 0
}

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

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


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