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

@.str.36 = external hidden unnamed_addr constant [18 x i8], align 1

; 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 void @set_universal_error_with_message(ptr noundef, ptr noundef, i32 noundef, ptr noundef, ...) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @initialize_cable_library_variables(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) #2 {
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca double, align 8
  %11 = alloca double, align 8
  %12 = alloca double, align 8
  %13 = alloca double, align 8
  %14 = alloca double, align 8
  %15 = alloca double, align 8
  %16 = alloca ptr, align 8
  %17 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  store ptr %3, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  store double 0.000000e+00, ptr %10, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  store double 0.000000e+00, ptr %11, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  store double 0.000000e+00, ptr %12, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #5
  store double 0.000000e+00, ptr %13, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #5
  %18 = load ptr, ptr %7, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.MAP_ParameterType, ptr %18, i32 0, i32 1
  %20 = load double, ptr %19, align 8, !tbaa !11
  store double %20, ptr %14, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #5
  store double 0x400921FB52713C02, ptr %15, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #5
  store ptr null, ptr %16, align 8, !tbaa !5
  %21 = load ptr, ptr %6, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.Domain_t, ptr %21, i32 0, i32 6
  %23 = call i32 @list_iterator_start(ptr noundef %22)
  br label %24

24:                                               ; preds = %69, %4
  %25 = load ptr, ptr %6, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.Domain_t, ptr %25, i32 0, i32 6
  %27 = call i32 @list_iterator_hasnext(ptr noundef %26)
  %28 = icmp ne i32 %27, 0
  br i1 %28, label %29, label %70

29:                                               ; preds = %24
  %30 = load ptr, ptr %6, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.Domain_t, ptr %30, i32 0, i32 6
  %32 = call ptr @list_iterator_next(ptr noundef %31)
  store ptr %32, ptr %16, align 8, !tbaa !5
  %33 = load ptr, ptr %16, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.CableLibrary_t, ptr %33, i32 0, i32 0
  %35 = load double, ptr %34, align 8, !tbaa !14
  %36 = fdiv double %35, 2.000000e+00
  store double %36, ptr %10, align 8, !tbaa !9
  %37 = load double, ptr %10, align 8, !tbaa !9
  %38 = call double @pow(double noundef %37, double noundef 2.000000e+00) #5
  %39 = fmul double 0x400921FB52713C02, %38
  store double %39, ptr %11, align 8, !tbaa !9
  %40 = load ptr, ptr %16, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.CableLibrary_t, ptr %40, i32 0, i32 1
  %42 = load double, ptr %41, align 8, !tbaa !16
  store double %42, ptr %12, align 8, !tbaa !9
  %43 = load ptr, ptr %7, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.MAP_ParameterType, ptr %43, i32 0, i32 3
  %45 = load double, ptr %44, align 8, !tbaa !17
  store double %45, ptr %13, align 8, !tbaa !9
  %46 = load double, ptr %14, align 8, !tbaa !9
  %47 = load double, ptr %12, align 8, !tbaa !9
  %48 = load double, ptr %11, align 8, !tbaa !9
  %49 = load double, ptr %13, align 8, !tbaa !9
  %50 = fneg double %48
  %51 = call double @llvm.fmuladd.f64(double %50, double %49, double %47)
  %52 = fmul double %46, %51
  %53 = load ptr, ptr %16, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.CableLibrary_t, ptr %53, i32 0, i32 3
  store double %52, ptr %54, align 8, !tbaa !18
  %55 = load double, ptr %11, align 8, !tbaa !9
  %56 = load ptr, ptr %16, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.CableLibrary_t, ptr %56, i32 0, i32 4
  store double %55, ptr %57, align 8, !tbaa !19
  %58 = load ptr, ptr %16, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.CableLibrary_t, ptr %58, i32 0, i32 3
  %60 = load double, ptr %59, align 8, !tbaa !18
  %61 = call double @llvm.fabs.f64(double %60)
  %62 = fcmp ole double %61, 1.000000e+00
  br i1 %62, label %63, label %69

63:                                               ; preds = %29
  %64 = load ptr, ptr %8, align 8, !tbaa !5
  %65 = load ptr, ptr %9, align 8, !tbaa !5
  %66 = load ptr, ptr %16, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.CableLibrary_t, ptr %66, i32 0, i32 3
  %68 = load double, ptr %67, align 8, !tbaa !18
  call void (ptr, ptr, i32, ptr, ...) @set_universal_error_with_message(ptr noundef %64, ptr noundef %65, i32 noundef 121, ptr noundef @.str.36, double noundef %68)
  br label %69

69:                                               ; preds = %63, %29
  br label %24, !llvm.loop !20

70:                                               ; preds = %24
  %71 = load ptr, ptr %6, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.Domain_t, ptr %71, i32 0, i32 6
  %73 = call i32 @list_iterator_stop(ptr noundef %72)
  %74 = load ptr, ptr %16, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.CableLibrary_t, ptr %74, i32 0, i32 3
  %76 = load double, ptr %75, align 8, !tbaa !18
  %77 = call double @llvm.fabs.f64(double %76)
  %78 = fcmp ole double %77, 1.000000e-03
  br i1 %78, label %79, label %80

