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

; Function Attrs: nounwind uwtable
define dso_local i32 @allocate_outlist(ptr noundef %0, ptr noundef %1, ptr noundef %2) #0 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  %8 = call noalias ptr @malloc(i64 noundef 240) #3
  %9 = load ptr, ptr %5, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.Domain_t, ptr %9, i32 0, i32 3
  store ptr %8, ptr %10, align 8, !tbaa !9
  %11 = load ptr, ptr %5, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.Domain_t, ptr %11, i32 0, i32 3
  %13 = load ptr, ptr %12, align 8, !tbaa !9
  %14 = icmp eq ptr %13, null
  br i1 %14, label %15, label %18

15:                                               ; preds = %3
  %16 = load ptr, ptr %6, align 8, !tbaa !5
  %17 = load ptr, ptr %7, align 8, !tbaa !5
  call void @set_universal_error(ptr noundef %16, ptr noundef %17, i32 noundef 46)
  store i32 3, ptr %4, align 4
  br label %19

18:                                               ; preds = %3
  store i32 0, ptr %4, align 4
  br label %19

19:                                               ; preds = %18, %15
  %20 = load i32, ptr %4, align 4
  ret i32 %20
}

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #1

declare void @set_universal_error(ptr noundef, ptr noundef, i32 noundef) #2

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 = { nounwind allocsize(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 allocsize(0) }

!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}


; 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 range(i32 0, 4) i32 @allocate_outlist(ptr nocapture noundef writeonly %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #0 {
  %4 = tail call noalias dereferenceable_or_null(240) ptr @malloc(i64 noundef 240) #3
  %5 = getelementptr inbounds i8, ptr %0, i64 448
  store ptr %4, ptr %5, align 8, !tbaa !5
  %6 = icmp eq ptr %4, null
  br i1 %6, label %7, label %8

7:                                                ; preds = %3
  tail call void @set_universal_error(ptr noundef %1, ptr noundef %2, i32 noundef 46) #4
  br label %8

8:                                                ; preds = %3, %7
  %.0 = phi i32 [ 3, %7 ], [ 0, %3 ]
  ret i32 %.0
}

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #1

declare void @set_universal_error(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

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 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(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 #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 allocsize(0) }
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, !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}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass