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

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

24:                                               ; preds = %8
  %25 = load ptr, ptr %10, align 8, !tbaa !5
  %26 = load ptr, ptr %11, align 8, !tbaa !5
  %27 = load ptr, ptr %16, align 8, !tbaa !5
  %28 = load ptr, ptr %17, align 8, !tbaa !5
  %29 = call i32 @line_solve_sequence(ptr noundef %25, ptr noundef %26, float noundef 0.000000e+00, ptr noundef %27, ptr noundef %28)
  store i32 %29, ptr %18, align 4, !tbaa !9
  br label %39

30:                                               ; preds = %8
  %31 = load ptr, ptr %10, align 8, !tbaa !5
  %32 = load ptr, ptr %11, align 8, !tbaa !5
  %33 = load ptr, ptr %12, align 8, !tbaa !5
  %34 = load ptr, ptr %13, align 8, !tbaa !5
  %35 = load ptr, ptr %14, align 8, !tbaa !5
  %36 = load ptr, ptr %16, align 8, !tbaa !5
  %37 = load ptr, ptr %17, align 8, !tbaa !5
  %38 = call i32 @node_solve_sequence(ptr noundef %31, ptr noundef %32, ptr noundef %33, ptr noundef %34, ptr noundef %35, float noundef 0.000000e+00, ptr noundef %36, ptr noundef %37)
  store i32 %38, ptr %18, align 4, !tbaa !9
  br label %39

39:                                               ; preds = %30, %24
  %40 = load i32, ptr %18, align 4, !tbaa !9
  %41 = icmp eq i32 %40, 0
  br i1 %41, label %42, label %43

42:                                               ; preds = %39
  store i32 0, ptr %9, align 4
  store i32 1, ptr %19, align 4
  br label %48

43:                                               ; preds = %39
  %44 = load i32, ptr %18, align 4, !tbaa !9
  %45 = icmp eq i32 %44, 2
  br i1 %45, label %46, label %47

46:                                               ; preds = %43
  store i32 2, ptr %9, align 4
  store i32 1, ptr %19, align 4
  br label %48

47:                                               ; preds = %43
  store i32 3, ptr %9, align 4
  store i32 1, ptr %19, align 4
  br label %48

48:                                               ; preds = %47, %46, %42
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #3
  %49 = load i32, ptr %9, align 4
  ret i32 %49
}

declare i32 @line_solve_sequence(ptr noundef, ptr noundef, float noundef, ptr noundef, ptr noundef) #2

declare i32 @node_solve_sequence(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, float noundef, ptr noundef, ptr noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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, !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, !10, i64 456}
!12 = !{!"Domain_t", !13, i64 0, !15, i64 240, !17, i64 408, !6, i64 448, !10, i64 456, !18, i64 464, !23, i64 968, !23, i64 1088, !23, i64 1208, !23, i64 1328, !6, i64 1448}
!13 = !{!"InnerSolveAttributes_t", !6, i64 0, !14, i64 8, !14, i64 16, !14, 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, !14, i64 192, !10, i64 200, !10, i64 204, !10, i64 208, !10, i64 212, !10, i64 216, !7, i64 220, !10, i64 228, !10, i64 232}
!14 = !{!"double", !7, i64 0}
!15 = !{!"OuterSolveAttributes_t", !10, 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, !14, i64 104, !14, i64 112, !14, i64 120, !14, i64 128, !14, i64 136, !14, i64 144, !16, i64 152, !16, i64 153, !16, i64 154, !10, i64 156, !10, i64 160, !10, i64 164}
!16 = !{!"_Bool", !7, i64 0}
!17 = !{!"DomainOptions_t", !6, i64 0, !14, i64 8, !14, i64 16, !14, i64 24, !16, i64 32, !16, i64 33, !10, i64 36}
!18 = !{!"Vessel_t", !19, i64 0, !6, i64 120, !6, i64 128, !6, i64 136, !21, i64 144, !21, i64 264, !22, i64 384}
!19 = !{!"EulerAngle_t", !20, i64 0, !20, i64 40, !20, i64 80}
!20 = !{!"VarType_t", !6, i64 0, !6, i64 8, !14, i64 16, !16, i64 24, !16, i64 25, !10, i64 28, !10, i64 32}
!21 = !{!"Point_t", !20, i64 0, !20, i64 40, !20, i64 80}
!22 = !{!"Force_t", !20, i64 0, !20, i64 40, !20, i64 80}
!23 = !{!"", !6, i64 0, !6, i64 8, !6, i64 16, !10, i64 24, !6, i64 32, !10, i64 40, !10, i64 44, !10, i64 48, !6, i64 56, !24, i64 64}
!24 = !{!"list_attributes_s", !6, i64 0, !6, i64 8, !6, i64 16, !10, 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 @first_solve(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr nocapture noundef readnone %5, ptr noundef %6, ptr noundef %7) local_unnamed_addr #0 {
  %9 = getelementptr inbounds i8, ptr %0, i64 456
  %10 = load i32, ptr %9, align 8, !tbaa !5
  %11 = icmp eq i32 %10, 0
  br i1 %11, label %12, label %14

12:                                               ; preds = %8
  %13 = tail call i32 @line_solve_sequence(ptr noundef nonnull %0, ptr noundef %1, float noundef 0.000000e+00, ptr noundef %6, ptr noundef %7) #2
  br label %16

14:                                               ; preds = %8
  %15 = tail call i32 @node_solve_sequence(ptr noundef nonnull %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, float noundef 0.000000e+00, ptr noundef %6, ptr noundef %7) #2
  br label %16

16:                                               ; preds = %14, %12
  %.0 = phi i32 [ %13, %12 ], [ %15, %14 ]
  %switch.selectcmp = icmp eq i32 %.0, 2
  %switch.select = select i1 %switch.selectcmp, i32 2, i32 3
  %switch.selectcmp15 = icmp eq i32 %.0, 0
  %switch.select16 = select i1 %switch.selectcmp15, i32 0, i32 %switch.select
  ret i32 %switch.select16
}

declare i32 @line_solve_sequence(ptr noundef, ptr noundef, float noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

declare i32 @node_solve_sequence(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, float noundef, ptr noundef, 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, !12, i64 456}
!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: CorrelatedValuePropagationPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass