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

; 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.OutputList_t = type { %struct.list_t, %struct.list_t }
%struct.VarTypePtr_t = type { ptr, ptr, ptr, i8, i32, i32 }

; Function Attrs: nounwind
declare void @free(ptr noundef) #0

; Function Attrs: nounwind uwtable
define dso_local i32 @free_outlist(ptr noundef %0, ptr noundef %1, ptr noundef %2) #1 {
  %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) #4
  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 3
  %10 = load ptr, ptr %9, align 8, !tbaa !9
  %11 = icmp ne ptr %10, null
  br i1 %11, label %12, label %53

12:                                               ; preds = %3
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.Domain_t, ptr %13, i32 0, i32 3
  %15 = load ptr, ptr %14, align 8, !tbaa !9
  %16 = getelementptr inbounds %struct.OutputList_t, ptr %15, i32 0, i32 1
  %17 = call i32 @list_iterator_start(ptr noundef %16)
  br label %18

18:                                               ; preds = %25, %12
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.Domain_t, ptr %19, i32 0, i32 3
  %21 = load ptr, ptr %20, align 8, !tbaa !9
  %22 = getelementptr inbounds %struct.OutputList_t, ptr %21, i32 0, i32 1
  %23 = call i32 @list_iterator_hasnext(ptr noundef %22)
  %24 = icmp ne i32 %23, 0
  br i1 %24, label %25, label %39

25:                                               ; preds = %18
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.Domain_t, ptr %26, i32 0, i32 3
  %28 = load ptr, ptr %27, align 8, !tbaa !9
  %29 = getelementptr inbounds %struct.OutputList_t, ptr %28, i32 0, i32 1
  %30 = call ptr @list_iterator_next(ptr noundef %29)
  store ptr %30, ptr %7, align 8, !tbaa !5
  %31 = load ptr, ptr %7, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.VarTypePtr_t, ptr %31, i32 0, i32 1
  %33 = load ptr, ptr %32, align 8, !tbaa !24
  %34 = call i32 @bdestroy(ptr noundef %33)
  %35 = load ptr, ptr %7, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.VarTypePtr_t, ptr %35, i32 0, i32 0
  %37 = load ptr, ptr %36, align 8, !tbaa !26
  %38 = call i32 @bdestroy(ptr noundef %37)
  br label %18, !llvm.loop !27

39:                                               ; preds = %18
  %40 = load ptr, ptr %4, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.Domain_t, ptr %40, i32 0, i32 3
  %42 = load ptr, ptr %41, align 8, !tbaa !9
  %43 = getelementptr inbounds %struct.OutputList_t, ptr %42, i32 0, i32 1
  %44 = call i32 @list_iterator_stop(ptr noundef %43)
  %45 = load ptr, ptr %4, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.Domain_t, ptr %45, i32 0, i32 3
  %47 = load ptr, ptr %46, align 8, !tbaa !9
  %48 = getelementptr inbounds %struct.OutputList_t, ptr %47, i32 0, i32 0
  call void @list_destroy(ptr noundef %48)
  %49 = load ptr, ptr %4, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.Domain_t, ptr %49, i32 0, i32 3
  %51 = load ptr, ptr %50, align 8, !tbaa !9
  %52 = getelementptr inbounds %struct.OutputList_t, ptr %51, i32 0, i32 1
  call void @list_destroy(ptr noundef %52)
  br label %53

53:                                               ; preds = %39, %3
  %54 = load ptr, ptr %4, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.Domain_t, ptr %54, i32 0, i32 3
  %56 = load ptr, ptr %55, align 8, !tbaa !9
  %57 = icmp ne ptr %56, null
  br i1 %57, label %58, label %64

58:                                               ; preds = %53
  %59 = load ptr, ptr %4, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.Domain_t, ptr %59, i32 0, i32 3
  %61 = load ptr, ptr %60, align 8, !tbaa !9
  call void @free(ptr noundef %61) #4
  %62 = load ptr, ptr %4, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.Domain_t, ptr %62, i32 0, i32 3
  store ptr null, ptr %63, align 8, !tbaa !9
  br label %64

64:                                               ; preds = %58, %53
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  ret i32 0
}

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

declare i32 @list_iterator_start(ptr noundef) #3

declare i32 @list_iterator_hasnext(ptr noundef) #3

declare ptr @list_iterator_next(ptr noundef) #3

declare i32 @bdestroy(ptr noundef) #3