79:                                               ; preds = %70
  store i32 3, ptr %5, align 4
  store i32 1, ptr %17, align 4
  br label %81

80:                                               ; preds = %70
  store i32 0, ptr %5, align 4
  store i32 1, ptr %17, align 4
  br label %81

81:                                               ; preds = %80, %79
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  %82 = load i32, ptr %5, align 4
  ret i32 %82
}

declare i32 @list_iterator_start(ptr noundef) #1

declare i32 @list_iterator_hasnext(ptr noundef) #1

declare ptr @list_iterator_next(ptr noundef) #1

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

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

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

declare i32 @list_iterator_stop(ptr noundef) #1

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 "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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = !{!12, !10, i64 8}
!12 = !{!"MAP_ParameterType", !6, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !13, i64 40}
!13 = !{!"int", !7, i64 0}
!14 = !{!15, !10, i64 0}
!15 = !{!"CableLibrary_t", !10, 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, !6, i64 80}
!16 = !{!15, !10, i64 8}
!17 = !{!12, !10, i64 24}
!18 = !{!15, !10, i64 24}
!19 = !{!15, !10, i64 32}
!20 = distinct !{!20, !21}
!21 = !{!"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"

@.str.36 = external hidden unnamed_addr constant [18 x i8], align 1

declare void @set_universal_error_with_message(ptr noundef, ptr noundef, i32 noundef, ptr noundef, ...) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 4) i32 @initialize_cable_library_variables(ptr noundef %0, ptr nocapture noundef readonly %1, ptr noundef %2, ptr noundef %3) local_unnamed_addr #1 {
  %5 = getelementptr inbounds i8, ptr %1, i64 8
  %6 = load double, ptr %5, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %0, i64 968
  %8 = tail call i32 @list_iterator_start(ptr noundef nonnull %7) #3
  %9 = tail call i32 @list_iterator_hasnext(ptr noundef nonnull %7) #3
  %.not22 = icmp eq i32 %9, 0
  br i1 %.not22, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %4
  %10 = getelementptr inbounds i8, ptr %1, i64 24
  br label %11

11:                                               ; preds = %.lr.ph, %27
  %12 = tail call ptr @list_iterator_next(ptr noundef nonnull %7) #3
  %13 = load double, ptr %12, align 8, !tbaa !12
  %14 = fmul double %13, 5.000000e-01
  %square = fmul double %14, %14
  %15 = fmul double %square, 0x400921FB52713C02
  %16 = getelementptr inbounds i8, ptr %12, i64 8
  %17 = load double, ptr %16, align 8, !tbaa !14
  %18 = load double, ptr %10, align 8, !tbaa !15
  %19 = fneg double %15
  %20 = tail call double @llvm.fmuladd.f64(double %19, double %18, double %17)
  %21 = fmul double %6, %20
  %22 = getelementptr inbounds i8, ptr %12, i64 24
  store double %21, ptr %22, align 8, !tbaa !16
  %23 = getelementptr inbounds i8, ptr %12, i64 32
  store double %15, ptr %23, align 8, !tbaa !17
  %24 = tail call double @llvm.fabs.f64(double %21)
  %25 = fcmp ugt double %24, 1.000000e+00
  br i1 %25, label %27, label %26

26:                                               ; preds = %11
  tail call void (ptr, ptr, i32, ptr, ...) @set_universal_error_with_message(ptr noundef %2, ptr noundef %3, i32 noundef 121, ptr noundef nonnull @.str.36, double noundef %21) #3
  br label %27

27:                                               ; preds = %26, %11
  %28 = tail call i32 @list_iterator_hasnext(ptr noundef nonnull %7) #3
  %.not = icmp eq i32 %28, 0
  br i1 %.not, label %._crit_edge, label %11, !llvm.loop !18

._crit_edge:                                      ; preds = %27, %4
  %.0.lcssa = phi ptr [ null, %4 ], [ %12, %27 ]
  %29 = tail call i32 @list_iterator_stop(ptr noundef nonnull %7) #3
  %30 = getelementptr inbounds i8, ptr %.0.lcssa, i64 24
  %31 = load double, ptr %30, align 8, !tbaa !16
  %32 = tail call double @llvm.fabs.f64(double %31)
  %33 = fcmp ugt double %32, 1.000000e-03
  %. = select i1 %33, i32 0, i32 3
  ret i32 %.
}

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

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

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

declare i32 @list_iterator_stop(ptr noundef) local_unnamed_addr #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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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, !10, i64 8}
!6 = !{!"MAP_ParameterType", !7, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !11, i64 40}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"double", !8, i64 0}
!11 = !{!"int", !8, i64 0}
!12 = !{!13, !10, i64 0}
!13 = !{!"CableLibrary_t", !10, 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, !7, i64 80}
!14 = !{!13, !10, i64 8}
!15 = !{!6, !10, i64 24}
!16 = !{!13, !10, i64 24}
!17 = !{!13, !10, i64 32}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}


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