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

; 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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @node_solve_sequence(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, float noundef %5, ptr noundef %6, ptr noundef %7) #2 {
  %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 float, align 4
  %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 float %5, ptr %15, align 4, !tbaa !9
  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 !11
  br label %20

20:                                               ; preds = %8
  %21 = load ptr, ptr %10, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.Domain_t, ptr %21, i32 0, i32 1
  %23 = getelementptr inbounds %struct.OuterSolveAttributes_t, ptr %22, i32 0, i32 20
  %24 = load i8, ptr %23, align 1, !tbaa !13, !range !27, !noundef !28
  %25 = trunc i8 %24 to i1
  br i1 %25, label %26, label %42

26:                                               ; preds = %20
  %27 = load ptr, ptr %10, align 8, !tbaa !5
  %28 = load ptr, ptr %11, align 8, !tbaa !5
  %29 = load ptr, ptr %12, align 8, !tbaa !5
  %30 = load ptr, ptr %13, align 8, !tbaa !5
  %31 = load ptr, ptr %14, align 8, !tbaa !5
  %32 = load float, ptr %15, align 4, !tbaa !9
  %33 = load ptr, ptr %16, align 8, !tbaa !5
  %34 = load ptr, ptr %17, align 8, !tbaa !5
  %35 = call i32 @krylov_solve_sequence(ptr noundef %27, ptr noundef %28, ptr noundef %29, ptr noundef %30, ptr noundef %31, float noundef %32, ptr noundef %33, ptr noundef %34)
  store i32 %35, ptr %18, align 4, !tbaa !11
  %36 = load i32, ptr %18, align 4, !tbaa !11
  %37 = icmp ne i32 %36, 0
  br i1 %37, label %38, label %41

38:                                               ; preds = %26
  %39 = load ptr, ptr %16, align 8, !tbaa !5
  %40 = load ptr, ptr %17, align 8, !tbaa !5
  call void @set_universal_error(ptr noundef %39, ptr noundef %40, i32 noundef 94)
  br label %68

41:                                               ; preds = %26
  br label %66

42:                                               ; preds = %20
  %43 = load ptr, ptr %10, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.Domain_t, ptr %43, i32 0, i32 1
  %45 = getelementptr inbounds %struct.OuterSolveAttributes_t, ptr %44, i32 0, i32 21
  %46 = load i8, ptr %45, align 2, !tbaa !29, !range !27, !noundef !28
  %47 = trunc i8 %46 to i1
  br i1 %47, label %48, label %49

48:                                               ; preds = %42
  br label %65

49:                                               ; preds = %42
  %50 = load ptr, ptr %10, align 8, !tbaa !5
  %51 = load ptr, ptr %11, align 8, !tbaa !5
  %52 = load ptr, ptr %12, align 8, !tbaa !5
  %53 = load ptr, ptr %13, align 8, !tbaa !5
  %54 = load ptr, ptr %14, align 8, !tbaa !5
  %55 = load float, ptr %15, align 4, !tbaa !9
  %56 = load ptr, ptr %16, align 8, !tbaa !5
  %57 = load ptr, ptr %17, align 8, !tbaa !5
  %58 = call i32 @newton_solve_sequence(ptr noundef %50, ptr noundef %51, ptr noundef %52, ptr noundef %53, ptr noundef %54, float noundef %55, ptr noundef %56, ptr noundef %57)
  store i32 %58, ptr %18, align 4, !tbaa !11
  %59 = load i32, ptr %18, align 4, !tbaa !11
  %60 = icmp ne i32 %59, 0
  br i1 %60, label %61, label %64

61:                                               ; preds = %49
  %62 = load ptr, ptr %16, align 8, !tbaa !5
  %63 = load ptr, ptr %17, align 8, !tbaa !5
  call void @set_universal_error(ptr noundef %62, ptr noundef %63, i32 noundef 93)
  br label %68

64:                                               ; preds = %49
  br label %65

65:                                               ; preds = %64, %48
  br label %66

66:                                               ; preds = %65, %41
  br label %67

67:                                               ; preds = %66
  br label %68

68:                                               ; preds = %67, %61, %38
  %69 = load i32, ptr %18, align 4, !tbaa !11
  %70 = icmp eq i32 %69, 0
  br i1 %70, label %71, label %72

71:                                               ; preds = %68
  store i32 0, ptr %9, align 4
  store i32 1, ptr %19, align 4
  br label %77

72:                                               ; preds = %68
  %73 = load i32, ptr %18, align 4, !tbaa !11
  %74 = icmp eq i32 %73, 2
  br i1 %74, label %75, label %76

75:                                               ; preds = %72
  store i32 2, ptr %9, align 4
  store i32 1, ptr %19, align 4
  br label %77

76:                                               ; preds = %72
  store i32 3, ptr %9, align 4
  store i32 1, ptr %19, align 4
  br label %77