declare i32 @list_iterator_stop(ptr noundef) #3

declare void @list_destroy(ptr noundef) #3

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

attributes #0 = { 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 #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { "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 = { 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 = !{!"Domain_t", !11, i64 0, !14, i64 240, !16, i64 408, !6, i64 448, !13, i64 456, !17, i64 464, !22, i64 968, !22, i64 1088, !22, i64 1208, !22, i64 1328, !6, i64 1448}
!11 = !{!"InnerSolveAttributes_t", !6, i64 0, !12, i64 8, !12, i64 16, !12, i64 24, !7, i64 32, !7, i64 48, !7, i64 64, !7, i64 96, !7, i64 112, !7, i64 128, !7, i64 144, !7, i64 160, !7, i64 176, !12, i64 192, !13, i64 200, !13, i64 204, !13, i64 208, !13, i64 212, !13, i64 216, !7, i64 220, !13, i64 228, !13, i64 232}
!12 = !{!"double", !7, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = !{!"OuterSolveAttributes_t", !13, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !12, i64 104, !12, i64 112, !12, i64 120, !12, i64 128, !12, i64 136, !12, i64 144, !15, i64 152, !15, i64 153, !15, i64 154, !13, i64 156, !13, i64 160, !13, i64 164}
!15 = !{!"_Bool", !7, i64 0}
!16 = !{!"DomainOptions_t", !6, i64 0, !12, i64 8, !12, i64 16, !12, i64 24, !15, i64 32, !15, i64 33, !13, i64 36}
!17 = !{!"Vessel_t", !18, i64 0, !6, i64 120, !6, i64 128, !6, i64 136, !20, i64 144, !20, i64 264, !21, i64 384}
!18 = !{!"EulerAngle_t", !19, i64 0, !19, i64 40, !19, i64 80}
!19 = !{!"VarType_t", !6, i64 0, !6, i64 8, !12, i64 16, !15, i64 24, !15, i64 25, !13, i64 28, !13, i64 32}
!20 = !{!"Point_t", !19, i64 0, !19, i64 40, !19, i64 80}
!21 = !{!"Force_t", !19, i64 0, !19, i64 40, !19, i64 80}
!22 = !{!"", !6, i64 0, !6, i64 8, !6, i64 16, !13, i64 24, !6, i64 32, !13, i64 40, !13, i64 44, !13, i64 48, !6, i64 56, !23, i64 64}
!23 = !{!"list_attributes_s", !6, i64 0, !6, i64 8, !6, i64 16, !13, i64 24, !6, i64 32, !6, i64 40, !6, i64 48}
!24 = !{!25, !6, i64 8}
!25 = !{!"VarTypePtr_t", !6, i64 0, !6, i64 8, !6, i64 16, !15, i64 24, !13, i64 28, !13, i64 32}
!26 = !{!25, !6, i64 0}
!27 = distinct !{!27, !28}
!28 = !{!"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: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @free_outlist(ptr nocapture noundef %0, ptr nocapture noundef readnone %1, ptr nocapture noundef readnone %2) local_unnamed_addr #1 {
  %4 = getelementptr inbounds i8, ptr %0, i64 448
  %5 = load ptr, ptr %4, align 8, !tbaa !5
  %.not = icmp eq ptr %5, null
  br i1 %.not, label %.thread, label %6

6:                                                ; preds = %3
  %7 = getelementptr inbounds i8, ptr %5, i64 120
  %8 = tail call i32 @list_iterator_start(ptr noundef nonnull %7) #3
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %9, i64 120
  %11 = tail call i32 @list_iterator_hasnext(ptr noundef nonnull %10) #3
  %.not1316 = icmp eq i32 %11, 0
  br i1 %.not1316, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %6, %.lr.ph
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %12, i64 120
  %14 = tail call ptr @list_iterator_next(ptr noundef nonnull %13) #3
  %15 = getelementptr inbounds i8, ptr %14, i64 8
  %16 = load ptr, ptr %15, align 8, !tbaa !23
  %17 = tail call i32 @bdestroy(ptr noundef %16) #3
  %18 = load ptr, ptr %14, align 8, !tbaa !25
  %19 = tail call i32 @bdestroy(ptr noundef %18) #3
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = getelementptr inbounds i8, ptr %20, i64 120
  %22 = tail call i32 @list_iterator_hasnext(ptr noundef nonnull %21) #3
  %.not13 = icmp eq i32 %22, 0
  br i1 %.not13, label %._crit_edge, label %.lr.ph, !llvm.loop !26

._crit_edge:                                      ; preds = %.lr.ph, %6
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = getelementptr inbounds i8, ptr %23, i64 120
  %25 = tail call i32 @list_iterator_stop(ptr noundef nonnull %24) #3
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  tail call void @list_destroy(ptr noundef %26) #3
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = getelementptr inbounds i8, ptr %27, i64 120
  tail call void @list_destroy(ptr noundef nonnull %28) #3
  %.pr = load ptr, ptr %4, align 8, !tbaa !5
  %.not14 = icmp eq ptr %.pr, null
  br i1 %.not14, label %.thread, label %29

29:                                               ; preds = %._crit_edge
  tail call void @free(ptr noundef nonnull %.pr) #3
  store ptr null, ptr %4, align 8, !tbaa !5
  br label %.thread

.thread:                                          ; preds = %3, %29, %._crit_edge
  ret i32 0
}

declare i32 @list_iterator_start(ptr noundef) local_unnamed_addr #2

declare i32 @list_iterator_hasnext(ptr noundef) local_unnamed_addr #2

declare ptr @list_iterator_next(ptr noundef) local_unnamed_addr #2

declare i32 @bdestroy(ptr noundef) local_unnamed_addr #2

declare i32 @list_iterator_stop(ptr noundef) local_unnamed_addr #2

declare void @list_destroy(ptr noundef) local_unnamed_addr #2

attributes #0 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { "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, !8, i64 448}
!6 = !{!"Domain_t", !7, i64 0, !13, i64 240, !15, i64 408, !8, i64 448, !12, i64 456, !16, i64 464, !21, i64 968, !21, i64 1088, !21, i64 1208, !21, i64 1328, !8, i64 1448}
!7 = !{!"InnerSolveAttributes_t", !8, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !9, i64 32, !9, i64 48, !9, i64 64, !9, i64 96, !9, i64 112, !9, i64 128, !9, i64 144, !9, i64 160, !9, i64 176, !11, i64 192, !12, i64 200, !12, i64 204, !12, i64 208, !12, i64 212, !12, i64 216, !9, i64 220, !12, i64 228, !12, i64 232}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!"double", !9, i64 0}
!12 = !{!"int", !9, i64 0}
!13 = !{!"OuterSolveAttributes_t", !12, i64 0, !8, i64 8, !8, i64 16, !8, i64 24, !8, i64 32, !8, i64 40, !8, i64 48, !8, i64 56, !8, i64 64, !8, i64 72, !8, i64 80, !8, i64 88, !8, i64 96, !11, i64 104, !11, i64 112, !11, i64 120, !11, i64 128, !11, i64 136, !11, i64 144, !14, i64 152, !14, i64 153, !14, i64 154, !12, i64 156, !12, i64 160, !12, i64 164}
!14 = !{!"_Bool", !9, i64 0}
!15 = !{!"DomainOptions_t", !8, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !14, i64 32, !14, i64 33, !12, i64 36}
!16 = !{!"Vessel_t", !17, i64 0, !8, i64 120, !8, i64 128, !8, i64 136, !19, i64 144, !19, i64 264, !20, i64 384}
!17 = !{!"EulerAngle_t", !18, i64 0, !18, i64 40, !18, i64 80}
!18 = !{!"VarType_t", !8, i64 0, !8, i64 8, !11, i64 16, !14, i64 24, !14, i64 25, !12, i64 28, !12, i64 32}
!19 = !{!"Point_t", !18, i64 0, !18, i64 40, !18, i64 80}
!20 = !{!"Force_t", !18, i64 0, !18, i64 40, !18, i64 80}
!21 = !{!"", !8, i64 0, !8, i64 8, !8, i64 16, !12, i64 24, !8, i64 32, !12, i64 40, !12, i64 44, !12, i64 48, !8, i64 56, !22, i64 64}
!22 = !{!"list_attributes_s", !8, i64 0, !8, i64 8, !8, i64 16, !12, i64 24, !8, i64 32, !8, i64 40, !8, i64 48}
!23 = !{!24, !8, i64 8}
!24 = !{!"VarTypePtr_t", !8, i64 0, !8, i64 8, !8, i64 16, !14, i64 24, !12, i64 28, !12, i64 32}
!25 = !{!24, !8, i64 0}
!26 = distinct !{!26, !27}
!27 = !{!"llvm.loop.mustprogress"}


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