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

; 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.tagbstring = type { i32, i32, ptr }
%struct.VarType_t = type { ptr, ptr, double, i8, i8, i32, i32 }

@.str.30 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.31 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.32 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.33 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.46 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.47 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.48 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.49 = external hidden unnamed_addr constant [19 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 i32 @bconchar(ptr noundef, i8 noundef signext) #1

declare ptr @bformat(ptr noundef, ...) #1

declare i32 @bconcat(ptr noundef, ptr noundef) #1

declare i32 @bdestroy(ptr noundef) #1

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

24:                                               ; preds = %4
  %25 = load ptr, ptr %7, align 8, !tbaa !9
  %26 = getelementptr inbounds %struct.VarType_t, ptr %25, i32 0, i32 3
  %27 = load i8, ptr %26, align 8, !tbaa !18, !range !19, !noundef !20
  %28 = trunc i8 %27 to i1
  br i1 %28, label %39, label %29

29:                                               ; preds = %24
  %30 = load double, ptr %11, align 8, !tbaa !17
  %31 = fcmp oge double %30, 0.000000e+00
  br i1 %31, label %32, label %35

32:                                               ; preds = %29
  %33 = load double, ptr %11, align 8, !tbaa !17
  %34 = call ptr (ptr, ...) @bformat(ptr noundef @.str.46, double noundef %33)
  store ptr %34, ptr %12, align 8, !tbaa !9
  br label %38

35:                                               ; preds = %29
  %36 = load double, ptr %11, align 8, !tbaa !17
  %37 = call ptr (ptr, ...) @bformat(ptr noundef @.str.47, double noundef %36)
  store ptr %37, ptr %12, align 8, !tbaa !9
  br label %38

38:                                               ; preds = %35, %32
  br label %49

39:                                               ; preds = %24
  %40 = load double, ptr %11, align 8, !tbaa !17
  %41 = fcmp ogt double %40, 0.000000e+00
  br i1 %41, label %42, label %45

42:                                               ; preds = %39
  %43 = load double, ptr %11, align 8, !tbaa !17
  %44 = call ptr (ptr, ...) @bformat(ptr noundef @.str.48, double noundef %43)
  store ptr %44, ptr %12, align 8, !tbaa !9
  br label %48

45:                                               ; preds = %39
  %46 = load double, ptr %11, align 8, !tbaa !17
  %47 = call ptr (ptr, ...) @bformat(ptr noundef @.str.49, double noundef %46)
  store ptr %47, ptr %12, align 8, !tbaa !9
  br label %48

48:                                               ; preds = %45, %42
  br label %49

49:                                               ; preds = %48, %38
  br label %88

50:                                               ; preds = %4
  store i32 0, ptr %9, align 4, !tbaa !5
  br label %51

51:                                               ; preds = %59, %50
  %52 = load i32, ptr %9, align 4, !tbaa !5
  %53 = load i32, ptr %10, align 4, !tbaa !5
  %54 = sub nsw i32 12, %53
  %55 = icmp slt i32 %52, %54
  br i1 %55, label %56, label %62

56:                                               ; preds = %51
  %57 = load ptr, ptr %8, align 8, !tbaa !9
  %58 = call i32 @bconchar(ptr noundef %57, i8 noundef signext 32)
  br label %59

59:                                               ; preds = %56
  %60 = load i32, ptr %9, align 4, !tbaa !5
  %61 = add nsw i32 %60, 1
  store i32 %61, ptr %9, align 4, !tbaa !5
  br label %51, !llvm.loop !21

62:                                               ; preds = %51
  %63 = load ptr, ptr %7, align 8, !tbaa !9
  %64 = getelementptr inbounds %struct.VarType_t, ptr %63, i32 0, i32 3
  %65 = load i8, ptr %64, align 8, !tbaa !18, !range !19, !noundef !20
  %66 = trunc i8 %65 to i1
  br i1 %66, label %77, label %67

67:                                               ; preds = %62
  %68 = load double, ptr %11, align 8, !tbaa !17
  %69 = fcmp oge double %68, 0.000000e+00
  br i1 %69, label %70, label %73

70:                                               ; preds = %67
  %71 = load double, ptr %11, align 8, !tbaa !17
  %72 = call ptr (ptr, ...) @bformat(ptr noundef @.str.30, double noundef %71)
  store ptr %72, ptr %12, align 8, !tbaa !9
  br label %76

73:                                               ; preds = %67
  %74 = load double, ptr %11, align 8, !tbaa !17
  %75 = call ptr (ptr, ...) @bformat(ptr noundef @.str.31, double noundef %74)
  store ptr %75, ptr %12, align 8, !tbaa !9
  br label %76

76:                                               ; preds = %73, %70
  br label %87

77:                                               ; preds = %62
  %78 = load double, ptr %11, align 8, !tbaa !17
  %79 = fcmp oge double %78, 0.000000e+00
  br i1 %79, label %80, label %83

80:                                               ; preds = %77
  %81 = load double, ptr %11, align 8, !tbaa !17
  %82 = call ptr (ptr, ...) @bformat(ptr noundef @.str.32, double noundef %81)
  store ptr %82, ptr %12, align 8, !tbaa !9
  br label %86

83:                                               ; preds = %77
  %84 = load double, ptr %11, align 8, !tbaa !17
  %85 = call ptr (ptr, ...) @bformat(ptr noundef @.str.33, double noundef %84)
  store ptr %85, ptr %12, align 8, !tbaa !9
  br label %86

86:                                               ; preds = %83, %80
  br label %87

87:                                               ; preds = %86, %76
  br label %88

88:                                               ; preds = %87, %49
  %89 = load ptr, ptr %8, align 8, !tbaa !9
  %90 = load ptr, ptr %12, align 8, !tbaa !9
  %91 = call i32 @bconcat(ptr noundef %89, ptr noundef %90)
  %92 = load ptr, ptr %12, align 8, !tbaa !9
  %93 = call i32 @bdestroy(ptr noundef %92)
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  ret i32 0
}

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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !6, i64 4}
!12 = !{!"tagbstring", !6, i64 0, !6, i64 4, !10, i64 8}
!13 = !{!14, !15, i64 16}
!14 = !{!"VarType_t", !10, i64 0, !10, i64 8, !15, i64 16, !16, i64 24, !16, i64 25, !6, i64 28, !6, i64 32}
!15 = !{!"double", !7, i64 0}
!16 = !{!"_Bool", !7, i64 0}
!17 = !{!15, !15, i64 0}
!18 = !{!14, !16, i64 24}
!19 = !{i8 0, i8 2}
!20 = !{}
!21 = distinct !{!21, !22}
!22 = !{!"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.30 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.31 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.32 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.33 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.46 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.47 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.48 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.49 = external hidden unnamed_addr constant [19 x i8], align 1

declare i32 @bconchar(ptr noundef, i8 noundef signext) local_unnamed_addr #0

declare ptr @bformat(ptr noundef, ...) local_unnamed_addr #0

declare i32 @bconcat(ptr noundef, ptr noundef) local_unnamed_addr #0

declare i32 @bdestroy(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @write_node_buoyancy_information_to_summary_file(i32 noundef %0, i32 noundef %1, ptr nocapture noundef readonly %2, ptr noundef %3) local_unnamed_addr #1 {
  %5 = getelementptr inbounds i8, ptr %2, i64 16
  %6 = load double, ptr %5, align 8, !tbaa !5
  %.not = icmp eq i32 %0, 0
  br i1 %.not, label %11, label %.preheader

.preheader:                                       ; preds = %4
  %7 = getelementptr inbounds i8, ptr %3, i64 4
  %8 = load i32, ptr %7, align 4, !tbaa !13
  %.neg.neg = mul i32 %1, 23
  %.neg27 = add i32 %.neg.neg, 12
  %9 = sub i32 %.neg27, %8
  %10 = icmp sgt i32 %9, 0
  br i1 %10, label %.lr.ph, label %._crit_edge

11:                                               ; preds = %4
  %12 = getelementptr inbounds i8, ptr %2, i64 24
  %13 = load i8, ptr %12, align 8, !tbaa !15, !range !16, !noundef !17
  %14 = trunc nuw i8 %13 to i1
  br i1 %14, label %17, label %15

15:                                               ; preds = %11
  %16 = fcmp ult double %6, 0.000000e+00
  %.str.47..str.46 = select i1 %16, ptr @.str.47, ptr @.str.46
  br label %27

17:                                               ; preds = %11
  %18 = fcmp ogt double %6, 0.000000e+00
  %.str.48..str.49 = select i1 %18, ptr @.str.48, ptr @.str.49
  br label %27

.lr.ph:                                           ; preds = %.preheader, %.lr.ph
  %.02428 = phi i32 [ %20, %.lr.ph ], [ 0, %.preheader ]
  %19 = tail call i32 @bconchar(ptr noundef %3, i8 noundef signext 32) #2
  %20 = add nuw nsw i32 %.02428, 1
  %exitcond.not = icmp eq i32 %20, %9
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !18

._crit_edge:                                      ; preds = %.lr.ph, %.preheader
  %21 = getelementptr inbounds i8, ptr %2, i64 24
  %22 = load i8, ptr %21, align 8, !tbaa !15, !range !16, !noundef !17
  %23 = trunc nuw i8 %22 to i1
  %24 = fcmp ult double %6, 0.000000e+00
  br i1 %23, label %26, label %25

25:                                               ; preds = %._crit_edge
  %.str.31..str.30 = select i1 %24, ptr @.str.31, ptr @.str.30
  br label %27

26:                                               ; preds = %._crit_edge
  %.str.33..str.32 = select i1 %24, ptr @.str.33, ptr @.str.32
  br label %27

27:                                               ; preds = %26, %25, %17, %15
  %.str.31.sink = phi ptr [ %.str.47..str.46, %15 ], [ %.str.48..str.49, %17 ], [ %.str.31..str.30, %25 ], [ %.str.33..str.32, %26 ]
  %28 = tail call ptr (ptr, ...) @bformat(ptr noundef nonnull %.str.31.sink, double noundef %6) #2
  %29 = tail call i32 @bconcat(ptr noundef %3, ptr noundef %28) #2
  %30 = tail call i32 @bdestroy(ptr noundef %28) #2
  ret i32 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 = { 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 16}
!6 = !{!"VarType_t", !7, i64 0, !7, i64 8, !10, i64 16, !11, i64 24, !11, i64 25, !12, i64 28, !12, i64 32}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"double", !8, i64 0}
!11 = !{!"_Bool", !8, i64 0}
!12 = !{!"int", !8, i64 0}
!13 = !{!14, !12, i64 4}
!14 = !{!"tagbstring", !12, i64 0, !12, i64 4, !7, i64 8}
!15 = !{!6, !11, i64 24}
!16 = !{i8 0, i8 2}
!17 = !{}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass