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

@.str.16 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.22 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.23 = external hidden unnamed_addr constant [9 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

; Function Attrs: nounwind uwtable
define dso_local i32 @write_node_type_to_summary_file(i32 noundef %0, i32 noundef %1, i32 noundef %2, ptr noundef %3) #1 {
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  store i32 %0, ptr %5, align 4, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !5
  store i32 %2, ptr %7, align 4, !tbaa !5
  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
  store i32 0, ptr %10, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  %12 = load ptr, ptr %8, align 8, !tbaa !9
  %13 = getelementptr inbounds %struct.tagbstring, ptr %12, i32 0, i32 1
  %14 = load i32, ptr %13, align 4, !tbaa !11
  %15 = load i32, ptr %6, align 4, !tbaa !5
  %16 = mul nsw i32 23, %15
  %17 = sub nsw i32 %14, %16
  store i32 %17, ptr %11, align 4, !tbaa !5
  %18 = load i32, ptr %5, align 4, !tbaa !5
  %19 = icmp ne i32 %18, 0
  br i1 %19, label %44, label %20

20:                                               ; preds = %4
  %21 = load i32, ptr %7, align 4, !tbaa !5
  %22 = icmp eq i32 %21, 3
  br i1 %22, label %23, label %26

23:                                               ; preds = %20
  %24 = load ptr, ptr %8, align 8, !tbaa !9
  %25 = call i32 @bcatcstr(ptr noundef %24, ptr noundef @.str.16)
  store i32 %25, ptr %9, align 4, !tbaa !5
  br label %43

26:                                               ; preds = %20
  %27 = load i32, ptr %7, align 4, !tbaa !5
  %28 = icmp eq i32 %27, 1
  br i1 %28, label %29, label %32

29:                                               ; preds = %26
  %30 = load ptr, ptr %8, align 8, !tbaa !9
  %31 = call i32 @bcatcstr(ptr noundef %30, ptr noundef @.str.17)
  store i32 %31, ptr %9, align 4, !tbaa !5
  br label %42

32:                                               ; preds = %26
  %33 = load i32, ptr %7, align 4, !tbaa !5
  %34 = icmp eq i32 %33, 2
  br i1 %34, label %35, label %38

35:                                               ; preds = %32
  %36 = load ptr, ptr %8, align 8, !tbaa !9
  %37 = call i32 @bcatcstr(ptr noundef %36, ptr noundef @.str.18)
  store i32 %37, ptr %9, align 4, !tbaa !5
  br label %41

38:                                               ; preds = %32
  %39 = load ptr, ptr %8, align 8, !tbaa !9
  %40 = call i32 @bcatcstr(ptr noundef %39, ptr noundef @.str.19)
  store i32 %40, ptr %9, align 4, !tbaa !5
  br label %41

41:                                               ; preds = %38, %35
  br label %42

42:                                               ; preds = %41, %29
  br label %43

43:                                               ; preds = %42, %23
  br label %80

44:                                               ; preds = %4
  store i32 0, ptr %10, align 4, !tbaa !5
  br label %45

45:                                               ; preds = %53, %44
  %46 = load i32, ptr %10, align 4, !tbaa !5
  %47 = load i32, ptr %11, align 4, !tbaa !5
  %48 = sub nsw i32 12, %47
  %49 = icmp slt i32 %46, %48
  br i1 %49, label %50, label %56

50:                                               ; preds = %45
  %51 = load ptr, ptr %8, align 8, !tbaa !9
  %52 = call i32 @bconchar(ptr noundef %51, i8 noundef signext 32)
  br label %53

53:                                               ; preds = %50
  %54 = load i32, ptr %10, align 4, !tbaa !5
  %55 = add nsw i32 %54, 1
  store i32 %55, ptr %10, align 4, !tbaa !5
  br label %45, !llvm.loop !13

56:                                               ; preds = %45
  %57 = load i32, ptr %7, align 4, !tbaa !5
  %58 = icmp eq i32 %57, 3
  br i1 %58, label %59, label %62

59:                                               ; preds = %56
  %60 = load ptr, ptr %8, align 8, !tbaa !9
  %61 = call i32 @bcatcstr(ptr noundef %60, ptr noundef @.str.20)
  store i32 %61, ptr %9, align 4, !tbaa !5
  br label %79

62:                                               ; preds = %56
  %63 = load i32, ptr %7, align 4, !tbaa !5
  %64 = icmp eq i32 %63, 1
  br i1 %64, label %65, label %68

65:                                               ; preds = %62
  %66 = load ptr, ptr %8, align 8, !tbaa !9
  %67 = call i32 @bcatcstr(ptr noundef %66, ptr noundef @.str.21)
  store i32 %67, ptr %9, align 4, !tbaa !5
  br label %78

68:                                               ; preds = %62
  %69 = load i32, ptr %7, align 4, !tbaa !5
  %70 = icmp eq i32 %69, 2
  br i1 %70, label %71, label %74

71:                                               ; preds = %68
  %72 = load ptr, ptr %8, align 8, !tbaa !9
  %73 = call i32 @bcatcstr(ptr noundef %72, ptr noundef @.str.22)
  store i32 %73, ptr %9, align 4, !tbaa !5
  br label %77

74:                                               ; preds = %68
  %75 = load ptr, ptr %8, align 8, !tbaa !9
  %76 = call i32 @bcatcstr(ptr noundef %75, ptr noundef @.str.23)
  store i32 %76, ptr %9, align 4, !tbaa !5
  br label %77

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

78:                                               ; preds = %77, %65
  br label %79

79:                                               ; preds = %78, %59
  br label %80

80:                                               ; preds = %79, %43
  call void @llvm.lifetime.end.p0(i64 4, 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
}

declare i32 @bcatcstr(ptr noundef, ptr noundef) #2

declare i32 @bconchar(ptr noundef, i8 noundef signext) #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 = !{!"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 = distinct !{!13, !14}
!14 = !{!"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.16 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.22 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.23 = external hidden unnamed_addr constant [9 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @write_node_type_to_summary_file(i32 noundef %0, i32 noundef %1, i32 noundef %2, ptr noundef %3) local_unnamed_addr #0 {
  %.not = icmp eq i32 %0, 0
  br i1 %.not, label %9, label %.preheader

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

9:                                                ; preds = %4
  switch i32 %2, label %16 [
    i32 3, label %10
    i32 1, label %12
    i32 2, label %14
  ]

10:                                               ; preds = %9
  %11 = tail call i32 @bcatcstr(ptr noundef nonnull %3, ptr noundef nonnull @.str.16) #2
  br label %28

12:                                               ; preds = %9
  %13 = tail call i32 @bcatcstr(ptr noundef nonnull %3, ptr noundef nonnull @.str.17) #2
  br label %28

14:                                               ; preds = %9
  %15 = tail call i32 @bcatcstr(ptr noundef nonnull %3, ptr noundef nonnull @.str.18) #2
  br label %28

16:                                               ; preds = %9
  %17 = tail call i32 @bcatcstr(ptr noundef nonnull %3, ptr noundef nonnull @.str.19) #2
  br label %28

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

._crit_edge:                                      ; preds = %.lr.ph, %.preheader
  switch i32 %2, label %26 [
    i32 3, label %20
    i32 1, label %22
    i32 2, label %24
  ]

20:                                               ; preds = %._crit_edge
  %21 = tail call i32 @bcatcstr(ptr noundef %3, ptr noundef nonnull @.str.20) #2
  br label %28

22:                                               ; preds = %._crit_edge
  %23 = tail call i32 @bcatcstr(ptr noundef %3, ptr noundef nonnull @.str.21) #2
  br label %28

24:                                               ; preds = %._crit_edge
  %25 = tail call i32 @bcatcstr(ptr noundef %3, ptr noundef nonnull @.str.22) #2
  br label %28

26:                                               ; preds = %._crit_edge
  %27 = tail call i32 @bcatcstr(ptr noundef %3, ptr noundef nonnull @.str.23) #2
  br label %28

28:                                               ; preds = %20, %24, %26, %22, %10, %14, %16, %12
  ret i32 0
}

declare i32 @bcatcstr(ptr noundef, ptr noundef) local_unnamed_addr #1

declare i32 @bconchar(ptr noundef, i8 noundef signext) 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, !7, i64 4}
!6 = !{!"tagbstring", !7, i64 0, !7, i64 4, !10, i64 8}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


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