77:                                               ; preds = %76, %75, %71
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #3
  %78 = load i32, ptr %9, align 4
  ret i32 %78
}

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 = !{!"float", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !18, i64 393}
!14 = !{!"Domain_t", !15, i64 0, !17, i64 240, !19, i64 408, !6, i64 448, !12, i64 456, !20, i64 464, !25, i64 968, !25, i64 1088, !25, i64 1208, !25, i64 1328, !6, i64 1448}
!15 = !{!"InnerSolveAttributes_t", !6, i64 0, !16, i64 8, !16, i64 16, !16, 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, !16, i64 192, !12, i64 200, !12, i64 204, !12, i64 208, !12, i64 212, !12, i64 216, !7, i64 220, !12, i64 228, !12, i64 232}
!16 = !{!"double", !7, i64 0}
!17 = !{!"OuterSolveAttributes_t", !12, 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, !16, i64 104, !16, i64 112, !16, i64 120, !16, i64 128, !16, i64 136, !16, i64 144, !18, i64 152, !18, i64 153, !18, i64 154, !12, i64 156, !12, i64 160, !12, i64 164}
!18 = !{!"_Bool", !7, i64 0}
!19 = !{!"DomainOptions_t", !6, i64 0, !16, i64 8, !16, i64 16, !16, i64 24, !18, i64 32, !18, i64 33, !12, i64 36}
!20 = !{!"Vessel_t", !21, i64 0, !6, i64 120, !6, i64 128, !6, i64 136, !23, i64 144, !23, i64 264, !24, i64 384}
!21 = !{!"EulerAngle_t", !22, i64 0, !22, i64 40, !22, i64 80}
!22 = !{!"VarType_t", !6, i64 0, !6, i64 8, !16, i64 16, !18, i64 24, !18, i64 25, !12, i64 28, !12, i64 32}
!23 = !{!"Point_t", !22, i64 0, !22, i64 40, !22, i64 80}
!24 = !{!"Force_t", !22, i64 0, !22, i64 40, !22, i64 80}
!25 = !{!"", !6, i64 0, !6, i64 8, !6, i64 16, !12, i64 24, !6, i64 32, !12, i64 40, !12, i64 44, !12, i64 48, !6, i64 56, !26, i64 64}
!26 = !{!"list_attributes_s", !6, i64 0, !6, i64 8, !6, i64 16, !12, i64 24, !6, i64 32, !6, i64 40, !6, i64 48}
!27 = !{i8 0, i8 2}
!28 = !{}
!29 = !{!14, !18, i64 394}


; 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 void @set_universal_error(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #0

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

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

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 4) i32 @node_solve_sequence(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, float noundef %5, ptr noundef %6, ptr noundef %7) local_unnamed_addr #1 {
  %9 = getelementptr inbounds i8, ptr %0, i64 393
  %10 = load i8, ptr %9, align 1, !tbaa !5, !range !23, !noundef !24
  %11 = trunc nuw i8 %10 to i1
  br i1 %11, label %12, label %14

12:                                               ; preds = %8
  %13 = tail call i32 @krylov_solve_sequence(ptr noundef nonnull %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, float noundef %5, ptr noundef %6, ptr noundef %7)
  %.not30 = icmp eq i32 %13, 0
  br i1 %.not30, label %.thread39, label %20

14:                                               ; preds = %8
  %15 = getelementptr inbounds i8, ptr %0, i64 394
  %16 = load i8, ptr %15, align 2, !tbaa !25, !range !23, !noundef !24
  %17 = trunc nuw i8 %16 to i1
  br i1 %17, label %.thread39, label %18

18:                                               ; preds = %14
  %19 = tail call i32 @newton_solve_sequence(ptr noundef nonnull %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, float noundef %5, ptr noundef %6, ptr noundef %7)
  %.not = icmp eq i32 %19, 0
  br i1 %.not, label %.thread39, label %20

20:                                               ; preds = %18, %12
  %.sink = phi i32 [ 94, %12 ], [ 93, %18 ]
  %.0 = phi i32 [ %13, %12 ], [ %19, %18 ]
  tail call void @set_universal_error(ptr noundef %6, ptr noundef %7, i32 noundef %.sink) #2
  %.0.fr = freeze i32 %.0
  %switch.selectcmp = icmp eq i32 %.0.fr, 2
  %spec.select = select i1 %switch.selectcmp, i32 2, i32 3
  br label %.thread39

.thread39:                                        ; preds = %20, %12, %14, %18
  %21 = phi i32 [ 0, %18 ], [ 0, %14 ], [ 0, %12 ], [ %spec.select, %20 ]
  ret i32 %21
}

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, !14, i64 393}
!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 = !{i8 0, i8 2}
!24 = !{}
!25 = !{!6, !14, i64 394}


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