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

@.str.26 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.27 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.28 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.29 = external hidden unnamed_addr constant [19 x i8], align 1
@.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

; 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_x_position_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.VarTypePtr_t, ptr %19, i32 0, i32 2
  %21 = load ptr, ptr %20, align 8, !tbaa !13
  %22 = load double, ptr %21, align 8, !tbaa !16
  store double %22, ptr %11, align 8, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  store ptr null, ptr %12, align 8, !tbaa !9
  %23 = load i32, ptr %5, align 4, !tbaa !5
  %24 = icmp ne i32 %23, 0
  br i1 %24, label %51, label %25

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

30:                                               ; preds = %25
  %31 = load double, ptr %11, align 8, !tbaa !16
  %32 = fcmp oge double %31, 0.000000e+00
  br i1 %32, label %33, label %36

33:                                               ; preds = %30
  %34 = load double, ptr %11, align 8, !tbaa !16
  %35 = call ptr (ptr, ...) @bformat(ptr noundef @.str.26, double noundef %34)
  store ptr %35, ptr %12, align 8, !tbaa !9
  br label %39

36:                                               ; preds = %30
  %37 = load double, ptr %11, align 8, !tbaa !16
  %38 = call ptr (ptr, ...) @bformat(ptr noundef @.str.27, double noundef %37)
  store ptr %38, ptr %12, align 8, !tbaa !9
  br label %39

39:                                               ; preds = %36, %33
  br label %50

40:                                               ; preds = %25
  %41 = load double, ptr %11, align 8, !tbaa !16
  %42 = fcmp ogt double %41, 0.000000e+00
  br i1 %42, label %43, label %46

43:                                               ; preds = %40
  %44 = load double, ptr %11, align 8, !tbaa !16
  %45 = call ptr (ptr, ...) @bformat(ptr noundef @.str.28, double noundef %44)
  store ptr %45, ptr %12, align 8, !tbaa !9
  br label %49

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

49:                                               ; preds = %46, %43
  br label %50

50:                                               ; preds = %49, %39
  br label %89

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

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

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

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

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

68:                                               ; preds = %63
  %69 = load double, ptr %11, align 8, !tbaa !16
  %70 = fcmp oge double %69, 0.000000e+00
  br i1 %70, label %71, label %74

71:                                               ; preds = %68
  %72 = load double, ptr %11, align 8, !tbaa !16
  %73 = call ptr (ptr, ...) @bformat(ptr noundef @.str.30, double noundef %72)
  store ptr %73, ptr %12, align 8, !tbaa !9
  br label %77

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

77:                                               ; preds = %74, %71
  br label %88

78:                                               ; preds = %63
  %79 = load double, ptr %11, align 8, !tbaa !16
  %80 = fcmp oge double %79, 0.000000e+00
  br i1 %80, label %81, label %84

81:                                               ; preds = %78
  %82 = load double, ptr %11, align 8, !tbaa !16
  %83 = call ptr (ptr, ...) @bformat(ptr noundef @.str.32, double noundef %82)
  store ptr %83, ptr %12, align 8, !tbaa !9
  br label %87

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

87:                                               ; preds = %84, %81
  br label %88

88:                                               ; preds = %87, %77
  br label %89

89:                                               ; preds = %88, %50
  %90 = load ptr, ptr %8, align 8, !tbaa !9
  %91 = load ptr, ptr %12, align 8, !tbaa !9
  %92 = call i32 @bconcat(ptr noundef %90, ptr noundef %91)
  %93 = load ptr, ptr %12, align 8, !tbaa !9
  %94 = call i32 @bdestroy(ptr noundef %93)
  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, !10, i64 16}
!14 = !{!"VarTypePtr_t", !10, i64 0, !10, i64 8, !10, i64 16, !15, i64 24, !6, i64 28, !6, i64 32}
!15 = !{!"_Bool", !7, i64 0}
!16 = !{!17, !17, i64 0}
!17 = !{!"double", !7, i64 0}
!18 = !{!14, !15, 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.26 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.27 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.28 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.29 = external hidden unnamed_addr constant [19 x i8], align 1
@.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

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_x_position_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 ptr, ptr %5, align 8, !tbaa !5
  %7 = load double, ptr %6, align 8, !tbaa !12
  %.not = icmp eq i32 %0, 0
  br i1 %.not, label %12, label %.preheader

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

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

16:                                               ; preds = %12
  %17 = fcmp ult double %7, 0.000000e+00
  %.str.27..str.26 = select i1 %17, ptr @.str.27, ptr @.str.26
  br label %28

18:                                               ; preds = %12
  %19 = fcmp ogt double %7, 0.000000e+00
  %.str.28..str.29 = select i1 %19, ptr @.str.28, ptr @.str.29
  br label %28

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

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

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

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

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


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